From bf92c4559e4241c08f702eb941d1e1bd3666d08d Mon Sep 17 00:00:00 2001 From: Josh Siegle <jsiegle@mit.edu> Date: Wed, 19 Jun 2013 15:41:04 -0400 Subject: [PATCH] Update JUCE library --- .../open-ephys.xcodeproj/project.pbxproj | 7 +- .../UserInterfaceState.xcuserstate | Bin 123596 -> 138935 bytes .../buffers/juce_AudioDataConverters.cpp | 17 +- .../buffers/juce_AudioDataConverters.h | 17 +- .../buffers/juce_AudioSampleBuffer.cpp | 17 +- .../buffers/juce_AudioSampleBuffer.h | 17 +- .../buffers/juce_FloatVectorOperations.cpp | 17 +- .../buffers/juce_FloatVectorOperations.h | 17 +- .../juce_audio_basics/effects/juce_Decibels.h | 17 +- .../effects/juce_IIRFilter.cpp | 260 +- .../effects/juce_IIRFilter.h | 172 +- .../effects/juce_LagrangeInterpolator.cpp | 21 +- .../effects/juce_LagrangeInterpolator.h | 17 +- .../juce_audio_basics/effects/juce_Reverb.h | 22 +- .../juce_audio_basics/juce_audio_basics.cpp | 24 +- .../juce_audio_basics/juce_audio_basics.h | 27 +- .../juce_audio_basics/juce_audio_basics.mm | 22 +- .../juce_audio_basics/juce_module_info | 3 +- .../sources/juce_AudioSource.h | 17 +- .../sources/juce_BufferingAudioSource.cpp | 70 +- .../sources/juce_BufferingAudioSource.h | 17 +- .../juce_ChannelRemappingAudioSource.cpp | 17 +- .../juce_ChannelRemappingAudioSource.h | 17 +- .../sources/juce_IIRFilterAudioSource.cpp | 27 +- .../sources/juce_IIRFilterAudioSource.h | 22 +- .../sources/juce_MixerAudioSource.cpp | 17 +- .../sources/juce_MixerAudioSource.h | 17 +- .../sources/juce_PositionableAudioSource.h | 17 +- .../sources/juce_ResamplingAudioSource.cpp | 21 +- .../sources/juce_ResamplingAudioSource.h | 17 +- .../sources/juce_ReverbAudioSource.cpp | 17 +- .../sources/juce_ReverbAudioSource.h | 17 +- .../sources/juce_ToneGeneratorAudioSource.cpp | 17 +- .../sources/juce_ToneGeneratorAudioSource.h | 17 +- .../synthesisers/juce_Synthesiser.cpp | 17 +- .../synthesisers/juce_Synthesiser.h | 17 +- .../audio_cd/juce_AudioCDBurner.h | 17 +- .../audio_cd/juce_AudioCDReader.cpp | 17 +- .../audio_cd/juce_AudioCDReader.h | 17 +- .../audio_io/juce_AudioDeviceManager.cpp | 50 +- .../audio_io/juce_AudioDeviceManager.h | 28 +- .../audio_io/juce_AudioIODevice.cpp | 17 +- .../audio_io/juce_AudioIODevice.h | 17 +- .../audio_io/juce_AudioIODeviceType.cpp | 17 +- .../audio_io/juce_AudioIODeviceType.h | 17 +- .../audio_io/juce_SystemAudioVolume.h | 60 + .../juce_audio_devices/juce_audio_devices.cpp | 32 +- .../juce_audio_devices/juce_audio_devices.h | 20 +- .../juce_audio_devices/juce_audio_devices.mm | 17 +- .../juce_audio_devices/juce_module_info | 5 +- .../midi_io/juce_MidiInput.h | 17 +- .../midi_io/juce_MidiMessageCollector.cpp | 17 +- .../midi_io/juce_MidiMessageCollector.h | 17 +- .../midi_io/juce_MidiOutput.cpp | 17 +- .../midi_io/juce_MidiOutput.h | 17 +- .../native/juce_MidiDataConcatenator.h | 17 +- .../native/juce_android_Audio.cpp | 17 +- .../native/juce_android_Midi.cpp | 17 +- .../native/juce_android_OpenSL.cpp | 17 +- .../native/juce_ios_Audio.cpp | 23 +- .../native/juce_linux_ALSA.cpp | 688 ++- .../native/juce_linux_AudioCDReader.cpp | 17 +- .../native/juce_linux_JackAudio.cpp | 182 +- .../native/juce_linux_Midi.cpp | 554 +- .../native/juce_mac_AudioCDBurner.mm | 17 +- .../native/juce_mac_AudioCDReader.mm | 21 +- .../native/juce_mac_CoreAudio.cpp | 119 +- .../native/juce_mac_CoreMidi.cpp | 17 +- .../native/juce_win32_ASIO.cpp | 296 +- .../native/juce_win32_AudioCDBurner.cpp | 17 +- .../native/juce_win32_AudioCDReader.cpp | 17 +- .../native/juce_win32_DirectSound.cpp | 23 +- .../native/juce_win32_Midi.cpp | 53 +- .../native/juce_win32_WASAPI.cpp | 427 +- .../sources/juce_AudioSourcePlayer.cpp | 17 +- .../sources/juce_AudioSourcePlayer.h | 17 +- .../sources/juce_AudioTransportSource.cpp | 17 +- .../sources/juce_AudioTransportSource.h | 17 +- .../codecs/juce_AiffAudioFormat.cpp | 148 +- .../codecs/juce_AiffAudioFormat.h | 35 +- .../codecs/juce_CoreAudioFormat.cpp | 257 +- .../codecs/juce_CoreAudioFormat.h | 29 +- .../codecs/juce_FlacAudioFormat.cpp | 17 +- .../codecs/juce_FlacAudioFormat.h | 17 +- .../codecs/juce_LAMEEncoderAudioFormat.cpp | 17 +- .../codecs/juce_LAMEEncoderAudioFormat.h | 17 +- .../codecs/juce_MP3AudioFormat.cpp | 17 +- .../codecs/juce_MP3AudioFormat.h | 17 +- .../codecs/juce_OggVorbisAudioFormat.cpp | 19 +- .../codecs/juce_OggVorbisAudioFormat.h | 17 +- .../codecs/juce_QuickTimeAudioFormat.cpp | 353 +- .../codecs/juce_QuickTimeAudioFormat.h | 17 +- .../codecs/juce_WavAudioFormat.cpp | 77 +- .../codecs/juce_WavAudioFormat.h | 41 +- .../codecs/juce_WindowsMediaAudioFormat.cpp | 17 +- .../codecs/juce_WindowsMediaAudioFormat.h | 17 +- .../format/juce_AudioFormat.cpp | 17 +- .../format/juce_AudioFormat.h | 17 +- .../format/juce_AudioFormatManager.cpp | 17 +- .../format/juce_AudioFormatManager.h | 17 +- .../format/juce_AudioFormatReader.cpp | 19 +- .../format/juce_AudioFormatReader.h | 17 +- .../format/juce_AudioFormatReaderSource.cpp | 17 +- .../format/juce_AudioFormatReaderSource.h | 17 +- .../format/juce_AudioFormatWriter.cpp | 17 +- .../format/juce_AudioFormatWriter.h | 17 +- .../format/juce_AudioSubsectionReader.cpp | 17 +- .../format/juce_AudioSubsectionReader.h | 17 +- .../juce_BufferingAudioFormatReader.cpp | 17 +- .../format/juce_BufferingAudioFormatReader.h | 17 +- .../juce_MemoryMappedAudioFormatReader.h | 23 +- .../juce_audio_formats/juce_audio_formats.cpp | 17 +- .../juce_audio_formats/juce_audio_formats.h | 17 +- .../juce_audio_formats/juce_audio_formats.mm | 17 +- .../juce_audio_formats/juce_module_info | 2 +- .../sampler/juce_Sampler.cpp | 24 +- .../juce_audio_formats/sampler/juce_Sampler.h | 17 +- .../AAX/juce_AAX_Wrapper.cpp | 892 ++++ .../AAX/juce_AAX_Wrapper.mm | 26 + .../AU/juce_AU_Resources.r | 70 + .../AU/juce_AU_Wrapper.mm | 1462 +++++ .../RTAS/juce_RTAS_DigiCode1.cpp | 64 + .../RTAS/juce_RTAS_DigiCode2.cpp | 53 + .../RTAS/juce_RTAS_DigiCode3.cpp | 71 + .../RTAS/juce_RTAS_DigiCode_Header.h | 73 + .../RTAS/juce_RTAS_MacResources.r | 6 + .../RTAS/juce_RTAS_MacUtilities.mm | 165 + .../RTAS/juce_RTAS_WinExports.def | 3 + .../RTAS/juce_RTAS_WinResources.rsr | Bin 0 -> 3198 bytes .../RTAS/juce_RTAS_WinUtilities.cpp | 140 + .../RTAS/juce_RTAS_Wrapper.cpp | 1010 ++++ .../Standalone/juce_StandaloneFilterWindow.h | 304 ++ .../VST/juce_VST_Wrapper.cpp | 1616 ++++++ .../VST/juce_VST_Wrapper.mm | 261 + .../juce_audio_plugin_client.h | 33 + .../juce_audio_plugin_client/juce_module_info | 42 + .../utility/juce_CarbonVisibility.h | 79 + .../utility/juce_CheckSettingMacros.h | 99 + .../utility/juce_FakeMouseMoveGenerator.h | 66 + .../utility/juce_IncludeModuleHeaders.h | 34 + .../utility/juce_IncludeSystemHeaders.h | 66 + .../utility/juce_PluginHostType.h | 165 + .../utility/juce_PluginUtilities.cpp | 79 + .../format/juce_AudioPluginFormat.cpp | 17 +- .../format/juce_AudioPluginFormat.h | 20 +- .../format/juce_AudioPluginFormatManager.cpp | 25 +- .../format/juce_AudioPluginFormatManager.h | 17 +- .../format_types/juce_AudioUnitPluginFormat.h | 18 +- .../juce_AudioUnitPluginFormat.mm | 250 +- .../format_types/juce_DirectXPluginFormat.h | 63 - .../format_types/juce_LADSPAPluginFormat.cpp | 705 +++ .../format_types/juce_LADSPAPluginFormat.h | 37 +- .../format_types/juce_VSTMidiEventList.h | 17 +- .../format_types/juce_VSTPluginFormat.cpp | 329 +- .../format_types/juce_VSTPluginFormat.h | 18 +- .../juce_audio_processors.cpp | 28 +- .../juce_audio_processors.h | 20 +- .../juce_audio_processors.mm | 17 +- .../juce_audio_processors/juce_module_info | 2 +- .../processors/juce_AudioPlayHead.h | 26 +- .../processors/juce_AudioPluginInstance.h | 17 +- .../processors/juce_AudioProcessor.cpp | 17 +- .../processors/juce_AudioProcessor.h | 21 +- .../processors/juce_AudioProcessorEditor.cpp | 21 +- .../processors/juce_AudioProcessorEditor.h | 17 +- .../processors/juce_AudioProcessorGraph.cpp | 32 +- .../processors/juce_AudioProcessorGraph.h | 17 +- .../processors/juce_AudioProcessorListener.h | 17 +- .../juce_GenericAudioProcessorEditor.cpp | 41 +- .../juce_GenericAudioProcessorEditor.h | 17 +- .../processors/juce_PluginDescription.cpp | 17 +- .../processors/juce_PluginDescription.h | 17 +- .../scanning/juce_KnownPluginList.cpp | 67 +- .../scanning/juce_KnownPluginList.h | 21 +- .../scanning/juce_PluginDirectoryScanner.cpp | 69 +- .../scanning/juce_PluginDirectoryScanner.h | 20 +- .../scanning/juce_PluginListComponent.cpp | 111 +- .../scanning/juce_PluginListComponent.h | 36 +- .../gui/juce_AudioDeviceSelectorComponent.cpp | 25 +- .../gui/juce_AudioDeviceSelectorComponent.h | 17 +- .../gui/juce_AudioThumbnail.cpp | 22 +- .../gui/juce_AudioThumbnail.h | 17 +- .../gui/juce_AudioThumbnailBase.h | 17 +- .../gui/juce_AudioThumbnailCache.cpp | 17 +- .../gui/juce_AudioThumbnailCache.h | 17 +- .../gui/juce_MidiKeyboardComponent.cpp | 23 +- .../gui/juce_MidiKeyboardComponent.h | 23 +- .../juce_audio_utils/juce_audio_utils.cpp | 17 +- .../juce_audio_utils/juce_audio_utils.h | 17 +- .../juce_audio_utils/juce_audio_utils.mm | 17 +- .../modules/juce_audio_utils/juce_module_info | 2 +- .../players/juce_AudioProcessorPlayer.cpp | 17 +- .../players/juce_AudioProcessorPlayer.h | 17 +- .../containers/juce_AbstractFifo.cpp | 29 +- .../juce_core/containers/juce_AbstractFifo.h | 29 +- .../modules/juce_core/containers/juce_Array.h | 29 +- .../containers/juce_ArrayAllocationBase.h | 29 +- .../containers/juce_DynamicObject.cpp | 29 +- .../juce_core/containers/juce_DynamicObject.h | 29 +- .../containers/juce_ElementComparator.h | 29 +- .../juce_core/containers/juce_HashMap.h | 29 +- .../containers/juce_LinkedListPointer.h | 29 +- .../containers/juce_NamedValueSet.cpp | 86 +- .../juce_core/containers/juce_NamedValueSet.h | 47 +- .../juce_core/containers/juce_OwnedArray.h | 29 +- .../juce_core/containers/juce_PropertySet.cpp | 29 +- .../juce_core/containers/juce_PropertySet.h | 29 +- .../containers/juce_ReferenceCountedArray.h | 29 +- .../containers/juce_ScopedValueSetter.h | 35 +- .../juce_core/containers/juce_SortedSet.h | 29 +- .../juce_core/containers/juce_SparseSet.h | 41 +- .../juce_core/containers/juce_Variant.cpp | 127 +- .../juce_core/containers/juce_Variant.h | 71 +- .../files/juce_DirectoryIterator.cpp | 68 +- .../juce_core/files/juce_DirectoryIterator.h | 36 +- .../modules/juce_core/files/juce_File.cpp | 41 +- .../modules/juce_core/files/juce_File.h | 35 +- .../juce_core/files/juce_FileInputStream.cpp | 29 +- .../juce_core/files/juce_FileInputStream.h | 29 +- .../juce_core/files/juce_FileOutputStream.cpp | 29 +- .../juce_core/files/juce_FileOutputStream.h | 29 +- .../juce_core/files/juce_FileSearchPath.cpp | 29 +- .../juce_core/files/juce_FileSearchPath.h | 29 +- .../juce_core/files/juce_MemoryMappedFile.h | 29 +- .../juce_core/files/juce_TemporaryFile.cpp | 29 +- .../juce_core/files/juce_TemporaryFile.h | 29 +- .../modules/juce_core/json/juce_JSON.cpp | 85 +- .../modules/juce_core/json/juce_JSON.h | 29 +- .../modules/juce_core/juce_core.cpp | 41 +- JuceLibraryCode/modules/juce_core/juce_core.h | 40 +- .../modules/juce_core/juce_core.mm | 29 +- .../modules/juce_core/juce_module_info | 7 +- .../juce_core/logging/juce_FileLogger.cpp | 29 +- .../juce_core/logging/juce_FileLogger.h | 31 +- .../modules/juce_core/logging/juce_Logger.cpp | 37 +- .../modules/juce_core/logging/juce_Logger.h | 29 +- .../juce_core/maths/juce_BigInteger.cpp | 29 +- .../modules/juce_core/maths/juce_BigInteger.h | 29 +- .../juce_core/maths/juce_Expression.cpp | 29 +- .../modules/juce_core/maths/juce_Expression.h | 29 +- .../juce_core/maths/juce_MathsFunctions.h | 33 +- .../modules/juce_core/maths/juce_Random.cpp | 29 +- .../modules/juce_core/maths/juce_Random.h | 29 +- .../modules/juce_core/maths/juce_Range.h | 61 +- .../modules/juce_core/memory/juce_Atomic.h | 31 +- .../modules/juce_core/memory/juce_ByteOrder.h | 29 +- .../modules/juce_core/memory/juce_HeapBlock.h | 29 +- .../memory/juce_LeakedObjectDetector.h | 29 +- .../modules/juce_core/memory/juce_Memory.h | 41 +- .../juce_core/memory/juce_MemoryBlock.cpp | 29 +- .../juce_core/memory/juce_MemoryBlock.h | 29 +- .../memory/juce_OptionalScopedPointer.h | 29 +- .../memory/juce_ReferenceCountedObject.h | 31 +- .../juce_core/memory/juce_ScopedPointer.h | 60 +- .../modules/juce_core/memory/juce_Singleton.h | 29 +- .../juce_core/memory/juce_WeakReference.h | 29 +- .../modules/juce_core/misc/juce_Result.cpp | 29 +- .../modules/juce_core/misc/juce_Result.h | 29 +- .../modules/juce_core/misc/juce_Uuid.cpp | 29 +- .../modules/juce_core/misc/juce_Uuid.h | 29 +- .../juce_core/misc/juce_WindowsRegistry.h | 29 +- .../native/java/JuceAppActivity.java | 2 + .../native/juce_BasicNativeHeaders.h | 29 +- .../juce_core/native/juce_android_Files.cpp | 29 +- .../native/juce_android_JNIHelpers.h | 29 +- .../juce_core/native/juce_android_Misc.cpp | 29 +- .../juce_core/native/juce_android_Network.cpp | 29 +- .../native/juce_android_SystemStats.cpp | 29 +- .../juce_core/native/juce_android_Threads.cpp | 29 +- .../juce_core/native/juce_linux_Files.cpp | 29 +- .../juce_core/native/juce_linux_Network.cpp | 32 +- .../native/juce_linux_SystemStats.cpp | 29 +- .../juce_core/native/juce_linux_Threads.cpp | 50 +- .../juce_core/native/juce_mac_Files.mm | 375 +- .../juce_core/native/juce_mac_Network.mm | 123 +- .../juce_core/native/juce_mac_Strings.mm | 33 +- .../juce_core/native/juce_mac_SystemStats.mm | 43 +- .../juce_core/native/juce_mac_Threads.mm | 29 +- .../juce_core/native/juce_osx_ObjCHelpers.h | 29 +- .../juce_core/native/juce_posix_NamedPipe.cpp | 29 +- .../juce_core/native/juce_posix_SharedCode.h | 73 +- .../juce_core/native/juce_win32_ComSmartPtr.h | 51 +- .../juce_core/native/juce_win32_Files.cpp | 29 +- .../juce_core/native/juce_win32_Network.cpp | 98 +- .../juce_core/native/juce_win32_Registry.cpp | 29 +- .../native/juce_win32_SystemStats.cpp | 29 +- .../juce_core/native/juce_win32_Threads.cpp | 33 +- .../juce_core/network/juce_IPAddress.cpp | 149 + .../juce_core/network/juce_IPAddress.h | 82 + .../juce_core/network/juce_MACAddress.cpp | 29 +- .../juce_core/network/juce_MACAddress.h | 29 +- .../juce_core/network/juce_NamedPipe.cpp | 29 +- .../juce_core/network/juce_NamedPipe.h | 29 +- .../modules/juce_core/network/juce_Socket.cpp | 43 +- .../modules/juce_core/network/juce_Socket.h | 37 +- .../modules/juce_core/network/juce_URL.cpp | 33 +- .../modules/juce_core/network/juce_URL.h | 31 +- .../streams/juce_BufferedInputStream.cpp | 29 +- .../streams/juce_BufferedInputStream.h | 29 +- .../streams/juce_FileInputSource.cpp | 29 +- .../juce_core/streams/juce_FileInputSource.h | 29 +- .../juce_core/streams/juce_InputSource.h | 29 +- .../juce_core/streams/juce_InputStream.cpp | 29 +- .../juce_core/streams/juce_InputStream.h | 29 +- .../streams/juce_MemoryInputStream.cpp | 29 +- .../streams/juce_MemoryInputStream.h | 31 +- .../streams/juce_MemoryOutputStream.cpp | 55 +- .../streams/juce_MemoryOutputStream.h | 38 +- .../juce_core/streams/juce_OutputStream.cpp | 29 +- .../juce_core/streams/juce_OutputStream.h | 29 +- .../streams/juce_SubregionStream.cpp | 29 +- .../juce_core/streams/juce_SubregionStream.h | 29 +- .../juce_core/system/juce_PlatformDefs.h | 56 +- .../juce_core/system/juce_StandardHeader.h | 38 +- .../juce_core/system/juce_SystemStats.cpp | 31 +- .../juce_core/system/juce_SystemStats.h | 29 +- .../juce_core/system/juce_TargetPlatform.h | 29 +- .../juce_core/text/juce_CharPointer_ASCII.h | 77 +- .../juce_core/text/juce_CharPointer_UTF16.h | 77 +- .../juce_core/text/juce_CharPointer_UTF32.h | 75 +- .../juce_core/text/juce_CharPointer_UTF8.h | 71 +- .../text/juce_CharacterFunctions.cpp | 29 +- .../juce_core/text/juce_CharacterFunctions.h | 83 +- .../juce_core/text/juce_Identifier.cpp | 34 +- .../modules/juce_core/text/juce_Identifier.h | 35 +- .../juce_core/text/juce_LocalisedStrings.cpp | 48 +- .../juce_core/text/juce_LocalisedStrings.h | 56 +- .../modules/juce_core/text/juce_NewLine.h | 29 +- .../modules/juce_core/text/juce_String.cpp | 116 +- .../modules/juce_core/text/juce_String.h | 90 +- .../juce_core/text/juce_StringArray.cpp | 63 +- .../modules/juce_core/text/juce_StringArray.h | 72 +- .../juce_core/text/juce_StringPairArray.cpp | 29 +- .../juce_core/text/juce_StringPairArray.h | 29 +- .../juce_core/text/juce_StringPool.cpp | 29 +- .../modules/juce_core/text/juce_StringPool.h | 29 +- .../modules/juce_core/text/juce_TextDiff.cpp | 33 +- .../modules/juce_core/text/juce_TextDiff.h | 29 +- .../juce_core/threads/juce_ChildProcess.cpp | 29 +- .../juce_core/threads/juce_ChildProcess.h | 29 +- .../juce_core/threads/juce_CriticalSection.h | 29 +- .../juce_core/threads/juce_DynamicLibrary.h | 29 +- .../threads/juce_HighResolutionTimer.cpp | 29 +- .../threads/juce_HighResolutionTimer.h | 29 +- .../juce_core/threads/juce_InterProcessLock.h | 29 +- .../modules/juce_core/threads/juce_Process.h | 29 +- .../juce_core/threads/juce_ReadWriteLock.cpp | 29 +- .../juce_core/threads/juce_ReadWriteLock.h | 29 +- .../juce_core/threads/juce_ScopedLock.h | 29 +- .../juce_core/threads/juce_ScopedReadLock.h | 29 +- .../juce_core/threads/juce_ScopedWriteLock.h | 29 +- .../modules/juce_core/threads/juce_SpinLock.h | 29 +- .../modules/juce_core/threads/juce_Thread.cpp | 29 +- .../modules/juce_core/threads/juce_Thread.h | 29 +- .../juce_core/threads/juce_ThreadLocalValue.h | 31 +- .../juce_core/threads/juce_ThreadPool.cpp | 29 +- .../juce_core/threads/juce_ThreadPool.h | 29 +- .../threads/juce_TimeSliceThread.cpp | 31 +- .../juce_core/threads/juce_TimeSliceThread.h | 29 +- .../juce_core/threads/juce_WaitableEvent.h | 29 +- .../time/juce_PerformanceCounter.cpp | 30 +- .../juce_core/time/juce_PerformanceCounter.h | 29 +- .../juce_core/time/juce_RelativeTime.cpp | 89 +- .../juce_core/time/juce_RelativeTime.h | 65 +- .../modules/juce_core/time/juce_Time.cpp | 57 +- .../modules/juce_core/time/juce_Time.h | 53 +- .../juce_core/unit_tests/juce_UnitTest.cpp | 31 +- .../juce_core/unit_tests/juce_UnitTest.h | 29 +- .../juce_core/xml/juce_XmlDocument.cpp | 35 +- .../modules/juce_core/xml/juce_XmlDocument.h | 29 +- .../modules/juce_core/xml/juce_XmlElement.cpp | 85 +- .../modules/juce_core/xml/juce_XmlElement.h | 48 +- .../zip/juce_GZIPCompressorOutputStream.cpp | 29 +- .../zip/juce_GZIPCompressorOutputStream.h | 29 +- .../zip/juce_GZIPDecompressorInputStream.cpp | 30 +- .../zip/juce_GZIPDecompressorInputStream.h | 29 +- .../modules/juce_core/zip/juce_ZipFile.cpp | 32 +- .../modules/juce_core/zip/juce_ZipFile.h | 29 +- .../encryption/juce_BlowFish.cpp | 17 +- .../encryption/juce_BlowFish.h | 17 +- .../encryption/juce_Primes.cpp | 17 +- .../encryption/juce_Primes.h | 17 +- .../encryption/juce_RSAKey.cpp | 17 +- .../encryption/juce_RSAKey.h | 17 +- .../juce_cryptography/hashing/juce_MD5.cpp | 19 +- .../juce_cryptography/hashing/juce_MD5.h | 19 +- .../juce_cryptography/hashing/juce_SHA256.cpp | 19 +- .../juce_cryptography/hashing/juce_SHA256.h | 19 +- .../juce_cryptography/juce_cryptography.cpp | 17 +- .../juce_cryptography/juce_cryptography.h | 17 +- .../juce_cryptography/juce_cryptography.mm | 17 +- .../juce_cryptography/juce_module_info | 2 +- .../juce_ApplicationProperties.cpp | 17 +- .../juce_ApplicationProperties.h | 17 +- .../app_properties/juce_PropertiesFile.cpp | 23 +- .../app_properties/juce_PropertiesFile.h | 17 +- .../juce_data_structures.cpp | 17 +- .../juce_data_structures.h | 17 +- .../juce_data_structures.mm | 17 +- .../juce_data_structures/juce_module_info | 2 +- .../undomanager/juce_UndoManager.cpp | 17 +- .../undomanager/juce_UndoManager.h | 17 +- .../undomanager/juce_UndoableAction.h | 17 +- .../values/juce_Value.cpp | 17 +- .../juce_data_structures/values/juce_Value.h | 17 +- .../values/juce_ValueTree.cpp | 79 +- .../values/juce_ValueTree.h | 43 +- .../broadcasters/juce_ActionBroadcaster.cpp | 17 +- .../broadcasters/juce_ActionBroadcaster.h | 17 +- .../broadcasters/juce_ActionListener.h | 17 +- .../broadcasters/juce_AsyncUpdater.cpp | 17 +- .../broadcasters/juce_AsyncUpdater.h | 17 +- .../broadcasters/juce_ChangeBroadcaster.cpp | 17 +- .../broadcasters/juce_ChangeBroadcaster.h | 17 +- .../broadcasters/juce_ChangeListener.h | 17 +- .../broadcasters/juce_ListenerList.h | 38 +- .../juce_InterprocessConnection.cpp | 17 +- .../juce_InterprocessConnection.h | 17 +- .../juce_InterprocessConnectionServer.cpp | 17 +- .../juce_InterprocessConnectionServer.h | 17 +- .../modules/juce_events/juce_events.cpp | 17 +- .../modules/juce_events/juce_events.h | 17 +- .../modules/juce_events/juce_events.mm | 17 +- .../modules/juce_events/juce_module_info | 2 +- .../messages/juce_ApplicationBase.cpp | 32 +- .../messages/juce_ApplicationBase.h | 17 +- .../messages/juce_CallbackMessage.h | 17 +- .../messages/juce_DeletedAtShutdown.cpp | 17 +- .../messages/juce_DeletedAtShutdown.h | 17 +- .../juce_events/messages/juce_Message.h | 17 +- .../messages/juce_MessageListener.cpp | 17 +- .../messages/juce_MessageListener.h | 17 +- .../messages/juce_MessageManager.cpp | 42 +- .../messages/juce_MessageManager.h | 17 +- .../messages/juce_NotificationType.h | 17 +- .../juce_events/native/juce_ScopedXLock.h | 17 +- .../native/juce_android_Messaging.cpp | 17 +- .../native/juce_ios_MessageManager.mm | 44 +- .../native/juce_linux_Messaging.cpp | 34 +- .../native/juce_mac_MessageManager.mm | 89 +- .../native/juce_osx_MessageQueue.h | 27 +- .../native/juce_win32_HiddenMessageWindow.h | 17 +- .../native/juce_win32_Messaging.cpp | 17 +- .../juce_events/timers/juce_MultiTimer.cpp | 17 +- .../juce_events/timers/juce_MultiTimer.h | 17 +- .../modules/juce_events/timers/juce_Timer.cpp | 22 +- .../modules/juce_events/timers/juce_Timer.h | 17 +- .../juce_graphics/colour/juce_Colour.cpp | 46 +- .../juce_graphics/colour/juce_Colour.h | 27 +- .../colour/juce_ColourGradient.cpp | 25 +- .../colour/juce_ColourGradient.h | 27 +- .../juce_graphics/colour/juce_Colours.cpp | 19 +- .../juce_graphics/colour/juce_Colours.h | 19 +- .../juce_graphics/colour/juce_FillType.cpp | 23 +- .../juce_graphics/colour/juce_FillType.h | 21 +- .../juce_graphics/colour/juce_PixelFormats.h | 91 +- .../contexts/juce_GraphicsContext.cpp | 33 +- .../contexts/juce_GraphicsContext.h | 38 +- .../contexts/juce_LowLevelGraphicsContext.h | 17 +- ...uce_LowLevelGraphicsPostScriptRenderer.cpp | 17 +- .../juce_LowLevelGraphicsPostScriptRenderer.h | 17 +- .../juce_LowLevelGraphicsSoftwareRenderer.cpp | 19 +- .../juce_LowLevelGraphicsSoftwareRenderer.h | 19 +- .../effects/juce_DropShadowEffect.cpp | 19 +- .../effects/juce_DropShadowEffect.h | 19 +- .../juce_graphics/effects/juce_GlowEffect.cpp | 19 +- .../juce_graphics/effects/juce_GlowEffect.h | 19 +- .../effects/juce_ImageEffectFilter.h | 17 +- .../fonts/juce_AttributedString.cpp | 31 +- .../fonts/juce_AttributedString.h | 31 +- .../fonts/juce_CustomTypeface.cpp | 134 +- .../juce_graphics/fonts/juce_CustomTypeface.h | 17 +- .../modules/juce_graphics/fonts/juce_Font.cpp | 17 +- .../modules/juce_graphics/fonts/juce_Font.h | 17 +- .../fonts/juce_GlyphArrangement.cpp | 17 +- .../fonts/juce_GlyphArrangement.h | 17 +- .../juce_graphics/fonts/juce_TextLayout.cpp | 31 +- .../juce_graphics/fonts/juce_TextLayout.h | 23 +- .../juce_graphics/fonts/juce_Typeface.cpp | 51 +- .../juce_graphics/fonts/juce_Typeface.h | 22 +- .../geometry/juce_AffineTransform.cpp | 23 +- .../geometry/juce_AffineTransform.h | 21 +- .../juce_graphics/geometry/juce_BorderSize.h | 19 +- .../juce_graphics/geometry/juce_EdgeTable.cpp | 17 +- .../juce_graphics/geometry/juce_EdgeTable.h | 17 +- .../juce_graphics/geometry/juce_Line.h | 41 +- .../juce_graphics/geometry/juce_Path.cpp | 41 +- .../juce_graphics/geometry/juce_Path.h | 41 +- .../geometry/juce_PathIterator.cpp | 17 +- .../geometry/juce_PathIterator.h | 17 +- .../geometry/juce_PathStrokeType.cpp | 17 +- .../geometry/juce_PathStrokeType.h | 17 +- .../juce_graphics/geometry/juce_Point.h | 39 +- .../juce_graphics/geometry/juce_Rectangle.h | 42 +- .../geometry/juce_RectangleList.cpp | 17 +- .../geometry/juce_RectangleList.h | 17 +- .../image_formats/juce_GIFLoader.cpp | 17 +- .../image_formats/juce_JPEGLoader.cpp | 31 +- .../image_formats/juce_PNGLoader.cpp | 268 +- .../juce_graphics/image_formats/pnglib/png.c | 4569 ++++++++++++++-- .../juce_graphics/image_formats/pnglib/png.h | 4570 ++++++++-------- .../image_formats/pnglib/pngconf.h | 1849 ++----- .../image_formats/pnglib/pngerror.c | 911 +++- .../image_formats/pnglib/pngget.c | 1090 ++-- .../image_formats/pnglib/pnginfo.h | 260 + .../image_formats/pnglib/pngmem.c | 657 +-- .../image_formats/pnglib/pngpread.c | 1373 ++--- .../image_formats/pnglib/pngpriv.h | 1913 +++++++ .../image_formats/pnglib/pngread.c | 4402 +++++++++++---- .../image_formats/pnglib/pngrio.c | 157 +- .../image_formats/pnglib/pngrtran.c | 4657 +++++++++------- .../image_formats/pnglib/pngrutil.c | 4725 +++++++++++------ .../image_formats/pnglib/pngset.c | 1997 ++++--- .../image_formats/pnglib/pngstruct.h | 489 ++ .../image_formats/pnglib/pngtrans.c | 694 ++- .../image_formats/pnglib/pngwio.c | 244 +- .../image_formats/pnglib/pngwrite.c | 2503 ++++++--- .../image_formats/pnglib/pngwtran.c | 293 +- .../image_formats/pnglib/pngwutil.c | 2880 +++++----- .../juce_graphics/images/juce_Image.cpp | 23 +- .../modules/juce_graphics/images/juce_Image.h | 23 +- .../juce_graphics/images/juce_ImageCache.cpp | 36 +- .../juce_graphics/images/juce_ImageCache.h | 21 +- .../images/juce_ImageConvolutionKernel.cpp | 17 +- .../images/juce_ImageConvolutionKernel.h | 17 +- .../images/juce_ImageFileFormat.cpp | 17 +- .../images/juce_ImageFileFormat.h | 50 +- .../modules/juce_graphics/juce_graphics.cpp | 62 +- .../modules/juce_graphics/juce_graphics.h | 19 +- .../modules/juce_graphics/juce_graphics.mm | 17 +- .../modules/juce_graphics/juce_module_info | 2 +- .../native/juce_RenderingHelpers.h | 141 +- .../native/juce_android_Fonts.cpp | 119 +- .../native/juce_android_GraphicsContext.cpp | 17 +- .../native/juce_freetype_Fonts.cpp | 412 ++ .../juce_graphics/native/juce_linux_Fonts.cpp | 500 +- .../native/juce_mac_CoreGraphicsContext.h | 17 +- .../native/juce_mac_CoreGraphicsContext.mm | 115 +- .../native/juce_mac_CoreGraphicsHelpers.h | 19 +- .../juce_graphics/native/juce_mac_Fonts.mm | 192 +- .../juce_win32_Direct2DGraphicsContext.cpp | 25 +- .../juce_win32_DirectWriteTypeLayout.cpp | 23 +- .../native/juce_win32_DirectWriteTypeface.cpp | 22 +- .../juce_graphics/native/juce_win32_Fonts.cpp | 22 +- .../placement/juce_Justification.cpp | 17 +- .../placement/juce_Justification.h | 17 +- .../placement/juce_RectanglePlacement.cpp | 17 +- .../placement/juce_RectanglePlacement.h | 17 +- .../application/juce_Application.cpp | 40 +- .../application/juce_Application.h | 17 +- .../application/juce_Initialisation.h | 17 +- .../buttons/juce_ArrowButton.cpp | 19 +- .../buttons/juce_ArrowButton.h | 19 +- .../juce_gui_basics/buttons/juce_Button.cpp | 17 +- .../juce_gui_basics/buttons/juce_Button.h | 17 +- .../buttons/juce_DrawableButton.cpp | 17 +- .../buttons/juce_DrawableButton.h | 17 +- .../buttons/juce_HyperlinkButton.cpp | 17 +- .../buttons/juce_HyperlinkButton.h | 17 +- .../buttons/juce_ImageButton.cpp | 23 +- .../buttons/juce_ImageButton.h | 25 +- .../buttons/juce_ShapeButton.cpp | 17 +- .../buttons/juce_ShapeButton.h | 17 +- .../buttons/juce_TextButton.cpp | 17 +- .../juce_gui_basics/buttons/juce_TextButton.h | 17 +- .../buttons/juce_ToggleButton.cpp | 17 +- .../buttons/juce_ToggleButton.h | 17 +- .../buttons/juce_ToolbarButton.cpp | 17 +- .../buttons/juce_ToolbarButton.h | 17 +- .../commands/juce_ApplicationCommandID.h | 17 +- .../commands/juce_ApplicationCommandInfo.cpp | 19 +- .../commands/juce_ApplicationCommandInfo.h | 19 +- .../juce_ApplicationCommandManager.cpp | 17 +- .../commands/juce_ApplicationCommandManager.h | 17 +- .../juce_ApplicationCommandTarget.cpp | 17 +- .../commands/juce_ApplicationCommandTarget.h | 17 +- .../commands/juce_KeyPressMappingSet.cpp | 17 +- .../commands/juce_KeyPressMappingSet.h | 17 +- .../components/juce_CachedComponentImage.h | 17 +- .../components/juce_Component.cpp | 99 +- .../components/juce_Component.h | 71 +- .../components/juce_ComponentListener.cpp | 17 +- .../components/juce_ComponentListener.h | 17 +- .../components/juce_Desktop.cpp | 21 +- .../juce_gui_basics/components/juce_Desktop.h | 23 +- .../components/juce_ModalComponentManager.cpp | 17 +- .../components/juce_ModalComponentManager.h | 17 +- .../drawables/juce_Drawable.cpp | 19 +- .../juce_gui_basics/drawables/juce_Drawable.h | 22 +- .../drawables/juce_DrawableComposite.cpp | 17 +- .../drawables/juce_DrawableComposite.h | 17 +- .../drawables/juce_DrawableImage.cpp | 17 +- .../drawables/juce_DrawableImage.h | 17 +- .../drawables/juce_DrawablePath.cpp | 27 +- .../drawables/juce_DrawablePath.h | 21 +- .../drawables/juce_DrawableRectangle.cpp | 17 +- .../drawables/juce_DrawableRectangle.h | 17 +- .../drawables/juce_DrawableShape.cpp | 27 +- .../drawables/juce_DrawableShape.h | 17 +- .../drawables/juce_DrawableText.cpp | 44 +- .../drawables/juce_DrawableText.h | 24 +- .../drawables/juce_SVGParser.cpp | 274 +- ...juce_DirectoryContentsDisplayComponent.cpp | 17 +- .../juce_DirectoryContentsDisplayComponent.h | 17 +- .../juce_DirectoryContentsList.cpp | 21 +- .../filebrowser/juce_DirectoryContentsList.h | 21 +- .../filebrowser/juce_FileBrowserComponent.cpp | 23 +- .../filebrowser/juce_FileBrowserComponent.h | 20 +- .../filebrowser/juce_FileBrowserListener.h | 17 +- .../filebrowser/juce_FileChooser.cpp | 126 +- .../filebrowser/juce_FileChooser.h | 40 +- .../filebrowser/juce_FileChooserDialogBox.cpp | 52 +- .../filebrowser/juce_FileChooserDialogBox.h | 17 +- .../filebrowser/juce_FileFilter.cpp | 17 +- .../filebrowser/juce_FileFilter.h | 17 +- .../filebrowser/juce_FileListComponent.cpp | 17 +- .../filebrowser/juce_FileListComponent.h | 17 +- .../filebrowser/juce_FilePreviewComponent.h | 17 +- .../juce_FileSearchPathListComponent.cpp | 17 +- .../juce_FileSearchPathListComponent.h | 17 +- .../filebrowser/juce_FileTreeComponent.cpp | 53 +- .../filebrowser/juce_FileTreeComponent.h | 17 +- .../filebrowser/juce_FilenameComponent.cpp | 19 +- .../filebrowser/juce_FilenameComponent.h | 18 +- .../juce_ImagePreviewComponent.cpp | 23 +- .../filebrowser/juce_ImagePreviewComponent.h | 17 +- .../filebrowser/juce_WildcardFileFilter.cpp | 17 +- .../filebrowser/juce_WildcardFileFilter.h | 17 +- .../juce_gui_basics/juce_gui_basics.cpp | 17 +- .../modules/juce_gui_basics/juce_gui_basics.h | 17 +- .../juce_gui_basics/juce_gui_basics.mm | 17 +- .../modules/juce_gui_basics/juce_module_info | 2 +- .../keyboard/juce_CaretComponent.cpp | 17 +- .../keyboard/juce_CaretComponent.h | 17 +- .../keyboard/juce_KeyListener.cpp | 17 +- .../keyboard/juce_KeyListener.h | 17 +- .../keyboard/juce_KeyPress.cpp | 32 +- .../juce_gui_basics/keyboard/juce_KeyPress.h | 19 +- .../keyboard/juce_KeyboardFocusTraverser.cpp | 17 +- .../keyboard/juce_KeyboardFocusTraverser.h | 17 +- .../keyboard/juce_ModifierKeys.cpp | 19 +- .../keyboard/juce_ModifierKeys.h | 23 +- .../keyboard/juce_SystemClipboard.h | 17 +- .../keyboard/juce_TextEditorKeyMapper.h | 17 +- .../keyboard/juce_TextInputTarget.h | 17 +- .../layout/juce_ComponentAnimator.cpp | 17 +- .../layout/juce_ComponentAnimator.h | 17 +- .../juce_ComponentBoundsConstrainer.cpp | 17 +- .../layout/juce_ComponentBoundsConstrainer.h | 17 +- .../layout/juce_ComponentBuilder.cpp | 17 +- .../layout/juce_ComponentBuilder.h | 17 +- .../layout/juce_ComponentMovementWatcher.cpp | 23 +- .../layout/juce_ComponentMovementWatcher.h | 17 +- .../layout/juce_ConcertinaPanel.cpp | 17 +- .../layout/juce_ConcertinaPanel.h | 17 +- .../layout/juce_GroupComponent.cpp | 17 +- .../layout/juce_GroupComponent.h | 17 +- .../layout/juce_MultiDocumentPanel.cpp | 17 +- .../layout/juce_MultiDocumentPanel.h | 17 +- .../layout/juce_ResizableBorderComponent.cpp | 19 +- .../layout/juce_ResizableBorderComponent.h | 19 +- .../layout/juce_ResizableCornerComponent.cpp | 17 +- .../layout/juce_ResizableCornerComponent.h | 17 +- .../layout/juce_ResizableEdgeComponent.cpp | 17 +- .../layout/juce_ResizableEdgeComponent.h | 17 +- .../juce_gui_basics/layout/juce_ScrollBar.cpp | 21 +- .../juce_gui_basics/layout/juce_ScrollBar.h | 21 +- .../layout/juce_StretchableLayoutManager.cpp | 17 +- .../layout/juce_StretchableLayoutManager.h | 17 +- .../juce_StretchableLayoutResizerBar.cpp | 17 +- .../layout/juce_StretchableLayoutResizerBar.h | 17 +- .../layout/juce_StretchableObjectResizer.cpp | 17 +- .../layout/juce_StretchableObjectResizer.h | 17 +- .../layout/juce_TabbedButtonBar.cpp | 17 +- .../layout/juce_TabbedButtonBar.h | 17 +- .../layout/juce_TabbedComponent.cpp | 17 +- .../layout/juce_TabbedComponent.h | 17 +- .../juce_gui_basics/layout/juce_Viewport.cpp | 23 +- .../juce_gui_basics/layout/juce_Viewport.h | 25 +- .../lookandfeel/juce_LookAndFeel.cpp | 81 +- .../lookandfeel/juce_LookAndFeel.h | 27 +- .../menus/juce_MenuBarComponent.cpp | 21 +- .../menus/juce_MenuBarComponent.h | 21 +- .../menus/juce_MenuBarModel.cpp | 17 +- .../juce_gui_basics/menus/juce_MenuBarModel.h | 17 +- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 88 +- .../juce_gui_basics/menus/juce_PopupMenu.h | 29 +- .../misc/juce_BubbleComponent.cpp | 19 +- .../misc/juce_BubbleComponent.h | 19 +- .../misc/juce_DropShadower.cpp | 23 +- .../juce_gui_basics/misc/juce_DropShadower.h | 17 +- .../mouse/juce_ComponentDragger.cpp | 17 +- .../mouse/juce_ComponentDragger.h | 17 +- .../mouse/juce_DragAndDropContainer.cpp | 35 +- .../mouse/juce_DragAndDropContainer.h | 17 +- .../mouse/juce_DragAndDropTarget.h | 19 +- .../mouse/juce_FileDragAndDropTarget.h | 17 +- .../mouse/juce_LassoComponent.h | 17 +- .../mouse/juce_MouseCursor.cpp | 21 +- .../juce_gui_basics/mouse/juce_MouseCursor.h | 17 +- .../juce_gui_basics/mouse/juce_MouseEvent.cpp | 29 +- .../juce_gui_basics/mouse/juce_MouseEvent.h | 29 +- .../mouse/juce_MouseInputSource.cpp | 129 +- .../mouse/juce_MouseInputSource.h | 23 +- .../mouse/juce_MouseListener.cpp | 17 +- .../mouse/juce_MouseListener.h | 17 +- .../mouse/juce_SelectedItemSet.h | 23 +- .../mouse/juce_TextDragAndDropTarget.h | 17 +- .../mouse/juce_TooltipClient.h | 17 +- .../native/juce_MultiTouchMapper.h | 17 +- .../native/juce_android_FileChooser.cpp | 17 +- .../native/juce_android_Windowing.cpp | 54 +- .../native/juce_ios_UIViewComponentPeer.mm | 61 +- .../native/juce_ios_Windowing.mm | 56 +- .../native/juce_linux_Clipboard.cpp | 17 +- .../native/juce_linux_FileChooser.cpp | 20 +- .../native/juce_linux_Windowing.cpp | 120 +- .../native/juce_mac_FileChooser.mm | 140 +- .../native/juce_mac_MainMenu.mm | 65 +- .../native/juce_mac_MouseCursor.mm | 122 +- .../native/juce_mac_NSViewComponentPeer.mm | 69 +- .../native/juce_mac_Windowing.mm | 144 +- .../native/juce_win32_DragAndDrop.cpp | 17 +- .../native/juce_win32_FileChooser.cpp | 51 +- .../native/juce_win32_Windowing.cpp | 249 +- .../positioning/juce_MarkerList.cpp | 17 +- .../positioning/juce_MarkerList.h | 17 +- .../positioning/juce_RelativeCoordinate.cpp | 17 +- .../positioning/juce_RelativeCoordinate.h | 17 +- .../juce_RelativeCoordinatePositioner.cpp | 31 +- .../juce_RelativeCoordinatePositioner.h | 17 +- .../juce_RelativeParallelogram.cpp | 23 +- .../positioning/juce_RelativeParallelogram.h | 23 +- .../positioning/juce_RelativePoint.cpp | 23 +- .../positioning/juce_RelativePoint.h | 23 +- .../positioning/juce_RelativePointPath.cpp | 17 +- .../positioning/juce_RelativePointPath.h | 17 +- .../positioning/juce_RelativeRectangle.cpp | 23 +- .../positioning/juce_RelativeRectangle.h | 17 +- .../juce_BooleanPropertyComponent.cpp | 17 +- .../juce_BooleanPropertyComponent.h | 17 +- .../juce_ButtonPropertyComponent.cpp | 17 +- .../properties/juce_ButtonPropertyComponent.h | 17 +- .../juce_ChoicePropertyComponent.cpp | 17 +- .../properties/juce_ChoicePropertyComponent.h | 17 +- .../properties/juce_PropertyComponent.cpp | 17 +- .../properties/juce_PropertyComponent.h | 17 +- .../properties/juce_PropertyPanel.cpp | 25 +- .../properties/juce_PropertyPanel.h | 33 +- .../juce_SliderPropertyComponent.cpp | 17 +- .../properties/juce_SliderPropertyComponent.h | 17 +- .../properties/juce_TextPropertyComponent.cpp | 23 +- .../properties/juce_TextPropertyComponent.h | 17 +- .../juce_gui_basics/widgets/juce_ComboBox.cpp | 23 +- .../juce_gui_basics/widgets/juce_ComboBox.h | 17 +- .../widgets/juce_ImageComponent.cpp | 17 +- .../widgets/juce_ImageComponent.h | 17 +- .../juce_gui_basics/widgets/juce_Label.cpp | 40 +- .../juce_gui_basics/widgets/juce_Label.h | 35 +- .../juce_gui_basics/widgets/juce_ListBox.cpp | 103 +- .../juce_gui_basics/widgets/juce_ListBox.h | 26 +- .../widgets/juce_ProgressBar.cpp | 17 +- .../widgets/juce_ProgressBar.h | 17 +- .../juce_gui_basics/widgets/juce_Slider.cpp | 70 +- .../juce_gui_basics/widgets/juce_Slider.h | 17 +- .../widgets/juce_TableHeaderComponent.cpp | 17 +- .../widgets/juce_TableHeaderComponent.h | 17 +- .../widgets/juce_TableListBox.cpp | 17 +- .../widgets/juce_TableListBox.h | 17 +- .../widgets/juce_TextEditor.cpp | 42 +- .../juce_gui_basics/widgets/juce_TextEditor.h | 29 +- .../juce_gui_basics/widgets/juce_Toolbar.cpp | 22 +- .../juce_gui_basics/widgets/juce_Toolbar.h | 17 +- .../widgets/juce_ToolbarItemComponent.cpp | 21 +- .../widgets/juce_ToolbarItemComponent.h | 17 +- .../widgets/juce_ToolbarItemFactory.h | 17 +- .../widgets/juce_ToolbarItemPalette.cpp | 17 +- .../widgets/juce_ToolbarItemPalette.h | 17 +- .../juce_gui_basics/widgets/juce_TreeView.cpp | 85 +- .../juce_gui_basics/widgets/juce_TreeView.h | 20 +- .../windows/juce_AlertWindow.cpp | 31 +- .../windows/juce_AlertWindow.h | 17 +- .../windows/juce_CallOutBox.cpp | 17 +- .../juce_gui_basics/windows/juce_CallOutBox.h | 17 +- .../windows/juce_ComponentPeer.cpp | 36 +- .../windows/juce_ComponentPeer.h | 41 +- .../windows/juce_DialogWindow.cpp | 17 +- .../windows/juce_DialogWindow.h | 23 +- .../windows/juce_DocumentWindow.cpp | 17 +- .../windows/juce_DocumentWindow.h | 17 +- .../windows/juce_NativeMessageBox.h | 17 +- .../windows/juce_ResizableWindow.cpp | 17 +- .../windows/juce_ResizableWindow.h | 17 +- .../windows/juce_ThreadWithProgressWindow.cpp | 17 +- .../windows/juce_ThreadWithProgressWindow.h | 17 +- .../windows/juce_TooltipWindow.cpp | 17 +- .../windows/juce_TooltipWindow.h | 20 +- .../windows/juce_TopLevelWindow.cpp | 17 +- .../windows/juce_TopLevelWindow.h | 17 +- .../juce_CPlusPlusCodeTokeniser.cpp | 17 +- .../code_editor/juce_CPlusPlusCodeTokeniser.h | 17 +- .../juce_CPlusPlusCodeTokeniserFunctions.h | 17 +- .../code_editor/juce_CodeDocument.cpp | 98 +- .../code_editor/juce_CodeDocument.h | 17 +- .../code_editor/juce_CodeEditorComponent.cpp | 78 +- .../code_editor/juce_CodeEditorComponent.h | 27 +- .../code_editor/juce_CodeTokeniser.h | 17 +- .../documents/juce_FileBasedDocument.cpp | 105 +- .../documents/juce_FileBasedDocument.h | 17 +- .../embedding/juce_ActiveXControlComponent.h | 17 +- .../embedding/juce_NSViewComponent.h | 17 +- .../embedding/juce_UIViewComponent.h | 17 +- .../modules/juce_gui_extra/juce_gui_extra.cpp | 18 +- .../modules/juce_gui_extra/juce_gui_extra.h | 17 +- .../modules/juce_gui_extra/juce_gui_extra.mm | 17 +- .../modules/juce_gui_extra/juce_module_info | 2 +- .../lookandfeel/juce_OldSchoolLookAndFeel.cpp | 17 +- .../lookandfeel/juce_OldSchoolLookAndFeel.h | 17 +- .../juce_gui_extra/misc/juce_AppleRemote.h | 17 +- .../misc/juce_BubbleMessageComponent.cpp | 21 +- .../misc/juce_BubbleMessageComponent.h | 17 +- .../misc/juce_ColourSelector.cpp | 19 +- .../juce_gui_extra/misc/juce_ColourSelector.h | 19 +- .../misc/juce_KeyMappingEditorComponent.cpp | 38 +- .../misc/juce_KeyMappingEditorComponent.h | 21 +- .../misc/juce_PreferencesPanel.cpp | 17 +- .../misc/juce_PreferencesPanel.h | 17 +- .../misc/juce_RecentlyOpenedFilesList.cpp | 24 +- .../misc/juce_RecentlyOpenedFilesList.h | 17 +- .../juce_gui_extra/misc/juce_SplashScreen.cpp | 18 +- .../juce_gui_extra/misc/juce_SplashScreen.h | 17 +- .../misc/juce_SystemTrayIconComponent.cpp | 19 +- .../misc/juce_SystemTrayIconComponent.h | 19 +- .../misc/juce_WebBrowserComponent.h | 17 +- .../juce_android_WebBrowserComponent.cpp | 17 +- .../native/juce_ios_UIViewComponent.mm | 17 +- .../native/juce_linux_SystemTrayIcon.cpp | 17 +- .../native/juce_linux_WebBrowserComponent.cpp | 17 +- .../native/juce_mac_AppleRemote.mm | 17 +- .../juce_mac_CarbonViewWrapperComponent.h | 59 +- .../native/juce_mac_NSViewComponent.mm | 17 +- .../native/juce_mac_SystemTrayIcon.cpp | 207 + .../native/juce_mac_WebBrowserComponent.mm | 17 +- .../native/juce_win32_ActiveXComponent.cpp | 17 +- .../native/juce_win32_SystemTrayIcon.cpp | 44 +- .../native/juce_win32_WebBrowserComponent.cpp | 35 +- .../modules/juce_opengl/juce_module_info | 5 +- .../modules/juce_opengl/juce_opengl.cpp | 17 +- .../modules/juce_opengl/juce_opengl.h | 17 +- .../modules/juce_opengl/juce_opengl.mm | 17 +- .../native/juce_MissingGLDefinitions.h | 20 +- .../native/juce_OpenGLExtensions.h | 17 +- .../juce_opengl/native/juce_OpenGL_android.h | 19 +- .../juce_opengl/native/juce_OpenGL_ios.h | 69 +- .../juce_opengl/native/juce_OpenGL_linux.h | 21 +- .../juce_opengl/native/juce_OpenGL_osx.h | 19 +- .../juce_opengl/native/juce_OpenGL_win32.h | 19 +- .../opengl/juce_Draggable3DOrientation.h | 21 +- .../juce_opengl/opengl/juce_Matrix3D.h | 17 +- .../juce_opengl/opengl/juce_OpenGLContext.cpp | 47 +- .../juce_opengl/opengl/juce_OpenGLContext.h | 17 +- .../opengl/juce_OpenGLFrameBuffer.cpp | 23 +- .../opengl/juce_OpenGLFrameBuffer.h | 23 +- .../opengl/juce_OpenGLGraphicsContext.cpp | 105 +- .../opengl/juce_OpenGLGraphicsContext.h | 17 +- .../juce_opengl/opengl/juce_OpenGLHelpers.cpp | 27 +- .../juce_opengl/opengl/juce_OpenGLHelpers.h | 27 +- .../juce_opengl/opengl/juce_OpenGLImage.cpp | 21 +- .../juce_opengl/opengl/juce_OpenGLImage.h | 17 +- .../opengl/juce_OpenGLPixelFormat.cpp | 17 +- .../opengl/juce_OpenGLPixelFormat.h | 17 +- .../juce_opengl/opengl/juce_OpenGLRenderer.h | 17 +- .../opengl/juce_OpenGLShaderProgram.cpp | 17 +- .../opengl/juce_OpenGLShaderProgram.h | 17 +- .../juce_opengl/opengl/juce_OpenGLTexture.cpp | 21 +- .../juce_opengl/opengl/juce_OpenGLTexture.h | 21 +- .../juce_opengl/opengl/juce_Quaternion.h | 17 +- .../juce_opengl/opengl/juce_Vector3D.h | 17 +- .../juce_video/capture/juce_CameraDevice.h | 17 +- .../modules/juce_video/juce_module_info | 2 +- .../modules/juce_video/juce_video.cpp | 17 +- .../modules/juce_video/juce_video.h | 17 +- .../modules/juce_video/juce_video.mm | 17 +- .../native/juce_android_CameraDevice.cpp | 17 +- .../native/juce_mac_CameraDevice.mm | 104 +- .../juce_mac_QuickTimeMovieComponent.mm | 17 +- .../native/juce_win32_CameraDevice.cpp | 17 +- .../native/juce_win32_DirectShowComponent.cpp | 19 +- .../juce_win32_QuickTimeMovieComponent.cpp | 17 +- .../playback/juce_DirectShowComponent.h | 17 +- .../playback/juce_QuickTimeMovieComponent.h | 17 +- Source/Audio/AudioComponent.cpp | 2 + .../Processors/Editors/SpikeDisplayEditor.cpp | 18 + .../Processors/Editors/SpikeDisplayEditor.h | 3 + Source/Processors/GenericProcessor.h | 6 + Source/Processors/ProcessorGraph.cpp | 32 + Source/Processors/ProcessorGraph.h | 2 + Source/Processors/RecordNode.cpp | 19 +- Source/Processors/RecordNode.h | 4 + Source/Processors/SpikeDisplayNode.cpp | 15 + Source/Processors/SpikeDisplayNode.h | 3 + .../Visualization/SpikeDisplayCanvas.cpp | 108 +- .../Visualization/SpikeDisplayCanvas.h | 13 +- Source/UI/ControlPanel.cpp | 18 +- 904 files changed, 49446 insertions(+), 27683 deletions(-) create mode 100644 JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.mm create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/AU/juce_AU_Resources.r create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_MacResources.r create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_MacUtilities.mm create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinExports.def create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinResources.rsr create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/juce_audio_plugin_client.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/juce_module_info create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_CheckSettingMacros.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_IncludeSystemHeaders.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h create mode 100644 JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp delete mode 100644 JuceLibraryCode/modules/juce_audio_processors/format_types/juce_DirectXPluginFormat.h create mode 100644 JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp create mode 100644 JuceLibraryCode/modules/juce_core/network/juce_IPAddress.cpp create mode 100644 JuceLibraryCode/modules/juce_core/network/juce_IPAddress.h create mode 100644 JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pnginfo.h create mode 100644 JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngpriv.h create mode 100644 JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngstruct.h create mode 100644 JuceLibraryCode/modules/juce_graphics/native/juce_freetype_Fonts.cpp create mode 100644 JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp diff --git a/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj b/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj index 191c0e73d..1a6eed4f5 100644 --- a/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj @@ -3591,6 +3591,7 @@ GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = "open-ephys"; WARNING_CFLAGS = "-Wreorder"; ZERO_LINK = NO; @@ -3600,7 +3601,7 @@ 7A6F9B742B69F66DC3E29FA8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; @@ -3621,6 +3622,7 @@ INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; MACOSX_DEPLOYMENT_TARGET_ppc = 10.4; + ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-lftdi"; SDKROOT_ppc = macosx10.5; }; @@ -3629,7 +3631,7 @@ 95F63B27BAC6E72226C3E356 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; @@ -3670,6 +3672,7 @@ GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = "open-ephys"; WARNING_CFLAGS = "-Wreorder"; ZERO_LINK = NO; diff --git a/Builds/MacOSX/open-ephys.xcodeproj/project.xcworkspace/xcuserdata/Josh.xcuserdatad/UserInterfaceState.xcuserstate b/Builds/MacOSX/open-ephys.xcodeproj/project.xcworkspace/xcuserdata/Josh.xcuserdatad/UserInterfaceState.xcuserstate index e4adefc948629c5ca1756c4b6c9afd5595d188ac..d1a8401c5a9dbf8de590c80415a4c50bf218f003 100755 GIT binary patch literal 138935 zcmd?S2Y3_5)&ROQ+oWBqOO_?el1zty4W>g9kZl<ZZgBxjQ;aRZ;D!qwvO^l_B%~6O z&_fHP7Xk@sq!E&k-g`*zy}q-%T3IrJI2Z1H|NGv(!IpN<oS8Xu=JXlQXsWAiY3<+t zMG8@vqA7-ADK7o)^m`_Cn;&j&scmeS)U9#GoN#q(OJ%pJ=IYtC@VLBNYh#m@Lg%g9 zZP8a!Jf)*-l$~-=y{SIbDO6voAC*C6QvIm`R2DUaI+Z$&Dx=D&3Tgs1k(xwRQj@7E z)KqF3HJu7kVQMBdmujI}sWxgpwSZbot)R}P&Z91%ZlG?YZlcyv>!}UYMrsqanYxF% zm%5MIL)}m9rS?$|P!CZLQ;$)vP_I(2QLj^PP;XLiQEyZ4Q14S8Q=d>@QePnkv4}%F z(jh$(kcg6y0U6OmGznFr$!H3iil(9ID1^>LRcHpPMl~pmW};bWHmXH)&|Fl9>QMt~ zL``TOYDO)n6}6%HXaQP?7NNyx30jJlq2=f-Bq4%UptI3A=v;IjIv=e>7oZE#Md)I5 z3Az+rhE}1=(G_Slx)NQ5u143OYteOR4Z0q!MK_@JXfwJE-Hz@+ccQz{edr1FBszqi zMbDwP(P!u@^dtHS{fvG=zhfSY*n+LthLdp@+ynQ;{cr{zfKS5#9K?Be3?7Fk;K{fO z&%o7qCT_;_@e;fgFT)bP7_Y)t<7@D>_<DRZ-hpq!x8pnT-S}aA03XE9;6wO%{1$!> ze}X^7pW!d@ulO&Tr8(L_8)*w|r=7H$?m_pYd(pk=K6F2N06mBvOb6&}I)~0hkI+GS z8a<s3(Pz?C^bES1uA#&9OnMeQo35i<={9;ky?|awFQU()CHg%2eEKqa6@58<9leI$ zLf=eprMJ;{(09^z(f892(T~&5&@a%h(eKdj(jU{G(Ld3@(SI`x!!iORGG@lYxEME+ z&h%t@F&WGVW+Zbea~g9x6JW+LW0@kRm?>c<FjJWtCd|xa8kk0=iCM@jViq$?n9G<| z%;n4#%xdOJ<|^iD<{IV(=0;`{vzgh=+{)a>+|Jz1Ji$E4JjFcC9Auth4l&O%&oOT@ zZ!vE(?=bH&?=kN)A244sUok&1zcIfvf3ujSS&rpdffZRJYhrDzolRjqY#Q5@?a7|P z_GL$~BiU2g)7aD5QEZUSW5=+CY!O?|R<c#>47Qq`%hs{=>^yb>yO3SRp39!cp3h#! zu3|4|uVXi|+t}OKJK1~KJ?uVqKl>2-82c1^h&{}{%zndu%YMgx&;G#v$o|Cs%>Kgu z%Kpaw&hea%({lnRau&|PC37Awjq`FnxIWw|Tqf6_JDnTFjphPeHkZTYa^tvSZX!2{ zJCm#8W^gmPI<B5;;1+U=xW(KOZYd{mtGLU#E4bC%mE2X_)!a_*R_;#j9&Qh}kK4~Z z!X4nA<PLJra)-H>xL3J1xVO3YxDUA_+-KaE+;`khJj1g*$Md|7*Yg5z<}G|O@8x~G zpHJs|^L_YJ_)LBfKbRlFkLCk>HlM@i@<BeIujD85Q~0U;G=4fC;;Z?Yx(wX_-5}ji z-3Z-jy3x8EU7jvqSD-7_mFg;VlXO#b({)w48r>}299_MxN!OyAuUn*Bsyj=!LU*oi zrS2l#rMk;?SL&|Ot<l|}Tc_Ko+oId1+o{{FyIpse?q1#fx(9R*=^oWRu6s)NjP5zz z3%Zweuj$^@y`y_y_mS=s-RHWmbl>WJ(EY6YP4}ms($jiQuh%E(O?s=|p-<7L>b?4O zeK&nieII>4eSiHx{Sf_d{i*s<`fPnrKUP0pU!*@nU#_31pRAvzKT}_=pQ*3a*XbMe z&H6U|Lj4l`ay`+Xqd#ANq5cy6D*bBx)%xr7YxOtjH|RI(x9WH3cj<4_->JVxzem4M zzhD1|{($~T{XzY+`osE{^snmQ(7&yJPyeC*i2gJEm-=t?-|K(U|Em8(|F?hzR?rEe zU=%EZU2qC+Ax-cLU4<S(Z=tV{DP#$Qg<---;dCJ&<O*YiaYCU`B9sXegi2wm5E5nx zVPUo~S7;FC39Z5cVX?4GAW2n8;iQ>KbCTvJH6}GBwI;PCElOIPv^?poq_dOGNm`k7 zLDD5jmnL12v^wdUq-&GbCf$&<K50YJmZY1Lb|mdgx;5#xq`Q*tPTG@nf6{|V`;#6` zdMxS5q^FV&B|V$;Leh&#uO_{g^j6Z_N$)3pkaQ&JlcX<_zD)Wy>AR$#l73G5J?Rev zWk3ejz!?OCXfPSf2D`ywa2ebNufb>NYUpO@W$10_XUH&Q83r1L8ipB8HJoM$7_tp{ zhB1cmh5|#0;S58CVS-_@VTvJSIMYyL2peh*a|{iJMnj9C)v(a8$gs??+_1uMw&8rk zO2fs5OAMDAt}t9}xW;h3VXa}EVZC9qVT)nAVTWP2;a0<)hPw>+8TJ?+Fg$2@#PF!$ z3B!|yXAFl7hYc?nUNO9Cc+>Ef;XT9qhK~(L44)gmFnnY9*6^d@C&O=s-wl5oDI;TK zje4VCG#X7to6&AeF}jRtMz67pv8%DCv6r#0v7d2(G0Ql_IMg`Oc&c%<F<=ZD^Niz+ z<Bi3}5@Wfs!dPjXY@BWk8LN#o#@WVNW4*D#*lcVuE-)@ME;TMQ65|TvdB*dN7a1=$ zt}<S3yvlgBagFhM<4wkO#!be}#%;#!#$CqU#ygC68t*mUXWVCe!1%E75#!^=CyWP; z&lsOK9yY#ge8u>N@lE5q#`laL89z3DX8hdvwecI{55^yjzZ!ot{$>2zM4K3s&ZIXP zOh%K{WHUKUDJG98&6IBHV(MY)X*$K!*VNxMz%<x2#5BS*(lp96+LUVwn(|HKOhu+* zQ<<sUG|5zHnr51AnqjIo%`(k4)tTx|^GwaA`KAS?C8nh&$wW-&n$9y_Xu8OBnQ4{j zO4C)Q>r87*H=1rTZ8U8%Z8dE(-D28hy4`e#=^oR)roE<priV-qn+}*BH$81SXnM}{ zyy+#=%cj>&Z<yXOy=(f=^pWXP(`TlyOkbP6H~nDx#q_J`Pt#v!Y^Ke;S!Yf%8_X87 z)tqd0np4dlv)`O<?r!d3?qfd1oN4ZF9%LSD9&R3CKHWUZoMX;4k2U9;3(ZC5QgfMk zqIr^es(G5Z$~?n7(>%*O*IZ|AGS4%&ndh4qo0pi+GE3%j%;%afFkfiC)O?wFwfRc( zwdU*0H<)iUZ!m8(-)!D$-f6zYe4F`p^WElq%=er3n)jO@GCyWMV1CN{wE0={bLJP# zFPUF6zixip{Eqnp^M~e7%%7USG=F9O&iuXkXY()SKg@qxkOf<e7L&znu~@7Yo5gN% zSkf(BEL|<#Ed4D5ELoP*Eu$=>EdfiRrN~ljnPQo0nP!=8nPZu2sk78u8Z3>LCd)j_ zGRtzySr*B1vE>rWrIt08>n&?7TP@ox+bugRJ1w_Zc3E~??zil<?6W*zdC;=o@{r|W z%OT6Nmgg+bTi&v~ZF$G?x#bJXmzJ+AUt7Mhd~5mB@|WdrD`icx8mvaE$!fM*tX8Yd z>a+T->DGSM3~Q#fzjc5$%R10H$~xK_ux49}ti{$6>s0GB>vU_#I@elft+zH<7h9KD zms(d^FR)%{y~uiv^;+w7)-~4at!u3}ShrcXTX$G@TJN>qXWe7H-@4bj&-#G%LF?1j zgVtxPuUTKWzF|FL{lxmI^+)SZ)}O7v*ccmY<7`%&&1SbbY{@pKEydQ&*4@^_mSr1g z8)O@78)6%38)nP31#Nk@F}AU`eA_tNc-utVBwM9zvTdeqmTk7J)z)U4Z(CqnXj^1k zY+GVG-?q|rf$c)u)wXMF*V?YLZMJQ(-E6zVcBkzw+ugQ@ZI9R<wLNBg-gembg6$pK zySDdi@7unzeQo>3_O0zt+h4Z7?V>%&Zm=8eZhNZTV^6bt?LNET-q+sGo?*|l_qPwQ zXW37;kFt-p2keFRB73oYihZhmnti%GWIxkhWuIYhus7P9>`U#-?91&J+Ap$SY`@li zoqdgci~VN%R{J*lcKZ(dPW!#~`|Nw{2kejApRhk^f64x`{T2JG_7CkJ**~^_XaC;* zgZ)Pba$pDTU>s(L#bI^W96pENk?!c{$Z%vjMmkP)oaQ*)G0rjGQQ(;5sB}zrOmR$g zOmj?k%yG<h)H&)M4UR@flVhG^nPa)*EQjPEjunox9hW&)IWBix;keOplVhD@r{fmK zF2^3n{f@nkeU2v`PdT1;9CSS6IOKTN@tosL$6JoK9iKTqcYNXa#qq1-H^=XeKOBEL z{&M`CEG8!<8<Jhg?&Q?up2@wEdnXT09+EsXIVU+cIhdT6T$)^#T%KH!T$MZ{xjMNf zIh;H*c~<i5<ksZ2<oU@9lFv>)C;8mu^OCPfUY&ep^19^p$s3Y)CGSqYHF<CHzT^jz zpGtl@`C#&^$*(29p8Rq0k>pR3e@Ol@`6nlK(oV){c3PZPr_Jee`km>{F3t>RrnA5E zROe~V)1Bj-<DCW0LT8b)*jeJ7>YV1B?wsSC>#TDwbS`o(b}n(A?_BA;z<HtbBIm`< zOPrTF*Ep|tu61s8ZgXyT-tD}{d9U+6=N{+%&b`hjoKHHRa=z?*#rdl9L+3}%kDW)H z-#dSB{^<NE1*gy{ObVM~NwKEbQhX`?l=PH-DH$o5DI-%(O*t(kKV@9X_>_W_Nhy^n zlT&7<%u1P^(wfqiGCyTS%GoLBq^wH0Jmrd%)hRcntV>y+vLR(x%I=g~Q}(9pOL-vW z!IY;{4yHVlawz5Xls8h|OnEEi)0EFrK2P}~<(HISQ+{)CF5abc>0N?LbS1e`TrQW} zmFnv0>gDR~8tfY48tNM68txk58tFRKHP)5y8s{4Cn&_J3s&s{2GhMS>Ev{Bqn`^#n zfoq{_k!!K*JlFZIm98sYSGlfsUE|v5+T_~oy3KXF>kik0uKliuT+g@;xt?`B=X%ri zmg{ZTXRgm(U$}m8{p$M7^}CyQ>)d*`!=3DQy1Tl&xx2f2xU<{?-Gkht-2r#DJI9^t z4!ZN)W87u#a(9J$f_sL$+Fj#ra?f)&yO+Dqa!YRFzQld0`!e?`_geQ2?i<}Vx!1YZ zyEnLZxp%v7b>HUR=YGKbp!;d}LH9H6L+;nzZ@Axdf8zes{h9l7_s{NM+`p!>saz_b zYD=}JI#QEUyQFqa?Uvd-bwFxX>cG@NsiRW^soAMHsky1a)V$Qv)Uwp_)H747QfH)A zr#7ZGrOr!TmbyIktW+uW;?zr0FHK#OdVT8J)UB!8Qn#nxoqA8|y{V6;K9+hQ^>FG7 zsV}C!l=@!k`>7wKewg}A>bI%irGB6Kw}<i|5B3;6CXd<U@uYdY9-rqFPhU?zPljiN zXQby;&sa~sXPjq(XQF44r^XZZ%=9#ST0E^D$wNFVJePVd^Q`h*?zzIV+H<AnD$jb) z2G2&%ZqKcr+dTU`4|pE*?Drh>JmWd!dEN7d=S|OBp0_>kc;5AV;rY_@mFG9l@18$A ze|rA%{GCRnC8ZhCjA`z))HF|8T3YY4K53_<4NV)CHasnumX|grtt_oPts-qg+Kja7 zw3@W0w0UXGX)S4IrAcWdZAIFpX_uv~O1nJmhO`^gZc5vcwlnRPwENQbq}`vkH|>eE zC)1uvdpYfuv{%z!OZzD8<Fq4b->3bM_M;bhv6uETUe?Qbd9TiE_d2}EUZ=OKx0|=S zcYrs`JJ37IJK7uYW_ydg#oiL{8Qy8$>E4icuD8xx?``lldYioSyv^R_-m|=tmv}Gn zUh2Kfd%bt9_Xh7a?{@DF?@sT%-ut|Jya&9Gd!O*W=zYoiviE)O2i_08A9=s^e&_w( z`?rtsAs_bj@n!fjeFJ@ie8YUheW&?O_htKXd}DlLeFeTk-x<DA-vr-8-xS|e-<iHD zU)VR(H^(>E*XV2Vwffq8i+qcH%YA40&i0+-yU=%$?=s&tzO}w}zRkWJzMZ~XeRuor z^F8R>?|anul<%PLu<r%mYrfZgZ~H#<9r1nX`^xv7?-$?ie&lEUqTk@R`R)D`zt^Ac z@9FR7AK)MAAMPLJ&++H`$NSIlSNNy+r}?Y>HU8QD27i-(zJIY_@~`l(^k3k=%)iQi zrGJfot$%}mtAD5ecK@CJJ^uUsd;O34AM+pZKkk3Rf7t(m|3&{x{x|&}`;YiP@qg<7 z%>TLn3;$34pZ&l1e@&;;nRGT?pKeG`OZTSx(*5b_>0Q!$r1wtmlYUBiX8Ne~ob=rE zvFZ8gh3Q4<6VfN9PfD*$pPW7;y*j-nJ)B;j-jLpyz94;J`l9s3=_}IDPCqC8-1JM* zFHOHJeO3B~^eyQ(r|(GLnSN{fZRvMabZcm<t9yacQvxMYNtB7QPAn?Rm>XWyG8ukH z;$0KERo7Luv}~XZlu^PGy@4`Q7KtHfuhb)C?lw59e{fJRcTm6Ju>OPk4H}j+uwV9| z0fYNx4H!0P$l#n|g9i^E5Hj2IbAuBbo9DJPRaJ*`8>`#u!ws!k&&iaJ>a~?}QYn;+ za#N|4hf1To5-V{MFX<$`BuJu^w3YHx=~NdOMmGTIL3NP~l2J0lkSqY=flqy=%e~Y# z)HE*0Yp$vfhs^2lpt!jv+#Ifn_Fi5!Bd4*UwYjmb4kCLYvn$#tzabCk(Nf(U4mT7w z)<FBdvBOp|x3{fmsGZjq&aZ)))XuC8H;2rp$AZW86Y3uvFm%|^z`%aFgYts?24(jj z+AlC<z_5Nf!-ixJ8!#v@YhYGR$m|0If$CNWE+!ss>}bmy8|!9NHRrcXsBNj8Q3s<< ziOvN2&W?NKTCyZ-;NZUgtgPY7`udj)fYs^iA3AKnvSo*r#UDrwUQeY09ZiR+q0}&H zI5lFjy6z1?$VuwQa0{?Upt-qf(FOn*IjN|uSP6;hw1qsK8cX%sMvbCIQvoWQ%As<p zAeBdrk*tzUvP%vrS#nA#l1p-Lqw--1$5RDVAyov6T0)&6rNSbnNnYs`g2qW^f+`4_ zAoU5ElLIX+5S*=QXbslXwl+4m6jUv0Y-<gf%`o4x*^LW|s^-_us)9FD-~mj%plU|A zE@bW}lSAXVxYej=t*xtVT@+{zSCv8Fw{=2oc!7#8ib{UhVg2J!<c3>nXEh|iAP-2z zUmI?b84{Z1)z*bes#<4HgRklw<c4NS4;y1nTXi^8UsW9{tg3A&3^%l8)YohDJd>J1 z^;%C=Nxt<|wd9wHVac6P9vyRjYq-8eUBFq?oDI}$s#Z#udP==D1a(v+W!*s4Qw>rV zsp|%+iJB*Mle$YirU9B*&Nah#nF@tfvl?n!+iJokT}LlzqU8Un46%?}G_|NKw-%VQ zv7xFNIA9?)QtM_3wY)<&5_Ho`>d|#{)4CWW=TPTPFDff+Ypnu)RTya_b&kwRY9HrQ zD??^m6rjDcjnw(E-CannmgU7o)Wy^#)TPvA)GF$7>I$i^)KAKgGNt~~04YlvxRtt+ zx{A7*x`w)zx{g{yT`vuiMo9%yq4b0FCqXnpqhx}nO{#{io&hT}zP2?Zy8anui|S`I z0vGv@@jkn%wR(0Q2pd?FvTz+_2EsMb*2hMh-_p_+2C38KSZIMU<~B9fHnake=NLe_ z;TdhSjy<%p*5<bA*0yF438}}xP|!H5MO(cs)Gn&m&D71*R%#oyo!UX|q;8Q0OGBig z(lBYbG(sAAGwjtK)NSzZ4(d*-3+z*mbSnHiO*&l`yCHK|AfHOGC<)|!5Z!&n4RwoD z>6QR$EXYndr2-K0jt(wts%oeS*C@=bitq%Da%7zpZc!1tW4f=GcUo(>xdEt9+W=IO zbwEc1k@Zp^1EISmfPwMLvL1FNs0q0rb)!8<%~>b)E>XWcqI}T^d4M`36Y_ED3F=Ae zDe7tJAoYwiS_(+nQjU}>1*N>3LF{z_A|9q*fKM-h$TI^G$4F!0(>RTgQO;_oWworW zN*Y^g<=v-FDFGCWxTUyB29X&IrgSt+X}GBlG_Xb+S>GHDBy+U}(K8{0#_*+$3-V#D z7Rnr*mJm|LrRq|d#z*&+0~4!iY6;hjX>M$5YN=Q#@5aN_yI_z^rQQRPQ(Dz9E1c8V z*3c^Dt775<>O(M3lzz*?tsAJ1sF5+>wYEp3@hbSI)Mv0oqf$j{w~_js`hpsn=v551 zf7pZC%70D$Dl5KksBfw7sPCyCs2{1HsGq4{q#~(UDv{2RN~JQXT&j>JY=iaxo%)0N z6Mp}VD5?v>zylMdNzyv_{jKyJ{QO?#1X-B}o0}V(L3sc>11kp`WU*Nz>y(JfF9oRs z6MzR%GRmq37DIj(-AIbak(<eTvL$;_`JyHe4G#H1oZtfNk)}~}GAKNgZ6xRnES-*{ z37M_%E())%BB-?`OZxZq_m^#rtYHKD`iBf09x*kL2~F5-&O>HoK~`i#cH}_G$ca*r z3%OA$@}M;2MLy(5>8K0pin^ihs0ZqadZFH^4>|?)Mg33)%0&Iq0F;FWqCsdd8iIzR zVQ4rSfkvWJ(P`*(GzyJI0hEn$P%a9hJTwN4MfqqP8jlK4Au2+}s05vXN>LdqM-@_~ zG+CM=O_ioe)1{Dfrc@=(kgBB`DJ;#DW=XT9T4|0nSE`fhr3R@{YLezj%~FfhDz!=T zr3KPLX_2&8S|Tl#mPyN{vm{9((hBKp=^W`?={)ItX{B_5bfI*Sbg^`abg6Wiv`V^M zx<XnlT`659T`gTBT`OHDt&y&m)=D=>H%d2!%rhIC!VUexO|uuZWLC6*^vN98*fKj) zGn-p7OPU*Jfq`2OOpzG_JEkH(v#hbLxjHOEREJwyz*x$R7)_aD!XU_MtJSX=)lE$y z^P-r>C*Bb-Wm{EU?cyp~0%evp)y@r<)HSxY%A<tw$jNhf5ddM4F*{@qpVYo{t6Hnd zXM^snY01nh852-H%l%9~sr>}nYHAycWP?E=;Ixy9yfoZWRS))P!z`r-7<}c4<Cl2? zEY+&IoY}I0S=CTAE8Hv-X3B}<j^Q$p4voz<?UY%3Qn4S8wX&;P!WH?!y0Gk0s>^cb zN$p%EpR#>qCqwPx<g%}}M^)(>yG83y>Qv&k322H^*f3DXqHG*>UZIoPUk8p>_RO4< z+C%J&io&f6z~76VPQ{6L1{+9S5ZOO!YHV(mH&5G%<Bi!o$7An_RrAA&%v6Y1e&YSY ze4<?!fL|?7XZnewjpA%kMSpI%6$HMvU7AmzgK^*?7u3!GA7N1rNZ!nr=IYE@ZMB)8 z0-I*nR<~r%3OCk=TbmbUD!#PrX#Y2OIif$K^OWg!BD|bvTJ<pY7Ihkh^2fZk21RKq z8nfgCXc#dI<QRh*#!@LX@5E6?>CuvzfQ@r&TfpI1lvC9(zp6#;^W-Yz;Czt!?P}-b zDm9gA?buJQa4eYF6d_N04=303ixrOf;L0|%n?)zra_KM?*cm5BP*vpTG}bpYHbgc1 zlK(ct9?N1?r0=Yg+I#Hk#MrD#Pbac56A6|EFv{nLGa=5XN*6icD7%U|vl|=1!+@A$ z$Xs<&XLppiROZ!qQv3Kvfdh;<|G(X1lw%?@)*PG@(G5p?aS5iX2H#bodLs5nB7O<W zVl|?PKyrken^cDqB4Q1yAE)*^_rFNpV(@~;6vV2Ir6<r^qFKsTM71VhS~3?vtO^1o z>J9<Z6<k>eiA3}zu+r2M=>F&xRUG7~l?3Qdg0mN+jAL{c;9h<LLqAc<DI0&`2@K$9 z+9lWx3Adrrb?r&*T65L3A%vS_-L;co+<<+a)7H}3SYOcCI5*HxlNS!xshe%~Nu5Zn z`iV6T6q=n}OGjmO)f7~09pK3S&Z@K<BC)Gdb5aSXaexvFitXmVsodHp7Ap`>?lMKC z#~9hOQhBcQ#7PGX9c#zI+Mi^1QweXi$7i5}x)UFDlo;(1)HsP9yYQ1vZg)|a24-?1 zA=-Z{xO1xN>WbT1vl|zxYu|EGr=<zZMB(9RkOO9Xa;2QMSt0rfmP?(Q@X(?X|2w5r z4)F<yUC2sGrR{_hr|nUJ97S@Uh}oHlVd}&6jaq1>Q2Cr)*H}GQoyGr-fbmgYV3U)p zKjN9QIM(unzE1A`ZqFeA>WL?X4^%FX1}GIq`0psah?5hMelUTP8*!Ofn^y}WsHrWo zO-^n+<XFN0rg3szd#xjlt)fQa$sri*`~*22Wz|n^zCatlDzlHWL1rr%c61}U2@>^@ zvK~muZ-gi7sF4*#W$;BQlt3HMg!O2nv|hR?k}^kI&<?8CCUi5}ingKc(gtaxv`N~$ z3GGC;pj~LUv_;x3?T~iLsc=h8q+qb1v052P%aoZ=s8<LHPDo~zw?dA(vZZZCt&-<f z`@0+J+0Z@G&64Rgv<Kaf_M&~1h#o)>qW$P0^e}n^Jwi=IkD|xW0r>a$6s?Df(gH|c zL$O)2oVJ9tc3XWzQCs~Cxw_99Zm2oxp{06uRdW>-|1>Lw3I$;(&oHZi1yDJnwykWf ztq%jzddRt2HRSEDVTK*BG*(Mn%~;xI{#v5U=8*ZtnGmZPk(mjSx2kS-V@qphpa~L% z5o%<rMLtzcO__4VisHHFf(I{KLCu*Zbycl18=LD}G7GD!i_0cuKtNV`kl7AXmOEa1 zJ)nQau#A?PxtV2)TA;ivGZJ~vR4OXv^hyhK(i|=eH_xwy6m!N*xzbX89tTm?JfpEe zhKqSWR!KHNeiqzpIR&XQ&r|5>kl6|4XXW9Aty+p(Tj-7GAbLhF(l{0X)QdsWj?F^m z(;%JgZ=C5@N>}|b4|&pI{~Smqj2KZOmsk0l!}Ho|o5L;bZ>ySTDRrqW)62s3P;OXT z?N`dRRF-<4nzI8PMlYZj(M#xM^a^?vy@p;#Z=g4&TckUsJ<@*ZfOJqgEWIkdEqy3` z7OlcV@1PG8vie8pV{`<4BJGlHlWv#pkou?{eJ=Cv7t-#;y!$o!27ROO?sveu-=QC* zTg`gl6sJU4=+%(#K8jUhGW%fEcD`^R&|K42+t3&*ju+-P_+|Y5+J@>ns1mI4&unh2 z_s3Q#9H)!yw%R(#&#P>hnUNv?ceHPRRJS9t291Dn6{z@XnB^}hm{8~+kkQ{?)ClVX zl|oRujDC$R!$N;xl!)9IV;UX7taO)jFOd7b2)VHi$c^>V-3iH!lQeQ;BRYVM*eu-x z#P$HO87mkD|0QCBnwbATC-v+RS;I#t1jY7Pf?_B3BqV4W_5wlu(*4o{K+p#@f_9Y& z+D+P<n4mqQ1nmt3?Tt^7_5nfDWrBVW*2GC8C<v(9s=Ca^nGt@H({+pf2Q)pp-w^`` zMaY^NN7gJnG$C1s;o(5mk<vrbqd?ZjG_sy9lXaBzaALA%Yh(r0b^!i;Cp{u<lc<v^ z527<uKga}y>c9WGJUFV`5d$OS92-Z@@wg-*InThQK+baMap@@_=hGTFC(7iUBt4Os zoKx^rJXMymcsg+DbbO}tq*(wyodSF+214d(C!bG2bt^^gO0IXw|B|pVJ&zck6(Md- z9C2six`f27#|=Q-Cg~aJIUw%y8gW}>;<ieM5)*eplvfoMh8IiE%Dig9XN1g897Wjw zH!Yo*zJU!p8a$dolL!hn$KhkFVGMZ7|Jrnm>HFVKNLItDc32+A8U&x0kTuT7D}gmG zlwOct2G)2*V~tB>*0@x9F)?dguCWGQ4f}32zDjxtcAW*71Kkla@A*H)9LF$&HLi$z z4eapf|3P+$8)LgApLhx*1`LZZz;$s9uokaR$N(GgMqq%=(reP2zyNP)46s#ZfNj$2 zi5XyLlmT`D1MI@LN^bxI*klH{=Kq>>I0p4%Jf%P|f&T*!|Bp(C6PVD5to{+^xHFD9 z?!kK#GRHpr05HdX=^g2PV2%$o=6FPAjz^_;6Enx-QRa9OnBz(OwDcY@hgVh|=Z4I$ z{(nI_#4tzB@towCm%uFV|9?kz{3jC}F>pYHd7h19p2PT+gv|3QehrxC4e2B46JVZC zHRgF+W}bJXj}tS``}hO=fnw5q1kCdhJ|Z14_XYNu4D4g*8Zs9i#Xg;LoI3{1<rss! z!Be&K7pjj86*tX|{+>$gp{J@xKaZR2SNQvcll=kzh<4$hrO&0WAt3gRHrd~(!5i@J z_z&p|>8r#O{+ou2?Bog47#*N7%}8IGIhb&7m@wBnWUfC+6aJ@qOgY+;F*`vV4*yL} zrFGy~KS~QQLV-?#5vIWid&whY;MhsI7PzTx@z;bQm;(oS{j=dXuR=iDq!3X3Y>oNs zKoizUH>uB4l+Tf<Bb`e7fylInPNTiFPx?{%N%~p(WfKhti|MX(H|bY6e)GHZha7dZ z#hz=C4_ZPnGi2@#PqU+E^r9!U@{~h5#SM`&I_jwy?R1S=sG}SPg@CGjR#!f_qYm#B zy6-yaHzgECXV95y%ya|YKQ4SqXHkRKNv8N?HG_x4v6`VnmMzofHiRB2&uu6@j2=#p zkp7bXCWs;kZGxjl`BXkV3g!k^CJ;Dr1k;m`Ysu$<<dbbmg%1QMmFT7tK!mPxv&X3A zg2l~ew1wNk>M1VyAa{bt@@b{A)~f2ca=jh|)#Mu!Csft7g|)%u(PvP-w$o$iv2;E? zjvh}J(1mmnT}+n{1ZT-vf;fVBf^-Dw2@(hr2}&Z!u$?Z2rIF8lccCZJljur%GChSL z`QW#_R&Y$%L{Kt8JqXGmsK0s!Jci2ZLAZ*B7AT{x(c*;aYQb!y%XJEjKf0LO##K%r zW``ko8jiM5m_R;Ks2+zpHb#$3k(@#xN^4t7w0X2c`P5Vg{s5Z8!?@1N;V62@Y>I(Z zpUCIZJ2hMtTxR7syvi(+l`~pH2C1jChQNXFAw#qS;dCv?QhE+SX8A-o#MtP1YR+c5 zfo`Om=y`NAK^B6n1lb6(6XcM3#}vLyP-A+N+cW6X;_?VEAtjUEUcaU>$zpmbWnE7% zA;`I&UPe%ge8Ye|dxe!+0xj}%G+;uX4Tq!Y6$H7~)8`Q6miojDLW5dKUqtoVKwm&# zND#2TNB($;@-a>7Q<9*;74%hdgVpo}1bG2)1AVpp(FY%;K9Q+u$gii@$vf@>`Ud(& z`X&XdpP+Pty2uaZuAn9K+Ew`p?PF+CT9IF&WCAs0+i5t4yAj&#q;FB+yAjk~{;pvG zM1W#qB)1e#Qw_=8^u6sAypN!sQV;FbUiyJ{dOb)`FR73A>S6j(`4y1Jvz~s8px*7T zo}izSU#$jWtf!wQs89Q=L-cd<s~ZUNucx0U=#=(XFVZi|uV5bC*VC^M)VKZB>-3xQ zt2YShw_YKSER2$4D}>q$T(t4MM}N>hs}BjvY@gK;`V*?xx^)q)NPkZE-9~>we@TBu ze@%Zwe@lNye^38F&;Ww62pUMxV1kAcG@PK31f5FI>9XvV+52Z|&U(55*jnnXKKLCD z)XV&?a(d(`Ln%)gtUMhgfflvM`rjYPlKABV3QBv1Qz1c~!A=<>^_~RVp$3j+tLOEZ zB=xmXc|A<(T?zGu%F(^Zdr)W5?Z!COL1^1;gw%VQLNKl7P3<w2nzKpUp|K6Lv3H^7 zY?R+K-L<!;Nxgv$)z-ZuZ|NrOtu30tU^1CO!01eWW&o4L02N0Q6d)*@pqx$2U}gx_ zg&9UrE<r(AAm_^~Dxda+L*|Kvlq?j(<HK;^yGIAG4kED~P(EQEi!b&xYCDvC=s6ZD zMiFR0>TE~FnqEvclMDRC<Pem%o(U2(<~VYP$!Ep`12f|Y8oQpl1CDRQY`scq!{46E z_mA)o7%*bc;1Pqe{DHza#XYcp7F@lNH7KgMnKPI&z^GjFz?2g-KElk*L|77L5>v@c zCa8d*VuDKBmt-1qX6&5{OcgVOphAL*<gv@==%b{U@0#d3dftBJB8JG8VrDUO;+oH8 z>Iec|d<NVN0gY85qqe-He_YFXOlw@rHfBCSWdxOL9Y=4!P@6Z6R+__MnNFsOIvUjV zuy5dGvRal4CA*;+RW0(dpGZx+Y;Paq0u5#<b1vKz!7O8zGiNbyXAQH0Ihz4pF_EB2 z1XU6Ql$}D*RDz}vG<_@8gE=2AIml-&WG-SZW-fudo=^zxIRMGKilB`IZ6fFvdA-fD z<&-Pm!T^UU<!OQli&9N7lz`nDYO0!RWMay|DnTc!zf@C7*2=lznN@9dtqLj?k3aIL zM80+!GO!J;aAqGYD)^x0zCq+@Jx4DBnG9!a;7XJj^~hYytdZIDI)ctz&s<MXl|1h5 zYX6Z7RF2h!#v?Z|5ZGDItRrZ~dS(Mb)l#2w`2>;nehagmvTkH<X0|fh2&y3{Owi1Y z%nl$RNd8$e*)EltqIX=c%0?`MD_a_7DIcTPe87Dvkmierjhs*K_<T&{#Fx66?*Lnc zxs#yTl1UrdJ<Nk}6$5iGb04#Zxu4m~>|-7vsFolwY333Hyk1Wbi2KHynf=T|%)`th z@c+k{0|bHin@7+hg24WO|1KivVyVwmFyO*U!7S7oOi_oZ3?9zu2b9~u<x27Rg@Scb zw;;TcEy*I~Mk1GHF(!DIs=W&?gmsrq==LjGrfBb!3WcssZ8ISKAGx9lPImOG?$=b; z)}sDU6^TZQ=b4u&>n7$f^8)iC^AbT|yR{J1N>JM-<`w2ukln8n1Y3B4EV~!V>y=W{ zTw4#P?X)h-+p8D4b$AsKusLx>5Yxui)`SCfb=qAg-8(eWgnWFfu7P`+NA0UVWx>=X z0|yR<I|Bv`8a!ax1oa+)mzWQkk0_D(m^s3H!hFhn#(YlY!#>o8s1*!MZ>N}i4p4!p z2bOJrEMI0IUs+K+Q)}D)j-c}iT0#&QLW`x;kU0{ahkY8iTDgrf%8cmkCeiy=RCfHD z8oZhLhWVEHj`^Me+hZv~XAwjQI-8(#!JKA(hKW4F{5m<dV_>!Ape7OtGsQV%{$T!u z%P3$d?fj<R(V@(yq^h=g1M`<$DsfyGrE`{IekDkP9w(?WRDH_GPgf}8Fe&3`m$fQ@ zP6hz!xqPZDqWvJnWVx)qOOoH62k&A{YP1KE^AECS)`DPXtt99IIU~7vX2)Wd|18k* zALs>zl&phIPFy##fpy9hOjJ^$wsf)Xkhxb!erR8jcnPq9O_kAg8XnA{xa)dUIis;@ zhU!+y7Um1Aml9bYI>4s0X8FoC(1_tF@Vhw-WiB8NB#NL*fa2<?yRqFNt^k5#1KUH1 zE5JvERoPx3IoaL>UDhGEFnr*kzW%{Ov!XT%+m9Vc_1es4u$gRsb^r^;^yLIyLC|V~ zt|aKH&GaaCFgpZ(f+2_rx|*Qtln>X-YR9B1oIEJwYLRtc<%B9o&VyWRnJDKT8|%W8 zRR~ov%Br+oBSw{6M4+*w*=$ftEEu5ItY^VyyH@VP9YrZuL244FtQt%*Gtyd)Wyi@a z^9fqBp2~+{2sE@rMxeUr@&GjGVirOcs#(UC60|mAma!FJy0a5lupw?B2<`&X;3u=w zVhtm9IvXPBMuKhvlPYd>T}L;^nN(~IJ1ef`Y!)=tdV)4cJ*Gs4r`l3W&x|$2*ao&y zb$+xVG_$Sp1VO%UUeC4>v_+XAR7gdM*nVXgyGWkLVix4x%>*j&qVrhJlDN^VU_o$g zC1{(}qY_p|<;t$3SFDN~%S!g5xK<alz<@gl+9_)k*@xGR7Ih|5_A9MlWUpXXvsVH) zUj^KJ4SOv_&YBw=TUB<D?HT#J2-JVg3OCfYwWxgqNm`*;OnsBmq$;bUUJ-P!ybX2{ zbpOlj8uohVV=a3Fdn5F76}uk(`oIQi>LmC>9(6U%;f4uKRq(TQO0`-)r{0j`uZh$h z9&3Y7X>6|5>@vBpdkNY@(C!#z#cpCZtICR?dkDH!(=F=u+YXw7-NEi;Z((<_y9v6D zpxX($gCH<w?uyYAiY2nVgY51gv^$7s_3Hz&RKB|tQaO%7>;a(BdWak!pujS|PoCKx z3GS={Kbd`6mKfInStB<Evd^;5h0O9TQBidmcTZmYLT+H6mnC9n!Bz3~0{fzR!`MId zuz`I^#xA>x{{*USm{-^js9rnRSJ~It*V#ANH`%w?x7l~tciH#Y_X*lZ5Lk^6E7?!b zLj*lc&?5vrN)UudK%YIngX+S5MCG$b*iYC`+0WR|*)QZcrEEt%0miQ${)#~o(OZbV zKhX~$`Vu)_DQ`%7djPpbx$P0WVYo)l9kKjXPFBpzmb}Jh5Y}K9JJsz2MzeYzF*`gP zOz6husp@r+W!1Cc{u4m0el2ZlfC~yCo~yVFA#?wNs+LwcG+PI^GSsx&{c1D0w!TJb z2$v#)3WGZ?V9RQHN9_-WkQO&SCC^h<yEq&jVv6dMtHak?M@A2I2a5F1Zz!y7sEy7A z1|0W2BJ8x)`Gb=y`Pe_%zu3Py;KC;fdWs;3LLJ=1VUFe)jwR?Bf?go_ccKFU9c!}5 z*ZIYdB|{TI5F*gV7cvi3b*}PrAOvaTdy2~1nv|P9I<$|2>9n>6em|aCj~Ps4-dqxA z1ToGT2s*T$gZTDy5I$>H`J6qX-k%MbvljMSSPc@gUtQxYs1MEy3>-3iNdLTk!v|*P z^&6BmsDHm<!Mq{;h6Dq{2L*-=4fY>0SnI^ex#Uh#2zq`!=O*Z|Og=9}{UeJ2<BD*i za{HW8-aKW=z$~x~1`Zh9UrRf1KCTM{OgTT7PSA@4y}W_z%5@{?Rf0|N!-l+*VwJq~ zpBJUYSCF=cTQU?PG{NF!#u6$c(&H;3bM^6zPK_Ckd$ZO*_pMQO00)JAo4G7*AUB8` z%nc#vHG;s&dV`=h33_WYH;fz3jo?OdrxNrwLGKXs5kVglY?N1^UmTOED^SuLhP~d_ z65&quA=JaRz^?3-06s(Y0F~Qa;Qo!;*7?c>r+pKEYN*Sh_&FT8U^Rj{5x8bpX%y4^ zE*MCnfrr!{71BY@K~6A5bU3(S$9$*JG02UHS~J{Og5Hf-VBC1HT(|<Rkf8Sn`XFk# za3x$>tPMgnaTOA<;`<U@L>e9)Yp!sW+|&-B(`C>PWzh5ARX~q7L`4~L)u0Ty8iI~U zrWd(caJT^c9d0&P%gy2DR<<ay3vl8I`i!7Y3HpR!!+(|aWe++-T(jeCjew0@3#1gd zCT<?rOwi{9eL>Kd8@X2cLJl1MuOQq{(ASXFP#J21$^+WnqyrPITFi1Ed-+t_ER$)o zoS<)_K^cy4E2&;vxE0*l+&SF2+<6>$+usuO9YNm{1dj5L1pTyyyMVh;PFJ!yvTgq} z!AWY;^4f@@-!*#IpkEoFA2tOXb7)=U&jB?$OSZ^>8C@Eq#sewux*e18BG<8~UP#v% zFs%<I4;2TcULTu?Rw@?to>%p~hDDA9#UN4XbqzIVx7o&B%U#E<;jZV_ayM`{ayN17 zxb@ryZX>se+stj@ZsxXf+qmrn{X)=h1pQ9X9|ZkL&|d`oO)y0;A{Y})6U-3I63h|I z6RaaxPq09+D5nBM?iOwrx4RPD#TMm?RDynm_!?4-T=~u>xHz_D>C!-H&e$@=0OM}s zZU=jy{e+LwY9l<pL%9T64MS*%!P*3L{*LI1iwY`3ft>RE3BizzS_8jN0Z&EhT1IX! zUAlBkPEKe-u(T|{xJZNCt3alsT)4utaglu4+tQ^u#f91VMZwV6{M?fKP<~-xOc2Jb z&JfHt7>FwlKEJ4}JWx;&DhZTFM*vnGz;%m*D=RO}F9}7UgSnxS(&F5ToN^5{*niN( ziQov&To7qXmll_g4VH!qa`OrTW1<6iLV<Fl5=e_z%~Ig<i}H#~3i8X!LwWfHK@A-k zG=MH87BJFbs3=ev1v{jGbwOp}DhN6H<@gq?)7W4DlF^~EpiEU|V$lISuQWJKuK9!v zm3(kQzU%^mFU|fz8Ch_<y&OyMM-EPdpi;@6TM3=!=Y)!iLnZk++89Bz!x#hq5?66a zd46I3<Ul#BW2hiFAqa5?b#-1*@CE-RzOu@~?BaqlSdaV(f%0G|IH^2X8s!jBu`tF_ z$HrLzCrH}h$QUqAL7-?%C}+~7ko=(n_$CCLQIs1f&DBQumV#|$=dl&!7mW`UXOGJX zl~xqNyrT>Eu7b%cN4ffe4GqV_YE)7e7DKu!R9;b(Uo=MR_5%gDPdsp8AO}uvg>r)> z1;v$x!J_g|d7yMmusqb%RIN4qSZU~rZwLpwN{fr*;6M|}%o`6kIapd8k|&@FBegO~ z-Thy2Uu)M{YvyrB?Z1)xhWl1_y&}>uVyAQjOB`9#l-2j#4{^Z^?q}{#*^K&y`<45R z`<?rPU^BrMf~^GG2)1wL{^I`TDIW14@f-vv6YL|{Pw;R5zcQnos+x+BJilRPqpHm# zWaUNP07ev_M6h!`ZzMQHrp_^Lk>?@nyn(mzc7k05r$r4b-pRYcTH;f9c<d%Pbpv$= z57&Pa?CHc+@*Qn2z6;;|C~Q4tY+l*=x@c18tS`PVSQvaig41KHFTOuNfY0LQ65Ng8 zt^{{cY_6LBf$^W&HE>t`(zD<1vq7W$P#)^BHuA&x;rs}KyA#}l;GP@#Q~A^Q(+TcH zaBqU4oZ=)~Uor7_WiRu2GMUB@d`i?1<Hzw3+1$d9=L`5kzKAd8O9<{uFwioC;7o%1 z6FguGo5PpMh8UI4L#Xpwg0o~p4B{Gikjz4zFl_!0nPHu=8dY+g356hh6~P0ewh|v! zB<8U!B#4Uf@Yff1n;+w6^R@gOelB0f*Ygd0Bj3c&<D2;wzLjs|=kp8rh5RCZF~5Xg z$}i)W^JnoAPxux5+59>Dx%_$j`TR=$0{%k&BK~6j68=*DGJX|*Ie!Jen!l32iocq_ zhQF4-j$gxH&#&cg;BVw_;@9!(`3?L=eiOf$-@@O_Z{@e~+xZ>*PW~2t7r&domA{R@ zoxg*>lfR3<o4<#@m%oqS!{5*E<@fOq@DK9)`G@$2`A7Ii`N#MJ{Nwx+{FD4s{L}nF z{u%xd|1AF;|2%(~e}R9Ie~EvYe}#XQe~o{ge}jLMe~W*ce}{jUe~*8k|A7CH|A_yX zKf-^)f69Nxf6jlwf60Hvf6afxf6ITzf6xEG|H%Ku|IGiw|H}Wy|IYux|H=Qw|E;5R zNQZT_j?u9?PRHwXI=xQNiMk}6L1)yNbY`7JXVuwscAZ0)taIv8bS|A+m#XvV(sW*( zPv_UA>$>Q=>bmK=>w4&V>U!yV>-y+U(E%?HCU^+JLkS*6@Nj}*1CAv4RDwauz~&o8 z@MwYq1ZNYRLvSv^L4xxLhHWyI;CzC|5j>vY0)h((E+V*?VAvvO5L`-d8NuZQR}egb z;E4oJBDj*^$plX!cq+lu2%b)Gh~P5`1}>UGa5cd-1cwQpN$@O!XA@jY@En3cM%58q zPjCaljRZFlJdfaJf?Eh~CAf{?`2;T@cp<@y2wqI^5`vc!yo})G1fNB)L@*(E1;J+% zd=A0q!Z93z&nI{#!50vGA;A|Bd@;e75PT`Yml3>*;L8cVg5cEzUrF#)1Yb??H3Y-P zzK-BE1Yb|^T7qvN_(p<nB6uCa>j~aK@J50+5xkk;Ed<|8@K%Di5xkw?9R%+r_!fe9 z5xkq=TM536;M)nlgWx*}zKh_y3BHHmdkMae;5`K2Pw-xX_YwR6!4DF=pWufGewg4# z2!52{#|S<^@Z$tOLGY6VKSl7<1Ro^$8G;WH{4BxG5&S&ChY5ax;1>ygiQtzBeudyy z34V>>*9m@u;5P|=i{Q5jeuv<934V{@_X+-h;13D@h~SS2K0@#(1b<5KX9Ryv@D~Js zN$^($e@*Z=1b<8LcLaY=@DBw4NbpYt|4i^N1pgWp1-kx<DDZXkZUVWv`Lc~0C<uYY zr5WJ5fyWgbiXp6n=#XrVb;KAk+#<%EZny%~^(d%{l9J-ma@j*E2$bg)mlj6*hS(C| zP3_oXLZBc&SMk82kfRhxSHuO2y7)_%g0(FhkJ=crj|B%dZ!BC;f$N?C-`GH@;!Fj> zZ!0Ma<>r@axFNa&qxE)l1G6jg3vxpf0;TzZqVni~$1A{{@ELVQ3S_U2XrY9=Vhp%< zGQm{eME#_V=8U)*M4i%LQ6Re@7%DCa78RC+%2e8GZOWB4Jv(+aCRh|Km0cC^=)mU# zLqC)QR=?H?G%L(|bjMaDr4bV47v&UG<bs2%czI=^ywc*rkW7_w%_of`<75S0?~dre z9|@@*4>&pH;M)a&Q!Byd*M>1oX_wWpU0F_`C?xyKWyKYxIYGr~g)tPD0_~J>MVI7E z1%baK0)^WmvyXA0b=3-ZcceI=@>M2^cPtYoRF*%cC<Go(etAJq_H?3M%v9Q>AF~Z) zedJb^+MFPT3Z(6OO!(4ZWLBjW1wn8r+d~36C=Y_B-8wW?o&5Ge#ya~ts1t=I&ZDCU zaZnJ211L`%RG>iiVPztXDJ`ymKP;ol1<2kW2ef!1u$2b7PytOn23Fb0)F2_(3rKq% z1F|GoT9{uZ$6R2MAwCf$J%sU~S*JrUI-<b)<GP9QT?>kHlwGHd>Kp~U$Faamip$Dj z_v8d&Xi+~|2eCsKlRK`F7T$>?<b}rpj3XoDs{x}oAx4>qA$cjaF|Sg9?Qy`l5H^aD zm#Y<!e+)qBu2$f>$Dulw!>@IJU4k}R%qTaQmtUl)BhU&EYtq`RO)#Fa@$GRg4elld z?%xE&bQ_c=DREO!V`ydNmC-<#ZnFXw&!}a=l7J#06?kn7P;LNgk&4E{A94!UMM{m9 zE`?=)%^DjO)9p|oJ;#6qc~=@Gz^>yWEh{gMZazrFE3A;X`}n}5?oI_bCK{MsQIrd# zEGU*EbJ~pVQJ}iF#|(2T3-Yr;85Dx#$<GGWP+r*~<f+@EwDBF)rlPb|jsbNT2V|>Z z&}lKypfnV11F<cLXO_h5p8X1J&vsZj_5)$W-25`IBr3~7g%B1i0A(!)Afs~N5v7$a zrWF9lVZx|@fwVY`p>I0`XtJ_kDFl6?a4j+znK{cq1?7f7@U<H(Pby7gCJUNhrIEI+ zV}hZ&gB_uRlOmRo79)&_u<D*wpp)B&C66Hl;<g;3$Jz=VR)Bi611SN$iTUMYqp?8< zk!6>HHPTL!my|}1_C~OC$A*eS<&`B-#IGtau67uhS;UBl(+-dy1mfA-;fhP;&~EHR zAYBL`F}#*2@~nfb7(m7FTGR?D43q)U<tSw^CoTxB`%q~ULn2r?g#a++C<7c(fV}M^ z93Kppbcn`Afg$S!qeyQDhG~N(A}iWN;cDHN9g(+-1|{qp3WAZXE!H;*a10@|;l@!E z@=7p-7|NHyv?ElF3DxU<>NwPjqT}+@uO0DD43x@2+zu%K9b{*q{}_4!31ZfwByMg0 zR)D+5rU3#aC6G2z4U~Ma;fhNt<217#D{cI-ZGw}6IThuKr7DNV;V-2{b0~UN0Z%&y zIFK+ee^P|PdYuA$N-S)9`U0pUZ(!9vFAJ8#K8hwj^rF%-J+@_Z(k0`^$XH@0t~VY% zs=QK=I}?jb$9E8NP)#FK^q-R|db<Lc5j%+X;j6m_<{Pmqz@m-i8@*F$-1QiZE6PhM zVDl)>gGMd)@w$uas9im4J4K&%yzbOhiFg27cYdWs+`6~VuDv@AysHA<BX&MAFUcGW zz>0t_3ysYKUm{Q*&>Hnn8ug5Aq~%?r?nrTgETLj-XMJy_)juV(^nDeuZgI$?iLnp} z=A%iRdGsVoDzXc}ojJ~MvXn->V*8PmA#kh0f?7|(BCzY>sW$h)O0&3)GO-kPBTV+F zO*Kq`?b#tO7buu0>(NMFt^#Nrmz>j&R9bcK(5jv96D0KXrz>qbp8?bdlm=ZpbfPM; zN^NZN>P1;GS83tv(4sUrIU)2I1^Uzu(7{QHa|qHNBoX9rLHozd1{~*X@cb1)+^$IV z;}W8Z_?iC>71V`*jOe%^$`TwqTdFUK%pCr#bF05xJq@j8cFTiu$~H!0=*tp9D{z54 zS;Z=%QDdhG3UmsJ$E`q*1@A@!t5m?8iNH$pqr5p)f$D}P$R~svBd&AABm{Y;X!dy1 zP#;p7c;lKxK$I{@oH(AL0Czt&u&NrtqRY|Jx%#lu#((TKsua^EI{Tl%%PR6>RMFgH z4__8xWtCvm6l%B|6yWq@4@Fs-s9~<3r@#+U^5al;aJ<xb9#~ImhF7+e1Le^&27Rl7 zWLRgAC>i1$IjSP3pL24-9*OS01qzxGok0@`MwOKX2eyl(D5Av*qLKd&(VzhdFfIF! zFl8mcBq^Bk|IL^n#HL1p<iM&tQ`r?Lg-Q%LMxibE*$Uo)oxv-Mez1EX1{#QoCFsvn zFl2WILtZeLn;pm*F9$C{gn@??TjQV&=>i2|R%Z|<EVs~KtRNWO83a+&N)abH#jvmC za)#Idj{Y(Q-RYe{mtO={Kg7cVrE<(NL79dAiq4NsT`r|y0VLBHFzP^x7EhGp&(Y<( zN<nv8XT}!cd2m#Vpl$-L1qc=tm&n*Px?ii{8r&INN(>lmQCWN_MI{=J>lGZm{t1Wt zK2%U%tTnq)X*S@Wn#qMtr9sd|iccP6G_P0M59&;NaJeCDPzWV8*$_&LrW^E|6cnA} zIxUnfSF4QCihT4pD+u~^W(<lbgy6YWMy21bv^}*mZ8g!QdUX*mFUCu`MM2dmiCjLm z6ygeHfjp&t2SVFXwz^e8(kW4@MGO+N`yC3R{+*dvMNw%n$n}Ea;*#h%?pB(2T$J`o zB$**{ATbikFAKpbEr@=DOpzaGjCG%aAhSdN@dzRm4U`pz#s@3GZ_=um^m`MIKE8F% zF^iz|4=T+^9k=tGu|bfBrNQ!w(jv&!6jVTpBu@@-Kv)kPtD@jUZ7L5d*iJbvw)`T+ z@`vzqObA8)n9}n2RE!WIr=$dwPfid@&tjCs6AFU9$L%@>K`D5&+Nhsans(If@g!^y z6>0LkW28ubNI}z4O~s>$j6g9Fj-JEw3Wko`Ga&}hb0BR?+U@!mm9`xfO2W1vp&=qE zyN1R25M|W71=(bYa`h{npouKx@{3eG8Op0DQnYp`4$bSGL{l0Z1A%O?suQDms}qw0 zPXa^*3<)ezIp_)umK$*#LuIhtVw}Hs6?A=$%PTpc#9+6TRTh;8q9KzHl!o1p*)Wnp zigP4BR@xkUQ6p_i3MwEnTTvF*_EV*8M|Bs!sO{60XAVYnhe*N~otSLGhF^E0^9VmH z2}_7yX{#4yqwf?Po!ZtVfihs7j#~4_P9T6l4dgC!N-AW}Qx+<6N>kh1zbFVgYWsK+ zmW_oRJLDuQqQPqY?@F_d_H}$SRmrPGrCP!?;t0nu+g}PMP#aL5+wOkAv5Y45FYYOs zQCUgABD6=VVuDBzfiDk1U%AkS#@rf#1*Bjf-U0i>s%F`3gz8}#u^hVujUx;3GKh9V z_*%{q$0c6{M#0ljd?dgV%*z9_Sa$hyG?oob$S;QKgcxZo@Cv$)$~ghLJV-n%+7L>| zVf*KRM29lnXi``Z6hs}DF99Oh;<?3|A`%RpCCiXOq4MI;z^qU<<O`tpc)waOD|kAx zL4xjq<G}0%83d9CG@DWmP+pu<tnr~>Q!sV3c@kjCFB%KkBH4#2P*x6DDZ1Lp3KDn| z$4d#3Kz<OsASeM)*e9=|0OHJ$+Q=CXgVT%$!KL8qsIn5^3uHsYPBQ^w^tRwpFm#kq z2{0&$XIbZf-%$kB^kvZ$i{Mjmbo9;=;7~`QVam%7LbP4UgsL-*lBtV=uoK)Dj}UfW zd9ggXD5CBPqM`px?|4LD5y?JQL<9-F6f9%^8B1YBL3uu~4|qP&46iaCr6i*)SfIqz zG_<EEXgiuM3CLCij>Lrg(((!ruW(t7;$IhQ=BJRMpy_$c(P^2FoLJ2y3{YBig2Zrg z1L`)S{dd$5!XO1vM_rs?7A3)45Dd`+3&POOjzC=-#nyq{pc>%d07n;jgo3COJ2T23 z2?WJy3X+UtQZXurmGT!QDO?(5kkLxxPOw=dyrFRdByrnAR6>q|W&Cl6P!1+iIh><` zx`7;!G1_V<p*}fFFUxSSdqTm|()Os8kf&fiJ_D<mfz?2WDwz|oER|9k6_t!M!bwrW z=PPKBFFRDUTFaw{R-oYMgn*X!k*Wg~167v#;0_j*=V{xixD%sMG$|ziAutMJEEkl0 z{FW^3JdSp`1=V^L<;78|R46z)#u*Z9h>D`|MNr=Y(+G@#w68XgNu6)67!?{1Xziyc z?K{EA6-7$>f<Sik)Q>P-Y24A?OE`F?v0NHb2pTCWjjH}-?}|IB4ZY@HPF<-xgo;0{ z{Vb(@#}G$?(W@c_DxSdA081)2x{;!*Fh@bvF(7wLRQW|pB^~(Hd5~-c?;5HMO103F zP_H5@lP?IX_6HiO>J}}AGhT4MYj(JLE@TO`^G;gXAMEEquCn{&4^a35IY4caO$xI7 z{{$IS;1!k>L&_O~<cjwnYx1=yc!&QByowhLTPROa;@bG;D|kA0m`Yfr0RQ{LRKilF z;js=$MNW7K%Z0Pzjw}f)#CcS&-R7@^vxRenbA|JS^M#ed1;T~GMZ(3xCBmh`Wx^`q za^VVLwQ!|ym2kCijc~1Sov=o@URW#KAlxY2B&-wG3mb%u!X{y}utm68*eYxjwhKFi zox&}`E@8KDt8kleyKskar*M~Ww{VYeuW+BRN4Q_uE9?^<5FQlv3l9ko3y%no3Xcf~ zgvW&^geQfkgr|jr!ZX4l;aTB1;d$Y(@PhE7@RIPd@QU!N@S5<t@P_cF@Rsnl@Q(1V z@SgC#@PY85@R9Jba76e-_*D2z_+0ox_)_>v_*(cz_*VE%_+I!y_)+*t_*wWx_*M8# z_+9uz_*3{x_*;Y<pF}LuA|tXQC-S0B)Qf^Bib<kDG>RtCELudXXcO(CLrfN(Vv6Vz z-D0Zf5z|Dk=o9^7y4XeRDs~gQi#^1iVlT0`*hf4?>?`&YGsH}>zc@h55(kQd#KGba zaVT>@94?L!M~bJ4r-`SFqr}l-K+G0%#9T2b=80p(v0}bBP8=^5h=pR2SS*%^XNaX@ znOH7Xh!ez#;v}(BoGeZer;5|W>0(GcQ>+qah}B|^7#3%Wv&7kAtvE-VE7pniVuRQy zHWB;>!G95&A~Ys6LuiiBIzkJCP9n6C&}Kqg32i5IGNDrl?IyH`&|X6O3EhRz-3Z-- z(7g!VhtPcqok8gSgw7)LAVLoz^e{q?AoQt(KAq5`37t*oTtep&dMu&G5xRiTMFcKP zrb`K3PUs1Qo<!)$gq}+1>4ZL$&@%{KL+F`=o=xEHUb>FJjiz)Hf$MtdRzlAw^g==} zCiGH5FDJA_=oJJm&ZW;I^hyGkztR^I`cgu#BJ>r6zLL;a6Z%?0uOakWLf=T}b%fqP z=uL#)Lg=l8-cIP9gx*EyTM2zTq3<O0-GsiE(0d5Im(ULodOx8bCiJ6(K0xRv2>leH z4-)zip`Ro4VM4!1=$8roDxqH|^qYi!o6zqP`h7xwNa&9V{RyEzBlH)9{)*7w5c)ep z|3K)U2>lD8e<SoCg#L>#6oG448MxDtBaDtP0%4K}V<e23Fjm6Y36o5i6vDU(;~|Wf zFn+>xAxt;I^dL+x!t^0bU&3S%raxh_2s4N<LkQer%8Ve)sf0P5Frx{RO_*H5<Pl~p zf%`t00>Ts#ri3u1gefP?1j0-r%w)n$CCqffoJp7&gaI9MF=1vBW;S8w5V%y6X&_7! zVVVikN|^bCSxA`0gjq_M<%E&oLP`SnQ8MQdW+h=RBn-5@lrXCZa|L0pB+S)>xt1_% z2(y+jHxgzYVKxwE6JfRxW-DQ~6J{r2b`j=Q!rV@nI|*|)VeTc&9>VM;aNi-bpD+&- z=1~Io8Zu81<|)D)B+MbgJV%(rgn1DJmDnt{h^=CqIA2^KE)*Aui^V14QgNBMTs%vZ zL?W&b&lb-S&lS%T&lgvU7l;>%7l{{(mxz~&mx-&y%f&0i)#8=nRpQm+HR846b>bTF zdU36IgLtEOlekV?FK!SwikrmE;ui5{ajUpZ+%E1AcZ#=&yTsk%t>SIs?cyEco#I{M z-Qqpsz2bf19`Sy0ueeWqKzvZ#FFqtbEIuMWDn2G25FZzx5T6vE5}y_iiqD9L#An6l z#OKAs;tS%7;!EPo;w$2-;%nmT;v3?d;#=a|;ydEI;(Oxz;s@e~;z#1g;t}x^@l)|L z@pJJD@k{Y5@&6(2I>4ejy7oo61zlx<T^5!tU~kCwVyCLHp@>~KG?j=#0FB0&c+!h0 zrk76>mGqcuNslqT7t?$1y?6h2_TH^r*kJVcd!F};!0wsT=FFKh?c1K;_58l)4?TbE z`BTrId;Ze%*Pg%i{JrNNJ^$?aSI@tD{?l{6hSMZzx@o#=k~O?W(1;pIlcMRN>8a6Z zdTDxVQZ-slnkHS7q0wpdnoNyBlcmYl7&SQ>lg6yEXsnuCO`fKYrmv=-roU!@W}s$} zX0T?6W~gSECSNmLQ=qYF>>7v0sc~uC8jr@S@oD^;5t@;jQJT@3F`BWOahgI+k)~Kv zqAAssX~t_NXeMfo&`i=y)=be%)lAcrYo=>vXeu-_HI<rKn%SB;nz@>Jn)#XqnuVH0 zngAugLdow?@&}asF(rRa$zM_Oca;1aCI3aq`-$&Hd=KK&iO(cHoA_Mf`w>5k_yXcR z#E&3;G~tppzLfY0#7`!^f^g><?lj}8iLWDmDe(=&Hxj>!_%+0@C;oKeHxPd=;eIIo z3gWLMek<|U5Pt*l+ljx8_?^VxN&LOUKScbK#6L^?3&g)p{9DAoOSo`}|Cso%i2s)O zABq2!_&<pMhlFk<;OdAJ5;P=eNys3<NJ1YH29uCaf{g?x30@M$l2AlKDdAcWp`3&Y z5@wMwmxP5RRFP0m!g3OhCZUytV@NobgmomWC*dR#P9@<C5;l-<9tjtca0v;Qldy$^ zHWIES;YJefAYm5?cagA%goj9Yl!PZqc$S10NqCur*GPDigm*~zfP{}p_>6=vN%)3@ zA4vFxgx^W{o5Um%c@k4d)R34#qJcysiG4^MK;mE$hmq(a(M#e;!pTsvki-%aCy+Ra z#Hl3CAhD9fIV3J1F+k!H5|@#<g2baqTuI^@64#S>GKr^=covE0ka#|c7m;`=iT@+< zDiYgByphD4NxYrJoh05x;=Lq3K;m8!A0hE^5}zjVc@keD@ih|PB=KDmKP2%J5<e&L zD-ypY@dpxrCh>2QIFh=PB$CvFq%@LrB;}A~A*l~Z{Ye@`(om8LNOBMkHAy2#8beYc zNhKsrAZZdw(@2^@QYA?XNva~LmZT*lEh8MAkeW$4mZakeCkLdHNjjaRvq(CJq>Ut9 zL=rCei@McEQ@fsH_Xu^veVCP<9qh%C=zss%rF^*}yHalW(&)zOmB#i5v{eVKvEWUz zOL1*5Uc-$1JGS8!a>Lz|@XFo+Hq376R4yiG2W<+LM_;5|gI5jOU7;+$`O0$imf_2n zN9&<QVW)dQJL3S^kyTuv_H21{ORJTZ_<*+4bK6}qZ_EP(1<}tB#8`Ws(zbYLU!sf_ z_e7=1lz_InGsT83Q|R=LDn-Rm4W8z0X>4whMJ>UtZ#AuW^*%<})0CEb2DGy}YdNu^ zgYOs=1pl91GS|2Qm$R@3;-lr<ptOc7kjg@rmetm`;0~+0<<$*qaCun^dp{(wn7t=F zwn>&?V##Qa&u8}xXbtuj{AeE#`~d!Ci>AI&p^i6Fx=7vS^(CZ!u|hp9pl#?(QwL}x z`N9UgtGu*o1x~xjR~N-w>k5U3j0AU?CAL<ScZ6DwL_hgAv5s<;(zHIHJ^m1guhKU| z4;vJeHo$T5a6%pXO)OVeD_j}6ZgQt9p~-JhsAnhW99=PaNlOzRziz-=;qjg07NxbE zfVSyBYdAjav-g>nv&(|y8}z5Jf0nIWQPYaeqj+pIx*P3K_%H{w<^P!vB^a?A<KyKG z-YI%Eb+>lec5a(9q3!Nhq{s_skLXN_#9f8)F5iC{tEY#Q7VvD?p?wK9+BlCZjrQ-V z(!74VT}^5JXzI@>)CUH%v;UjYqT)+g`S`-f`{B{ey{I&Y7gP>`219Q?$BjX+Dvb{9 zq6WQomnZQU^p-+BKcGFXGYxhnWJKw*voIOF!>higaCKc=hkjq-sUV>Jq8(4{YODGh z`BjPk?}unRcxqDF)80~0SWw0ifnyq*mtkO3dnqyMqoMao%j$8ne_WRHiJ}2}f&~5m ztunj5tX|#2zf>A_{{N4f>_Xqli5NTCEqSq#>pO)j_rXYI)J7V1gEpcjRvqNwrm(rW zYE3K;KPx<VyW9;OzQo<|4~4ovpk3U~<=L%gEd@t3wk$2^B>Jn#wY+Y5WAhqWrr@>m zwZW$x<K1n)(mF0fTi;ph2k35{1%V1A7Ils4*;21$g|E?F)w#`KOQ`c+DGK$m0qxw* zr0zuL?WZo~D;rws%Bvcb?iHP=^y;lNh^N>)9j&^e=E52_X$oF`8<(&2!u!Ll<j}o1 zpk30Ld|hcSDzrzxeikf2#Ex6NvXtga6U-62q~1{OKVw3P!)CK7iGN(nW~Jrv2i35l z>FN09s-~qev7uKVr9nLI(zS_PM@dffG_lt}h5DoezlT@FPnROxhNswZ3LK`ih&RAi z9s<vajR%t#H!1hZM!lgIxj4L+U14V0!7Oit{aChUoctc8$?09Rr`Kk8`_+=x7<-OX zs8=Kqs4M*v^(j`9W6y{L?|_dJXq?hyWk9>EGlO=iFUFcNIvgm5j0t|F3JbHls8f_u zT!~}(5eoIW2R?qb?<0{aXG?(+aO78H<0I`frS<s<s()RvXxKyJ%VBY*ovF0F@IOZf z_>de=Lta$0vbB}Xw&PlytF#yhXmKxWLmjGM4UIKb4NDtaTBBdfJ3wh8@jz`<S)??M z$Lm`DbK}ALn_CK|RMp_3+5**^`J3do6^1ueuV(*@nho}<QCO)7Xiw^ll}<WUe9jhA z?5<i_Ti+O{mfsDmUb%R2Bt2z+si<NvV-y8{A8(?i3Tt>=qtiD8I$^Ez?!e~A>V09k z()5x;;~n5wt`e&T?q;R&`a_fQC^ObD5AkY0MrnRoKpW`HBMz`<lm*Lh?Us9b9j7$A zyo;gLYq#4I4_Bm6Z|ov<kJoK;BpeJ+Rj41`Me1Ig)1z7+iWzFpQmEr{{rdlGkoe9T zEKx>HunJonm*aWEm{IRMg@Kg;?V8RQ=%gdYHyaZpYBA^sa3en6=w&zH7p!8>mn)Ol z;JyFxE_#u|&@ln+^aEr_i3}Jn@aPI=ZVlyCSOAD`=yIi@H399M|JG2ryP?3+T)VP< zMWfo}>Pn@(wOw>1<QLwA)!ANc3iWjX?a`e{bAUZNG_8qFqSWU$*DH*ikiermai|25 z9V7Y-Eb`VhtH<}76$U7vJ@Qa!Vil@CY6JfrO1md@)xLg*GjWg$zPg6F@+n=V?)CW- zXQ%fmyq^}(R&=Jb#71kEqs4c-y-HJO;DXM?E0)1!$q7|0OGn#nemt|}@VoGgsm<>| zpK!XOlby#Dx@R5C1Y2bWF|C?CWfd>g(@N`S|L4V#sO7AfK>dQ!!np~C?!+dF3RlY7 z=#;9aCY)ST^XgZWW;Z5Su}j=63&$&4Fa%9*Y+P2jqPDEAeN28+Y3+i5cHIH`VW*=} zaC=5{&2dH@lGeHvHFd>}EAjkctzz96&A+EGb<rUjBI{U0iG6sxv1N5&3d&}9Rb%?f zx|OlJXL^0CFmy=*h7K^+t2ljl<#=}0s=9XTA-%p(7`iN=oqB*~i;UUqv4zQ1)$N_* zTcwpN0@|7XtrgXs6)`sdNoi|S7sIXB=JO>E=D#b{uS`&9P28!X`m(G+wLbih(%hB= z)v`{S>$F#~7me|9XmeG;^7@t<Wr2b{k23?wXKSqU_U^7Qvn|1T-hncs(wml7)r5M} zl&TfzQ_Zp4uzE`hPge)Di#qeH1ME=cRcz6XZBU5zvEIFuR<8|cCw10pCz?=tO>~Vt zripZ=iR%N}#?G2JK*3@o#k8in72_wXl-7D16gF;5VDp2*MleMU2dtTO>Pt7hO$txj z4?JIp?-c)jOGxiLrS)49tN?UHBk}W{7*80WG<aKrnr>oe!zV)9;M$cNVwxPPG<ipY zy_Ww<Mm1f_&#Yq?juLZNKQF`Vpm=FxBUU8iI=M|@XXhcxEh6u_7aW5X^TuP8S#Egm zUU?mOiY-<4b}LNn4ro_*)<HWlOT1=crr+4A+qAU4rlnvpX2Kzcf>{`QjCpZYO<Z&y zq40Cp!C1&{KaUGdBf}9<nM20-%~*wpdk*5>0`v`bA%0Z@GT!<Xp-~{t7$r)>_a&IR z9<akkXP#4ng_+n9VWPso0|_>)9jG_7OMkJ&qp1kB@nx}mOjY=Ju&db*%5@3%efF+U zs6TXQ2BnaXMfQ-W7AktrQP_9{kF2)qdMjI+<u!wX`V}<|E3wUcajT<xC7v~p)zm_T z$YTL*Yda$UZd*kAUJ|{m)4X&|>(b@<RZaB;%}Z<9l5%t1lKK`T6Y<L)y{i>oo=A`% z|10-Zxawdw+Ixx8)>8>a^aJ(Os9?%oR}Aib4u!AK&+)OeLE-6{gPB!FyePi8qm|~K z3usU1%=G_C-SI)3r4nkx+tdoS_7yv%#2hK;y-H#0g@ATiXKZz18O8RU<`Zj`X7(ML zDqDDfh}ZghrQMeU+U5fkFJ9L%17<Kp%KPFKf0MT*;Q^nxAbE<y$*Turp|5=qh|R4d zYmRF9^_dDQuXj0K+gyp`^|=c5HxsN`CH5$MB9uBt$GEciif&9gaG}!t+lOlQ8cLCr z{&p13_XL8eBukm%lE}*xX5Q_xrtOLMy7u0zP=7zcX!5T@N_&?Ijf`?8q`Xku*sMN0 zZc}*qFrZy<fE}$p2NiYA^;Hc8p*?8vo%=ea&5sXe1fNldK3%I)7wNrSY3|ei|6PT# zdr9N+(AyQhKJRLY-0k-Haj?hX^?Pg{uh;Le`=UzZy>}~gzwD~>+PtoWMXlcVD%8JD zaLOTZn83gjjuexT>%^v94=U|^d+4?bwTrfK26|Ls;rj%&_yg>xQ63u;37=A${V|}O z^542-bipW2w&#^be(ti9_-)=qtLeR8R;d5lMd}`(EAbJP-ft+>e-CJ>GX))>U1Epi z*g6v&maPln@K3Nj9;eiI6~_KN1i`d%u^d(7gXu>~n}2sv)z~BGO>D@|73%u~+7*XD z)uEv(oCm58Qs2m2BqtqOE=ogdzUo~3sBqCe!H%NDkuMzfT9ln`p}lqWElmwoYn0|= zg2Hb~<NU#xhO{5CyWsONZ2hgUB_4R5-Zf@AI;@l0P2nUZK~<+q)`?Y1yYV7g6{(`a zK+l6QFjh_sPyXUMe5yuir`Ms{Qy0nE<C{)Xnod2KIu6Hxm=g=CT`)CMVIVERGIduX zf7CI>*l?bjqqLThpu=~iwWzK?qppQ*om5|uPt8>t*9WxY6K|kslBZla+3mIYUC}3W z-KuB4Q~N9A4F~g7L}hDzLw##KHh#&ujj}H*Cb3H$qO_d-pDP!vYK2?cs@JqEty?v5 zVr(-7N;5eD?b6Oht}exckgv-7qm+vQ)Lqr3v~TY6xa>$=Tut>W)U5~e1ZcZ;p1A%n zMrkzfP;~#;-k`42VugXe2lMihGWFf8sS}jO`X6|ezH37pTg+rVDE1U;>J){Kfd^g~ z=^`JoId04#H$!1&aDqjfF7>L&fYVYCwV^wv;n_;VL;wE|ghsC|$MuK>3Rn3DHQ^7g zV1?^8@q=)c(q_TI>;xUmMN=0mjoB0IH|>(WW3#H*308RLQJkiiDU3J|Vj)^}e^6Yz zO-j4&gOPW~m!w(wA4?zwQEMNuYsys(>;Pv`<LY=PSgEk(4QN+&HoE<*)I^OfWq(bu zN?I74@D?>UR@K&2u{Ei9ZjM#B@gLgd<oNknOn^8+;bG*VN!HqpjWLa%tTaCQKOcTV zM+()>V>g+{`Q;f(i(>=Y$(=bs;*N<jTx2g^j8x|+Z4@5NNE3CdMNDHCD2)~We+{?c zxD%T<UaIg>nt+dg)wBN9z^l5|ICYc4$M}Oe&5Mn^p`YS*tfg*Mnw}WYF8^=773IyL z#)3CyC^u`#<qp;3wyD=DOiW5J)l2N)QA`9QzRDUw>P<>(Q@Wn5Cq8MLdYeLhT7vM< z6`w-4?W9PsOKEX>f)=}^y<q(9;H-A)JxYrehqgu+f6Z51Slpv<Q5n$s+PN;<?Gf7N zQ8RRCfor&9xV@md9y_L5S{nkZ+F$dQ`iMer_J7{I8Jw(EwbbB5OKiY-QfXptf)uMO z&JpGEvHdP)^Jbjxo>Lf^e`vPHM*3b%+<!@Fb>V+r3`CDexcMvfb)~t$K@?IokBkxW z9i`Q(E`}Gk+heyST5U=FP@!IP5Od=w4~iHr&S5@N+O7M~rkh&V$}TIydSDfDO`PGb zz&?z+*cHLlua)MOB-o5}P&!IDJ7`6Ht{^fsk5j=93QzS3Rw)mVr%=7AELfvZFN*xC zu(0g^e|bChg26b|{H5@<{6A-?9ad<yNlF`y2P0Win+C;S$TX`8I~&^Fs@K8{XM zj_ZmWAe_kt4_$*0H|x^&R2pqbun{ov7>}mfpV^8IU|Oxx*2*phFuNNox`_gqR<BS$ z=3q`VqPFzKh+<S4Ta#e-O($xL_muWq%c8dccYNWM)~fKbHo>H|6JFX+F+xEjH1gM} zZ~f8sQyO1)FdGjwDyR7|=|+qd1}lx9kl<uQV#zxiJ7U9;cDT|YC8%6>rHg{O&}2QT zfEL%VQ)&351P9Q&(r{ezAEQ~H(%vZtGxb+?bcHt|#I!hCY4NlKXKcD6VU%j)_OZo> z!6K#gGXmP9+NJzad$SL)^-yn83P8#j93%gDg@dya)TTS}<xV3?_;d#wjc@`_*|8eD zc?5?(*eV--8?Tqi3Rh=$F=S%_(VK7^n0C5C{oDkr5(lXD*f1h5x5ZQoVhk`#VP@l@ znL@>^Pjt44RXbl{<bs2F{3^7KQuU@x?U7287s1S(xqm0lrwkz~cMWUn6zZ1*v}+HL zdZ(_fl$n>yhoBY5R*pogAK%d)rLc6_!CcslHgV&!vSxIt;B6u$lPAabt45{$D-Py9 z=~#b{88+jFlUAkqO<nEQc5L`cn2D`Xs9$+7g$sqy=x(gU(Kz9bSDN2)F#At*v%%V5 zOzb#GX>wZv4?lQ;EPQCSgS9U0=?Y6%A9#k^J}Zp%u-NHs>^9{X^_;Ena&3a_C2@F( z8qs45i81Y+ue5jlq1kiW(WKxKrP&)3Y$@$T%ueH6RTu71i_ypb6vnn6+?l0ZQ0Qo8 zxkYL8mM+Ga4rhDzsQu~MYZU6Yb&<LkJKhuCkfgm)p?=4~oYjOQSmVm(nmQIl)Z^E! zO5-~Z?Lug5E*cj@cPc#W?z(ytKkcBsTcLi}!Hm$cdw=2w+y|5<?>U%T)j}5SRFw}a zE#G%A*Wf}ehXQhVdLGm7pHP~9;J{~b@c}9BXIJc*C+)LJiw_=}gKp6o7NSpQcYA5~ zDXctnFs>B%S3_ZEH~(s1Q`mXrU|hr#XN7|J+xz~-RYlsj6^0%=WX|D?bB+&`7N1Bk z40SR-wzosO#4Ik7eX2D2)WNuKD0;Cprl)<SwDQdV*B17U78A7JE1W!c$js`9GwUx( zi!U6SqL`dzsI0eZ|5O^@cgRGw$BLT9DJ{Mn(4N@YO!g4u`SEWHFgNE?xE@^3wC-sV zH>fQwIgL*f(nLyrm6Bhh<ku<rjkdIuv>sfaGz}%cNy%@m*HZG^>xTriS>?_3%d48# zg!r6UkI8c@Hj)Rl{o?+F5vIPH-IIcgiE6NIYev<IC3OoY)YsM(HZ)9ZX~7Mh0d4=d zFUb#R)z!v+t8d}1elz->bJ;2L*E(zt_pn@#+p})&T8G2qAC_xd7ZN8kEvG|qOlf9_ zW2NMGDfvAn&im_!FtXFP-@MK}e=Y8m@C?iKI{hGPcR6Cn_D>rEvdJ$d?@N9u`DIFK zrX;+G-AYL-+tP-n4dePGzd^|#Qu0S2o3xsd-QC>FslDx+xod61a_t_MC(NNU&DS9* zf7%FeIEs=#q2x~)ho8x${Nty-Sv`NP+wOJ_%k|q_j6=8E5iNL8+V~F1PDq<5bNB@% ze;LK$;LFBmpR@piJAK1)9X6*o%w&05Wru2<l{Onp&ZXq9Dft`5<hMaJ4w&%Bb=GTT zd7W<ey4h>J5Itg<Kw2#$d1P8uT6J0tC4W!JKTz_Il>Ad$T3y;=ki?t2KU4BAjO4F} z)6sS|EZER;&9Sm5UWb3(oV9pnE?So6v|~C{_Ug1XkYz0;|4zw&Fj@XoY<RA-^33^b zT^>6~dE8#u&~1<PGD<tOL$ar(oi5w(Z%Y0r%7z&ktA5%bv+8&G!v;Jz?ZOU8U6gil zkQC1mpA<z(J803`muEAF^*O_YHl=N4X4{;0W!hC~TZr#Yd@}Jo@j_eLwzM{giYH=4 z;w2E`Qx2=ys*`5tJ(diAc026obU2wD3=r-Z)7_f3lgV>i+U;p~r0pQSC-EBMdlBEe zEp1oYZpd>N@u|dXnLKHSQ=VOazSZ>S8CCPv`dwaljLRL2OCJ0?(y1Owdz?w5+NqvM zdlJ$-O?(FNIwp;tIpWTSg~zR2vRLV-P8*yXSDZ%Ed@=3S4qfN9wAW?VF%X{xnxR;i zdhR28Ka^?O9TE24OZ%9y_kP+3X&<J2M7)vs9O6yHo7>VpN&8eLWg*_GkUD&W%Z}eB zZ5uD?Fu1sUh^roZq$~Z9_G^ba{w?iy==e|K^N8=mblg|g@q(Z3yrOX7TD#3<M|Z-2 z<y$w8#o3s_Dm^J(0Oj;<>D|+l)6u2+6F-3XfyCpNV!FijNyiJ%gNYx)C=WfHzPPjg zuhFIz=gwd2x3Tfe?hOt>UVF4Nrt8wPJ93<KV|tEk?R?^gM>&pm@(*oK&I!gGS2*aT z_emef6w^1oUwZ#^sKiFRop=ZF&bIVH>4RlTF5=yX-EVdaWr1~dA0c}PW(+>BI}|z7 zUFm-2H)@$x`iS(Aur6Nc_7d-7*7b+R(A0`ggX-}6eHcQaY;U+br5C49=up8E(~pqV zGLraFQ3~#*`FPx#AVs&+9_DR&`m7EWJUe|3c$-K37~;n=-o^z7FrnDGVc+|Rt{A(R z3)on6#mjnNF~Z@I>2)2-yf}Rc=++ZoM0_!$TcXJPdr?WM96MOIi_06*8`E1m6nbU) zDp}|<;>Sk`J!<0}{srv@#q@RQCo=BTqGkF?=_iA`Q;DBQ{1J@1NlH)t^}c_cvPC>B z6L9-ue11dvMyANK)6YpiH~l=~rw~7t_-VwKx22z-eu2#0bmC_y+#S9Mw<~w~*7r(o zS+EwDTeIQOZ+C^=VRQO6rWmzBKD{mdYAEJf;%5?H$rLjysF><aeSR}tFmEj`0zpcO zaRkobbVR45>D$w9XS%sL{g(7w)A4@%9OCB^567C{mVQV24p7}i`~u<^GOCLXYj|r| z+rPG3wlaXZ?JVQ-#n^dI`Xe1`=+X4YWIG>8e3fEn4761(6Z#aag}(g`)?xgfNN9LA zeIKZ)PAAe|N`G0VRzrMknA+~<QA4NhzqP$jzm@(zV@x&5e31U3OlmRlOTwgf^?mv7 z>dieCtaZ7anB>@T4@1}yzDWO;QB&<9-=%*Kll@3My6{oVWXt3pvXIMr|F(H+gHgeW zfnm;CzZVV`2@1cb|I?wg`!hJ1#pT4W2(!4mdFX~WtFMV47c#^Q4Jc(u87Ub(GLX47 z5q~uC&BV8~W%SDEEmLYGex*X`@b$Lc6OUf{X~F69*ZLetuIx7Wlrlxl$j-1p2-Q(P z!<vyR3vmqbtHbKpS^wL@ex5g#7#W$SWem(1#`G~LV{pchjG@FIOZ-~mk0X9vTSk7y zaGBKc#Gi23^|7<T^I@OoE)Mmu@KB%O<l*7?CkDV^jtPL?Zq~;!h&}<hG2l8RNJ< z85k~3A^uc|z@K(FgT!uqw|i@v>M_)NJS;`@+u8KO=8cYd8Iv=nLmbtfoiQV$0^(E> ze+KbqGI7pg9cXv+@P!-BFtUNwhq4A-C0N&Rvoti^hcf189N8h=s*Gyc(q|KYPS|Ns zfJiR6vM|_(yeJuj+^;@k1ylG@8Ot&nGSKVJBYq?C=M#THTSj9>6F5YFx{&yb7>5@h zPKEC}>*5ccZX<GXkIRKgsoMdCJ8f*hi74i{41zf7z3Ie^lOPV9=ThP?W8z#Mj9B$Q zyl~vt`3u&%ogUUV?XKWlJUEa==$@5vUWW?bm~lSnLP!52eiNg+SvKUTNv2<)TDaB$ zO9r!KryE(n!(nITstD!FGp_8A@>LmIWK&*6{FW$F4*6>Jy%Xgu#OVv0^16)eprjhD zGj7hf1w3NZ-9~&H<MC=GT9<t?sT-Wl=V3{J3poudqIqLD+?{c6haBFQaX;wpAs!jQ zb&T%yitKZ~$kU=k<#n(kn#~8YE+>n95y2nLc&bCPPiH(M3w|T<H$@4aG1<4IeR(6} zrHt1>N<C`4k?|%te4F^2iNA$$cx#YDeYZcG>$lHe>v1^2q2JF0_qcsA&h%l%XH21L zc~HjZ8DD_xSH#~={2h$!j-W!TZtr&AUz0JI`dRX0ciLF*bz_DUE%^@_YznC!6@JUW z6cXh_9?8(|D9H!*8}{V+a=dif!|_tb>3GJX+6b)^bRySBmqI*B7<V%k?@?@i!?us# zkV(Pp;7_jjg)O5?)#*S~r`4tD(sd{o+(-QV#6Lj%o;ICcmnrl2An|(@{tn-`x^wy3 zE1NdH5ERCRhp$3?L6@f+z(nYy>#OUh!$kUF;vXUYQQ{wK(+$)Ol0|r&_$Lm#2)oB! zTRMB<CR7KUZdTc`JA96?7)~9l4y!u0&aXptST~CJr-*-=nfDplvAc`2>(kk=#Db2) z5zN5+(dBDhk&YFIRr3Vh1f5(Q=AR?}c||#_OjPjQJ9nPUvR77dLWMY-z3R$!tT?Qj zuA8B&&|y~aBJul(e~I{)+jO&ZC=Tn8=D$MxtBl9j4(AB6^UQ5epP4>x0YY*xBD?*p zZsByql+JZEx}}guwMwO{*BvFh4m#+YVeRbrZPY8xL;Z4>@?fT}46eGPb*n&1wWI5f z(XEzAAvC=cCbhfSzh}_O;c}|$j5xvxx|2Jkbc*g&nbLd2zaK>@`KL$D{#HqvBR%76 z-T56-x<GfKOzA`7qt`C-?=>v8DwHCz=L+3bprresZj)}a?n>f6A^ub1KO_G0Hr*E8 zR+-Wl#D~@x4quqq@pJ71Pmb@#DsaICBG^B?xS`vwWAjpVBi*6Hyp%=buZd@i8=(T{ z@Oi&qxDLaco23jWf`u)9k8V$g#2(b`MQ1=H`i}VTL5%+)*kPMTO>NrS3%ohJu3(-Z zR|oMrdh}qVds6otD67uwbkFNv0A=*LpNRjNQT~Nd-Zfz2THlC2=Oal1B|KymEYa9p z(V3*~b=^B1GW@RYJz4tSi2prG`i#~aHT~MT!>78h7=x-q(bu|fz#!yCZS*h3;NQwn zG~H~~ApP*O6x!}Vaf_vNu^j%Q`xA84W8h!9zd?6D@%u^OKvzgoV&L@W@7#n;(cwh2 z^4S?#^z!K1l%Ci3VC<?5?)sj34cABCn}qHpBr~#nklpHTWw|+*AhbGJpvGmVj4ZB3 zj~d(cI(>&#PrXquS3L!h1hzmD@}{iwwm-W$UZ46tdRFyR^-KLAy<GJadXUgFijwBF z-$tYbDMjV@dYj(ekp}f1y%(bTN$5pFZzgK0tifd8vuusg>9er}E|_b(?C$7^ynd{{ zq(cps>dS(zBczd#9%gW7)vfp3Jl&|IF|P0|L_bA81Elm*_0#m_`spO-NYImzNrItG zU!k8Vlgc6?TOoD$LdniYzpQUq--4ApADb<pgdghr`hcD-Y3h&ESLv(uH6-MaU?Rax zf~8Ggr^k|}eklo75^|ZE^A6`gxXbpzb7TH@8S8jHm={se$z0jVeh9}heY2h|YwBC{ zt@@SvRV4H!p&tqTNf^+kU#-WoCIX`{kc2^p-6*>k`<`veUn~2S3-c^x0M?(ZKLaAD zt{mvk)Sm^DoK3<I5{5F93=4X`Fmdi*)f?H;1}2$yr_;%nY8)PD#t|Mw^%v+b1zq*N zd71ulSvA8+C{R?x=JolfepGf5au1g;NZ1}u6ZBj3*K|njTK#o0H9HB8C~Bz}4w>x$ zH76^s!GIBJx9E3(nra-@@6_*t%y*LDBEijM_5=f4!@`2ztM|we$nRujZC6ZBzhD0l zNa`QZ@6kV~-%Emz1VoGxB#dm+KdgTQBp)MT6bYjl$uWo1vv;T07Jie81sE6Gy}=%D zgkxh3GJ58ze?k8W(~w$`RR5~}HCf-|NGJ^Jd)I&ozYgDjD+~Q>b<`Cp-s<1gf7GGz zKGuIC6Dua6Bus2~vv<$!-gjkhjasGGf35$4sreiIxBBn&-;+>A!gvxUkT9`L|D*mV zsQDKXjv!$YQ}g7*s^<KsHk5w+AoSs9BdpiOYB8wGM5{TI%Vcv?)y|hGWMXd0;>T1H zrbRR(luY}>gXuHY?1P;o;?|kHGc!8UbEYm+FH^(N5n5VdT`u*vRTI}Qz>0P-v2r@Y z+io&VnR%e5I{Ih!$?Pjrn@K`tn75r(f46Quax{1grjXcA5Dqh$Loy2(H8qFIv}M|5 zYO_h06Q%}-dVBmaSI)z(7^DyWNX<RdmpQsa&c<Yp<@#h6k}!{i`OFCx$a%@;jPvvI zz*%qu3CkmyHDHdYXr4Jfb26i=mY!u!$(#zh<s>X3A;9P!sf2~q3%(F#KXqUe2uk^` z=$tfjR_1)r%$%J$Cv$Elc&a7=<6bQZb#0joG8ckofP}>)u+;`(>EU$Po!370?xF?6 zW&my*o5A{gHkCE_%=%1L4prAuV<yU>nav~|MZz*BQG=|d1<wwvJ$=DiXK*bLE1|(+ zmxHB<;juJxb>=$IRUI%gkIy^-bcuu&Bs4O*O^ojD=7Fz@t@Yp-OESTE0p=`hD6+8~ zLlMfSWp3z@<Fhl*k$n$Lw}7&oaAMC#!~6|tLAyGT(}hOM%!@KF?~utWGXE!&T1mpH zFsa?mz29)Qd;sA+tk7q7M|QSlZp*w5)YQBG^_e%w)K-(QCPGapS**GLRg_|}`3}@v zkt##xZJE26m}=>I=I+cpWom0lI4(?WXEpci6aCIcjB>E<@5df1B`wH&AoJl4i9M3} zs7&m55<&|lZ24~g89$ZW!u-b`T*C4ABi;X*%ojT(w=eT0nH=nUVuZJ<qji7yE<ruT z!-gii4?E;S%)OcU9;m6i%KMog$ka|I;gm47-OcGg&N%5IR2@;50X1i2+d<~%ncs9s z?c2=nWNN38aC#KA5jQ=$|Hb(ENanAZe|0G3-<ki&l+GmKtS}{n%s1|QeL8}i8wT*A z#;V9@;0?jam)f=~Lr()HUj|IRkeade3*lVW9kBgr^=ChyfFS2|!2ca?_$}s&K6`YK zGw2L#_NBU=%V0EM_GLgizLA9U8QlwHx^GYW?crzTAm>K9fFS3Lo*^6h8U`_%YP*&U zgAGGuxi2E&;;`J<J#^t&FA1m*xV&J`?+SM@gWcfi$Q%Z*!6y^Dlmxau5t<$*=bdqJ z?n2bkeST(L47p)Fjy13;m|>iu&`@MRl5qtI|07`&37gvtr3PgRb|nc{DdY~{ylL0O zD>hCP`pbG|8$v^_Fx@bVsaLII8)h5k$Qs#7!nUwRFpIqPNcaC1!rh&$MuJILcwjdK z3~Umn+ItLj228?O(s4Bj*M!OKZq~k4eB@@9G6r*wNcq*U+|b-1Z!LyaxD%#D*O72N zhzU0YM}w-rU;3yw3p#Gr6@8fFBLDQ;qZ1>;aR#<XWmso8-f)6pJqb6Fu$_dPNw}rW zaH0W=REASXxRr$47}?to=dihZ+>RSoopLvN9o`p)roApUxH){b=;?vsTm#!(s&2xI z4D#+$VFw92!#dwtz1e(h>PDs4Mb<M6n+$A!sk-^L8L+>UnQu1<cZNx!Vrtm2uqZxU z8E!P(%9MPQVY}gG!!0D-O~O4S+)KiJZHC(nx6737C*c8w(qZfxZRg+k*S*TJ7An)> zu5q7XFGNrsK@ATX9+pLTkc7}W43Y++<iSNP7huuR<_UHUyE{VeDZ}#}>h=Z0i!!-~ zNq8hmw<GN5opO6S-M(&MMMHIiziU9z(C`5Xm=Zn?O2QLzzu3NM=74XQBL#;~Hc5vg zxmn#W!r^CzuR&LJLx<rT!?&P|S<zD@u;mUxUhbH9^x`w#eUl9f!G#G2YUZG8^G0W1 zhF=YA=u-EpzYQ3=vN#f+BY`b=2rn>xvB74xW76Fi?|m+|8j6LKVD^Ovj-s=#EFr5W z(}Y@9ou$d@CF^t_2``0py0c-CCw29`it9VVfiO##6&$<N0%4XhOQ{^bLIPVyQ4+bT zTW|a8CstGNu{~Vqmf<*<)hDaN>S5NPETww*Itg!tsbN}r!P@Ot%8W%#OS5cQtbC~I zhFP90ln+^-e2av)Bc$Mlzgtda13&ERi}+yHn5<%EVYU4oStVJeumonj?~=d{WC+0n z8Q5ph;wzaSn$g?6%)rRvqa7z}N*1dhs;+2dRb(mk!w*S_ENbj*u)p149w|%fi>$O{ z&Cg<6D^%xlSyfr`)(YVh64-$Z*$kM=Jym$wKQbv~C!zkERiDKs6RK{P)tH6J1XJAS zBzzGj1slA2OXU^Fr@idB1nS}uYR6<9*CDlaS;x!Nz9Ql4C~B$J``16v-lC^uoylZW z_1d$tHoyw!knk-D-!UtEAMC#k3x9oOK!8p7gBd246=4NuO!k#^Vb*0Gs_ycvD?k>R z$&V!b#K`{4$U=1wSN*;{7-0O!=;C&JW^K!2a|m?}UZ17RA$}#{w<wv1md!6)9Uro? zZp-R${*bjh3-gC83=n^i@F(N#ub{})NjpY=09#<wHp|f+umyH8cw$OpS$ncN+zFWV zXcl$?W<5c|KP2o2U6E7hwtO}~r|gyV;gkkaPPUE|j)PgxWxdp)*e_?j0-~>x*p0;Q zjA$|=y1Uso<cm*VhJBoDdh5gPY1k)@*LSi$?9l8VWqk~?pOPq$C^E8Akk^KV=IVFu zVoOMD_;<+L1)O&HK!n?`vsl?my~q5Rg|ZdgT<k$&Pmm4un2D!Z$DT3|b7pj7k3Bpy z%lb2$1FfvTvi{EcCu={6y-4g$Vk(K+w(O+rZZfSj5<_bWhi}y0xnscv->tqABaho1 z>=KcjHoI4LI;2pInAsWGI<8N4CW$%{^-R&3LHh|uxC}pR0X3VC&GxY=H&~v)2pOg7 zY*TiyY^7Fc%I=dbm#xGs5<}}G!Sif4PPzDXIR-dv;VD@5kZe}7${w0MEIU7YIEgtV znn*O0Xlcu~Wus=5?Ih7kB3rEx59?~hZr9XTCKU#AY8Nz(1cLdt*AF#?oiKZJb`iu; z9Rae7vr8aO8Hs&K?8n6EFZ=dz;i<>kpmK+kCH^>y1-cH5rO|XJXR{rAs;N%)jBM=S zW6nL0#LyxLD;50tN%=7zS>s-8F;HeY+4HgkAf+12vX9KJl1U9AacH=ouwGqyR#n^~ ztn8)P%bDrwvyaMNmfb*NK8Y}30g1M@>=oIKko9O1?Ig1G0?~Om=MTFU*jhH3k7d)L zpo&rFWP^9iN^JJp?DY^wz0XtjiLzeYBznSn*?D{5c!_dk6}xb-E2QExvd;l2)!mHQ z=VqS=&74o7k3>Jy%n0TMyEeS_Qp*_^qDbs#r*T+$2Q2zy_giLPn!Tw*({0YaQf6@! ziEIHRG;Pl}O&=_;lKUf@^s=wXzOh3}H)U^^DUBs@Tok2&=ihnk4=gm`#3%Fra88iD zBm1rnsokA@k4&wIM0UU;#FzJ%qu)PXi3je8cka!845U<}c=qGjPe64~kyuJ%8B^W( zpz8X*m_6>7`(a$07pn7mgCWc9W2tDkM3MbM_A4FIeKq?vnZ=1DvQrk}(c!FB%X(vU zV3kf^WH~SU-E6kjqR!*T+45S8IGMyL5n2O>R!(cYjq%8K@Z<L4u&;cb-Qlp6{bM$U zt?XY&oJL|f6L@-1;Qn`6{}}%@hy{0avYkHgW*pm$4j6wKlNgU`X}qzUvAZm91&K4m zJnpPI>%vEWJujH_L3egv<g}TwhcOk@R7Vn{)|e(!n?>U6Fty!6apvEfN}0O^mj)dX zk&RhKGpMOXAfv@-<@y-&NSsUJJSOsdCNkzh<vmY&4!qfdiJ#5Gx`#7(DlV)_<3J<Z zc&^%mjrm4-<GHwy#6@8)ckZZq<Xrm{*$r(`0=tbPK+5PbdW}A#pTr|ctRk_R#F{qa zNaHB5IEKVp66+X?iw|dP+v%)*{Jn2B&y#lo_)&9ZdskTY6;aFt;}l4vnrIuR8mB>; z=_D>Cv7SkD6jL~g^UYrtbq`jC;a6<CFz9-{>`Zoq?rh@%&{f^$Y+PtuB)bJhhUF23 z*Z*|epa<`QTe#U7M7t|;zRp-@Jc@Ct>axp>4KlSx5}P8_s{T2z;@Er^*I5D15m`hq zwis74Vru15;~L|!5cxO~n@MEr5n?M78RgQ|U+qdolIdmT0EAvh>~hA`n2aYHPXk%i z%?QTRjc0)DStPC^@fb!{K61a<w{Og>0hoj`7M+;Cv(Y_f3yX21@nTRlo^QOsc%ktk z5|1TuEs0=oU7PU|<E66X$CDUZ2sn)C=Cx1lsrcwjxx=_4N4t&NjBJXe8WWAz8!<&P z-b5mi$QB>OlY(Jvz{K373x0+1pbo@s>_k8q^RZ(|5f8iFxVuBLcN*`KHFFAy>>x%s zY@aw{%nK}RgAzv2P^2~PF$U*IYST^Qqeje;j8BkwI*Dg67SB|A!H4<xvW@9TpqTZ7 zJ2f4im;>_0=ZqarlZ-DLF->B**#;8N4)cil_0M<gPgX|1$O%Z}+r|$du6ktr(D)Hp z{Dj1FNj#6SxRJ4l$aqfftIM#-4E24;i^XNu|6`8y8ox4r53;J6n(+tYk1~fBka%I3 zLu5=P#y6)U;5u2Bgx$d53X$;-<Nl7A%;9p9WNH_acuANVPEPH2AM=Dfzm8-fIZ{q9 zP*UCDozpufmFts(Io4$)Ue3h5B50B2Ynx}5-UEyH?QEsb8N3+7;bT99y(Y(yV**{( zEl@e;91G~?lDLV)&5Z7qL1(nxl2$Zdi`g)%3;JbW#CljX)d4v}K~*(A<qXTo2UX<0 zTS(l>sBQ~#Tb;D@z0045aeS<ff?ZB9j>l(*p(4z>bJ$Rm<H_;n_;N7RTutINBwkD6 zb!|B#b1>8}_qm?L8x(aOzRtf}*Ld4YllCD(26vtLyy3o;Gd_nc>#IhvoGCe2)@MQ> z0&G`=zzB2gdqehaYLWYZADcpz<T<A@XI_VDo}aS-YF<R*EhOH`)O?$)=FQzdw{By{ z9oW_nJC1lj&+g!n;E0}UbLu;!dsNOcnZ-Lu+!0~1x*NZEhH~YG(-z(aoztAdwxp@% z_c^O`uq7=A;d>W}yBUjj2K{Tp{_oFv@(Hl$VLMe&!eEsvmp^9qm_s@2stwhwBj>an z`Kk@^ZW8Z_u;{GK=4&!=9fKRWug@EvSm&IZ!&XC7LrKm>Ir3_Vcpr)PhiUC@yjPR| z=^ODitDH?aY%xTgt8F>*Vu-kh#0SHakdtI~@28xrW2bpSw!JZjt%j(M5;?c!$g3gZ zLnJ;NCWX@6$HT8ULK$!(d*5>I%DKNo`5wsGBb)P45+4hb+TA?%zM2dli)rk}8oMi! zF62Cx^E6{jZEVPSCg)jL^m!67JUj_%;!{DVYgkx++cPgC61mv2va;dAVT;+ClJiQ= zn~bhnPLuOi&fB2-E{V^O_$;IQob1e-E*`rl1<nDYZq%&VOf}}<M9#-KUv$XqmpNa7 z=r<(3K;nyx=stzn$DY2i99tS3!Eo*grgI+5;i4naPdUGXu4<N_^GD8~p!+w8FO&ER zqx&kOi;D(oAAM#plpr5vumyXbywf2(_cC=iNgXM{lw#^3o9cBEBZ~l7TfLV1wjb6# za2f@UjcqL9j%-RZWimF^E~qdWOj%qXlaa)?NMs8E;yXd{>wlXwqii0?VV2I)Fqgx@ z>ROm2Mvoh&TvPv!6kr-)8VJgRNqmn)cDzCSKvuwnbA4+b#<GBeEv~ZrP>_kcSh*}x zPBaymT%fBO;!SRoM^?Z`Bz_FK%KTW@cysN-Kjpp{slJ;=n^=8GwO5;pO{g!iIE(V> zXAw$`pWJ$fd$Qbt5Vu2p(KN|a-XW>!rWrD+FG&0{LaN#KaLW1|ObTplIKu@Z;d#4h zu4z$+)B>g>WoloO7=3(U(CG`_w#bY*BdMfmiKzjkRHt#K<)#%fsqaW+hZkgR?Y#ZC ztG5q%4OR$tY&UL4QX-CNrRi7@Q;j&LwWi}_Vn33|76U>F<b-!$KjsT1;zY`+rjtyk zgOurH(<!D?O{bCg3yHsy_#278x0%i`oeA$ilJ^IRtadM=c7ON=>Yd9^aO^tqcNhv+ zf3Pru?ZcRL1m`u8esr<v3dp10kN#)cB&+5h64{!8qUZXb1IMpMcXzmhqZrmC!-{S* zT@PxiOKPSYOg9FpNl7Gi3sb|ATI%N)%RcUja;4i%!JJ<$W}5CaA?G*ULsBwHJSa&* zuzy!=ckaFVq|m(&*!_i|i4BNR!Oirb=~3ngs#G5{JudSnk(3hVZ)bJVjA?(BAh^kM zRhuuofyVTliRJvJ=S?q|UNr3^sV7Mql6sNUyUp~nNzVDDRFbp`wZrENyHlsV^;r5M zNP!p75ta}D!!~>0^a-R;k0zg*K9hBlPEtl#CnyD<`GxtfxKgm`ThmWW9p9P0H~nDx zkt97ynIsuV%4#$HZ2CnelueTHu&ZOIw_s+4w-^Z%o6&i^;dp3HG7FGFwL6$avn0!4 zBFP+9#?Ja*THjdP6v|B^q*Bc~kW$@1VAh*6xjyDBlB^`LMGXmy8W>0?9({e%UDvP` zF1eBsyjKfnrJ`KeY%%v`9I9PFWbS9~FLT(JB(}Jq3?o9>`bSQ{F%gHKZAACj!z=UV zVP-pssoLJ`Fgs;p14tSeA=W&~>3-#A)TmwTv^z4MaPK#dFpmW_)i7%wXD*bf4JK(w znA)y>H9H4QTC{L2?ynAR7eopXa!m6CbFg5gwlU8<)r^9bc{)kMNXlml9L^ND>(9@Z zzjk>)ra(3az`1!A@nSa$n`fI@y-Ho?g=V>4CD}-_hq;8m?;BXYFg_<X*O^(ZN}bX& zGip`l6(l)Haxn(oK?^sJ*m=>_l^COZ>=Xy~E`dRJ@Yr`aB%52!YdR!*ta&ZSt|Q4y zl8=!M-p+*izw5l#m8hZwZv({UJQn+cTl6AiPcpNSOEvbH&oE=;GH)PhBuVUwCTX-B zQUBcd>uE>HuFVRg?2aLf`4O7un=b)P)lu4fsrfS5;$umQtRP^i@=`i6L#Anur1Ivg z%vXby>U7<Fjrm%cR1ry$<%3<eTT(yTn9WMyEccE&{$#${d`E|}?lA9!th-4nC5bH{ zNWle!oz>m$$@u2u&^2N<<VaAVH>QMQzR$cDWYrD+kojSm$B86G)(>_c-TX({*Ja4L z-N8ZF>xl%2r_5{*l<JvP^9yF|fik~D(qxjRFeaxmgY5YEwkt1B9?b4>a0F#$7iZxf z2b-6jA&!{k4fDI8teR??-!s22^I1;PbWm1egs$<X>VC6>F7A!&Krw%2{<=enzcGI+ zQ>q|oW`t7n$g8()>CvvU{9^tSl+3@He>4AX{)41hB+Vvi4oP#{%zv42bke+^q<JK< zvjh^(5*)t4a@T`b%$uaWTXs=4M`wE?qKiP56iaW&qS}=#sTM8Q$Aa;45lI0ii+p~e zn%j89Qe@58uYkHT9E)xFcOiVT%q$f0ELoNg7ey=<3l>F?*-O<V)kLdX+`9W~5N@|i z$1=deYE`Q4Y8hrht%^~rBWZCIHU7tuH{U3W?uuN^VsTmgAf=kvSw>h!LgLXREhUL9 z9!SB(gWdY>jtzI1FvhY|n|^F1M1OL|TuEaowoK@d!HJe5Ko#!aK+<wXb%h*2hdg%7 zOMWCW-ryY8hAbZ;-W5}zx6H8223^%clx2=(t}J*HNk@kTM<HtPXBSQjdaXNh{g~xQ zOC2a#sw~x(8cQunEhM#)w34J%ZI;EBCE&20q+>{0%{W|hIK6gfLy7(MFWCuewrK!Y z#{|a!Cv&iHV6e1U*n)`ay=Rs+7A%NZjw5L;N$li;v@SRXEI)R~XOs3~7J>35i?YEz zZ=TqF>6Q~MY(+%1I%GNBf)x?wX(y1hKB92fWzQ_l7uf8?$rfpCk)7n0^DGy2XugXr zm&nvkB<Z9GwQKk7eZ)4mo%uFfwt<p*4`{Po4SBC6=@gRK%7KI{oPwqFk-9C<vGOL{ z$H?{`vIU@6HEy@u&eW)ugIVsd?2s8egQPRV45CKjAD(*!axge9$oj)MnB^YJ9uQL< zLoE+l_R7RIkaTvK7#1w|UMOUt6Ua3z8%oN`RM+x^<=GB(_nhT<ncBG|vBd*rK6mZD z2XCBzWINrxYIzHk)PvmHmUp1L_eeUQqzjntE)4og)nB&Cqf-!zP>YAJIDElfYQa<| z;)9=9zU+|0uPk5799~RPWaVJzwfpw`c>Kn89R6haopGpEue1DNL8;2}H%XU~#8wU@ zdF7yC;hxJzTmTMjHr7jA?x1<??1s27ht}>^)Ru11rdyM(yj8G@R>_)T?P2X{)mVF3 zds|bjT5Fm$-I`(5Suw}iMADTcZ6RqJNmr8uhq|7m8%f$u(k&$2M$#Q5?IZ~a$6X}d zL(+XDJ-~<?tXbA<tI?WcHCfG8i`8n)wdPs-So>Q0S^HZDSO;1Mk@O%*kCXHaNiULw zY~Xd0-XZA&l0GHrGm^d{={u5sBI$RMAnJZfNv0Is4-oaDj5S}r+g;im&^lJ<udc!S zEcp$MOGXqFlsHR#zEYnz-{bMv^Ia}~S$<JTkw4#qZC`~Yj#8(qH2Q5Ct3#o5RXa+) z;^I=Lx1=oJXLFV2yBuy`evz%jlaC~&w6w%q>?*PqMf2oUC~a*|$?f(RVLdp%1Y0=r zT_vTZ`94P({;$yEw3p!Vy)vgQn$jqRQd>JpMGl<EC<P}jU!gnS<pDeX62Cnk<ZZ>p z?&2a8fTJlDDwM8iN6FzXb2y4^zI+>I&-pHVG2iF67v-1QeMPpi!ZN?jTNq8LOrdmL zJ4$6vho=ysGauU_ia^N+jXAwV`M3iFq82*K%KR~Unxs&=p&ccgAJaHjaZ$dv$ZLb` ziv9V89<Kw+ayem&Lbs=|ESjfsh0;y!D3z3yc}k1Dg^UT<uB^}rN)XXgZ1cFv9A&mL zhbx*=r9$cEc9d*IuELU{;<9`%4#B{7CI0-PvLaW0DNbs*U2b2A%TpRnX`Vvq)^?N% zi(K|X+!_Jx6fvH_j^9&Um|s*}>?tWNE^-tX#!w0<lx}ZN$yS0h?sj{=qsU#B?<)2d z!*;&H{9-4(s<;flaKzZIR-v?`9VM(aI{byjrTI?3gL!7LEg#hbTfW2QD|HnY!>vj@ z(bCl`ly<eF<ad>ox&5V%{4z$wRRWFs-S|ImA*QOxmWoRJ#nF^jD3tDON2#!+u+Ujp zYRh-~Jn+miKfJ(OQksw1fwR<J<|(wtdO?dq>F#!vJWh|>S?q$Iu%8H?i7w|aDfH!g z+<rT&ke7H$V*F{fLh0UilpH1QvLckg^9%hBctMfdm0t+b`3|@^P6fc(Z2oBJ)+v<k zZ%4`ID=M<vJ;jU(@Z<!MLd1c5Tba*YW-lssm)K%#ccMaRPdiEoYsDovDxGgb=^wGc zR+L}pf}@t&{iV(_hu7{Y@hStT^%N^onJv~+N!q)`dOArDv7|0L^zuXKWr@j+HNjVW zTV7;ORaiH0?k(1{NqTsF>dRcuqzA0$CEab^XgxpaQErqq-+FOCtF2qzRJEdZW^>hw zmYU}Jrq;RjD{AXjmshneCF!yCoJ7)Qk{;P-z0`Uc*OM=^UT(!BifL0TCWbyXxo*Xh z)}^2n^}AVB4J+%k3rKqOMb69ltedQx=STf{tMy85Wb`lOPi?Ux@McadDV^N7BwnCx z)@{}{Ze)jl4`?$=X3dQMR!Di*Sg&Ks!x;F)7AuCqC;yG|wln43Owv<o%5zvTcFOv> zilnC_`q^#0LW?QZqoJnnw%*H{#sK^57AwYBtfM8i+k>p>y(B%a*0k69M5yVlB)t&R zbX3F7Sf67JKTFcSE#3RB|FiRUL+rj}eT9ANWs+XrVttjQS33Wi>}GE=cHbiDRW)`C ztsjQiy@sUMBJ6$)O<~d!*3@U#FIdx`lk~<G>z5?G`EQ#3mNkuJ<1MwO%dEeKn!b*t zw<Asej;7(?;imtx{u410=KJri9}<)-w;Rakb|>jQHS&{kdxXf}K+^jW^6-HO@!a0I zS`g1oCF#R0xoISQ^e^Pf)w70Crv6y1;qqK_sNtJP`Xt<Nt`%}Ej%vD3ZojZxvJWVB z&K;CHB>b1$p(K4Cl6W|4xPYWD)Eb_b>j^b{D@k958@9$uJR)~gMB>pTeH|h`ju9^; z=^HiTf!qlp;<uCZZJ0QdDoUowxl<#YPa_FuZ)97|V8l`L`9Y0%ZSK4f@f{@n7$zRa z`J&t-8Rr3#e%_K>MG`IvOW0d;>sZ53`>$#Z*XJ$|HN1<Y-@*-dTNESJ(YY;5s-W}d zqF4M8lIj>nd^Jgbsu5q2i^;1Th3+KjuP||LK@9Pea!+AWolMd{|2`Dto|(IWed{br z;kM+SO({wLMi(0yyXR9%H#K%w=VI0)vwJV4bPux|r;AOwS2A4$V^FNuZp*zo!qPRA zf(16&_Sds!Z=e)Wt=SWEG24-w-9sr-N6qfc-OY&aqLdz6a_^*+p6iD!#9%bFYI$8n zYjgdICG#4a>Q>~}H7#A!66!|x<zkY&HTVA92PmZ%rS#sK`(W-~N=c;@Ez?#SzF$(e zs=lT!G%yFW`ta`xn`@TVx7O9Pu57LgX#3QzYOM`^7W1H*s)qcU#^p^b@dVU};Ezii zTUuwW_IUyxSE%tPa-ZP_ZOeT!_o>{cDJ7j!GAKp2E%({n=enOsDSApNpd=Gx!-ggc zYg+49)wiyhQP<Si+*%CU4Rx*cjVmfvE@w|u$r4u7Em>Z-q7_d}Wwratv?lg({E3aw zvD9YPw>H$thIoZLsx9}`+}Cnn&wYbZGAYGODS4DKVEy0_*Kg;(&$xak_ubt0D8)c2 zS(K8!E%$@m4|6}F6eFeNP)d;N0qxp}VG?g(H8w+_fOcr-A1tb>SyoZkga@@+8=C{# z!JU6vZX=k$^c}~^|C^p$S+uggp*AGK*SX)TiSR@2kGVfliiJ|Fl#+|e!#J({{TU;2 zRea}<Tnswx6|p~$%S)n^K9tgzQu=|)*zaU2HC%50Zd~q*c>>onPt22MPpueUTh&@M zEv?&v>ZXSJmR6hXrKE1%lX+p}s5$*s)it-kU~~F4Rv!f)Ynj`xiuoIUJ+ohHV^cbp zbm~>xMJZKl%rW)rKNL$emHk$%Y-re*(xa!QSMNDfD->1qt7)ieX<0C}qOcX+pc*dO zvcB7T&HC<hD^}Lj)YaA2)$U76?~#$2%{W?Cx29zt{;RaQRi|H{yq@1`$XYL~Pg&n{ z*3^nJJk*U(7B@CDHos)HSbOB=_34Y>SJWR{hgKJtHB>EW!OyJY^&K}r7Cx<)cD=Y> zLYJDnvZlVaYCIBFR1At58){!1FmTY|c`}zP@SQpGKkFC`*4EZRLqK*~Pz(Ep<@Xp~ zU_<k>S=WP5K{hIys%q+rY@D|H`W_(XaEAEX>KKBb-5z|fq#iw}aRvIyRyX^l&mYjH zM=7ONR@c@M=x{2(4`@@TR!pi}Q&$`8_AtW>qsPo_ZftB_pTtRA8fWDCa`~JC`En^Y ziJQUA=c>6z?r5%sTgjckoywiVUB>;7+ss|XZR4)yuH~-hZsqRe9^@Y9Uf^Ei-se8z zKH)y&{z^(p(j@7VOi9+HK}iKk-lUSG@ktYtCMA_8%}JV{bY#-<q^6{mNoOXVowPM+ zN7C-3du0W8OOpS~jaB}u{3q#tO6ecW&+~fZ^;|f$V#><aD!fp~-Ui)<Uun3J&@=l< z=^c5!^Yq-HYjWSo)8?h+zL%GgrwexTfs`@`J)KepQ_7HQ@-q42ysW%zzL+njl%bS# zDWwdfl;P|jNtd#q)u;1*I&)1E3!0sO2yEd)0~3F!qIFF};!m=7`+}eBJ5G|-^I~3K zbjE&p{h8~x;?KcK?THnGYA7XN*4n_lL9&ACw&o3FGZ^j6#@ebixmB&X&JhkrZuu1L z7s1$>H;g-K3)c&MD-<j9Y<XU&GS80sp2jNXx$``f;t1C7P{rFuDK1L!T$AU^^XHAo z8<{sMZ#1R&C<XstNGT<hGJ#TX1zOasHm^vYi>5dO+U1?SsMw`9K|`<N24|iH(JzD+ zSFKo8)iONxjnKUD3KQ;t_KS8*6gDB0DU;ZOIjk%=ysD|GpcoyQjZ6g?PU{*l5H}Z; zH&nGQZfsuOQZS{eW?IFZ;Z4dfqCQhmGAZ<DyKT5{cuVcFf{HaQt#!)_Cf8Rtqcazj zH6vym)7ZSM1&uV<Rn#@J@w#RB;?VC4X33GXrJyk8!&S}IjVst!)IU0*uBsMaEGT0W z>gM6m@0aFHRy5!}@TW9`15!w~f=FgEJXlI?YHmELAk-nJ<;~#Ix8{}SO{Ww;rHt5` zSCKc9QbtnBsPzLXkEyS1T{>%NUHy`!t$oLxxF_h?_=h}pg=oyrTf}HAU^K=AX$10) zq?ECgGA=|T`pYtv(3cnI)yIALsJvyAQbZ}m>j!lFwWhol_O+u~o29`vTk}>@N*Se$ zPu%9(yyMxIk7Hk+82s`HdFv_V2uhih_{*o}ox#3*8vF8;;Fr(LLmoVpQl>?|eER8% zs!sYX_z$@gZ{&`;MVp%ZXphVDF3h{A$FDt2d6(v0*7K;IvwBYNaaGSnJ*#?FQql(M zK7>+0y@I-bM9IS`rIJ!+Q}W}Kd=({MOx-<{d@CjIqU6np2D}BO7i-d^d|uwwis#HY zoE`WEg^8H~?Xq?qxUz+L{Sl2VOA8Ke6p86Uw<s*k3TUVQHx?=<27^m;V?%k>in@mQ zV6{VOXwJcWJROQbh-qnTMjF$!lr^c69^~DbcUNUaD~2#+2pn<*j>E}+t`9I2a04R% zjMwQu1AlT{20oL4ew&d4;By%Rfx!SipJ4+W0KS*u1r`A-ffIoXfQx`jfXjd@fK9-a zz!qQ|umjiy+zH$bAaB6K7F@<2U@!16@F?&y@H@xp^gs!43UDp(5bzH02gm8V0|Eek zam6&J$CE~S3jlug1%L|}4U7RM0gHemfoh-@SPU!$jshBh6+jbk5`gyfrvYaGX8~se z=K<#fkP)}ia=3k#)87GrU;T?5m)Q*fznS1Sb2b3_nXSMo;27W>06NLs3|s|3ADLGJ zkSp^Z0J3L30Xzjf13U-31-uV@2z(5D0el5~1AGVk!*PZ*ARU0c4E+E*-~oz(3BVD+ zWMDc_0aOCu&j4K*>Veh33Bc(9cr$<}T-(GM9s(W#9s|Ia0el(2mjQekUI6w19|4~L zp8?>_0NxDX%>dpEKLWo12y9tdz(`;k&<I=z+yT4-`~;VTZ)R%&$boAcxa>>--^n%t zCcpyZ0|fx&%XR{8zzg^R(9VXfvul7;fJ*`RR`%<_-yCOzUX1uYj>vLG8vq(O|H>Kh zJtMwngpQ1Jf%(8fAOKVWpl7TDmH?}O)xfd9alrAwdH}v}JQ+9@xCwY3_?hE!3_u|O zIyl+F<-q<qmjG?RHNY*v-M|CDlK}LY^D^)b@B;w<H}wLb2NUGP-gnM48vvgs@M!{{ zCh%zjeG~XJflm|oG{L6W_RX2Vp9%b#z@G{HnZO_RcXQas&6zd;;Ky_xa3cUdOwR%z z0N-<*IR!8Seqbs9+U6C&-@ty3vm^oC0Ui(meBRO%0Kb-0APvX>^Z@i=$p&%&(8Nw3 z&XNc81^NR6fx*B~05-C~#unJe0vlUkV+&-*1|1F?aX8CpU@TAw6a%Hecwizh377&* z1EvENKqUa3VOtDmfzB)o0qD#EomrqWY=Ggg(S@_r1IvKrKqGK8&;qOkjseyHYk_sZ z2><~n0jB_`0cQYb0q|vO6Yv_x<%0Lzi-7MrE)P8AJ&mvn+4@|<aeYMqZT5x#_Ztqt zANu{xas3wo`#5d@zB^zm@H58^#ODS+%5j7G0kGkqZ#ix-=nckqhTwNY&Os>e1}p~9 z?l8zc?0$~R_W*4iHynB%4j&i}zbb(21#fVitqj=4arWK-__e>qagJhOC&xJrKm+g$ z$GJuU;Mbi2Kt?y@^E3jFbDS4EdT-@8p9z4Dd@pdE-v?X_?8mSIzDGR9aU;FJH~_X8 zITM%%)Bxaj<Wk@$0N)=8UmXcPN5WS}o(jNMM{Wcz04@T+$H>coD}Y;odw@Lv`p!t` zY$S9!67r9Pd?V5RsGdL{0PT;0Z;XO&N1?q@u;D1s9R<3hKz9`Ajso3LpgU?4$Bk|U z@R`y0{piiWoxrmkHwL;IV+IBQqk*vi{BR8PHU@q;W;`$vKwD!V>loN*3~Vu`0;mM4 zfn@-EYz%Zb=4hY=KwlkmJOKH}K>jh1e+=Xwb1rZ`a3KJlj)A;m?gJhG9t0i&9syvB zvHgLo0Ps2%e;d0Oco=vAfIh~;zGGqkvF`yN0AB)M1K$GQ13v;k1OIT`xFn!Ezym{o zVZd;}1~>pWa304MrT~c7g&BYz=mQJ|@__=t4mbh$P~jM098d(50A;{5U<Lr6D4YeX z1)%rB6958E0-%S&k2tRANC5s+1YaqFZx*3H7M%z{S4H?t5qzcSOyC0GA^^54f=!EH z)1pnlHNf@2jlg!`Mc^d>K2rprDTYkNw*b&z@m&CPT@1YzLx08lfR}++f!6`(uNXWP ze*%04d;xp~{0#gC`~m#MaV2>`UjVi#83+sppq~=xvg90&E7bscAQQ*}@VQd_trU7L zg`P`YfCqq|l@<cUKq&w}E1d{HccqoUY+x<`A1YlBKrf}xOX+DGSBB4wN895;b3E)Z z9`+ayJB-Ko$4>&L0I<XO>A*Z-0k8;wzQ<PswZL+q31|jd0qAu+^g14T9e*XT1!&{A z2~`|7aS(uZCW8No;C~|co_GW>8JG%`1K?@md|)9E0ND3xfI46Wa5T^YtOPCx{s(LZ zt^&3KS99DE;AawaF$pv$f&WS1e-ikfv;?RJmI2^<QX{Y$I2Je#fQ}|XN0XqVNoN7) z0OtYc1G@p(eiCdy=|12AU@yl_hMZII`6>APlnnsBGX?Tbfy`6jS5vM7ZUAlqb^@R? z1$3r>&J@s@0y<OROH-Z#o&lZ%egb|0;4f3)FH_(zQ~u$&sYw82nF_wAg72wofVIHs zz(xT6J@q2s5&(9X3VlokA5+1{RPZqsd`tx&Q^Cj7yMcRw`++^c$H1q+=fIc1*TA>H z4;(kG8i2n{I|G26)6NFY1<>ZS3xQh!$TST!r-A0QM}S8G$TjT+;6>mi;BDX?;5`8J zr$NSPkZ~GhoCX=ELB?_sNCA2Ry?|684HyVa1K@Mzuz&e+z&hXr;B)|bFNgf)kh>gm zmu~~$3+3Ra{0RU&l!J%zSAf@nw*bgo4w=g#b2(%#{|5Mu<ECo?v^RYWFc(-1K+n^U z2M9PBI1M-xfG(!PN2a6g=@$cNfBMb9ZNMD>bUht5pMDnrUZ%s|)As_<(RAo%`jY_o znGV@!3<Ju6MgVQhfFI4+4uIDgutNoOQlSG3fDteO{Q(=`1U!Hr7zK<4(7!4s0~Np` zpaFmk6|i9i^i=`-Rlt4~@RthkU2!9DCjj59xF2{Bco={!D`3ZpcYqIpPXOqw0{W`> z9{34>Eh~QIxS8Dm*lZ^FoC!W>g3p;&pbr3EXF{(thXW&l5@0-V1TY1F>@(*A3xEJn z4b%ZkfM#GN06WZty=R^aoDaa?XI=_i32X(f2Cf6(>oac$;M+5w0iFl;0kHo}=zHdy zz-IvLJ`-}xgd8&=$4tmk*&Pr7_+h06fIO9HfCb0{`T>xmatHvMRYK>L(0L_vUReZ` z0+6e6CNLYA2P_1R1Rzr->{|(WDj`oL`f(*>s)R3BUJSr*E3W~r2W|px0d50ekIDxC z$Wyr&cnW|$D&Ge_0zL)40KNvk1AYXUEWZPPa@?$BKm>XKkZG14fNf@(fn1;uFcg3< z&2j=Bzz0kQDgnqa3o^`t46`7^tYtteum(5|H~}EwEZ{-__L#L5fIVix9<y!)ZU$}z zAj_=B0N7*}Y%=Q=05+NR766%ML6%vt$t>7p7Hl#Lel-hn%=(MtX7d2}pADPLP6r^z zZ1~x1*kpD-0RCr#|JmSwwjU@0V2{}ofFl6-+3ab+DgZpreguHtW<y`I(bnu=IBpK? zKL_@o1N+ZGTXWFX9N2$OUjX#yfc_lNp9A`HMgpUOMZiknMBo(QG~i6&Y~Wk~J~{{O z&4EtlTn#`cb8Y~31NQ>Z$sE{r4)~e#IPetk4DcR+zBY&P1v}398`#frb79Z9u;<(! z0C=1WTh0Z4bHU$SH{b=p-`p`kAy5L80ds+B;5h*Lp8GZM9RT^~qK&z~1JLtav@x$6 zzyp~;7LWtLU*=hXK0tq95HJ+T2gU)QKW_;D|DJa`0K3n70C*C36?o(Sn!58SpX>f_ z;Gb_RB`T5Z`<{K@v+w(sVa$xdFvi#hGh@ci*tfBSq${OHsVoU4m8BviLLzIZBxGN@ zAKmvq_wSs?`JL<Xna}(Ae!gBG=XcKUYA#OTUOmooJ_y2|LH;oB4l9UzgcZlT!@M`F z7VZ${4q?q`Ne4R96=#Npq4Tge&}rCqzGfHt3_Hv@F7P|<9p>I)?j7ddVeZ{C6Hk*B z^X~ZqFCtq{*?PKn&$9R~dUnD+drss{KHx{(tEYMO{F5tO;|33dpjQZU>t(lk*{xpA z>gArj+8}=~@9H&^*I3C$WbdW7UNVRKxo|%hZr<T`GTi=$%NX92cJ!bZ5%i%S1Bhh= zW0}BYmh(0{_?C<K-opRk7V`FflBakEckf-2GL)k>=Fz(u=Fz(g_NsSZVi<_7d+Rtt z?g)2{C`4&I8zF0i91;Fbh}eo*McB!RA2@_NN9Z!*H~v7jh`T%pg2({78Tk^$sYn&7 zQ;WJZpcQTDKxew)+{m5`W;ElN!74sx1Dn{w=X`<hB=RJ3ME->=k^f+CB5wyllzBwS z5|x+yxMx&RWQ!_~Y*DgB$re?I7RVLVo{q>BC0A50dK1S;>_b!<)3Fy(^GIhgb|lLD zqSm6nsLzl$O5Uiw=rZachdIj6$R2fz`}`XOeRSC8F`gqQxyVfc3R8>{R7CbZX5FVX zviFg_k2&_~j@|7ed!KklGmRB|if^LNPaNeqdh8=Zv>8S}Np`Bykj6M8+CD}5CZeP0 zi+zfYWiUfXWD--+P4q10vVes+JNivl@c|#P9vwyNC;BV)u#X?mP4o#)VaCz7xyQpG zaD33$Z2RUVKW5vv2xT$bzLhZFzIEx(AQtfkJNb^kc@PBsUf@M^+%F#m@veUMq+cn# zv!8eN^Ui)%(RDvv_v=6>y7DSL>5YE+3E0oM{RW_;eiLwZzs>Bzz4|{(VH(nlQOsr; zI_kfg40P3BSN;8Le_i$0RsXMWkN&&469h4paemAc^c~}_F|V;4=f>zgW-Z<mqw|<g z&}ocLV{{s$(*YqK;|WUOodX)sgyyuOJ)Lmp0o`%W0q!|qAaUq*z!8q|3%>@zKtDgw z_cYKQ2S(6`e&}YPxeRpgfk~t=j)}O(K;PKFPdOU|vCs1gL$Oz}OL?7@yu~}b%g4A| ztgd2p6}yc+9N-{_kS*5E$DZUAm$-=@Vju8t5De18AUzDq%+uJBK^3S;9qJ>`Aom*7 zlioz3k3qhRK|9%pa|WH^JQw+cYurHhgPb|YnQ_jGb55Ky;_O$PZ#YiBabfgAzj1ns z(^FgudWzFioSx#Qv541L&I<Grr<XXr#OWnYmbl-8VDNKPryFCK%v$s|cmtc*!sl$~ zYj*K1d-3<zU_A~#%u(ELupS4W<{THeggXwtk1pe1q#%{hU%Y*fZ$(?oGv1xz-6?(< zt60q*%qso}*YU1+?;27Z-{KJO8ltBmdK#jqAqk{19vuvM8}}aaJwIXQLtmmW#TdXa z{M=A?9qNul-Eo*13^VItG7t0aVc|qFff>wZD?8ZDS^nfo5Dd@E^JFIn`Kd<}`jSi< z)0oao%xt(j4|nI`8Ti(Rf5dvW@g>e0?yTY8;XcF7V7M+ul;%~ubHt|{<X7z5i1S?J z4=x8mLWrlxhKvdFCAeckQA$x3y(Uzl8a1g+3wk1dg1!<)VO|O5m7tS^Nle9^66Rx< z5;kFn67-tz1-`w6A2El7WBd{XBO76UBjq0%K_B`tfFTTLB#G#4q_ajkW2E<w)WgWb zoa8j;_>Jp9AYL%)QJx?(S#al3?mVghg(*e}N>PS#`0hq^!9I>!g6>Co|LDhfhG)r+ z-bUxA5IP#&FbEROBk>?ICHf{3kK<<(WlNMT@dCeN4vBvwXW~unV6PL+GU*W>Clhus zDJ#C!B)gboPD#1Rhwmt<2*r^<$=s66EvXV!se!pA)#DW!(~Oq1p*@}GitdxlHmNsJ zm~m1Ju?$8RNh45dl9?x&dD1v0G6nNUn#ml@K4~GkOIpSX-eeW4$>0M%Vm+U*na{8z zNnf#(Z`i{=e&7&C_?Z)&;w<K!bcsK?!ZmJin|nMAg5(h9m;5A8VUEe>m~4*8IeCe^ z*o)-C*o)+n*okC2kz5hqLvnR$QI`fZqA4wCO*=Z$h3<qAP9)LvXCQG5VK^g6WDH}O zz+}>x!EEM{&SIAGIxBgLcX*HY`H*#N<Wsh?jW5~3ZocDt4)7yCag1O1l{1{@B7g7~ zSNVrq+~q+Kh#QP~lqbkc7P9d?ImksG@>7sfl%*}*=)o|ONo5K4WQ;u-BjXs^#>h6t zxnrD{;=B|yN->)hvq@=88`?9P@l4`v*77m?Im+=MNR=~HzEt^A%`nyMQq3;a98&e4 z>O!gZFZCPjU8=hpM=;hM$JXE#oH^DE$NHJEW;b>j@{V1NpBa0IBSA3ES>v2F&ROGX z(vT+fCWct1vw%gI*En+;XHMhHV4Uv9>3)1p3ScM4%R0Ut9Z5iE<K20D2J86*osBog z@!m21eh^G}oJ{C`LM5tVPbYMtJ0no+gmJu!&L(WYJ0_e*j){-qdzttw)oFn4CWfPn zi33T)j!sNx9b0jqi6{7tOF=N{NxWlHcB)Vp@0w%}CiS5oc74)fmhu@p`35;A*}+Nw z1i|F|l%O<zesT-kX|g?<Z2ps{@*Z+b*6U>Rn0$(}=wymcrevZb_F#$}Q}i*#eWpaB zk111_#!9?v%KPlXK215u-5{9yC{JKMQ%h0?Ii`BoRNYP;!(`I%j;ZoYm1nAVOtq6! z?c~&3LEw*rH1A4tr?d)G#+=i<BP|T?N%Nln{*z{DAF&zTq?vKrMeND6r+I-FX@YNT zS_cwH#hy%i6T33)1HQwqO!IwBe-d+<ZZ6a9>U6t0-8-g_WGoYSmyg+iKBwz*x;|%Q zAqTneb2D1u>=^?XhVy4E=WV=W#t;0Ay_lJa=a74570h8~1MJhx;W&Th3RWZcOufz2 z+f2R93h@;7a#ne2P@5zsVt%uBvJYp@x)%hq?eT1Pon4AbRHYjc^g&Ovr!pPi^lUxN z*7t1po$bD}-FJ?6%yH%%ea&&^oL6W}e}*9UoJG9B|M;4{$Uf&f_xU#n=K9&Wes->( zovY)yY0Tgo<ehsc2<AOc9`e(ZzQkY#^FC)gH}SstkI;<vbi(`Q&m$fA=gU7|{sl#O znF`3dU<}S*@CD9ZuqO!8AH`hLv*G(lZ$wjcn?4cUraM1<7vJ(Q2o~yfp?NIy{6fz! z^!&of%tnrd-|-_q1;L{1<fQ-|2_u{ZEawe$u;^#($zokEehELb*mH|@y?7u?u+xiI zaf~yZ4}v8xkdK0R_mXJ*%#zo6hxhRO63;L3{A(qtNEPB4O){ULm)E`uf~Aj>mFK93 zu9vpNjxY7>(p1*6i7i~?9uI?HSsA>0S#`XBnfEXAGs`|=GoNvlyF3Vj<?<|-XSttQ z?)}R>yWIPiA3*NqzXZYSxhRBrzV2?X55YWN_s-Y7^L6ih{Q`e;JqT8mrv|l2WCG^1 zVjH_LpEum^jTgyHdtRj{>FDl_mFVk@zmRujIoxSwEk=;SIPB2MLmUZ$H=idD`DsoE zIx~-@c<-Cee)C7{#{aUD7rXJl?nGjK|69lk%=>@GIfwhb<r{vh9<MMH&%L#T1L*24 zU9EDTRYfRHIQm*;e^&jEHJIBfyRhmH-0khcnAzLz_jYe$h{gTiwmWaX&k26xQV_h8 z5AS}b6rO!&DEfG3Bir~g2v$GB(`2Owedvb_tJfgI>irzW{oc*QbG(2Y@0#1Yb*M{y zS_eUfj2Zqcqasx>iwv{K@JvPne1{oLX~BQbx1%Fn&}~K-`pD36hK@7zlA)K3IEG-K zGDc!wGR82L3D}#AG-faxv&=|mF=m?aI=aeui+9jjhR!lRWF30R_>`^aCqq9OJFtft zb|K??%rC=EWY~!ebIdTuj9)o}9n84MAN<8t{^1sPc@P9D4c0u$6J#a}*|3jma*&HW z<fjltDM4xc{kWzAm8nKebiYRLYZ}so=Cq<M9q3Fq%yvyLA~54MX1rzqgNSDs35+J0 zRK_!jsZ3`Ub6LP5USm0LU|-g}&AYhdnzek)1~##U&)Lq`?BZMYvY&$-<|xNG$!X4U zf#12z-(2S=ceu~LLGb<~JWeK_CM(bJ0xy!Ad=#Vz#VJKu%2SD|)Sx!?c!kC^qa|%< zPba$aDn02<6n%*ymca~V1fxhIg>g(|3e%X$9Oko-B`jkFZ?cNjWbgqWv7S%Z%x8ST zSM1~)_OOp1IK&Zt<^-oW%WqubPp)u{8$qzv^J_i7*7IvUzt;0>J-^oTYdyc#^J_i7 z*7Ixsd;T`}co+m9hIou8d5ULvmh9x@CGt{$!W5$<Whh5Qs!*L;)TIH9Xi5uO(~gdG zp*vxO6G=4v8Au#M7|uu%8N*m6Fqt%FFq?U#vzVp4&Pv|m9p2-8K4cvm`IN0}<4bn1 zoA3CZ1N_KO9OD;$<qYS!$RGU0RsP`?cX<%_hv;~eC&)||vhh4Q$VDFVQ;4FJpfoR2 zfyz{)CUvM!Lz>W>R<xx9o#{podJ#b%`Z0h(#50TpMw3h`<C(-%rZbDVEMO6@v79&f zA8+$6Ygo(2Y+w^x_?+#0%`U!WFZ(&jVUBW~lbq%p7x<ma{LOW4a)<l;8w4Le!sBG( zX|nPhFYqF{$wxtoP@Gbfr973WN)2jLk5_0+Gg{Jy_H?2vuhNs=MA4TRVj0X(Mlgyb zQW(cXrZA0}%wawYS;8__u#yk>kacVff_2Z}F6;7AfWmm!Ix|`4=hyl9b$)(*4*c1A z`?KEuthYbw$Kt&8vzbRa_kv)9&Ne)ScW-zW**7F3?*@4{$h+YpH@L-J9t6Qg9c=7_ zdvA2_jqbg117GqrX1vjiKY1QmKPiMfpUCscBHqHzeDW@KW|Mhs%8wasDuNkpT8(#Z z`h?AV76hM~^QYeV=?j?cr~3GGII?~^fyt!dZksdVZkye0v%77Uck>X2k-%u=-Mo(j z{K!v1u*LaXDo}~4*o!T?-6HQ6nYLtLHd}56!PZBSX{)og+P$rP@&2tNF#D}$zx8J> zaEU*;5(J-l=Vwi5MoZeTmt!2qH}Ki%AoyIi&;9GqPjHH}L9orwZ0k%{?BO<hxXqt$ z`yKD!=Kb5Q1;H1QnCBPn{DqFb7|9nn=L_%s;s*`|!S=eyu)Q_y=*VHt;2Yd7`*!dC zvN8>5i0ofBXB8i_o=-5Rud-u~U)jO0icymJyuq9JnXgs{!Pi-Mi9DG7*M&%7Iy0Gr zpZnVVzrKhJUti|$AlRX=9X)XO9leP{&pTw@q30ccqKBQH+v&NTp4;iUou1oi-*$e= z7CvWt5bSdPt}?ug+3#}KU9#?4%SX81F8AB@ZxHO3dv{js>~4FwTjt#|@0NMD%)4dY zeJ2RMc>;U!jlKBB^WVfWnk4+pH{)=xZ+u(d__n^e%Yz{Jb~yg*+X+l2EeO8z^WW*| zyL{;OyCV2I<hw=K&F_}6A_(?4bC3S_<RBM*W{-F5k!epli&@J3AlRE3+4g$(UU%8s zgZ>O)5b@|~?@o5}9p4AR_c?L?_h$QjNy^~8-<#|A@9-Y)2f;pnw$JyouR67;%RJ=V zx01K;{QeL!?0**7_j~_-v)V7i{=p1o1iIR<tNps#udDsKIw0$Tk?8e6GO3*AFYL*I z>)Z^2AL`SZwsfE~uakkSKYYl#AUK!_-5q?9-01sY1aau&;4l(6$sb(CIR~BdV*}dI zj*fI;6Fb<&x9kmqLwY+@i7M#kkZulbLC1$YbLhWk_6Nb?R&=Kay^!PZFI>Xehu!h; z)gbt(A<q2Cy?%19pSrP@t$faQz7B#TS@69bu@gt~<9j=zvm<HP-y^e_8w5vna8w6J zb#PP%M|E&?Iq$Is?>_o*5FC4+0(j4{qLe^4$L#H~Nle9ikJ+`KGxIcAc@F3N{5o&& zKi&?4<NoZpY{#8<ydZY$_*iB#n|Y*jjempS7kl%|V?4=tJoAh9{<45YL2x1`-f=?T zCrVNV`*vbI8?oCbbab*b=5Vqmb*PWsJoypp@a##?{_2juR-`i3@cgguvl;LCbsJv> z!KtUv-6>t4%1Z%cKed9Dc=stePW{AL&T|nnJspKTJ3W*UjA9?hIl(FX%o)#}@!T2D zo$=fm&z<=JdwIq)Xa0NUw;(thgPEN5=Vy~h!ET-X1<#&6&AA{r*9^OJt}Cz76Yo3c znRDKE&il@J-+BN3`2oZ-80Vkg!fw9B?w<Gl-*od^Q<~F?w(R0Z4s#TDx}ehw718Mh zonG*B7xaGNbH3m!b_T&k&t3G~MbBOI+(pk_T!20=+MkPW^KKAaGUH1%s6|~GFcEuk zX+8^Cf_q>3i@&+f%^>)_1@8ZQcfttAeSSZNtiS8xcR%+>BihrEE_nVAXaBL0P3Yqf z`Tu-^?BpO9d5A`5e-39Pi985`%Xa2+7P9d?p1GXLIOM-P1-)K2x65)|mgBOy{pI|> z?80B(`&WMkBI{ol`5k{h{pF5VWW3TB&s_1$l{l_&pNB#4cZkQ3=Wl2IoyH7ib2kXC zK1pU|yei{WXI_m*&a3wCs{Oip0%u<R6YsuyEeNiK6N~e%4Z*#y>GYaTugQ7MU9P#y zb=_ar{dGC7hvDb0>-4%#uj}->POt0qpTd;KF8ou4>P%x1OIXH=Ah;pxjhyKHMjrCx z?l)w;q4yi^d1DOvym5&?un#w`2Eol<=;-Dk-0|ixzT*gT-}Ey#e+`0L=6|a<k?8-H z_uu;O-*^98-gV2nZv7Jkx83Qs?r;0^+unOy7q|WS?R%L0oq$Kt=^f|Y(divI@96Z- zew=qlPj~cm$IS0~-(By!>wR~<@2>aVJ%Il2I{)q&&IiFge}2z<?z!(h_r2%7_ihBi z{YNnC`%m%|{_MV)-#7F7W`5ty@81l92Qoc)oJ>4T3<=2fAc+*r@_|ks97o0nGCr(H zQ<~F?wtUGx<b3!eKLx?RX8vzi+~?mg!r8$Oc;?^#o;enTf);e8J7I*gi5=|XTlNN_ zP!0-HloFI?D(NiZHI{QH2tD!ynRuG4jAbUXnTMZwWIw-flGB_ELXTFWKCjT2W^Cmf zzT<li1fj<&QjZ2SqA4r+fDc*6#vt@~PKr>Bl9XWt<C(}5rtv3oKYovgLFkDPx_Ban zfy6O{E8NF3PkQFb#~6nDJ?WiKPC_S{p5jGbA}<9POfo5q!}*zR2BFN4@;Lg+tgp<m zj3x=sX7+66Bj_jdZ(Ks&r>fErJw2tTr&{tq-2bVM*?>7dU5?t+MPE-hVhx|Nh0oa@ zgtF)-i+5(JPAxp2#Z0rj!@KyIENg?%Gk)RJGw$<DA&OFh3CzK4pE28K7V}RK%BrKR z?w9omGNY@ky2`4nth&motE`^O=DBR1%jUUkp362J@5tu-Y<4Q!8(icDx46rLAoOek z&VJUrp7pM0{oJ!=^PC=^dxmGp&QMa(<#Q96!hY=Eb0;~?xghj>6!Cce`4Nob3|F{{ ztj{|?dnD$W-A-g5&Pcw%canV{KX51ry-<%<w4ptn_?T_z-0xBdy|60?<!DR?{CSS9 zyvhMi@GCOpI3I*^nqN-u%Gr*NbYT-a@SdFCBEyT$da)P1ai<sivXg_z_2LnJ4nnz# zP=QLAeXbgqO|IF@WdVzL7=&KZ=}S8GI|4#4WoH6&m`6H`ImKo4_0l!WE4Mr4jzA9o z9DgWx4BzAY-1^V$e!1N*PjlQSPd9oXzkfDAlxH{Y<-a>IlxKes%G(5Y&)XT#=Jjk| zcgkyqdC&42mx53}XXP8l2u6{_5zINCXY&2`jPEFaYxM1(O%LS{$87Vj!#wkUiEi`D zP@oPiFwX*QF|Pt^*~;gbX94ppSb{24qb7c?pgk`54!)y;Yw&Z0D$@Y(EF?oAGcDv^ zg>+CzjzV%2il!d}h-C^N;LJkqT1fsvw}VjON61Dl@{pfG6y;^ixUlmIn{i<?E?kR7 zIJ2<37j{PBc=S~`fzc#03Ex#=-&Nt6%)z`1FJ%=Uvjz7rydC#1yo>!D<S;rf{4-`< z_&is+7levr;yGU6MRJpm;*_E+<*114Mf6xiS4DguMeKDE`&7h?i`b_kx+!ALMa;QK z5@Q(4cw{e<&T`(vY>RB<Q}kG58|GW&JM3i<*^9_t<PcYaP|=*|v8Wjp?Siw5I<u&r zil*X>qIxQ-r=rd(x&YryQ8O>Pj1{cJ*+rdO)Ls?c%VCakoRgg9cP{fc*SNv0AXF^i zDfCpVAVttqF+CO2Q?aU;Yq8qYr2!4GtHnAI!2kvk&oB~@znJ{R<S#abY0TgqbWu#U z;*XMrmvC-zyHva;=25&p&MEGjEbf~q-hs}TQE_`!JdBaN&KiE?7cO8Aia!iOC7#6H zN<4$VTS{anF9j%!?n{)wT}xELxh0%eq9fj4BAiH~>CX^`<J=PVxI{83xL=96$Wp@n zO1#JWe8@VsvW+jX$0c_04QGQ;N%>0VLa!xT&;|Qf(%zLE%uwuKN&8oF920R~$u#s? zau#-?<SLw3@-ueg{U!IXk00=zlsv&H&Tt-Gm3jpCFI64;SIYjCa$YI(E9L#A(pk(> z+^^J1+^>}Tm2zIGkJ-Q{*uPTFEp?ca*t=5a`0pJ1SL!-9xx+mk2L4Yy^3ag>=(V)H zDeYdRomu)VbXwY(rJY&YnWaBPr=@jTdOJET?arm$we%5w<xg&K8)ubvR+$j`E@L0c z*oQLDlY<v2h#tyRqdxMKu?uCI(~8b?qX#|FRhdWzG76c?%w{oim(f)jU6ql)jNE19 zE@KzU=&H;nHuDvGImBsnROT{&qpLEyD)Vm;Dr-h%ALmKrFPjCq%NC$4RjEO3>hTIK zX@gG7+UK%ekiTpM0~p3w(lF<;vX`AlI<l9Qy{znI-{xI1&~e#6xf_IDE=(Dm`?8*1 zZc7LB^s;ka*3-*<=!f%Oj%6@INMsVue0dpm_vO_%<K++d2>rZlmtX#ZFWG_b=4CyV z%S2AxwOlitTh4jq`s4lOe52(?;+%40n2dXtbI)?Kn9F>eUC!OgZNx5>b51$ul-tdB z{K!un<2WZd#U;$Ad_ZQ*qkJ}=$6U(irw~OcPAPO%z6!6PtMWQ3FLU``m`QnEl^;Yr zW>bCyqi~1v6Og<7BFv=x``D-Q>yW*?@1eZx<z+7~d--qK%RY`EbNS2M<PP_-R~774 zg{R5Nb7Utcxu}eM6=Kj=h1akP6`WaNEBdP7%nHt|;LHjK&{qY0RXB>iDxBaq{^mgt zs`v!@s;IAu`l_g}ih0miMSWE)g1#!2q!9xd%}U;5J=<}=itbl&KL<IC*;G8uIh<MX z5`P4tO3tkGGPTihr9pUSC7o89!xEOUf;U;k2YiI{{LY+ErBB(y*SKe;pSgg0Rl1H| zE9te8UMoLNCiGhQ8J@*GE4ydqqEw_7b!mWmR&Gi=I?@HZQCatudtwJF%U1b)4x!V^ z?pE2kRRS`j&no(?;+!fu&}S8WR&ibxeO4)j{i|aCs=Pugx)Vt>{n2%mI7VXUs`zfI zq%xj~%w#EcpvpS7vW+j<fgPx#n<_tI2dW(9IPz98k1AKtPgVU?)lXIZRJC_i?OoN} z<f9<|Ua4A)5>!A>Rh!Y7UPNGyRr@i3VI(k`BvSDATGcet(OuOwY+w^x_?+#0%U<^L z1BZ~k>aSeFT&wy{s`*Z;$z4tEYI0Y5fftdxT3!lJh|*M}0d45YtC(Z8-b4}0V1_cB zk;q<6&(&tL1RYmf%g4xFP3~%PSF?ZBb|H7QJ?um0)sAtNzp;na^juBu>T*|?yLwji zTwU(!Ie7{DSlxb9FGmfU(3TE#rW-xbb#+}=*L8K-s}E)fGq4BM^;rEPSGgC2YUrqj zvuZf2hK_3Js75}DQ;M=UvqnWK<IEc7S7Rb;aNinVVJ0<>Vuxy+<TU5FjC<Cw|21xK zo4Y}%=A-xqYUZLC&Zy~(npLPyEgI337PP|IHQQrGHQlkMdDI-kSSBzTdsK5C=`7|o zmSeAKZsrt!1)*Actz{2txnHenIIC7`+R>3NbSDzuTrJ<6-=P(%HHg8C!Vc7$jdN-( z<#kr_7Vq;RI<KXpTAOfwEnU^xgRW}nsFsduUEp_gRqG~quoJZ&2BF#^bX7YGIVemS z%Av2?`l?+WJ6zixYU`_ZbM#f)PS@^=U9K&6ZF8$Vnq*RuzxH%yF_-x)#C>YZUHcfa z)iI|!=2XW{)Ug9~>QJAC*uy%`tJ8tbbmLWe5{};Lm{Xl`Ok*Z<a8?~>)iIYkZ?cMa zc#k#ctd6ege9zCE<u@+zCs(+Q9j>FNx&eBs`#4$2O;L1I*Dlqqi;n8*sIHFcwxc6m zkhyLTWUkv6^R26+x|5iSj_T^Du8!)y#&X_3?z(c<mAmeTe8w(*<QIPB4ClGXRsP`? zW?c6^ve$c(?D+2L`8%nej_cXUdNrwouIuTzo|)Ebi*KM_CuFau<9Y)bfqB-GwVtf? zWUaS=MaWw3f4t3VGI*bjY-10HID)S0o!}I@uBYpIx~?aCJ=yEo&wBp`q57G~L4FFM z>-r^-zrOtS<*zS){o2$+_w`#KbN${7A_4nYU)S|hk-xtD_2sWGe|<Yre<6!miQM%! zv7N8cb^UMI%VCak9Qo_Z?{}+(>OTlV4P<Lj2{Ufchj_*?nKWiFn|Undb)45gXAN}L zKxYlULLUvx?v(<Rq$>4kO&7WoMmUiSB#t2rBY{!4*DIUZjc#AD#|<AL8@b4XUK{GQ zq3jJ`rUH6x=*)&SsD)i_*bet<*dOOK9L`7*amR-4*w7stx?@AVHq>iF=Qmu&yKH0| zU$O(48h*!*{KPSI+VCVgZK#8WcA(LtWI^Ue&yxe$8_C>A=0+tbMOn&God&d^D|Vn! z6n%*y7CYQXKaG-*z0p|4vmEno^aFQ-P-9&+&WiII7sLA-SELHgX{?*Zx@qh?Z|uCr zt!PVoUd5S>&7*NLsW_wYB&MRD#tT@)67<yAJ~Z}?H~xsvv3HHX#ojgE&p~w5SVxUd zbC%z@7=)TUN@>ijNdyD12Tk0q$xIgFoF>j`vVu3U=S@Dqc}><~Mol)co$vV>XEbp} zlS}-`6>f8nhe62yTPW1j*-aluS55O!5<NB5Q&T-P)l<{DG(}HMTcf9@9q2?)<ZU_< zd7DmPGHKYSrs*tZDQ4944dibse^Z&8e#IX4VRlUqafDOI-&FplI%@g{m$6sPWN!8h zxhX<%N>P^b=&@OC>d}BkG(qlW-HBu{qevo!aZE(t&E_y4*_+Ak_veM0ZQwY%Z2lb1 zZmz55m2pOM-89!t^LBKk3*k7cc{KgdQ}b9xFdqFhH`nI+XugWo=%u;2Hvfdpe8x7u z<ZJfwGv~R6SvEJz79k$vNuDJ;Imv~&w#bK`T2#P1TQo)H7BaVxxrNLv!jQQ|Bz=&% zMGQkpMcx)VX`z!AOL?7@yvO@|$j9iah5RkPK;9O|ID^bB%(8`9w)l%%+~ooP2BDU| z*_Q6m(rjD4guE@wQ;DjWYs=a+rWq}fzoq;wJJ17pTP7fH%kfOYH`{VLzS)+GFwd6D zSb_X4<!>o(OZ~Q#x8;5ga+sr><{THe#GlCDQvO!*wz3bca--u`1u25;tz>T{dn?&n zRi_qpu#2tiVk>>Oil#pUiDL+fjKTNR${kv{L#rvwVJWNe-M3ng+^sfaPg?Ed8}{%$ z2XK#8$I*MMYv{RkCY~lMvbTN#*;~urTK3k(C`oDTck8+|r4v2rO%#2JVJLRG^(bU- zEqiPIx7K@WowwF;YaO?KpAT8bMz--KJJ`jy$lm%8_NDa|ZgY=^L8wg#eYde6ZJs4N zIk4kx^xsC$ZRBgC%Qo{d<2G;Oyf#~LUK{7NabBC<=%>w({De8T(Nmif{Kh{)sIBwb zK85qzI<Kws+UBGHh0#;n66mRIS)AYY70kA6H+s;E2z*a%2NBOO^wm~hZS~c50<&3y zylvO=F&oVKtQ9kta_TOGCChx~2-2tw_i$L!iQrvu@bOS=S88IK+E`yxZ_reh}U z7V#Q7YPSM2YG+36*0UYwwA;&m4sw{2oaP)lYIlkM&ev7D2SKR4uG;IUy^h+yL|$~& z-Y&H-Lpdr?8C|t+j}F>T<^w*#+3oFa`=2<*FZ_yq@cSS`?f>E`*SU%P=wMDAvf;cA zX41iV9h}#}c^xWJ3p?DQ0S#$FGo0^tNrwC`$xsJ#>0mA$bk<=s$>^+u&N}F<!%XHd zkEN{UW45uI?~uELnRNIOxjV?+LGBLv>Tm&lb-2dAL8xP9^wd#59Sb9ON4Y!7-LVSQ zk-K9Z>SM1uwxm0DspAk58N*m6pvR80k+EYsi+Bw)?zoDzY-I;Bca*uK%pGO!sOye0 zcl;GI?kICdGwyhW`$4Fayq)Y>ryS%W5BVuUX<nv0m5{%azB@IeGroaN5y;(1*PRBS z>rT4vr0Y&eq~IQ%(pbPs-s62fWE~sPcc(9LhfcfrmOUKe6u)yT2z3s4lqZnAa~5Rp zEPH3!JLjVyy6>#>&Q)nhE85Zl**kY50@*vu-Z_R?;uy&|W})lOy6(K3H~1fG(0ONj z(s@0f@G0_l-p6tD+}Un)mb>$1{^kxk@BD8N>Js8H+@ni2UZOa<?xO21a(AggZ5pHV zE-h(IJKUp74`lCRXS(RQ%M_+zr@PEyKFe6ao4mz4yo>Bzw(u4EIf~p}PI4Og{eH`k z-)|Z6`z=FVZg88sL8z<#yXw8G%zl?;sH+|CYRCOf%TU*H*zvBls7rnH-_;$uwn65u z(F`RCxx4DR>qO-5DtA}8yDnrgOVNGTxA}<8>_X<Q2RV%FU1jeob61^r)p^%Hxx!WM z2BB_G@GSPDTX9NJmh$Mko1VMX;}sgwl;-HUTQB-E0(ra1+fCkXQ_y!edArHmZ3*&r zdmX#dP0!uzN4M>K%U<N}CU-ZvyXm@{uDi+I?Kdv*M-cM+Fhkv6MyBq47(^n@>plnP zb$4EO=XGDkDpr%h`+SJ`cHhEooY(zVF7n^||3WX_|KULpdNtrt9w!q|k)3>$rZUy2 zNgd4eRo%SWing?;6I~dBxxH#$uYS)@oZ(OI1fd>};G7=L>G3pKd6C>WuSWswRF9(Q zphqnlV-7uf(2EH4(xV^o3?qS2Br%4`=&Fa^=^;yxcUi+)bkk!CpJO&XzG5f3>Tv-3 z)Z;vQ>Y=9|dg^hDyFn;SPhsX0mKpiO<PWn~VP)uuY+-54<8{m>Yy-{;b5_{b?7}{T znTy|*847b=*w386oWd@0jemnsPd)W?PEY6be2y2$M?s2EjFOmBPjl+ofR=PamY#a* zsi&R;utz=h)N?e+q%e*N%pe_qPxQ>-13qFs{(kHE1$yeKr=EK1`5k+azvmgQaGQHP z3_`s^JjOHVr&o4zkc-^N-phP@)uItiX+dk+(VZ~DagSc^(W@_mNn$edvH!hRAa^g{ zK`(vxlDn7Oz2xroDO=HhFTMBr0pDG(3;fPy{^mOO(RuhI$R7SA<{bV!`7z`0DpW`A z@Ve+bT<&nW!{rX|Kxewrn^<%nuH$eWhtI}tgzGwdF)MkCcX*dI=ssNb@UJ<*F@E7! zbRB-4zqraj+{CvPuKV6{_kIp}dzYXzdhT6;%G9Ag4QWg><nP@Pd3z6FBx8}ex1M{a zA$xC`d&}H=DZZ=TZ=m<y_NDg*zQkVi{vNq||Hx1Lirl^B?ydLUdhh*b5Q@-mL^))N zh$fEFI5)z#8?glQjWFK`=R~YRHxVCUz7ZQS--s>fD#Do&KjVyuzcJGY-9+dn;(ic{ zd>r3X<kLLEvzTpU9(+TQRjJ1-=q6G(kuB*&S6(HIaO`BHt|HAgQr<}YM4D}+*+%Lq zQcsa)8)>$YW*cd?k!Bkyf8-~8h3_ZQY$J6Oshh}){DIj<-r_C~_%{eeJ;Gzi9hHm1 zl&1!@kvmH6D7mBB&>p#?y3m~-$QosCQRe0Mm4>2@<J_og+~Z*o>J!2_eaxnhe)?o5 zC(i7XhkO*L66V&&?)2%1bNV=^PZ;{?)1QIF5zjD2kU|;@S%JCsS;cDP>a!mG^x4c- zwy~XW`H53p<|gLa$6Wj9Ct5$z<{F(9`yVZLwA|5hM;D?DHPBJCj-t)h?>-Ir-KU}G zu9$6fPh^jdqz{7_%>?XY^b(dKceLEmaz}r_N5~z$kx#LY(e^R=04Mm3OW677E9g7= z9uI?1-w==T1euV%Z*EFZfyz{)Ci?E%gyytD_P*`We_y@#jX}?S$D-rDGq96=?POm& z+4ptqWM4bk_if%q=Y3`GtLMJoaF~;v<{TIJo$Khlug?3*-dFa10h!4`0m@PpJ@>0k zJzhc2{bcPYYd=~0b)g%w_InMp@3)_$IJ4hX?0&xoLCAl+KGa`7{q@s78_(ms{x71Z z{&^`zdGym?KmD7dpZ;y>Ko5EmK@@%I&k$0Wihla*r@wys>!<%ayvI5=Vy^wS@Ht<g ztNsW1m5cm=@3z0}{r}-X5b_`855>qH^EjD!itH4mG}UQ9Bbw5J*61guJ7yZwiwNY7 ziDe`cnaLdHvydg&$rw8sqt6)GW8P;io7m3x{KPSSLH3w4$Q~nmjO;Py9AnNgw}a3C zyE))#a#4t)ltA_YFH;SBIY93N%zA)X4{(<O?l7P$eHcVM!$@E><C%os2Ta3V2FzwL z@(=hJT@TRp0J#Tz%`Wz%^8trB!q2$Jfb(4Aeh?a%ndixY+ynEFAGrt0Jy7m}c4c5C zs!*3^*pq?b^k*P(*pGq38N*ooJup!2fpQO&d*FQDK-U95;S0WEC-!6D9u6VvKv@UM zI#A~WPxCvsf>3OTth`8W@==f?lttE9Sz~35t&YB98{%7vwHvYh7=WH*^&C5lWKz*{ z>_n!J#ysSW&0rI{jn!?eZezb?FS?CA%5hF`3Of>OM`Gn2^a$C|?I7I_((Rx^*o{HD z9aMqJRHX*BXhdsXB?{l)pcrBq%qWsbVJs8S^PpKQ#!d|SfR9*@t_N-AD|9_b*Mq*} zd-fy$AUiSW8uxe@gyQrZ_ZUy|EZND4d&Id%oZjP#BY#|7n$iNf<J!@YFziTNBz@?I zd&CVz_PFURU=gpe9DT>V%No|=4sq@fw~=kg9;frTlbq%p7qB03*SX0Z+#}9C1_#JH zxFPKs&3Jr2gO~6&&Kc|*8oU8>9=ru}9&FBo&3UlB9K4SM9OE~fHQ4tv_}?HD{|Jwh ziRXBM7kP=i<fjC>iq}=VuHtnSud8@n#p^0wSMlNKDqdIdx{B9TysqNMFa=%3>nL7F z@&7~icwNQI9xr>m?D3oVjBV`Z5PFK&PyA*6M)r6;#mhcK_93zlG3Oyqkp)?Yw52EZ zYKXlWvXs?)#Ckr#SwoyPWGCh_L{EO#aA=60h8*NLXL06`JKV>aL!CL)nM1Rpuc7)H zniG8uHLIc3=!JbB>dr%#<LsgCIP`OTheOS0=q}7>sI!LJiJ|s*=+B(sS1xi5XAaB6 z(>QaOGlw~ISUw6;gkqGWG?l5384c@7Z=&c+3~~({!6<x(!^SWcdo^r2i+GFo`H*$k z-(jEfB|F%S?8EkAw}u_TE)ToPT^<CX;dXcUqdY-2o+k%(Yj|$*BKL54hc`gp;dW}c zof_VeF4(Ezc4~Muc53(l<R32o@NvjHd@(DLdH6fLhwQ^;9xn6nt>}IDcD`Z{hp<<} zf5%=8H{;>gxrx3<nDGcR9`Phkkp<aD6rv0@c!kC^qa|(7_lQ^NiR>d}AJK<FjAjCJ zSi&+^@FuJH0Q)&&J+hCGeZ&^N#$Jy2iL?C473{`{8{7{3SHklc@+M?P-UPdnpzDM} zl%qPesEfW68qpekC+It&Gu@Cs!M-F6CYec0Mb`<ln9FO}>x4IuKSBNk-6wpAz7uwG zkmH=>H0QX0t`l^fpzDPHvfsnLjI<{svr~{#l%+hCs7gIvp)pNqK`Z1QDeuTQl9<R8 zrZJN_=zHWc^gYt9jC_l?S<5DNpyQDT_z_)?JjNN$<69hQS4Lju3UZGMq2p0H9%Y|L z<wN#SMUZ`z?4x8KRR!ITs)?+ll96qczxPI&?<i-Fa`vd7Im>Tc;!m74>c6veH0ogx z8XfQ`c5}3|N9Un9m8nC08q$R3bikRT&2_Z7j<%Ph!|Bfm#$&FdXJM|R7qAF(9sNIa zG<r1|ypO#c{RMkD%u$YW5;GpHqtQAVZN{UoVLwOT3POo;Cq7LM3ga6}EJsE3lc=A> z1~kHK6J<{{+r&0>r4MnKZ{kGEH&KU)Gcn&p^G#fa`6jO9Eo4tL-^5MmIPrVTH_?0( z%{S3}6U{gAJm#AyyWj5}O4NDMQ^=O2&m>(X4Pgw<P0~@4-A~d{l8%y`lk_g;nY01t zC2i(2wy~Q-=qTwA{y`^6cd_@$x=GGV7P9diFOZW0l*R5OH>3%=N!CqrTe{JMUi2o4 zXmpi45?v+hC|O6z^I3?llHX(%X6tuQhx`ueP_nL)Wl#PZT_xMc<g@&SeN6rn-6Y$` zWc!%>FbMg_pF?9F<#Do-n-WyOPL8RD>|^R6`xx2B$UdeG?deDuF(i<Rog6cXsZ2-T zV;1omW;|vEW;{mjG3)q(Z`i{=en8)2PH+l$7;~PBnDLnFK`2G;6f;hFk%APVIHk~c zN>yr5o4PbW|0%MkbS9F4=sCr1qzp&jDPx(yWaLkgKSlp3dQbTudQPz$DRQOAm7?1e z-KOX^MYk!wnUovoI7P=PI!+Do7*8T|>N7k`c5)(Ls(h)9Xi5uO(+>TncA-0ZP7O!) zR6CN|A9qM~2fs@@l<E$t3CN$S|5W)?<xkab>Rxo4s@qiEj?Ij-$L1mr`RPOiQS`-3 z$G%Pm?mhNH%xmlg{^2HfxF3YZRiqy7G0r{4xyQI<(vV@?EatM4gUB%M2zGRQHu56F z_(BxrRr(>r_*e$>79SzQ_>FwZW$q%w_<w`Ygh!}OV`P}1%L%%iFrL}SFku0Uux}HN zBEtl`Ho;6M=AbY#Oe{fZdNT+aCJto;@9_zCVd7`#c;Z*=;J^1=;!o_v#H&GQ(i6Ny z5sFiiQk11Ub!bl?bU(?xCpl|U3KNih(qi0y(k2e@8`m+1N#-y~2a|L#*}hHAhjS)7 zW3n?Qm&05pH>Ei(XiYnMVy`CKtI6&-*}0S5aq=jV7{e0YWEHD<k8OO(*SPoO-F(Lp zbUN9dO#U4+n*2A{us2hlMZPHo(Z>`yr^q>_49#edU7XUD?%3}sLm0+zMv}-B(wKpK zQ<kv;Ij6`u<sHmqiaAf&#}E9-MgBmpDSu%;Q{<W&;!&O;J2^44sd*_tA?(A{m#IJ{ z<el0QT~2L->{Df*8bKfAo+|THnWxG;RhLs!S;||;I8~QZ*RY+h@r_K~#kcI`7{@t@ z+*4(qD)ZF;GT-EO5K4QTOgv3ip2Ho|WKWYl%}%Ekr6zT#M|~R7gpT-oCM}A-#1PA1 z+#yYNzYjf>HkR=$;x%-hwwyQkA0M)gFZc>~N&AL9e9up~PuefIPug|dA??3A+~Gd| z2BB$L$VOfYP?%zr#0;i2#qLg%dz#$Sx-p1&hBAx<Ml+c-7Gh7P$vkZZ_GFqFOnV=> zr^!8S1A3pP_i6js&p{4zhVxwG1~N~(#{*=Zo(K7+m!TXLsX{e65=J<Y*p2D3O;5%* zK0Ot^PM^d)(vfevJ)XXr4CI`?maS~#OLnjunWxJ+UC!x8@%>G|f~?c+$#i+A%RBvE z5Soz*dom*zdB{&8?8l7a$ULJyt?58#^gE*`y@?_k`De^!BcCC|j060LInOZX8U8Mu zahBh>#2-Ourt@ajL?<)D@UEHt8Au%VZRRk>GKFc(WDbjXjpe+7j%I#`yUmh+mTz-b zd8*Qo7P!Z(b~ta=tGLH3_n74#vz$H4nX{ZZD;aw-%Q>^=vyde?XV(9Cn|CpbS?k$? z?{${lo@?fF&3tZkn&8a2o$&X-T<@Rj{d0#il0?SfeskSxuJh(PZ?5y^I&bbWR<M$t z{2qkny+A$ueKW5;-HAm0dEP&71l~K(`{vDNG5(I3r>A+|HE#`{vXyPvoq0R3JM;86 z?+A8g-U-ZXo|(-vvw3DV&&=lC<}P-9et`STx3}}%Vg3Xr2cZRKw!pt$FrG<F<s4VJ z$sO(oq4W@s@g$kaMotRg`$;#u^jg%V0s2gDPAl4=*K{*X?~60jN0Ed)>9VBDl5URa z(^-HH(%-|klm0Oq*vw~qfiBYZkbZz;xOcicr~ifQ>9VKGp8j9<he2qe><gbk=7mL& zd0`pMe_>^+QIp!dLQ7;`DDy%Y7mi~hc6;G8%xs|@SZD_p+JS|3V4)pYXl@JNWEHE) z;C*CYXpRfbaiQ#sDpC(!Eowwl+;P!=fA%%I_%;YF&PQp=Ql3i8#cnV5{>2{z|M!0$ Ud*uK9??QgR)c^NCp~WBmA7wKq8UO$Q literal 123596 zcmdqK2VfJ&(g1vWRk~A`t!5ca?-)#n6l7aA4sN*6K{2)f2RAI65+J!r@4Z(#Nk}KX zCnTiz-h1!8C;#l7PL_-y<l*=J@BiNmAn9gjc4lX%ZMj8lO^vaRQKMd92*WZQ!!rUS zX6I#(ncaUyv_00?+A_O;>!QP=^&PP}{p;H6mp0<hHT^qU+guDeZvAymQz;`cCdSQV zFqzB{W+*d^8P1GgMl!j~C}uR1$BbtVU=C!enHr{+naRvzW;1h`xy(FfKC^&X$V8YZ zvzS@N#F!4IlUc#6WDaMJVvc5xV@_l)WiDebXVx<tn2pRPW;3&exs|z%xt+O#xs$nz zxtqC%xu1D}d5C$Ld4+kEd5w9Ud4qYAd5d|Qd5`&s`GonB`HJvFAR>{7iI|B@6k;J( zVk5K2Y%+(;CG*I9vVbfk5ppQ0Ba28qX&_Oum@FYnNh3LoEF(>%nY55r(ngk(b`m2U zq?4>5E6FOdnjB8nkhNqTIf5KXR08BEax^)H97~QP$CDGtiR2`5GC75uN=_rElQYPf z<ScSFIftA}&LiiO3&@4!B62aggj`BCkS*i}awFM6ZX!36+sPy3QSuadnmj|^BA=13 z$dBYF@-z8`{LV_O!a7+O>t;P{Uv?lnoE^cAWJj|HvLQCi7O}<bA?!?cE?dVgV(Zz( zY&*MxUBj+r*Rd*l3VQ~79(z7}0edmKjor@Pz~0F2U~gd`V0W=kuurm2vCpz^vhT8= zu%EJ@v0t*kvVU;`CvsNK#yPnR&dUY3f!rW&FgJu7%8lSgb7Q%2T!_o(3b;bDlM8bT zxP@GVJCv*A7IF1l0~h5Mb4$3TToc#9b#g1XmE0<BHFqSZa>sGUbEk7>aA$HCau;zM zxlP=5?rQEv?l$fo?g8#8?m6yd?hWou?mg~(?i21)?py9V?pN+_p5aB_#k=_oK9l$G ze!e%K!w=*K@q_u1{8;_~{y_d9zKAd8r}35i48Dr5=9lnG`9}UQei`4yH}frgE8oel z;Mel&_~ZE#_!Ie)_|y3H{04p_zlq<>Z{fG{+xRQ^oA{ggTlib~+xXl0JNP^KhxlFm z)BN-N3;Zkm>--!1+x&a{hx{k}r~H@vSNwPUPyEmPp8^pCK@>8COu-{~1)ty-dJ8#1 zA7PL%SQsgc5vB+S2nPybp-3nerVBHKDq)ro5e^mVght^oVVMvU)(J-orwFGDX9?#D z7YG*%mkE~(n}jQbtA*=@n}nx?r-f&PXNBj4=Y<!97loIEmxWh^SA`FSkA#nfPlQi} zuZ8c0AB5k8--SO!UNnhj(JI=+pqMT85_^j|Vjr=uI9MDZjuXd=2Z;xZQ^i8@5OKO# zE6x;WiL=Ey;sUW*Y!O?<HgUPwF2=-F;#yG^j~0&;PZm!XFBLBnFBjK~8^n#`Ch<z~ zD)Bn;R`E9RcJU7J0dc4Jp!kURr1+HhwD_v{n)tf-hWMuVmiV6do%p@@gZQKPllZgv zi};85xAd^|nDnIdjP$(plJu(dhV-`dp7f#giS)VjmGrIjgY>iXoAjrNF>xl*WHwn$ zc9YALY4Vw}OubBfO#MxROhZj0OruO=Oyf<HOb3__HszbbrfH_>rgGB^Q;lhsX|8F3 z=}=R>X|bu%)MRQkwVOIkt4wQ5N0`8LjOlpONv2axXPC}5ooBkxbcyM5(?-)4(-o%e zrfW?%m~JxNYP!R8x9L99PSY;aqoyZJPn(`Iy=Z#H^t$OS)4Qe*Odp#*Gkt0L#`L}E zC)2N{KTLm{S+ig^nH96m>@;VXz2<;9+ni(WXC7!CVjgbJHRqYfnJ1d3m=7|C%!TG+ z^C9LkbEUc3JkvbKJl`BKFEU5XOU=v7E#~Fs4)aR$;pTN_)qJ%1IP;0-Q_QEE&oZBD zzQBC3`7-kc^Jeol^Ht_+%-5TDm~S!PZobQWulWJ<L*_@!kDH$|KWl!${IdBq^PA>( z%<r2&GJk6R!u+-QJM)j`U(COo|B{K!%aSb1R@ouDWse+C&Qi`(&Q~s0E>YGi8<Z`| zR^=*XyK<d!y>gRsvvRv~hjNc{ud-8lP<cdoRC!W)N_kFsUU^x0MR`McQ+Zc;Px(ms zSovJ}LitAdR{2r+N%>9rUHRL>Sa^$IF<WGd&0@E>Eg2S{#c#>B^s@A|^s@}I47Lon zjIfNh<XOgBCRnCe4zNtMge+l8k>wD}bW4S$(o$oowal^1wJfwmEcKQK%Ti0DrP<PA zX}82ID=n)mYc1<6U^&WioaK1S$(B<rXIRd(oNGDHa*^d?%jK5!md%zemMbk+S+2EQ zXW3!7$#R?JcFWzCdn^xFc3K{`JYspm@}%Wi%X5~OEH7JLx4dC_$MUY_L(4~&&n%x? zzP5a0`N8s|<yXsZmcJ~2TRAIlHCfG8tJP+8S>0Bz)n^S_v#ouseXRqngRH}>!>yyN zqpjnt<E@jeQ>+JDr&<fGVQY!?5No-$!dh*uvCg*6u`aMKv@WvNTbEduTAQrR*5%fA z>k8{i>l*7?t7--7vDV|PCs|Lno^CzEdXDv6>xI^fte06Yw{Eg-wq9Yq(t3^cTI-G0 z9oAc|w^{G9-fg|#`hazp^<nGd)+embSf91NXno20n)P+-+tzoiA6P%Mero;9`jz!- z>-W|ltiM=)wf<@S%f{L`n`ATDEH<mnX>-{;Hm@zq7PRHq`q&282HJ+&hS_p$qikbs z<7|^`lWhmt4z?B83T@MDCAKnKxvk1pZJTAAZJTdfV5_q&vMshPu`RPT+1hN&ZJo9i zw!>{}Y)9Hu+cCCdZ714JvYlo--FCL^9NPu93vHL$F0*a4ZL)2%U17W0c8%=@+l{tc zY`5C(wB2R9&vw7<A=@t7W46a_Purfcy<mIM_NwhQ+grA`ZSUJYuzh0t)b^$AE8BOr z?`=QZezE;w`_oSBtX;HAcExV7JM2z-rrl!?*t6`t?K$@T_5t=G_M!HX_FVfI`&j!_ zd&r(|FR&Nd!}cP3vAx<}W3RQ(w9m57w$HK8wJ)|Wu`jhZ+7GiYvp3nB?W^sF+t=9F z+Sl2Supenx?WfpJwV!4`-F}AsO#4~(v+bAL*V{MPH`+JZH`}+^x7u&C@37xwzuA6^ z{Z{*J_S@|b*>~9=wm)Kj!TzHCCHs5!_w66pKeT^j|JeSC{Zspo_MhxO+kdhDYX8mt zyZsM`$zgWL4#i<{SRFP;z>(z$I<g(T9K9Vmjy{eNj**UB$0)~WN1kJhW2|GUBjm_; z6gVmzm5v#XD#t=c#Br#j&auc*?`UweIhH%x9Wh6Tqtmg%vC?t0;~2-Wj^iB1J5F$% z=s3x7p5uJS1&#|HTO3;*+Z<Oou5?`G*zUO1ahv0I#~qG49d|kIcHHB5%<;J63CEL; zR~@f8UU$6V_{8z4<1@$Sj-MUBIDT~sPSGhjO-{2@b}CMb)93U%1I{dG(3$P*<s9l9 z<{a*v=$z!7?405(c20AaI1h2obk1_lb~ZSp&c)7lXUy5*>~yYhu5_+)u67>lJkEK% z^91LK&Xb%cJI{As;Jnbe#ktkF&3T3MCg;u0Tb#E#cRC+*KIDAX`JD54=iAPAobNi{ zbH4BV!1<x`TjzJq@0~w5e{}xj{Mq@7i+2ew(dBZvT^X)Sm&fIG`CR>716%`Ld9E?8 zv958hkSpI+;Hq#{x@NelT-B}`SFNkgwa8WPYH&qei(N}xF;|DH(*>@hTt~Z3cb(xn z({+~XY}Yxib6w}THo7*sHoLaCZgAb`+Tps%b)V~g*8{GnTu-~6aXssL)Ag3?ZP(|n zFI-=`zH<HM`rY-1+vGO8Ww+wCxUFuR+wRVC2i@83UhbjpVeaAXiS9}6$?hU|v3r`k z#$D^4>7M1TcQ?4B?&a=wcg%gHTXlo`RQGA_)7@vdFL7V$zRZ2Od%OE;_ciWo-FLX} zbl>H^+kKDwUiW?OC)`iEpK?F#e%<|s`%U*-?$6wxyT5RM>HgLIoBQ_+DZ`Xu&dAL0 zWOy@t8T~T`WDLy6%NUa}He*~yC?h|kAfqCqGGj(YRmQ@MNXDTVO&QG@Eg6SrtjSoL zaYDw487F0&mvMf^1sNA+Y{}S~u`T0@jGHoU&bTGxfsCCQ4`w`*@odI(8P8|Dknv*1 zOBwHFyr1zw#)lc-W_*|Nea7FJOeV=>Gr3GYQ^<5?x-#9Fy)$z%`(%#D9GRJ$IV$sj z%mXtI$~+`<dS+?n?94ftb2ArbF3DV)*^$|qxgztZ%%d}p$vigm%*?Yg&(1t2bA9H9 z%#E3wGOx?LKJ$jmyEE^}yf^c{%qKFR%zP^IwanKu-^hG3^R3LcGvCSlBJ<14uQGqj z{5|szkI7^9$R5RG@mM`JkKL2y33{?Uy*xub!#u-16FrkWlRZ;B#hz)N63-!?nVwmm z*`5YZ)U(*r?umIiJgNsgM|qC+obEZpbEfAk&t;y=J?lLiJlA-x^<3w<({q>SZqK8h z$2^aFp76ZldDZip=OfR@o=-fVdOq`f?)k#=i|1F*Z=T;he|Y}%{N?%Et9UJ5tJm)h zc(c4g?_lo`?@;e}?*#8e?<8;7TjVYFR(or_wca}KB5%F7!Q19t?rrxT;XTr;dck|D z_cZV6-ZQ+HcrW!{=Dpmz-Fvn78t=8<JG^&#@ABU5eboDy_i^tN-dDV@dSCN?<o($D ziT4NZkKUiWKl?Zz?-P8Y&*gLbGJH9{KEA%bk-l8tDBl6T1APbi4)#s=mHNtjb9{4s z^L+DtOMQ*L!+a}zD}Aect9{4%j`JPwJKJ}T?_A$`zVm$-_%8Ha<lE}o=DWgolkaBV zExucQxA|`O-QnBid)W7g?@`~2zL$J2`(E*V;QP?`k?&*Q_r4!|Kl*<1vwqIc`vt$# z@AA9-8U7r9AAeteKYxG!0RKRLo_~ygtbeLM<j?n)`z!pF{u%xS{)PUCf0@6@-|S!Q zKit2@zt(?(|3v>u{*(RZ`!Dcc=-=Ys>fh$S!he(hX8$ezTm3uz5BeYS@A5zAf8PIs z|3&{x{+Io)_&@M}=>N$7o&S6P5B?tmB)|r^03UD!oB>zB9moh|20Q_8pkJVWU_fAW zATKZ`aByI1AQZ?Clm{vTm4O+71%ZWuNZ`=G34v1rrv}apoE11PaDL$8z$Jn8fenEz zfvth70^0-E1+EX=6u3EXd*F`1J%M`zI|B~}9tk`ecrx%*;JLu_ftLfX1l|a|8F)AF zUf`3!r-3g6KL&ma{FTLJnX}|9TUJJvH!C}<S61Jw!C6DIMrDo8nvgXy>wv8MtZ>%! ztkSH?teIJJvLadaS&doCvX*DHXRXLun{{N?u~{c)ot|}W*7;eNW^KsYmUU&;by+*I zZqK?i>;9|<vUX)Xk@Zy83t6vZy_NM&)<;<%XMLIVRn~V|zhwOuWP)N)4myIapfBhT z27-Nq{eu021A+sCqk^M@dBHKk$-%;4I9L=c4o(Y}1P=+;1Z#scgR_El!9~IP;F937 z;F{pt;JV-u!6Soe@R;E7!4rZf22TxM8r%@v7~C4%7Tg}ZI(Sp?=HM;CTZ6X+?+e}^ zd?2_p_;~P%;FG}@gD(YN4!#n6C-`pgz2N)7&x2nCzYKnr&1Cc0Lbf?u&bDRSv)$Pl z*}iOlc6N5J?7rFkvIk`k&K{mUB71ag|CY|Crso+mBQpwPVeE`+R(bWvWzp5Kx%h9q zsxh;FeN$a5wvn+iHkDPmjf{hFsyvV#>cEJj|G2zS;j!Vuu_MA0M~xjZc4EPp5&2_B zj~kIUdg9pe;|eB@8#ifm#F0@_7@pPIzAV;OS062Gt?z7(wsaVjJxp(A@D+@g@iBfT zz+^E&CY$M{3aY3|s!27gvZ|<-E0`Rn57QUB(H}tuGJRF6YEvE9B`1Oe@zc<SluBbu zL+i?-_PXY1#L)+TsAzA9wnrNh)NAS%6|}Z=w6``jVf`lJ@FyCTv=pH{V)gCOXiHgZ z1GXQY+-)6mSKHc_#^s&Sk_P0YadBg`J>obh89aqfWK?+cgozVEV@4E?Eeekqn?Gv8 zh|u`a6Gs$G9G^dN^w^@jF?j_MM{h(Bs_(!OQu^*D_qL|BwP{gZdr53&W2|ve6ZY1Z z-~?&sr#$knSu=XfxZyc@d1KZM&sj4XM`w7>go&fqt$R)z{4vb94NMlw(f%AWftkom zVkXbk$GrswIa~i2jiGvk+S}_^Z$yA8v&*Y1w8EFk7|4T|Y0Tg&nS+_BOo+*63YbDB z%oH)js!MgN8EU5LQN5~9^{as^nGzhr=}ak8#+2irRx&fxEF8pawU;^!NJw=6DFsrd z4vjcGp;!z{aCI#m;fBVJ*7jIw-RjoPj)=p7{8le*U0GhYqH#$bKADF<AnT=di=s^t z#|SD8L+4UPqqd{5sj*{qs6AR&jpe<LnT^qvI=TcZ`mEddr=Tc|#u}Hjq`^Qtq~mXl z#;8JKv!cePXk}f;(gpZc=YckKFlJ<~x~*|pw6HPO)>OB;psr;_U2J51Tbm)#LzzX) z;0;Wj+Is_2ujWv3I16XiBzj%a5p9m?L%4)FY$LOjX;k~DgVZ4gf+nVwacyLpnHIIL z+HWJ%#w=I+s{_=53lL4R?mF;0l|xzGl9tAf&W31Zzo~2582Ue5B~~%3=a*L(HlljA zw$!zw4y<CP7-ZHkM|2~jBALPJz<yKP)+Zr3hB<a&d39N5M;&Ucrb?TbW2iFeG>&IZ zh&bE{fG%R2nB$Yloy43?Eyl^rDa@(NY0T-&8O)i?S?X|gggR2qRY$3#)jV~~70fxz zxy*UY`OF2(h0I0F#p+n~V6{{&Q-4tZ1i}FsPX(GiyB;U|NF1B#jU6Ks8ZfeYb@QTD z)T5j|JkPJ|s9#!y<_5>4I@*L4;Algl^`6m|#A2OMv^#zGgcem}SzBvkO9ui4_W)EF zUDUZ`&t0qTXz#4==xj%$khKR4rL9Y1#^`Nju4M*qW419@Fjq2HG25A|nQPQ>>Ued6 zI#HdZPFAOE!`V8JxdH#|U~Xdi;!F*y2jHIr)q|+vjX3(D_;i6KL_lXkV*XXMG_BU{ zTN<coXgz7^93kkO4zFsfYiWo!Xv(b{@idJJs8@={bi{!q^38Ovbwt}+PzsGLC?)Cz zx+92>m;N&fx_=rN>_4^kb&W0PC@39$qTS0Jwq6}lsejq2eK7>Ni+PF)@?qu?=27M` z=5gi;=1Fy`8dCGs0<};Lt3}(;@byI@KF2(dpI$_x=RhGAtJCn)A%-9mn$;!Cdg`w# zTVsuM_USC8fx;fgD%vOrRWM{}cbKXuTAKQ(Asgy(b_b$bZ9oi43t=dHRqM(U9II7S zqqEaOQe3(>r83@~Rsk|r*A|O56t}l_w#8~!(b@PM^A3h2^O<+i<W$wQEQuDhcD8h= zCAyh-pZNd-6pe0mv|}UlAu}cEyV3Szb-E7zDf1al(S%ho+HGP!XTD&jq<fTv?H}f# zG4fwCzf#xt4f8GY9rHc&1M?&E6Z13ki(0N$sFmsrwMwm4Yt&kG=9M`9zcYU@f8xJ? z6Nc$aSk!@8>TGpA{`;-^9sd12)dcF!!|m;@?dU#Gol%v;E!1o_P_Ghq`c-IkkOBN5 zAx7$Ka4_g^iHW3{9NLV|$yomCn$>M+8Zzk*DTWKN$D1b5QBeGiMoCBvW1a53i8x&N zECH{NB1U{`){GjSGm1tVdE+tI7(a1TJlG(1GV?k|5pfVFaS=DkAeqENyu?TRBtWuA zkYtlyq&LYSeMn!@kMt)4$UriP3?@U!P%?}RCnLy6l1oOB(Ik(IA!ErnGM-Ez6Uihp znM@%EkORp<<X|$Dgh)OqAcZ7Mibye;MoP#bWI8D&Wu%-`kV-OxRFP^@Lu%DI>Rff6 zI$vF&E>t7xp=zDFNUc{J)Tp{xU7{{k8`Z<qWonb!thT7FYMZ)TZC7JzhuW#GP*<v} z)Ya<Y>Kb*ex=uYpJyKOwP>)iNR*zASRgY7TS5Ht+R8LY*R!>n+RZmk-SI<z-RL@e+ zR?kt-RnJq;S1(X6R4-C5RxeR6RWDO7k2n^$wnbY;MBA3Gj^)<I(E8*a(i&TuYXr`* z+{*UWB^cs1qf+E1!4}t+<W{$Kw%11~M13?C!*D4#9ya9`N70Zq*6Uwslo4^PPHMdW zgit9v>zW!5ucH<ySBq>an_4?MXfLrpbdeMvgwR-wTpDpidz5xzT}NHbQuLh-vD~7{ z;*kEC(wW<%bV8jCjjiQ0V9*4(phuBcMPqf%7?HLt(I{Z&=j=azsuLKi)-@F@MORi< z*HX76+D-*CZ~t*8X&G9F*7k-j$sFFJ*!QMd`E{{qZArK(N|Q=`SPtz`;=1^>=|j^D zokY*7uQ5k;>zX`8n|qX%lxc#Vq6#Mr?pM$zj?P!4N9lFbXl>3M)}s`XIVz8Kti+5j znVs7GCx#P99}t=!wY9c)(8<%e|9F!o&)(E~R^5uIW-~S6)$BiA<R?M86f<ke&cgji zo4^^<O@Cpu0}Z}0UE249z#*OW(bC36m?Nw%K+BsOYp>5;(%G1cF0gHBV|^@lNwl>& z+R?r`_b`Nv&{X@sq04dqnc$PkZGUt*9b3)V_n6K`8U0w)*`hg3&0|*XhYaIkK^eLL zy^y6#X!-u5Ovodan?{XyD{b_&Lk_P%tKa2zde*7wQtQIrv&OM>aa&wGT@-pY^h-95 zC78;#bcIDd8@Y621!qRj7^>Qmg4X7?)|P~4U-REq*gZw8n)O}Mqtuf}Cn;vtDDBV0 zOlMeHFeqOU&26r$*R2bFh|pBAU}<YBW*8%zn<I|89_4N~bE)yw+M_i7(cqvWuJ~_L zOlVA;V<W-YAK$Qh7MF%qz5K2l^8JZN(&<Z-n$@@`Ldy|tZ_^V>tcbPfd7Msn*?&>G z6_^DVmv&XfBaXHEK`kAZG>WJ<3`{I{CDy92K%&nO3|%pm#ga(eU!p3_-w*P;kEmYy zH=-m&-vh~Bk~2>7U5NXL{pkAsN=}>jtM;P<yUQ-kY)Cr|HPVeeO4>-(j4njmlhd^x zs5W4HUeFoqXl*WSZCw^>X()<DoAk-Hv_~09c0b9%fhMz_jdXNX*H^i;SO+!ozcVUb zfk^VGH1w$83=Pm~LCIwPo6fC^v1EhTv%{3I9>p}X(sizC|3!xiogByE*!OU{sg<|7 z>N7~7Y5#kj5Jp!8HN|2l5B%(&C6`EPkdyr>(f(V*T~OE5RMFXy-?~a4`&f^%Wf;tK z<>5q;13B(lD`!krtbStT(xfkV7*&b?ol~m8`UKW4sFTuVJ9GbKyIUbgv)ua=cBWI9 z=4f-PQCca}KIb>J)-Th!_}>XIwaSZX(zE^}RXHn?BTuB&v-7)a4FOTl>JdHAwLDRv z)D+>r<MiT5PTcw-13g=Dnbla-h$g75Gd@jvwjQ!4V}NY*Y-(>1GSn&&B=(HJaOS63 z)6qt~XV(ji{_8e-w-{upw!%&>BbVbseSBLFF3E4gU)D2IYRjwfi?&gMY$P)`kWK0a z_44?VIoV3KGlMsiZR84aCAmu7sBTg>t6MgctI0LwT5_GbRlQ2xu3k--!krEAErX@4 z^;%D2^A_V)y)s<j#Ko+d4qT(26YE^msI7DB^lrf&ZRA#Un`(cR+(GUncaggph1^5# zCHIm0$pd63*~!c&50Zz-F8uTGJcB}QRVglB<94%lx@?Kd+MUfU<(<uo=>9%ew54IU zAD#6}>)PvZ^H00BQK2-7+cO+GU@7h#(c8}HXl#xm(q>$9bs5OJ9wUd{u(Z~zS2$Sp zO2^kK<G^DJFD%Ad&E(u%w7hjqOIu?dxuG^(D2z)ZSKs7Q*VdLxcdTfcdm(1<Gzx0Z zt!%36Slrs)9Lp`MtFNe@JrZ|-Xg}n3!BiJcHy)23HFDy}Si`d1>eVsaUX~lLyyt3r zD(Uh{42iTytE25J8gYqv<YKzllK!3oQP;kxwS~eZJ)fp6HsSg#rrC4}QdgeG$m0=* z7q_3)L|1hfOWejlZz4~SC+Q}QJptf;F>KnsS;TQ5E@$VoF3!<5ujU{hl<8>BVYomr zd2%J)UX{}xUEbN)9*uQ9t!rPR?M#g=td2J0hQr4C9BsRnu2Ro3hixa%k>|+^<VErl zd6~RIUL~)Q*U1~|HR?_39qN7RF7*lZIrSCwE%gKSv&1eu@;3P(t*U=WJ|Z8JPt<GG z8`K-s9qLe>(C1WlzfiABue)E9Z^$>A?tX{5`yKf~z20F)P4TLXlRF#B>$|B+(#k#t zwfnwtAk^N_+1S#WY>rozwB%6yIgKs#O}I<2A!l)WYjaNWE``02$nR`y!u5Gw4Rc41 zr2p-n+wVqpa^Bd<xLpNze6=jeDJ`8@mNR<fsGRav93R{%gqxSiugTl6$R8|8CvKKy zIr1?ps5h&(p}234i<>o}xLLD$OImTW7DL>ujqGA=tV6vOg&jm;^DYbw{!79}H?iV> zF6yO|^CnH!1j=S43zYS;!L$O+W_zJPbJRQ4dr+YF8UpP{1=?S|E4@GmB?LMI1v-Qs zrrwPL?L!6nJw_8fCQvj`jde}At&8LOM3?JU{|{ukJKf1+#>T~(n<Cacc0yXQPGl#c zSf{A>s}G`BA2P&x5Ebje>I3P;ns0~|UE41F^PRd=y;5a*(jFu@(?3vw;_koyx;@y9 z?Bp?VaZXDS=XAC*tvF|}RVdCH^<nif6zAiHIA>9D&Q>2uFV1=Fe0Dyyvg|_C(uM4y z>Z1-B^>iNUsS=7f7WBNHqU+YSxoc~^YyOvlO`<$`QeIrR4JpE1!ZxK9ZZq40!fjKZ zRG&fNK5Ga!Mupp<K9yd$D-*h^xiI!{^=YcBPIgAb@yKq1{eLskNurHv*gfDe0-AJC zI60o%!x$!k$Ntx$TN3Sm%Mf+Lx_3AtMKypuF0E=D&z^v)agzGH`Vy+f%Z6&4N>$@D z^@a4Rai*af?AbW)&SuY5U&LAGMCBkmB91%$PbtS9!eB!yQXZo^JotZ59a8$(70IV( zVe;sSaRs<AMFB2hH>6d7jqD~=fGz5)>Kmv4ZyE}41yz76)z{K1z|{!_xE2-QTK0PN zbyNU1Re<yVuUUsZNG~Z<3Wd|;KltPSQR}cD3{B1(6<3a%Qk3IX_O7(baW{JpD#v~5 z+v<C$9Pb;-v6CvtgX%l!mE+-ray*L4@hJPa`YtL*FX}pujW}NU|AKW$QjUVXCCNz- zQCZ&m|BmhWPZ*p$W^`P6o=#Do=h&CiD$gtItEfD$s~@VLpz?fbD9>9|dEQn(O0PWc zvG23*Ya!i-s5~FCAFCfbhNJq-MfI`vi#W=5Q=ffHoVypzX^nwS@GRr}g`Okhj+^$@ zoIzUcVUX@eKTl!yEB5=e%>KasNUmjnRzFw2#)8;42D860<2JItvwx^xs9&XL_-_s` zETar_EZN1e9It-q5Ru^_$gnsh;%M$6hW}|lCat!NT$-j1$NtUC=S-MbKgh}0Lz%N+ z53{j{gJ}<WJa$rJ6mA-0ISo-P=HOA@oTYf6R}&y-*9544b|rnzBs15mm+Qa#w9oOX zBbUYHppdyBm(BI!daFOGKdC>fzij64XffB1>#zQb$8UaD|DaVzck;Owde9P!nGweT z{53yuMlW$ft4KSfQ_&JXqobdSF;3U$8+Ekfpjc3)r*-MU9ld+QxZ&&7-?UN~H<HWM zYo;5yQ7Pq9E{_?vUbUwls~I;5kJU^Vziyqu+jwpY<!u5tk(<O#R{v7}2EqU#oAIbo z2~)xyjJ##3S%4>wkUe@_i=GFfC)>0gK3JgCs+(E?5lI#17wg*vE81stMmwYWDK2`H zJI&AZv{H3PUHvk;Uk{6F^k%%7bxoa7qjN>v3}*0ETroF|E8z~|rgNoS8CT9#aFsyt zG`Rpo1R?=30WkxSfha&MK&)4BRX8;C<ab|g7B`!l!_DR90ij2~=~&@GVLK2HkbXc0 z02!p80#A~%eh{v<C5GFm8;m-kK3d3aVz`E3{}Y30OkC{*Vty2hr_n?UO$q3cLj5?@ zo-qcgL<-7KC>@=#MDqkedTOehexS_p#}wi<co;q6uqVOlztEHE`_x?>oT_pPUX6?0 z&S;G{4uo@!Xi2%lfH>%haICO#&CFq2xE8LJYvY!4?LeGBTtM7FGJs^NLz1?=%+xD- zbGz2h7o@BrAUoPRde`nXLq!hf)-tXQ+!`R>4cs~)K6=9d<y}*xSSUuBF@S+P8jnVE zM*;C~;En+jP=_XU!hkw~JDC~0kvow)2?#2FkbXQ>`<Sf`txVJ4Ebd&|;B4+hAiWT9 zBX=JC*c(5pL*uL&$S>wDqp+7yfE*3>a{9542Ajmc0l%5srgvs5LICMYJA?4}QNyj( zs|?s{xa+!PaXpa!>OkYs4({eI&S`sfsPX7_?#`}OcL5pL)#_gEK4$Rx^>OdP?c|1E z$vwzD#O>l9<{sf5<sRc6=bivE7|0MHLxBtjG7`urAbCK>02xPZ6jcOt&>OfGQ~-5| z{=@Tl@SJLft`o+uujs$Nru{lhMQ`JzeljP%nvg>`^6Ty2(jni`AV;V}W~1UX;PGYs zTs!xH{`e#9ajrUK4(`j-j=062f0nG6U+bMP6mzsXWPzq@#@;ZU;`hv9n+;t~ZeaBN zH|DTS+H*W5uIu?&bx2h$o<2nZ@Wgo9W;}H#D*e2~ThIjaCf>};JX){`Kqdm21Z47N z-pbpUzC0SNDL@XOhHEM{!}L@v9>z{TnW^!JPLJZj=z-n9x|xnHKzb588DH|L%`PZ< zI5-(9$zU2lI=9~B5QPu$LDVlEHTJ*_d^V7S_A*2HK72paQ@$^dgEufc@R&1l+e=#l z$mv@1&Y7Gudi3P6<0g;I%L$dGIJhyR^6-+1ys-%f#}DC$Ax7;w1RnJ>Kd#I?mQ^?L zqxjK0>S_UyA|NGQLo$w^n0z+@KZ&0Vq!37$_MM(LPl%r0%Fu7>^82(43*u9XKbX%? zX<oo%+hQQo@D2rRtS|KHEl(Yl(z1jvO=(%imjgKj$aI5n;+_b-dD~R2Io1~UaXDr8 zrIQpx8$X7#hr1>C8h!y@qQKYkGx=HkY<><um!HSa2ZEif08$BL29PQs)j(>1)Ly|1 z<Rf_gzl2}J*Ygd0R1E@|iB|xiE*uBsLLe6buJ7UyJ7`c*NG~YBbB2^NyyYSxC@qFS z4QpwrYj2?Pqrkch=j#9HQ3iEbh0(=zolPAYDjiQw{HIEK^DZt<wshceb__P~gT5?` zR>q*5xFcgO-mHQ5g(Ue7zKw6Enz<avtPOk&$ZXp00XqHo?IL?3VW`DQel<n03do!d z{NX_6szYn&;Tq%l5&Th%YZHGYk5}aYnFj<VyI>Q4Gz#!oAPcG3j-h%mB!#Lr_p0$e zla?jg$HWa7c$o;UfThC5k8XGWy*PdtN}s<cqa)`}0TNN|M%PZ~&&OK|_%rx3`Lp=5 z`E&Sl`SXAr3ZxFmA|UlZ8h}KBEZ)Xnz+cE;#9xg6zm&fW$Pyq+fuP;%(EdZlj#7ut z$Ji#S?Ip!!_<4F4wa()a_K<cVGTlU-I#4)H`mDnzG{`E~uIup|!Bm=OS;n*QDjatj zU3T4GGS7IXE#CXvIv3%}_{jPZZB3mq{V&~P7y`JGzm{=r=C9(n^H=lN0BHn*q0TZO zO`G}a`0LR~-w31`NDDR6t#p)pmF<nqc>K&DRMWMb-@n_VxFsz}*%h#0T4O^r)YN2L z{xP6iBg2}fw(1wUwVfYWfBU5QYw|{o8IR}bC+1CDHy6K*8-ua`sC6&$ck#Hbfxm~p zm%op{pMQYg$&}y>G`eZ5qA%={6+IlMK{TVXcKu9G_|tnFDi#}UyPg5TSgak03S_yO z6>-E%);L2`#;LHCq8ypH@*{BxiLQtbGvl`MkMNK3kMWQ5Pw-Cy!HKs52+p9@KyU`F z!BCTb2D!PIe{OCvbyT*_J>Ha~B~JW{{7ZOI1NNv(;q?0}G^Q%+8rwJWFVk%Vdxg=- zzsf%cWF^u}4O_K`+$HoO#(JIl*R$zY3=`vDPoiJZF6v+TkLcI6_%%7sBzNF?^}YOO z{O4pBkRyN`Nf+t<(^ULFa{;>0zUIG4zk6aM|1FhOx{Vcj%kTLgB96h`6`)J@sgr#p z|06}W&+r)R==)ia0KJk&Hz|f*j?`JE@#FLSFQ_iRl3o1o{Acv)vPF0jd>;PW9>vWb zc-%>4fE<lN)_eUI|2JmWXd^ZXjFw&FM@=^c7LBC90Xeo?ialw}*x@<jCgdd|5J3{G z%-}78NiYktpa>Qq#{)S52!`R9VVt~$J6Ny_4*c7NSvC+fyr*j)&ZHj3uKSiE+{_fC zZf?%ZI$WYg6BwICSKwNkqH}c!-3L;y+2#Ba{w!|Agn)pH@*4znB&Ti=Fcv$Fk_aSF z(!GF&S*fnafXhLQmVJf(v}HdaXKY|fuq1#Do$(&%i7M@Y0X;-W1YH6KU1!CEE&+qC zjlw8lG?24_oR^5Vgt5Ye<giDWC}8+|4v=#(U`pv-zp3ph0h4f$5K3v8FBAYdAIJsj zz<KfR>5<afLz4q7VVY2)r#42HONDaEU>T5$HwYNaT%vJ^`-Bog?7BEhsHS|>2(>^i z1%fyG7)WLd^HO><UswPHo#5r_z&SWFx>oj^dej*yeOV+#Q(7$+&}nV}vXQzGn#&sT ziO$Kq`?S_C2u(t>(84G}E7>J17wBfQ_SV)8T^(rXLQhTLE~q8Zmd4JQP8&tifm^2Z zC%!h_L+$nma4Q{7gUvv0d`ajKI+4Z-VWqGN>9h)K@c#9+%>3E-+JdHr_Grt@wmST~ zV_v<!i%h>KCZ{33`)*GYd|qpNqY;8pTGs)&0mzml?<5={9I1OJAlCxfYB&>p`W=I= zK{!@8PB>mTK{!#siL?#K6+o^8auty6K(0=54O-+8H?Rp){qK#lpjmQs{{Lv4Q=}$r zM!BuQn(8hF1G?)ew>PMGn-eC6!j;sDU`)9=ev6)Pjc{$mLGMpW_{5Yu<WdKBqi`Ly zlKTp-nKa=B;YR)Lt$(7hQP@GT)8z1<Kn?xBS-77Wyj{3OxK+4KxLvqIxKp@GxLdeK zxL3Fj$W1_Q2679KTY=mL<aQu;0J#&$T|n*za?f_AuYj?L@Q|=ecvyHucvN_dR`6&* zbuY%g(l;P|57IAS@`A|+rU|r?M<;1US7|k--GqqwFJ7<~hzI_<c5BgPtf;je4LF9y zUVTbo%&ec(%a1O_2)ea>zJ8Trb^TJj83a-5U#mJ>@bW&abZQwx#4)P0F4jSdmQ8pP zuc0gK*PGE@=M7pzyf6^m8s7eZ)7bDuIz8+{c1r)W6_D!2!=s5V`t&SZ@4nGG-g{h; z*E~W=OIc$}V}cj#aLV_%0W?PEHQ{Y6GzhN?ZwPM+Zvnv}xgW>_Kz42x-Vxpv-V@#j z@*t4MfPDv~qp57W;<hwi)i6s~6fpW1aZJ$tu=e*DEX&Xve5yO!v^y|Tc^R1kv(FwJ z^?h%yKB+SX-=7IzP}BZ7kcT!1Ujlg;i(g$~fbboikw*jB6>;RP8nKGrB{rg|bqVgA zEeeepKWY4^q7jqE<QI(?n>TjUh>78%@gv5ELzBjaCQb;C8b8h;@}uxGCGr!HM>Yt* z0C|*(uNT(C<AZ?xiff{FFPpaUcix&Yc^EB>89i>4QIHq@6d5e|34aM#h<_Z&lN&`M zVpQ-n;HJ&wZi`a9+fV%G+qF{nR(2IwMruN6!@<i<5|n6(Q+z7os9)TDZ*kJPm!S-M zy>sfHX~!ii+Qm$apG1e~6kVcQ%mDHXkY|Blp!__L7q*BV(JT5yzZd}WB9NDWyaD7* zAli*+BT|%1AA!pDD9-iHSX?{xA91H>3}@xwH1H$!R8YJ3Bt|d)T%le5IXn%hfw~5_ z1xMqTkH#^l12=*#Lt;kqg&j%P@rX`Q6CGCL>C#KwuVXH@$7hBd`-uY*5so+zh_Smy z9D>n|I8+=4<P{*VC88N|q&PY`E@9flF=~GxuhJ_zqf?VZ7;%C)xf|#K6!dipdi*;Y z=-#@hIYTjo&QQz;@|J3UK@8)zdrW)8BC%MM#F9BNt#pAoJdk&Qyba_DAm3rOyS%+@ z^!DinkEJ5+=i4NfiRB{3aPI<n56JtQ#2MU4Vl|Ktv`p(mEXwO+K2ski<6_M*X#|@z zB72sw-u=0>`&hNXrDUT!3&kiic&iu@4;AagMPj|!0OVsJp8)w3$Y(&%Bz>_}Tr4i3 zYi$BvzzhWK)3^GH+iCImykFv?yd15AIjFa|N55lrP62wlB{YyieeoN*lnSIh>%T|c zh~FimClCFSzziDNGD-@Re)nlQS?O5xOG@?U1{PYYNkXE_tAnatr-=FdS3tg@g>*$+ zEgmkenS<$AOuL8^$k#YHq&ixMMWGy8hls6RJ1rc-m9$88I8;?IEm9e(nO3buHsU(* z2z0bvhe|XQoABo&wVQ|a?B1Yql!ki>-P?vM40MAyJ=Bj@tvzS#$h@2pIi<LByc3U# ztX*4B8Y(Z2l$MlFk5uFzQV^-CEw3pl3+r4Q6JJ8cE0D$G#S@H6Tn*RPeP(YGPZUq0 zVO3m=aU0YfEPW<zsMRUrsVT{ec!qc$HIZkEXNhNv=ZNP5`4I@ZqMw1FEBbYdc)oan zc%gWacrlRQfcy?D53B&V?*W}uI!j~Nv3U3X|6wA%x_-xbDrs5Vs`F)tb+fn?4WzgQ z$R8U-Oeg-N(%Hk^$>MgZy;qBv4g3Wx+hsJb7k8i~6mJl31oAhq_?opH;?3%Tz!J=5 zF`ewHQqhuHw+obav#WQC_w0u4K8lT_mi6S>`)FAoqNZsVuwt@heN=o*d|WI6)(or( zSPAWE#L@6SaO}DLLN_<BJ^H<&8x6@nBfdb*_Os%1;`6}Dz$(C6Hi<8aFNrS$YX#N@ zti8w0c2bE=pUZDkF}(wLUL#?_-xoil7W@P8L-8Z=WAPL5Q(&FIx`1^9n*nSlu%4|# zw)h3L;7p154H|7=z0`tZ&cgbs3hjeM{6A#B_r=}l;=&U&8^qs$^>x|qzcj0wNwl<| z-sOfDN~6i9mKu#TX1o%^9Cn@KA&E$=#7Vp)NTMW3Cdn+xk|J3ot7Mbxl0$MzF3Bxr zNSTsH@=89*F9oD5DJW%2y`<h!j?_o$EA^B5O9P~V(jaNDG(;LI4U>jTBczd1t~5#- zE#*mLq_NUCX}mN+nkY?@CQDPK1Ed3`gQSC{sZvPFmkOjpDJ&I9#nLpXL^?#8E|p4U zQn^$iRZ26YDydqkk!q!x(kyAVG)I~%&6DO!3#5foL^@QelNL$!QiBwg7E4Q{rBb7G zn6yl4lA5I!sa0x|mP_qYOzMz2r4`ajX_d5EI$T;Kt(DeEM@UCXssz$e($Uf}(y`KU z((%#>(uvYZ(#g^((y7vE(&^F}(wWj((%I5E(z()k()rQ_(uLAR(#6sx(xuX6(&f^6 zX@j&;+9Yk3wn$s0ZPFFemC{wxcIj&A8tGc;I_Y}p2I)p=hjf#4vviAet8|-myL5+i zr*xNew{(wmuXLYuzx05#Q+iN(2-pCysHs6<vw`geY;Rz5fb9cpUts$I+aK5gzzzg< z5U_)R9Rlo7V21%a9M}=Sjs!Lr*ipca1~w1aF~E)mb{w$dft>*CL|`WYI~mw1z#afB znyrI?Js8-jz=nX$2ets%LSVzd76Drf>@;A}932AebYM$?Ed#b3*a~1Pft>+t6|mL7 z)&N@z>`Y*10XrMmIl#^Zb{??vfn5OXLSQ4n9tvz7u#14L2etv&D6orxT>|V<U>kuw z4A^DBHUZlVYzwfhz_tOq9N2bXW59L*+X?InU{?aW3fR@a9uDjpVAle>4%j1rJrY<I zSOE4YV2=j&7+{aZ-R!^~59|rRo(Swoz@7~3DZrizEZTz8fjtA*Gl4w|*t3B>2iS9g zJrCIPfxQ6O3xT}|*o%R^1lUV~y$smPfn5*m24FV=y9wCMz-|F{E3n&uy#m-PfxQaY z?Z93Q>@~n%3+#2kUJvXIz}^V#4q$Hr_GVyj0rpm4Zv*yrVDA9-PGIi>_HJPB0rp;C z?*sOJU>^W>C$J9!`w+0ZfPEO)M}U14*vEi<9M~s-eG=HGfPEU+XMlYc*yn(K9@rOv zeG%A~fPER*SAcyL*w=u49oRR3eG}NX5~e_UR5Jy=cQXZrg(Wp573HDQ2p%9sqo4(S z5=QeF>g~yJ=rEWABaF8@MnqFpQBh-H!n6>f`t1f)TUl9ARTD0ZRF;NniYltg60|XC z#1>iITg(iVmJ~+frc3Vu=0^zWCwd&7$PL!6t)5es+=tiq1c&isG8`6R5Z{0__@;%b zXjiMk1r=qL)se!IDuX{vYOqbOc$@gu?Q7TO*OrtPMrMYpN<!r|3Dz*<(OA<voB%E^ zD2U7qS5@OU7-&D%AP09xiyIefiz6lFRA3=GZV~;H(F~KABn}b;!sVg-(r~1rGF)C( z8L8G~Z?wS_2ipwlPO3Ou9<B=2gpuotq7n?Ziz5XUg&1b*vPaK~t)_Nwl@L)$c|mDy zVK}0v2i1|Hs*17*l}ZgoSXf(7lOo3NHFQI|qr=!fqR0EyHOOy4B!rqeXKpwlevGQI z8+qN^RTqTHBcW1M>WbQ`f^Y;G2xA{As!(=XzY;_8tA-$_I|5DH;@s2D8f^cefe#>b z@hXQN;K!sNQxX(Rq`IWIJQBuSq^2}nhW{o=VCe|^*k_Mzu%b&_&56@6u^RmFJ;GOo z<6KqMQm$yqWi%DErv1A$t*DuX8Cq8-i%LVqM(<1}t%;Wu;%fz3SJMlaasJd)l~krc zDH>ET1u9fp6Rs+!LMpDRsKwVQXqsWN?G?0Q7OIs2>eN89_JFmlOWjOZW<nVb-UDQ1 zxT>tAn$8~_WIEIa0k77qPf9bK!uciTsF@{&l_imqvQTjsJl3p`Oil`XVYsriVh$bA zNNGiZHtP)ZSRg>~fqMe4tf;O*WiJS0*UF2HMmbueKuV*Ma@22B*Azka+Y4Zd7_oYU z-RPATBNbwV4y8eUhz6XI0$hj#-et2*xJHQh{3#$t50kYmSA!dn0#_C)zzYf@NkXd$ zRTYPg31rGk(<W{Zuu)M-x#o`0E0k0x+KfxnpX%u)l{lF-u^FsQ)ZqH3^hZ-=15mT! zn(;B3OwpS7(ln{AnNw<5JJUfLSgN8{hbu#xfz(JC2t#qm>G=ARXj2XrVLF?zXo16k zlQmKvqJ;{5o)l`3L6RO48LLVNpm?uHt7|F}lkX4>vezDvraBo@nFj17c#Xv}&5q^Q zmKS0#ODkwe$LMFJ1~s4ys&GzeNj{pBGSr2Vd~^*pbGo@N6IS<7gL?1Qrnahz&ZBPq zn5jW$CqZLPDQ>T*C8|uCJ##eJL0z!45QNsPu%sFzi8<AgGOP}j;y_bTC+q;O^kIM8 zNv#l|B2rnB7>$SqF}w=`Jy~_QYGxR<(&!9T&T4c)g%LD-iGanlNNbwJEP8%jM#iK` z9`<N==<w`#B!p2*enqKn!3^Oq)u26H-J*Snpt-F<6J`J{(|`tc0cpjtStT{oBB(~? zg`uiKte53iVKmYu60F>!NHV(`;mn;Dsfg6fsZ1corBKZfBoqWWiw6-Y-l0Q-%jm*Y zQAKNl)D#<iT&aO1>6-48N()mE9j-wo=~^NRDGODj&}qdlTu_sOd7aiKNklkungEdH zgaW7<P_M2YP7jAGF%l`6N&Q!NHuYo)U|fAdw)=DeBik5>P}A3~&Z*Dj<GLg7G7Z|0 zM#30m8-h4d15Ofz(cKh5oT5SbySh+~Y{#XV?7dI#-qqUjz3S6h-SN%}Rh84&uG>JI ztHCA73q_DL7L_R@aDfIqfK=k)k-8<CB?(nlmd-(;(Ez0cW4MaSIjNo*OP?s?oa8p) z+2MlP8ZA<#1A^}dO2osa%QW!pJ%FPKi%Mo265gP}4oilm5wqq}aHuQk1lHs8>TnIt zqpnzJv(~ata?1qMmD7tUmK4Uf?cS@RDzrPZDypV;H*!~Luz_UUUA;=4DOkfq$&5@7 zsLvYYHy&4DM4O^F*K3XY?V)jPO=T@k9xZt=q_tyj<WdNAx#z@8xn*zU^ihdt00ueS zX3%}yyTs5%&H%^F2naqfnIEc4RAUiXGtkwMX+@Yzgla-YqkFYRgOVE=Gd+=xRFqN+ zl^o4HptbU)w$g%y6u1452G&0Xj0P*3Vnom|?=Ip;c4wlpHop|pnZ0!9ajntdWI8m^ zKy6K-6fVcO9)C4>e@bhXGErt#;cP@^cbinWYKy`h)NMg0R62|L(fEQ+Ey~zf)zPip z3tFoI-CA|&ed<b(-sWYk%|0z1=?z}f8uaT%M0a9yjK0y)OQ<3)F(Wg*yS1na&rJ)B zi<Ss|KsV^{Y%MuNYmb%)^Ktb4N!(!KoR68mW{8s<>HBF>#q-R6hw38@RrdkWh9K=S zn=Y$Q<DBE`OgnOF^fQ2K*Xov{CQLOm*<*Z>7FvS~6;T(fnMOmMzSf|9Bo(&?Jq@!P z1ME8u%$p9ZswAPCKWb3@$xOQWzcrpZ$3sH2XPRg478>Gu8IDu0lqPWy^ef%W@$VY& zfIS22t`Q@;0^ByL3r{bR=j^$SZpGr@W}=bU3wU*HQI{(+^Ly?-HDT3rFsLara7!9+ zpFMX)8<|94Zk9Fp@!D!BmXP8LrCMboev>W=dF@(ST`I!pNnb6cadN1pz^E9Qts0Vv z`+`JUZ7rZ_YQgN;k%B^uM~vBLc4%lO?+coEF{-*cJf_PeB@nqaL{t79qOqgXVDkJ& znDWwK@@tq%{!O2-#HLq)XknFdN>hO<EF{qyg)!hk4eywJ!Ang)#=Ter4JFkQ%)K=X z`TK&QC>$=#4;4(O#Y;3{m?2eE;<|as+~kUexvz#WZ(k4=&cU<>eVCR<6&O4X&=5@B z7X*pWN;4+~6*#Z47LyVtng?s>4%!!VCFL0PW4IZrqBYCpz~1QFuzl~FK3rPS2Q5=E z26bpfD`wI9b7J^LYUmE!m%hby9uw8_a4FiKnc>okN{Zd++Gq{exP8H;)qpV;rRGCR z7!4d_H5`Ng2?u>1DXpn6noZD}jsB-*)QnVx(HCJ(sf8g%`^j4SvHQ{<RRzliWmvY( z$5L8ixxsv(hGL(z&M0Nmogc*st(&SL7_l#X&`co~&l47~Kx=!zzO*$=m!8$dv%Ib> z#ayJJ+9!)#Gp!2i3e}+^Do<M4PN-FhhGd^isZlXVukNK9qEY+8SZ#S#1={t}ii*la zKPt55-3O&>9}ZQB0$do0lvGFXR0dYR(WcNJ48^F@5af2FpNb$Z(NJ|+WO{fG=1ql0 z>)N!vPi<Wgp?iU9snswF9Y*unTJwYVO1xlN80}$IxTdzM9M@_}YjKIBh!!}otcQtJ zd3ctAZJvg0*j}-flxvYc);y9*DCUJ)%e_l6E`);0N_0L2VKmE0PNGgjFnq71lMqy4 zMr-uCL2KIGx2KA*t5jsz^X`=*^AZhBcQ=)aCf)-rMA)5&!!!)tr)OFWXj{<QRwm+l zbF<dAyF*Fa7A-W+B$^sll+bFuR`Qw?p&?5`tK0TLCe+B4l<R&nQdC>6dF@m*v3*2S z6)wiy5Tok!Xjbe4bC^k>slYB_Bua~}s9=Th#4%Eh)2%D{Gq2Xr4c)7*6rdBs*;YNL zye4FnOw4Pwh6DE4FusD6oJg3D)Y|NMP~&YXOKY(*TU(vd_9(4wcXyXMs9o$*&M~M? ztt6O_-3MmVHauY;h{yF=Td>6Xl`(n=H9A?tu}{;wGE|Kk*xhTMwhsufP=jli1(mfl z^Q1<FE@>K*`%Dc%cW<96!s=<b#*S-}wTWW2`5diT_xL)sneOD{g=1qOS5JhKl<j;C z6S@uDtl5=*;8w*p{XJ7!9gsQ+9E7fFRZ<ZNBgdKu(ki4C!uV(>1bmT(eNs2<v+CMu z+K79YC}LW>M2|y_cr{kLv3yNkY0BcO`BDu}ck_`3Pq?TE!(y897Z@rVnORbSyAzVF z@p=ticjuf2T@fxkYu+$~u{K?NrAt*^i^Aqj8lvvQmj)3|@xqFPBig#JVi`X+Qd1Eb zlNZUy^#Y`xnpc~z)bMmygEZt(<1p++B|yuAo=w{hP*YJ*k<i1dHB8-Oo-~+B%BSIK z5zS#rwUI+rN{se(8WMbxqDyI!;QAnDLAV7#Q=g*RQmixM(ni5_>|7#vxKYE`-DRc0 z7s|(qoe=^g`|X=G4BahM8VuUPGxa%`ca-Bodv#)o#eAEFqkDFi28Z4Y15;5+7_05t zN~q3hLQHpR2=_tzQW4_ptEr&OB@o@CA)4^d@=isB5fRO?3=?#}hGp76V=1dGttmnE zNnYXA`lD^hs1BEEH8lh6gBsfIVM`jZm180?v!tq~7R@W(L!sr@6^ZckVGYfoJ@(F6 z`6x*7Opj@;_CdtBeE|1uB<SzvA)eF_b@#<-xTp*lqG2dW<TB6fYY+6X(PAB(4SE2M z32<VNpVtuW!^}+RM;b%%l7?jD9;KMD!`k*2ZBe)?p&+knjrT##;^hrP6L1kXsYLaL zhGqI*yHJB6QVnkAz(t+{v@ynLXr(^7N>6P##yyd6RaH{e>TM14-W6EKjH-r4R9iX0 z$Wq%%qoblo<C>HZ{CgVOz1t2Qt<iG#u6?NC*arhm=aKFMwK$hreM|?-Yl@8N^vOQ- zM)Rb&_>YBAG-HKW^-i6VpYJ=4F1v-h^=fM>5>oj}!_mFYkY+;EmQOFo{Vm8ws2G=h z4L-iz_x4&)Vd#L-{s*o7K4@}nxz@fklpjubxu3Ph-Q&Hqo!1)Ets!OTkrLMEw|_}p zOGk~a|M@Rj*Y+Laj=y+&nbF#JFL9*ly>3!)^A4sO7)cc-CXz7<GN+;HUXa@(s*-YT zCmrV1MY!0C*){Gms4_}VvZy1Yr-AWB9if)GrqzeziJuWU1xus#%W##zIPGI>`@{Jh zD%55l{eT-^a1GF4(ySpX`A?AH4!p9;3S4r=BDt3RCxv{nMZ-JkU*OfUV4OllniDtr zXV>ubq9-#);9+BYvrK~?#?mcXrIDIix(;suyENdTsla>MTNP<*t2Y{EY7M=q4KZ4( z&`wOnPk6{)*_U!;NzRgAVg_I5xI+%g*>W$rx11yQk^9R1<o@yid7wN<9xM-$hswj` z;qnN1q?{{{l1IyV@)&unJWd`jPmm|dljO<r6!`%8K=~l~V0o$>lJn&Pxlj(vMRKt` zO)ilSk*CY0a+zE%SICv}47p0KmTTl%d8Rx|o-NOj=gRZs`SJpJp&XG9mFwh1a=qLj zN9D!x5_zfIC?6&-lbhsbxkYZ3+vMePyBw1{<W6~oyi#5zua*y&*T`$-b@CDNk+Ld- ze3X2&e2jdoe4Ko|e1d$Ue3E>!e2RRke42c^e1?3ce3pE+e2#pse4c#1e1UwSe35*y ze2ILie3^W?yk6cQZ<II5o8>L?R(YFzg?y!amAqZPTE0fUR=!TYUcN!TQQjfnB;PFG zBHt?CCf_dKA>S$ACEqRIBi}3EC*LnWAn%kPlpm6J$q&nq$dAg8$&brV$WO{o$xqAA z$j{2p$<NC#$hd#|U0~k__CsJl2KG~6KL_?pV7~_TTVTHj_D5iU2KHBAe+TwYVE+b= z0LK9*04D)w22KIa3Y;A{Cva}yGJ*2~=LaqexNP8h1J?(*e!vX?ZV+%ofExzf2;g#o z8x7nT;Kl(r0k}!PO#$ve;0^{Z1Y7}dVc?2^D*<jgaAm+%05=1;YT#;tn+4n);N}6h z0JsQnb->jF7X@w!aE-t%1FjjkR^XNc7Xz*nxRt=I25t@Dosis-zyWYa19vQN#{+jF za3=%a=*XQ8+?l|g4cxiFoe$iFz+DX7rNCVd+y>w_0k;LXZNOa#+;-ru0q#2BZUAlv za5n>YD{!|1cPDUn19vZQ_XD>RxQBpy7`R7)dmOkYfqNRbXMuYjxEFzY8Ms%0dmXqp zfqNUccY%8!xDSE*7`RV?`y9A0f%_V`Z-M(BxF3Q08Mt48`yIGHf%_YH0z3!20K5de z8Ss`s-U_@Ocqi~~;4^{u0`CVt3-E?LzBllFfbR$V0N@7!KLq$;z>fev7x>Y@j{$xh z@DqTa1pE}>4+Q>T;6uO{03Qav82A$4rvqOGd<F0`fUl;L^kw-K`BnKf`E~gX`AzvP z`EB_f`Ca)v`F;5V`9t|5`D6JL`BV8b`E&UT`AhjL`D^(b`CIur`Fr^X`A7LD`DghT z`B(Wj`FHsb`A_*T`ELbpG*VcFQ+P#CL`70eidm5rMX@MW#irO5hvHORid)H0G8K>F zReXwH2`E`gP{~$$DZP~(rH|5A>8JEp1}FoSLCRodh%!_erVLj`C?l0zWt1{n$y3HC zW0i5rcx8ezQJJJnR;DNiC<iJBDF-W4m5`FJ6exvCSSeD9m1#<ea)>frDOJjpa-~A4 zRAwkuO0`m>)G9NTS;}l>jxtx7r_5ItC<~Q{a;Q?LEK=%~1|_O2R+cDBl}6<-Wtq~X zG%GDitJ0<{SK5`B(xG%JE0mSWDrL2DxUxoBtE^LwP>xho1(c(dqm^TnW0m8S<CPPX z6P1&cla*7HQ<c+{)0H!TuLXVq@KNBKf$s!<9q`8je=6{20)GzhmjJ&R`0c>&0RB$k z?*)D*@Q(rBAH}~0{9C|(2>h48e+&GN!2b&TA0Y4`C?MDXZyFLjAoxKDg3up?VIYhI zArFM{AWQ<`0KiLhgy|rZgHQ{?Y!K#y5CLH^2+bh0fe-^>4G2eqa5M<Vfp8KCr-E=M z2<L!s2?*;!*aX5>5UvE_8W64rVFw7efN%#0_ki#K2#<pBBnZ!f@FEDWfbcp9Z-ek2 z2p@s)Dc}VS!Z#p%4|tV=@GA&^f=EE*L6ktWf#?D;6T~2hy+P~?c#K^f0^)EGb3x1l zaU6(~Ks*q{5Qv2!P6Kf|h*cogf;bz*LjliUi%URU24X9S?I3o7xC+FzAgUl91LE-@ zo&@4)Af5^01t6{maTDM{Q1L1duLbc25N`tUHW2Rw@m>&jg7`3qkAwI$;GsqFB@kZ) z@l6ol1@QwAKL+tL5WfQPTM&N)@fQ&P0P$~-@ZgsWk`ts%ko+KJgVYD40U!+lX%t9f zKpGFyWRMO7X(~vCAWZ{lI!F~DRf9AOq=g{WffNO)5v1iHb%3-Iq%|NNnQ}LTa;|<; z1N+`T+|+<aVVB^m*qX7zmD_dwLvAsBSD<!bYA!<H3)^C??XleCcRv?Z7Kij3o#{J0 zlP-x+E{c=>0N+i%-)BkVoxtwUi;LP@n=0#YkMqc-$pkNt6Z|ORi0qBvzv8t(fAecu zU0WN<Mtl8qH$FGV$$k=X9I}683uA5gdb=ik8(=D9_;wq5FA4iu#4&Sk6pXXud%bQW zE=hXbWc=Oq-T1jSPVI~T;tR@>hiylk-dFe<&7R^eNm=8s98LVvT}^L`lgI1qmhFxF zztWo2t5kP;^JO=Q-yQD)p1R)aO!-$`NHAQiy^cF&raTZQh!^qA>M@?FCFpwFU-Ae) z94Gfv#1Y#YxqqX-3HG{~BfPhvN_$gedZYA2yeq%__eMMUb@lPLt)~e8*?1Rz`-k^{ z{TpeZU5sC3f)~<gH!O8iv6tdR|L93Spp%TnJp{Fl`Y);0>-9M4zakF!FN}WbR7<(A zoBAwz>lE%q3$4PJjdqjCJ9@`Byg{>WZyozr({2yGF+~GDj1y*ia{8sd`#5>}eHJH& zuf&+&V|>Qnt5@0C6pL2YHFcLQzIm3qEKclMB`?yvWAdA-lNtRXPSg}}RPK$@e>1bF zpX|=uuW>puz7ul4>2!Yq41FI;@>|oZqKom3B`x*Qg4RyFvauol=7SW4`YYZcOT@8w zZynl;Ca3KNy=EtuzL6$UMn4vHwrG<H-!YgZb_*A$Zu^I^-V62JW6ZdIb-jQyb@EzF zaiaKo<NuW9-H9eo-l}PZd80;+O6x`});M)n#8LYn3Ve6!MVfMJA!dqvU2$R=|M^>n z;>1GrG=wjp7o2s|X$!spSevk(h~v<`arAHI4i31HGK5#)>E1NavjyLUtI_rS!;Lfl zN_o=wgf!E}g0GF$Xb1km0sI@D_xN)4<QX$CPB{1v%KL8!Ckb1ByL)^ic58e0p&k~e z-YepmvA3cAXOVYL$GXkYQE@^!5eF8XyS;*(mWgAzhqT6)=KhClCOFn3+-}6j#fkTg zI6C%5{GYi@(23=yQ7q%_Ai4Cm&)Sl36W$j}-&mDA-jn|y^3FTH$*O<YcOj!9kTgx& zBn^TrQ7lc<bOb@^1Z21DRl0yeq0p9DMh|<5q6|e)M#YJsQgE-wz4zV&_uc~fUMIPm zCT&U;;m05E^LZ{TCHbE3I{V!BQFZBfGCO=<oeou}E>er*rNPIY2%n(evl?lqGSp(b z<Qiw4pvUX?Lesp@Fspsgq*=weyt23~FK$|Kd4aEA^1ih#yJ%Wz1-GUJy1cKd3~ycf z?{Bhd*jD=n`MmVCprT;~8>p6j{z+_C0+O)NkzUIjwcu{N9;5aJriI1jH1|c*@=NCN zBGYnt%U140mU@aV^8VQ;uY7XP_{78%PfAL>E18#^CM73(T=6M^&K#-Ab)M7_B(Jc@ zD`~Wq8mE@&$~E>o!E92)CYM#x^U4eI3hU)azFLI)#9y4+Ff#^ErX9#=Br_(dB_^GC ziS?^Uy}!G=O`8@Nx)Qa-lqS}W{#7%WI;*g_G*rtoQ!TA~u5reH3tB+FAFt7st*^WZ zr{0iswyH;uTx0+LrbnaeWGySzGA?YQQU5os>~RKYRcdj)niw<ut3ZZuZNSZHb+1Nl zxm+zhE!Q~azd1A@u>K!IcHnE&A~SN0#m6i1ANjXlEs3i?%Sx>%oyN5<L0!nDssdT3 ztg<H5tE?N<68kh^^1q64?J7;}RNc2mr>@l08#G;|Dsb_Mo7}KP^p5=-YZ0$eOYEO( zocW)l+_3E61Rpe`XnODd>Y`jd(|4<i49qo_oB~B^qu`$ig;*+Ud4sCM;9O(=DbOK! z&=QpEd)1P&bB&AtbIGA9n|x#b?4mgCvGony_#t;-j$Fx+ug@=?&X{>{5gQ-Dz1Quk zT0?V<laHs?2~~(7cZ9AFht%?ipLl(!?~HnXch$4_UbV!Lr)KQPRRX1Dg`v9chtz^c zpPGtToBuwi`>vG>?eoV}MaG^opU2np`O|8N<C_>G{iB{HV9=T6+smuh(7d3QHsRk6 z(w!b|8E|>r2?>c#k1HiPA;BFu(tA~vo8QFr>)%-6@1g5YeVf?QYWbF`OyQ~7)C<g_ zP|5thTKvRZ<AM`xH|o{XxCT?v{Jiqwg7P@|vT$$nrOs0Q%~}0rmrqokCg&Q<PEe<& z`Zupz{0kCwW8-=m_=T#;lqQx&PB2saRXuou7rM58tLjp6YP(%^8{hY8d}i!Ho!?KY z4%2gu(~lRK|LBkUU4Ol({H|&-BiESK^yGbpZ*8@229x&`x3hD_WG>4rlz;8)o!9e| zGq80yrb;hsVgUbdY-IUQu9!En9n-3rT4Y5Nd#(Sb$bbf^HqCskY{=|trCyEFe0CF7 z|EuvsgA)aT$<#`{8>RVN!g#!7YP!e}TTiVbRG-d2HA|{okDSM4Mxjr-w2D#-U(m$Z zq-oOv!Wg*cQulLE1#K0h7QE>Hs_9fi?A<jEif%hqld2|$3QfB}uAR>+XWH4nv~+6f z^unwn&NBr!39UM*r7dY9+D(@h;PB&2iGoZ$Pc3{|6VX1w>g%hvAv*6?acaRUnpjwA z+UkKt6?00<rg9D-kB!TMypo(!&h`f{&bM-_#jR>$*SP882&v!C-aCSV{OM84S(9rV zdc20=-}tkU6JxC|RLfd-GTXi5HxB7)k?T*!rue@b=#0plUDU9u_E8nOtcl5V({c3& zwLH#$>vo)PCZ(Q63~sIls3l*1;xm|r4)AY?`+f*6F<UKh<B2a0)*tWIUm^2e16nw^ zw3tH(!Q-b^Bh=D2=NgwDFSC#1>H4JyjkfdTa&xXa-p-#jkpmIxVB5P8og=%fqBQUC z>$jj|Rn@L+VjglF)f$H4I4x+s20TwKerv9=^mv~6H+4QB8*7I^bvr_#hd~onHMX6M z19;vy$d|_r$SdG&%K?Xl1MZ5O;X8NLZASiF`D4I1wAEBqm1}a1v;VV4>SvA2*&=z; zpf)|c$5qnGO7jW}xTul5trwpesx~`vjpP5bHVqS{Zl5HmCzz#{x+~XMbqY!iPS4;u zVGd3xD&+umVUe632Dc*fRlTZD=JIo}HVxJdf*iwb*4_gddrs;>SoMgSdNwtvz-4NI zH#D*6^&gstVE_BOs(OjIT2<tx|NE2(KDSU$ul1^4x16j=X?$Q~aD^)U){}XR%2y4& z1IwUTU#S+hKi8OZyjs_EtQqI|+S$ftzT4HJZf|1w=>(ho;3^fIU_*-<soc9%oerFg zKA>S!7p&9qtNHb+DhHdG)|{Ywjz2%YMJ@c!Q`6)R&XZ>=8Vr%R=h@q`-F-60A+_DV zHv`mL6+;gI4ywi9dumPu1?(yWRk?fAV(&khkCFs$CkB=GpjzI8xyCuitKuh^Siw0S z==G3Wime`1)p<DAIPG}qG~MFxiQ1Et|5k~oR3#qyzdDlPZ;yfp7tgDDJeF%*bUbIA zyx8~`!a0*y&`7KJimKHUC-dxbg9fNxr~0N^=u=HR5pkTns6X;O;rUWf{drGS?3w>O z{%UOHrJg4~RttPC*O<~EDQ1<I#T8F4D4A7Q6j#u-YaF++c8ib8FJ^RKUQv=e+jsUZ z$bipPc`uxrQ_OXZdp$e8QOkYlWDaBk9;ga3QoW|U`72G-=zmm`>L-$S+W(Kv{kQr} zHTt#x{NQ82A*&!ukE$iS(ZrVKiB=RId7Uv?ZsMt@6Q;;V9puS`EFLl~58fqi9i}St z)=A7Q?*uW<`)6bOhOKpKx$oo}2Q{c80jH>s;{<iM<~;~GxhQ{L`Q)P6eftKr&#li? zi+S&4j!^0r^vmUwt-+7x1%|q{Q7!(1|GcpNPkd@oOZ(_wPHPeqlj57)Yin&+rGIj2 z_Y?iCQOGf0>$a*EhflonG&RikclGiD`ub1X1%<bxs?6vAc}<_mm+$!owsec956GL& z&D{0Zby}aR7Wd_UKL1H^@_y+4dHMAoH*eidE#vEx`AB78g{k|w-m+Ee1hwdIPv-J| z@cF>{MW(1le*d43V+Wpb4a$+8Y7sv+aV(+fhK^6v4wvhkSRPk4d0xfjX|Z`Tiutin zKHXJTG^tpw3)X)es&$&G%g_J!>oLKj)!>0f>)xtfzn;wTs()*N-3%TOkX>I;VEU_t z{@%pSRnvi?HZ|Pz3@U4gTGpSZ_B@C>L=W9^4p((J`hUNC)7Zvy>oKZMf1S*ekb#w> zbZS-^qaN>jH8T45uV4Qs_{!HPr#3G2`?R3kC{lH3mTO#cyphm98u<RZzODYcdA({m zMb%7mYW8`8=lnsZn1dWts;Z&OHO@VrgN{>C>(2**CYJv3@<cg4_8sK))#st}W)w}# zD+qqTrgep?Pxwh3G6%Hnb=xcT!ZA-Rx5dd=2deK8IYSC{npuu-(<hgf@?2xRnZqJg zotC-A>=O)&nys{-e*3*A4C)!aR4u7>6FWHnsD^|xJn+f%0X%kBHZQoVSfwgpY+~#C zA1P30^sv5-PLD28OEjIT*>C~5&Pdb0=R7>Gte8Hsegk>As)za1EV0&Y@di75i&|{d z$y|A8tgvlrVb)yZ!2g`cb;Ig<NxV}n#eOonnovnxKccB+WqI}Tc#o=sBiHz4154#Y zr<^8|?-ePJ8(F|!YBydF<$W`ickelaJ?IkNqE!|*xFoM)Vrkj5+U@dgGt^(i)qRFr z>udix-q|gsTY2HsxSV;6N~gv3FU~K^E1MUWCHEBMNv3iNDJx>UHoKSsZa42qPwxpQ z^<J~`xYVEz=auD`PM2Q^{n0+&H|5Bw`SikihdNr{ta{+ACYqAt^d$|u*uVjYY%h=V zs-D*SRR!8L(Uklv1yaijXBAH`4f&p;)-`I0?f>t`eT|*fZhg0^Q^%9~=xq^ASV>&z zMD;9Dy$bk%T4v`{^)L`matEH9pF{eU&Z!+w<du{Vp0v`r^;_6SRJFRC+GUmcN5$(o z=SfwI^O{&z`8PeBzfZ6Km_>*^rl0}ebE-1u|L2)m$W^nTvR+op>ej?&-oG)N@l0UX z9#q~NYI)9+xya$4>Z%PvaA*3iTBPg$evc|}-@abPeWYsT&NWVH&=&<P0RJ1u2V`9B zE^_dcI4BgKsTw4m%%hZ{%dKbo*J{ZrC*yE#V5-$C=LfZ%?k8hp6If1=AAeO#>2Ycf zKGdDM2yv{s^%1r33s3wIef_~y(BzN@3yb1>kD;hdx$nqmf6iP7RWpO4YSQcfzM2Ie zb_xuRL91$&)`V8a8E+idKmN(H9Ded16V*xHXW!X_V(m@-wqB=aXrXGAaT1TKG}+c0 z3~H%axyH&<(BuTKX9VveG;%`DU{+P?lWUA^ppx7wE-B@JzkkDcVudSzR&hyTaOT-m zAs07M0gn^ohJ)JLhRpXbvg(CgRy3TY7T*74ZWsi+vi5KF2J?mvYS9CmIOlkRUC42V z^+A=ai>k=rlQCOw7>Zi^y>qiTZ(@afpM@b-)g$|43~~RF9{$rP<W}HIDTCbOQq>xI zDmq&AjdlUashpv-P|h?Y8oDc8strkoWJ8L9m%$Ggnh`=XQfNk18!j;PP}&<V6q?aO zGp5QYG-In6`C12;6;ESkTAMFJi>Gn<H|OwkjUDU#6Co+imn&l&j4NQPB|C5Wq@r<s ziVKTUOG^5dm(MCH&oy?c_a)zRnni`d-|CQh$kJRtqS!R1GCs+9e!F;=%e`=9rN`qr zznycTdclODk70ncrmx{*Lq9`*p&2hUxk58RX!5EJ0}X?)hIiTL3r&HvrtoxHQ&Teb zx$_HGjjc>b^dw_WyfbCts7klX&0p&58Dp3r?HOwrXBcn5l8HhyNoXbuO>wm$&ybHj zg+en$Xr@YgN=~OehbE>xHzT%kRHclKJ0Wr5aQRc6CDRS%(vnic48u%Anb1rZno^;e zAv80q4Hbr2STaXw_<gywq~dg1a?ttF^A~QrYHVe^CnX7EoUQ~S<4TZ!sk28IR!Do6 z7?v8A8F(ZAY@xw`xk59q+OX2F3VYTF&3vJ$l=dt*o%Ym}bkjZkcs2I865KL4N%7Ji zSBfjpo{fg9q&=Gqn+;nGR|?G{p;;_6RYD`G4O<OYW6yS>St2w`r9I0|r#%Nd_pMCn zeq>B#f-^;i$CHdX@lJP;IoBI*k>=cBxY2Nvf$I@g2+c~NStT^9s||Y%w_?tIp&>$R zr8(<Pr#Uric0aSm)N5=d?_HC1C(+}^o&;B7kUe)B9+38gY^EPHJcK>m`><YUE|vCN zR&}0iE}NC7WQ-Y8>GsGhj!$-Z-4rbLNyBrEM*Vri3y7tCxm;+jkYZ_HI;0-#IOzBP zWoM90@k!GCu7tWe@w(w1DeVozn})XxZwt*Pq1h}nTZHDyYQwvR_mK91&|D=nTcxzC zPp8ul>C)S-d-+4GNJ{jzzTPBq%bumqo-YmGNqfFBd~Nu~@U75L1FjL8YlUV<wc&fi z57_gQ(CieNUDBT2r_-LAl8pE_zmj!A*6R3pw?_s$AwI~QW5#CEoWBfz8x<pW$y_Hi zdxYkCp}C>j*xab`1^Y&!xk(N7Y3%BI9k_YsPpQ7n#N|n>?ca?CqZt#7Mq`B0WaQ49 zTZCq>(A+9C`>Kr=W0ca~Xce0MLUWrm;r7!Sk>cM+W@n8aS4n%DEGvrJ<yttpk{33_ z2lgYz_QrFhMIDSCjh&30h30_J)CkQ%p*d7->|#6@i@3JuPNBI=T6Fj6wCLcGcV-+} zoj1DDBgZI7?nIel7#C1ujEP3?Xfo9J%Xop2(WH^l<h??3pS0$F*`CytjQj1i&bf^0 zJc)QIfl-||bLpx4715Ys>?<=jROe*8*w_!T1BB*5p?OG(ec0Pfb-JtVpS{14gGJe@ zCVAxODn2njuu(PU7)MIq4>b-m4mUFDeMD#;6`IF{=J9IdDC1~fg?K_}o|Ixw>*(rW z->WzD)phb!h=jzt3Q=U7B2AcRoMfDAEEbxlh2|Ndc~)qit2RzGmf#r%TF(p33(|xa zPiOiZ>N|7d>i6HK$xV<sL&qUIB$qQeD1qi07fO5P8Rr`-jSGb4WubXRXkHbX*Q$++ zjEk{H2+iw4^M<tN&C_YmfnRRBcB|&xarE0R?}Q{VA)X43K{Da$a(AuqGHFrBCToN7 zaxCH+Cpyb_q($#~t3>h9o{s64j;ZuGkwnk!trE%cL5|vLyjF_6+PKZQ-AJ$WzR=LQ zeke2_RU3C0clvVoW1;!vwC8S(`>JOr$LhvbCZ#0ApWn{q^d$J(^IMF!Nh|gmZ#C{S z?iZTFLi3r>d@eL!R2y$M-hp#y48IhbucQ@UpU!aCT>tp{<Hrixb7!Jc=5I=hQ?}=1 zbKnfr_<->dEDGIJJ!*Umi)c_7OME9S`rg}Ab?);=T86<_x0B*M3rAEY2W8N6#+RkY zP-8#iE5=t5Nrm`PXnv9+f0iN{`yDAO-aDo;$(2BF!z7uimXw%6KU9~P?;1a9RMU@* zpCFcK{3<lRNwL3sHSO?{t=F&j)2KR=F*-R}CcNy?h-zI-zc&8RsN5foKlw8APoX&? z<@&~yo%=kUdevWQ>*h-Fr^lbhzY%3TVmxX*X8cQNjtLEa{w=ghb%YWTrnHY}F0^4n z+YC|K=BG71@|$I~i`jx}5@heltCYQso2<Zok4LnMFkwza>j*=HF(N`}wL+^CTD{PQ zS4Tufn7y9So*}d?RL`8g0a(p}!?q2(2gp&r8xve^GDuxxiD(<qvC*J(is<aKqNUKb z^2fI(@9)(=XY7-8hi0F;lT<gPi-?VIH7YJ4!cC01kIo>pMj7J>Z~K_HH{s#ymX5CE zz16tdog}+<-d`Q)>K+lPNDVm^iAak`M{1_fMhdN2O0{_FjIQtNKV6Z;5ZaSOLMOWA zjKH1X3LG&+^otlQ#fF;oM+}L`_SqgSwAMP?OX9wN@6KhkejabPmyqJ`ydy?Mj7M7N ze8`QM;FD$-+L$_N2gY70mPGn$O1vxHACyTEB~sMnh~kJT5mSY>jnJMYv~7j9U3J8? zi0RlnLuk(y+V;}k4yUuG9EyE<UFN3`$pK#iAxn09hXF}$@}jP$%#T<s&8du75V0^~ zk<fM$+Rj3Ij?nVUstDop%(+5)p6Z#?S5prB-s82ht{%1ZW|&!9P1Z$hkf{=CG8}Pv z#1%dh&KKHPe{c`!G6wyb)SpV1=#mRH33V-D#MTIJcOSAP+z~-{AHi*laYE~q@s0P@ zlG~fzcNA%EkIdot1gESgi3}$K9ercOt!Np#h20miAGx;+ZGzCcrQAfX-2CnBe|KC_ zTl<*)%kg?}HMuk5zDA|qAMt?C_GF<=@!MXLxBs@IKW}0cB*i7WlN7YA_2gp_PdDnx zXCj{UN$W1O7x<+yy^lJ!JrhqllaWS6sY|U_BHlz=#H$gnMZ6xt#gjdS_Cle(NN9Ui zN4ypBwoh8B(59)<PG4%(T>rs&4{tB`rIv?fu3Cp2j`&KN@L9y?5nn`nDYO|vOKX-T zw7sh%zK-~YpnWH_eT25J4BEw~v$7vtyZPgUMEjUZSCX5QPDzxNJ;5p4?YfBk5%E`} z5&7Gs_#)C@Xb1S?i)YULeB+>za)~)H-d*b$lit)4Nv3eq8KxE{E;$_}w1b6qh|p$N zn_8J#`y}NE?a<R6+k<1B8TPk_u>7Ck!iacRUAJJena;wBkV8mQTT?rq6~l#ggx?=5 ziLRYJwe{%Agm^rg!s@%4DyDNx=Sx|kS|L-cshiT?<P_RbLOWWf${1fim{s`Lv**gL z-@6{^^v=`bU2+`YALN;mOcx+G<gCWj!_?EK<2a!m@7J-W`1f%glipSv$^?Hln=(vt za&O8sWtn=L$l3`)n<upSLR(O6y4b|zo;64<|1Uc2L92P}tKyQXa+Xw6<S2%bzu(Wp zO=F}HBTOSrqfDcPc9PIe7TRK=ol<QYYZ~V>f_}N=v>S1-{{ijHo^KN06mRCybo;HC zY?>yc8fx}!nr<rfSutH`OZ`zj@JrzXPxWplhjuPG5n>U$F0!*tm52-3)S4EU7W%}^ z6xuSsxSH!<e)v)6s0I~#nQ66j?{d=$(@N7Sp{)?wSwcHoXy;U$)|l3k#@szTS7_%U zNjv{^ws?o!17GWxdI`guL^lgsDc;Sa_+$^Y$KT?awwShIPRPwL({|G}n8WqS3xsx| zG-r{ll?R>sBGSef>2>7*+7s_x&WcZ=ggU8vOgGEug&HH6ZZYje>OP^Z5?UdpF7fr{ z*EIj4?QS_nkmE1*?PU9$=v@=9lUrlDyHUCKnC|t3ahcFAuM1<|Uzg>~kCjfKJ&JcF z`Uk3}|CyeUriWS~G(Bm03MHQr+Lc1PN-DY9t7OU8b>(~J`x=g9mxo<nw_H)JQ}89z z>y0Y-hUrb8f@_6#U4Vl7_fJUNHjV*)f_EDuA;~}9FnwV96mcQDSJPqBXQ;>p)$4^; z?zL#Wdo2goz4J=>>WyQWk;qCQr#bl1lNhwcX8O+bvy>ZZ<YD^7^s7(J%Z0XXvxVyL z(9L5eG^h^8BIQcH=`YjYkxC@<-%UchS!lNi?UmJ$%_CXKk7QnXmC(wK7VT->XsMaD z*mZEpA9C?0S+4IUCU`eflam6cRguO>3-*LeipZ$QXzZ~G?RKHPM%r_&FDb?iY16hP zt(ZrOicd<G<IsfQUBJk;k#edU(&LexBGswtPNDT~;CPoJ@c4s2E!t4u<B_qEa+Vr$ zLK2w}$t+cNQq@9xoj=76{N8VO?{G6iAGb^cxv-;l%8?gD_Ci?5iW-?3ndTFAz0ls^ z7sl}To?D05eRUwg?H}<(_Kh4UMTJ^jj2sj>7|&%3?M*^^v-I38Ue6W(_~L?ZV#ih{ zCM3x^AMc&$$~&L}s#N62$Z^OGInj+AADQb@@m8VTSEpi0(#P$e-|SP7IQy-g7&#SD znwvB?Yi?n;CahS5O%Y*JMOaC7WJ%;SpQzh}_IAIhLuHz?S8r}Nt}-z>#k(uORM9W4 zB61$$LQa|^=SNoh#2paY8o#)j19=Z`)LF@ughXkvGsR!mBbP+3l>Q6VW=5`xT#f%| zHx3Eyozj1IdHt8Scl*%J-+KE`Uz;g6LR^W#8NDHLbE9&%L|%#9twMW`(B3QM-shE@ zA2#Cb$2G`Jlrx}s?&6YiU9tuBH+7LaBCl&y?w-i&k$a=iJ|MIYO1TfIa?3yOY*y!M zDeMe#YDPxBPUybK0|<@WA9-8k?U8o~?f-=K5utrlXdkPNtcg76bLrzk`-JM!(>EnL zWG=n6aNH4Z^-M|fPqrf;ihK+ULN_3fM?QgDo)TLA|Fm?=GhVlpjLSOQubB*^T<&2b zORkZ+T(Xs_^UMp8uQuxL*CJm>?wdmUoX|cm<-Xu^_x8;fJ$MF7M+i+!^v;f*L5Gwg z-;ewRp&|R1$WJ2=BlL5jeMx9vmO@{VLJzKc*Y?>|yX;@&Vyk*2#p4dnjc+4=l1>OU z){p!-@)utiUlZEb)iAP7tjnr;bTI>3mq#8FNQ$qk7)Q-vjahDPW^V2ihVgIth1KL8 zIXrkylG;ymia~Ae%q`3YsaL4oJG0Rop|m%%5ciJIzANp0&ueeTA$xCKn8^5n=AAX7 z1n+jX+ZDLdZnl{lohF&vn$>C22SWRyUqhxzE8AYQoN1Cg1(6i*AE}zpF*iC*GRK;k zCYhZ=`?1i<-4yMoQpH2MzN3!jZ;+cb-nAO~HP*siNvK=5EN4zK%V|=`#>(8otWJ|Y z6WY)HI@a92;JUr%y}=yA+g5Sshu@DGW;sy`*;bh^HZxH&4-i_G1LS6j_G@o4<{fno zn|TJaOqVxrTq)i|W+_rjf0CPX%yJtvbbLmcecPbgZ-w?dzmf+#_xZHj)ff9hO>^Z} zG0!|viVBs2=1JzszO4B{Xn*vJV$tiNKh9b)x-wbDB!vo7n>MB93hBF0Yk=li=Gi`3 zKMU<Iepz(68`r*~8&k>REkW_P>l9mPULu8s8he?SnwR;6{U)@(`-Rn9|Gd3tMN75I zty_*VuQkgJy^w8<d4rh^J@ZDP{ZnY={)YCbHw-1?;#$vr(AR3wm5oF}s&SpETg`HH zFXXy~d54+RJu|C&e+lj1h}0?G8Zy>dzP-(S?=(ZUUQT(Yi*_M!nqj`tEEo4eZXB8S znOWRp(4uQ5bj|%nvvFkjVzaM(O=2s)HWr7>_ex12tMGm1`+btMLZ|afI@saWyYsJU z!PFu#K@N$N(Xdw9qvofOW`4~4xcLe5lR_6RbY}=%3!yu++WfTn8K1P4LRY(ka2orY zUe{-i=)0ZiZ2~!k87xow&3N4`k2{4tx?z6T%yB342SR5MI=OS9^X^<6Jo3e~H@0?^ zN7v+hi`HEBIUaXl7jHgnmaBWAtNGVvR`+DoB85(FUHJCTYVwY~b?2KyWE~>@$#r`* z=AX@fNKgM_{?+`O`FEj<61r%ivkIN9+We>ah)<SX=xTQuPM@c1rd3`$W5bKy>gG=1 zh@zS-7M<lx>5fn%TuVz!E1wB%gzl_5cNG78TbGCKk|Qa304m<?_KzMdW{a&c=UVKR z7@xFuLU(qZwESk;iP`G(Gr{Q(zoorJp4<u94p_QaIJsl#Ds&x$uA>ZpC$$|=&i?SW z(Tr<RD}jA|hGKGo+TRjb;w?!C4cTE>k}WAd{mv1(E_M1H7<<L{bMKVaCdwIB!08an zMV1U{ZK%^BmP|{QPuh7x*VQkLQyP;$i(56ux6Z&`cU>R`Sh5>cEyps{CoERzy7`4M z@P72t_yN8q)LAzHvW&5Kk2Qx{1hC{;e8-w~PN9ph6IC)k$uRfc+8)Qhz-cMAOh>Db zV^>S5Wrk0y1fi1~7{1!V81k0<jw8ISaWV@YwTU*zvH(dT+c?WY%Oc`gC3Hzbmy9G` zinkH&nB8IhRm&MZIbFCuDN*jQxV-CNbrD@*Su4ec+P$}|vs{AMONFkx(8=8kT@NYt zkVTX7+}ru`FrQP7e!Pq3Zjw1LQ8rn&O0gkbc(r94Vy_Xp3x)0?DYloIeRIctsrR|i zl_I;L;FiZyZMhMdAzL2HO_rN|zDyIkbiXfa@~>$#->^XqOMG2DyWMgKQ6W2T%bk|H zQ12e0%M^@1QLndDkIsAU*9Q$)?OhyT?F47K6P!U-KV*^P{LmUcZeg4++s3{^cX6GD zdB-YtP3TGW@WzE{RbB2pZ+Qi2mKQ89T3)ieEOh;aZh+7Y6uLpxmRBvW`J@dNx*@8x z)7Ls4JTG!+{|BG<`8mPmAEsMAv>e8Skn?oQXO_=>CgccR?T&{$a2Nk>Nt+9NqEZ6# z|2vCZo(j1rY5B$CTb|Ml7rKCL2j@P+CmU=GLc9l{0@lMV$D-s4mE|wX-%(0bn9z+9 zy3s;6M(D;?M>UUPg(^xXbmN3h?hoj4Pv?Sd&9wOkKJWK1D^y&o=WUi{;w5<!7>@dD zag;Giu26+s#E6QDVudQoCUkj1moM!p@YdooP3M9Qzp<m~OpxwLVK-ME5AzO(>IAoq zl1o$}Tb-y*QNATAU6IgD^k+1)m?hmWd{J)ppf8JzwJlgwY?NH23fU$^B}B1E6-Dzk zS?G$Tl2g<+VZp3P6V<$8FLz`mcMAp@-XlsLqzE}#jY^B+AVn0lxJ2ltNtx57%!BJb z(Pb`P=9B4SA&7w~hy4PD_KT9oC_;O4NR;mwg>Ht>&GZ|6XlB`;S>I%_YL)0+M@&xg zw>43tqU14(&@Rl4@*Shll?z>kUmEk5_uriJrB6k=O}_^xMag3nA$yakX;B=bknPKC zp_}6uMQ?K3EB#)k+461*r6kvdV^-9BgoSLZqAH^n;JQUZH&5v1OV?F;!;yFFl}}oG zHxJ~}ehLeHIL{Lw6p>|7axWybxoe`>3yHc!=oSjyA}MyUHzJ+;whO!BH|i<NNpvW_ z-Gh{%6Ejg)L|rMxhU!qFu8P`<*lj{5gl>rxyVRFFV}HK$>QuS+<CX(0dO?}u^^e3w z?TWfyN)9zCjJhG}MxRrc3*Cx3r|PnD7Z!bj!rnPQOUM2Q?T@NyRM^3&Lq1`vgl=_! zu#AVsmtVm_O=psKtv|kQk{NY>)c+6{@)%{*BT<iH_2WXfR_Nr`f$kEo)d_`9eDLix zqkWrz9#oU-&hkiLU8R0D>LsLx9K}Vw9QBG%NxJ>Z{7Tl`p1UYq#P~9jL)CtJ-;VkK zQBm(iy&Lsj)cZnrxzJr9bQ^_kQ+3pbQ6Kq4Z5FyMs;JZ0M^#^b^U-_P`AlH%*l)r& zQ9nu(zK!}W>iei4gzhS#+bVQd3*ENrsGp*K#>c-3-FBgqtNS`u_fMY*HJ|oe8#7`M zYo&6@-orjR)sMZgfY?SW(ORqt*>*+iqV>Lj>=e4XJ%vN1_qL4v>@DB)ziuuP-8woF zNg>;ZXmhkhX&=p8ty<{ho`P<VH}~?x4)px!Y9`h3PTB;9G~V@`q@dM==r+;qksGps zi0%;G(Wl`JLU*G-`wpJdb=aWN+o*3&*$48T+uGnoca3%;EM)s19UtvNNw?75EOfU> zCHHz;n{|Kxu=c4ZQ8Gy$@Ip!1igALFCZbMm_vnkH+)xWL(Y>NmeM;^Vy8V77Yp#F# z!JJRlsEs!3*y_MNx=*zCq0dl@6VU^s<wKt|+P4ec9ez;<I}W*dz~(o7qBxN37d1Ru zZsUiXFh!4zW*a{`SLkYl?x3{xkhGQw(~V(w?U7S@X7OxwdUJ+{(gKYwik7GJLq}w4 zG^g~XhIa|w-E|sv?(=T%IoC3!mq$oFb&Ds_<<WDcilH7DiJlid9~Bn}-MvC5AF<GR zAF()i<lRBPKk}UFIFIb)gGV>fOQPj2NXWK7dQ~*LAkj2|4+@=pzC!1HzJkX#9)ITM z!Su&2?<s;L?~Z2@gPcISH$=-_kkEE-iDnlhnug#Jp?g%yeaxFYo%=j$$ob4$S3E3_ zjF3ls*xRd(^^Rz{{}Hk;iQW^<{zvqULidEwJt-wV<qeRo&!s8z9$`V%CHqnN+zM^C zJCT`H-2!m*zG%4x61pzdM6(4FeW%bpBXrM7xz9<tHTlYhizmmhw#tT$l*N%>1jl=q z9Q^%N^!?GYg9+{0N22LqqUm5>5V{wo;Fr9DOUC|o-(Lwn7qBbAYGH6TJsT~1m(X5) zIa=*qUJ<%i5vd-q?pRRMrQi5*mC5p;5z2D5$M4d&qh${h+Vl^j)gI<`p?kwG4%44| zvZEZPcuxg+68+s(^cT_JHfrv7(cfe4k3#pB(7i3qeaC0+xCgK5eg%GXI;9`oiE^=@ z>26RB`aSwsqe}i2{kPKI$|U1Gp?hD-{lFKWYa%Z{`)nqD@p9jQ^TDziVs;+bnp^c& zd15SNK3Q8?eJ93r9|_&Ze&boNp4jsK*U5Y~C#1f0C%3E?t6gdt>Y)s4jMd?*=bsAQ zVZXGRgu<xi9o1b^xd){ty0wF~OJk0-o@+hNC+c&d`=U-%$+(g+>mt0>+{J2vUsSwR zt|^7KG1<zRlC`_geI;~XOW%DXeaGg;PWzZAr0=}D8*Hn~o-i@!;ZbWZYo@d|)ZVEz z%i7zg;&(##eVvMVGtGadY+<gI<n6yw>W1Fdfz}+Pg<Pt%4z&(L%Mn6H^2nzgbl#^N zSTZadnt2aedgL>8@d@5-B6d0gcQ>r#toe;<Szs;nX~_WOw*W2oU$1=E(YNSJh<PU8 z-vC*sT4yvWZl<*iH7kVf525>0s(Hkhh|TVa{Pxq@$9bHryx_~^pvOk6^R4p0bI4JJ zwaO}dS{@U+zx-MrDm}daj>P`HR-L(rKisRVmmtcz+PcQN*1AsU6`>Ck`es7kyxO|n zdMO%i5PFT!YZ0Z_ozCIbAyZ-Mw+4p!zDJa~<6e4(`Eo!XV!hhBqfv+NwC?hHMjtNp zXZSr+lULrSeO#qHaxbSiY$5uaW9yApxg}z~$$GQ(7VBQ2KU3&i3Vkb~Z(VKOXZ3A~ z=nX<I*X(86dHTkp2ir~C^+Coytni%&@YJ1iwccZW5Gz8iDOw-0K1_%o5qgu*N6HYJ zy*1j>e8>xTZfB{|B?o0GjPPg-6NC1PtWQ~=mtsS`ZNmD3^+m+KEc8)AA1%dNy<#V( zynNyC&J0uJ;3vVQ9$5%nv$MWweNRdaHL<k5Z~XwN9|^r(=;a=S-r=n=CF6>3d-hc- zwp(s!&<J_=Nt{9ZB-YQZ-$=QkhJDs=t=}Q{2cbVp=-W!U?WA0${g34RvDeqL(m>XG z(8~Io^=PA-9<%<Xw6{^0+6#RLDY2ufY1vn4&Akm8otKMe0r6{cazfxR$fmP-w=hCA zl(v>OwlHjDTxX#_N6PKum75<n`Gc*`5Uv#YEEq4MKx|S<e4t}(7MtvCY*Dsoo7H9$ z`tyXotI(e>^s&{p7@M!R(RUO2IK-abT&_uu8=8}x&ZEO}E|rw*Z>((R*t{F>p@L|O zwXyNe$XFjQ^e)u~ZxDa$_V<1U9|>}$%3W8vZHcz-I3(m&k?jIo51%l%&?owZ)fE4d zyJ#+lomr=nO@+H|rNNeN>(f|%+4|ZpCTjhKK3VAHLkxP4nqQCJ(Dr&?lPvdP>Lr*h z+crWf7%~w?+D7>lyg=xC)G3&^cH?8eUB>8$r|nQMrEV9+Ho;cZsI-Z;Nj_;83ccI{ z@Qnj&^24$R9hEO{@a>E_Q~aX@+jLvGG&j^fg{{Ii3v=fPeX7u>NpsVsxxA3aweAiF zQI*>i9%lTs-U-Rn1AljETWFK}?jgq>wxu@q-EAv`K2zxBK7ii44{%6#u{-+5o#^OH zk#iq;yg)80al$H4@H$(gkJs2PxA`8g(f1Ylx}5+HyLh^_yP7)1yD-q#<6lL$ZMDh$ z_mEALZHJBhciV2EC))A}1pPp@;@`CU)3<z~<^+*6JwCYB-)QshzK43<f^DCTuEut| z&<_@Rxx1jx_ByoJftzM8zZ=t2QoMWSZg0Dn60`?myVE8gt_iucZoA*c!!@>tgnp>d z50i3-`;@KhRM^bsQ&x@)IYBGu`E_A>-1ZDIZBN*qv^`~eTIfd#{V1UyE%almZO_`C z^QF>Qp&y6L)7z9BG7Ng>anpF29z6Lc8x#Lb#`dO7_B0`f-?sN{^fa<D$rbtusufJ) z5(;hFf=E(05r?NF`^Vq5&um{ySs|<HH@0u_^7lfYFZ2b{%e+YnS$Rh`{I+t6&&zVR zQ%>AS;5sk=YC9rjhMKzDj@phP^KYS_DD;!0%*j$F?_8Ms`7evHmJ>YmFNp+?<;Ilw zz)6f<Yj1&EyUwn+huhB(`YA#`Rp?8Eep<EtOnXbEy}h;2PZ#=9DR;(c9n?H@_2_=a zyL~>A3q$fOA`?=-kL*@^8*B;rk`nt__O`wlmI-~iKZb{T9cUiEZ@urt9S<hg4utKU z?Omn2L!BJ3pKp)#iJB$!v;CrKihr$mt8#`<y~Mg_n(c18M`{&n3}f$ZzW@*S6#BVB zFP}fq^ZbF_W*hf$?7i}QVY2M=;uE~D^>HNyonf=5+r52ENV$FO^f7i?odrTK9|X{Q z9|S;doBa3glIu;fiE#Ov9@ZcNotSNx{Y=QV+&<DyKVu&w^i@JHp9Ii*p9J9G&%FgR zis@C8<U!UXkM|u>&Y;HJo@eJo);^=jo^LO(7ut*L6YZ1ilkLU!DfX%M68kj!bbG0N zhJB{J%w8_^%Y>e`eU;F!5&CsPzh3As6Z*@AexuND7WylNeyh-L6Z&g}euvQS68dVP z-y?<3vd^~9vCp;7v(L9z+85Xt+85au+pFxtzQn%NzRbSdj@TQ7exJ}E5c<1>{vM%! zQ0N~O`X`0{IiY`E=ozNIF7$5;{Rcw-iO?Sw`mcnZ6LA6e58K!JUbm-To@;c?jh!ps z<Q`j6I;neHTt-4hN=jx*a%@skQhco2?a7Kw%SiLYCeb0KX1FpF+?jzl8QU*YC9P~A zDJ4BUGa)%6D>lXH&Wv?)mNz!dnUNIB3nMZ!Gm_KYY0k7joi?eGRyUNCnCMC4AWLip z<A7LqMrLMgiYtphQj-$mGd#(jtORGEq^+u?wGAYtxp?Fu6HVMHsfn@fB-HU_c;aIb z?@UimOixQlNDP#8tt#n~29jKfSuR()GbPqZTO8}=i?J!5__Wx}_>?qfR%({VnVcFZ zsalnEX#+`FY-y*mCK=1)nrTQ%!D9)@X|X&_gsG_sSy`SSKi#NG+R#9flZUsH-05kt z$!W<>VwdiTO-)L6;VgFop-4?kO3ez?=~h+J6%8b1WMm~}rYEOLC5T;CY66llF)7`d z<j!(sIkQ~uKuLF~k~TGv<V<s?W~8NO#U}HV39-xY#HMAXxnnbvSv%qkZ-zT5Gf>i< zs-!IqB&DXg<5QEJZoHEwbwV9aQhI7^T6%g?MrL}ND?K$x(tWC=s~SpjX1G&Wtc-P~ zC1%CC)05MQT}o<fdIDLMp2aU*L9u&Sm2`CjNi4p&JgMoKu?ZfR%*=FWETep9tjn2_ z=}u24tum4Vt$SRRw7r2Ok2@<X(Ua+l&5}ag8F<{2$REk69Fb#;nU>*650vzbD(Tt= zl2S8LQxj4%ow122Nn~c0hb&0W$c&}AOvsGSN=l6n&Vm<JNjn=zN=isdOh|X*Ctf5( zW>V!m8L26;Nr|3#`R0p^q>P|^dQFwIyMZKEMq*YPtIx5i9v4}VmgtU6MRcr-6z6eg zlFjJ}wC-(H(sd0aIaAWoc>7wqR05q65Ryte5bMlJNz95*OHa&j2F30JRnqkhB+;y; zXK*ei*2$J5ZGkf_Hq}j{X2yFm6S7>%@ktrU>Vl;GWBaE{mz{Q+(;Ii%X;E*I;|N>r z%Q|ac2FeSceRpHLB;PJ-|58cZX{YVIxytaWa%R{A_HV=Pwtr{;KI}22hkdP`8`g|P zb7$mDFC1EyH@&=|tawJnD0v^n+`(K!D)iJ&R(6&P{Vgxsf3^RnoT+VR|K0vat}$X@ zPT$&(^)H$}sbVsc0)96<uVhw{kpb)8my~2B#eT$obWFfM@3J3LE(rXE?^A!raKlwp z-;B)urIYF#v^yp&rkQd<qyL_3jLaB5wEnkL=f!AZbT}_YEA;z!#^{CqwtwKfm@{!+ zOiQ7^J(Tk<i;1lD&q|@c!|$IMi~SGdcnq&C+8V<u!Oj@g2Woc4#0dSte^PW?S#&$0 zKNPCyO)=-x7QI^N?+hwBpx~}Cv9jRvh5qiH%{x@F7J9sVsa4k%<Cfn_5c+#}#v}?o z&&C|@Yu+@A@kn*M3;q3})V(%_S*tITE)n_%>eNlgQxyRUXT>lW+Zoea=pWh{!_<+D zuBM9~Ad4O-^#2Q0bal+I+M+KN`bX-D9zoIMw?9auW5(76X`Ilr7v{5Uf)t-8^pA%U ze`Aclj<BTrM4fnYAV7FY3`Zn)#!M6Xr*_7a3jNdn#IAB#Fy474RKd5#RMy&ch0s4+ zSMWmYnix=YRSeUAHTirwP#fnJF{}Ll5<?pC@Qlymb+TXr^<t=k?~Gye=!@kRp?|5a z;9!fdjM-Xe@zp}lLo`0&*GS>l3jM30gx?plr&jn?LjPKwaI6Zj>86-l>NMXg^l#J( z-!FyVCiHKH68><^owdSI=&d^8!J6M2bH5aRpU}UvGv)!I=Y?QR=ivWj!H)?2d!Y(` zJcjwa&t=<%{(XPJ&Bg~=^?b~WvS45Gza;b@)>`$d6#kmfe-ujiGcoVh3dgG-`-LlG zgM@z=^RX1pI`60dqAB=1=1cjlFNFTHoiTJGpZ^nId?(fYUg*CFrS5AnztyVCg3gzI zb?f=!NDP~eY8w=kwT>`HbH7RsjnK1O=1nYzo?;#JRo{jx_5+8Zw%F^1{<}tsbwoNi zW4O~{7WyA{I#_1^vFf~WbVdWY|0$=Uj9Yd`bFb9&*rFMe=as9~$Pwc>OX;%9;c&DO z`k#gVmtBsw4%+Qsh5k3`tq8u)ZBtwrRogM=8ZG|crIr;;F0SAz^;u;_xyJT|vnvX{ zpJg7z>-1v_N~g`3#ap|(d;dDQw7g>Y+?1r;BzJA$=Qx;P?{;)?oa<oinL6^P&>z|D zINuT5oH^f75gsMNSkTWkIw>->prUwoamBpsq8X)S74k~Ak|KGFR?e(x@@?Wi3v-Gl zO_SGXvF*~}D}!cuFWvI>z`@dn7FU!M`2yiqrc^r;9Z8O4M~cuN6X6;W9xlRLRh?U_ z^#u-2p6qt?aP)MrIQo~+|1H9m-Hu+4R7aW!4-?_dM0j(lb>{{u1S!dD%S+2JDA(Ba z_#aHmE0~&7G=q1bSCp3J8qYocr+sC32QVFaDZc*=X*VoQUT9EjLO;i#P$mp^3~^+O zaIFZ}iEuru5WS4P?`L;!7b15?I_Pv7I%1q-ydzhHpCQ6qi10I!a?$rbDFsTqPR*2d zFF6X8GaW^ai6aK)bSuoO$Qu;VY-~QaqLo)Tov(y7Yp&7iF6c3`<7{rtBfcX$mgdWM z-j|Q+m?!g%Uk~kAQ98q<gss@IS08RL+G89YJ9TC4eOSlovr0-{KBL8%EnBr7IWR|c zMaP1Yyz=s~19MU<s0R6@WO-Gys+LvFN9D{aC@3l_EGm3C!qg%%$|g0MS~RbGH2+mg z-DS2^X{xllqODcBsxzw296m5dUhvK*(@RTA%U)@7R@)Zs&Tij<-{%z1FQU|mStWUs z%K5vjcpZ9m_8A}1%2=hZ;xfyK{<8{-3-h?Tg8^u4T4_n)OP$Z@a_(rKmecvpNZ*e| zQid#RSC{h;JIL#Wm(P!F(JjtN@gro_!ziyBIWxFFGtH?On^(0!oGYPLzg@2L_<Ld! zAIvDG29-{yuIx&bzfAGu8chLCDfGE(S9el3#P4&BhJiW#isls+daFHQc(Lb&L(57_ zE2_eja3w;qD;<<r#l?6zQ|YH<D`S*=rBs=zlq<88#mWk0y>gYZO}R$dq3l+!Q?6HT zRQ4-(Di0}7C@(5+C?6`HD2J8Lm7`%{VJ*WfVUDo2VO_%F!ji)>!g`1G4eJ*+IBaCt zn6L?9)52zi%?eu+c1hT-umfR-!tV7sxLKI*zsg1Gf7Snl-7mshddKIE$&TW219Jw< zs>tI~0eSDlZhkdIxd1=Qztz@`5(hgOd#K>k9i@&79Wxy)7yc!}TZ?c5HC==oMR>#> zM}@YHW42?Cwhiw}3pa_d^&&h{gj?hfVe4h}Z-4xHDsMe)@<XV_ht4^^B>AD7ig_hX ze^Oqx;QeHWUg19XyyOs6#wCuWGW9F?XSQX^nn&0k{Y-?LeO_DcSmAR}(JsewIfIE9 zT3VPluU%dRJFDH}liQ^ZFn;N4Jl7~wb}Fr?T>i##y<?N~<)tj}O|cg_u5fG=;WqCA z9s{v8B0NTfx7p*^?AYSC(s7kztK(`B-d2Qn6yaS&cvle~C&CkgmfajXe3Q{|E_j^Q z;3}7Z3$6auEi56f{>UgU=f1^x>3P#<=heUA+i{($#Q(Q9JUVVtJ-`i*qfaml-X5v; z_R6@rp-DIITIvjLI*F^Tk$WBc71J)qt&V*nyqyR?dza%j$L%7#y$J76)p^*Q;=+o_ z!zULNPnulOq1TcJy_wAqzRs&w#$AqkrHs3!j80w|_c>@9I*aggYGnj|*(as;%a1r7 zulMCA98Zeyb4B=hRh=9E+H;N<<=38<WuEUX^Cid2B0N@vcWb)LHy!WDFTW+f?DT&5 zUB`POJYIymn*Q=9j?d(mKb2p0d%yg-;|md<D8iHKzPxIc>Z+x`dw=j%;_s9x`-}$1 z_btY^xJ>(3i-Rq;IevBg=J?(5hvQGj5yw%-F$b+-ifCRWnm;MRcw@9hH2+Y9cNgJ3 zMEHdwyq5@PAe14(vqX3w5q>ePf#!GROwAu*k7<syX|84tz0YZ@z-_`+C1}k~G<_Rh z+;hD9LEE%aOYGUi6~F(g-BPcc9Ka2-4DUl++}6gV7JJdjya;jdtdjDg!FlqkO$PYg zg0I7C6Rj4Rnrj?&f=xq1-_|QK@ZzI34z<AaQ*g~`ZMpT0JX<X@GuJrvq#4;{Hxy)c zXH|vXr~6L6HeFRs`u?9^PS(b$7Tqt`xby_$aNLXc@@5qlm*(c@m2=BpT>h+y6a80t zdoRMv;o7Q_qBQUCWr~CtB)4(5NgS3_!5EEkvcgDNQEbp2x<Vp!2S%;Nx8Xzh7JgOa z3#yd}J|EEv3=jcPV1*cH0~s&|Cc`|agoUse1T2N+uo70oR@esDzz*02)vyO{fSceJ zxCh>cBZ^`=52nH;a3eedAHWyzHK4DFIiBecMd9UPN+kO7LM|oJ4jrH)#6t#TK_9pn z`olmN4B0RghC?w>UgR_=g_%$evtce^W8@;Jf~x?1BkzRI0e#Kr%ezq&GxB-;h+-ZK z<ACp*@rQW@tb(<GP3B8sHz3D+8{7dka0sx~{3JXL&%#Ua3cLnyz+u2{^Ph@hX$~#H z24_K6aDofm;DHMO-7Li0f*&kHU;<2n8GvpUbmHl3g(s#J%U;+A=w(4K3wrTrw8A6M zisc@72A+c#0Nr>ZS>efJ#e!~@x8Xe?R#6HNi>PE60Sn-2xF6mDVj1;2U`NzZ_)Afu z`A&2*Ag0keAg0m$G8+4$W1tPRg|h+K(Vd_lOoJ+@hKJx&Md6sdV&(f*6tP+X8CL3m zmG4>ko)sTiQz0EPp*Qpe<XH#6AQ%r5ARh{0B20!UPy*9oBisq^!rxT2a{)Ovd~2Hx zi(wtChb=(<+pdS(;U2gT9)q{wL-<8uVhh-5KOZgv^t7X=9X;*nX-B>tJ?-deM^8I3 zwWFUM{p{#xM?X9I+0oCA9`-V*0Q9lXg)0C(><8f~coTk5lo&0X4M~9PnBnj#d<I{@ zSMUvd2lDej0s6-L27ka2I0pE^5eCfxnJhLcjx*p)Xaxp{fJh)l4r1&eJ`Q5+AjS@C zcc6!ZSUEbuIdCp?g;<D#cu0UmNCppF06hVpIq;bSpE)uCpE>ZE1D`pti^V9#F$8j8 z7>s~XFb2j!F62Q06u~4YhN&<ON?|6H1G(I0Bs{1nXQBI93*k*gX^T#64=74IY-_g| zzEhO5Df4XdzkL*t5A8oylnz;NkD_$syB*iSyNc3@&vm+0Q98E-V%Yh0ML7p~=kT2_ z{I1Jv_)<~M9SD?r9=4yihvxk(Sf?oG<LC3qf%D0$SZt4dSW&ulgSGIhqQs$Z+#`zO z><ZiAZ$*h83N?!2>ImrTI-)2E*qDHQ?h&w`t^*wtuT+#I4dA1syA&n49V~*+6eR_{ zQ}!u}r!8~=V&mxnY0wYQ*E1Nhf$w|BRS$Z4$W_mDAXh!}pb{1WdUymZg)OifZUE|z z2cLQHr3d>x*yo{q&rfu1Er9a7lN;UfZFkD+P7J#vw>xsXBey$pyCb(da=R~AlncfJ zpSghFU$6ppz(K%QJ+#moI>9+W9`?X*J;=izaS#ub)dO355ThQ%qQ?c$6E21vAjf*( z!ycnx3{Y2lOa$!jf&D$OzX$gBm;>`+0pQaf*xTbexE^kVn_({yi=M4u6`*TR{;lUt za0}c8_@gKB?MeK5J^@d`%kV0^4sXKS@GcyNFW@WqMo}&_ff=H}3N%I+wt>0u1N;d` z;21-Q77z&*hz1+P06BC~XXpaw!THb)lA$}06Bk_w1%Tf#ngqo#74XAF&nQZ-K0rS8 zB3F8mo4u%yy`})Z>cwYzkt@B*pb{1WvFk-ldlA!K%V9lifGc1V+zs~vIn#@rNyVnr zEr9=0cLKgn#jmOOFZCX{4<3Mr0RN?;Q|fc@0=xvTz`O7Pd<35;O4=E4CJ>u614ID+ zNyC?Ev*Bkr27f6^x&nMIoqtQm&*}I%-2rC-d6s@IbcI+T&(h-o-=+72iy##y!eqcN z>G&nRR8cbcOeSS#A~TbCWD<`|;*iPrGZP>Yh(o3asF#@;kOlZV^J3@^!(b$ghOvNO zGx2LCe$8A7t6`m@Wc5{)-bSFD-ss;O{d=Q#Zx^^B2~q%^dSh_!Oy~{rd;MSl42MxL z2FAe>SOzO#6|8|v6r~UP^u-r_k=Ymh`=Wne^zJ(dhCmLWci#~(0rH^`@KIlU)E6K1 zEr;1K7v{sYK<xVx`@Yw~^>CA-T#TLl_<TP;->(ArPCxALht2)StA3Zk<**U919JKy zryp|qA*Ua5`jJch?tmIN1n<CmK)&=NU;2?R{SLzyiqaoj`lEM$^zNSr1uz5V0r}m3 zAuI;s(0>h}M}PF_j~@Neqd$7|N00uypc?kT4e%^H4==*Y@G86xZz;-vi=h-|0(K6V z1#^Hh2P}Xq0h<OOa{w|2?1ftay9V3^cf-B#C_DyF0P+W5;{a?NfQ<vNaR4?B_zr%6 zpWqkx4gOG+fd)v1{y_W(7D5qB0_-1%-v?s<K<plf-2>MGxiAoY2HpnfFc2LE-VYDK zBY@2Vv3Vdi55(qyufZGeyP^!Dyg{8I6$S!+9yAe(p#(~y4DiJua%2!?4_XA2KWH;t z1y=*U9z@Is?F4igM7#&x1o&tW{uy*TpwA#|A8dvc7y*<qm^>Q13D9*gaTttW2LB1i z6lI74&44y!NEFz>0d1i@bb@oh1s=$NY$$}8K&}oUhC}89IWvTu8L|Pc0dyULu0zmu z2)Yir1r7mv40#fs0sJ=P6?h%cZOA+DE_@EeZ3ub}K~IWQvb7Kn=$hRMurvE?z`xn& z!ub#nZb%07%|_pBjLaSmqhKuL0s3bX^K9afP2985J-Z6<RrU&44a7eCO2Gfw*prPt z+1Qi42kwA_a2Jpd*$==&@El-M_6zV5yba&N5AZYm2H2F1O*z<<(;Reg24GhXHswTv z9f(5?{?9oNV!;W-A?E_<1?i9leE_?1$m5(TFb%LNrwl4#8DLM&I=B=z05;`dOU^#H z9ctiCxChAXoCg70a)?XL2k<c*hA-f2z@{8*$@xoBhK7L#^ne{hTY?49e<*o0lsp=W z9Ye{Zp~PlrPeA{n=sy(whxUbR7zQI@G>n5>SOMrb^i{xb!|>NI${MDFNQeR(P}VTY z8g@1$0P=?+e;D$IA%9pu7y#2@Ib05#U<+)8?QkvJ0F*ZjpA4%3d@}5AcpRPqd@_vK z4nv<|Z@}B|E_@GvD9Uj38crOClb^#4Ks<*>gB{RuII$d#e#6mkcqa4)^cy}9$kX9N zVK@{+8N3AV1M-Le1iykT=P3NGC?lx5BeX!h7=a%~#K2k54)FU3{63-!bcJr<1pG2$ zERZWBX2Dvx6&{9X;Vr<X5g)+Ea2P&Ul#xbg1IQlP0XoCEfb5aT9oZ8y0Gmc$4ETE_ z_KX|>qku9;j)yg{3-Ig6|G{JMBs>lHbmV97C42+l19p$Z?vdC%61zv839TUl@b4)6 zI|~1fLbp-qHVV5(#lZ!DFGpeLs1-oIkJ=B!anzge5qt{RHtH+*7Jh?2;TYiG(anH- z8{HPN0DDF+faO3AjouFA%IHVo6+rhf%|Qoe0Ciyuc`ycD$D~7lz!zii#h6^kha#8^ zQ(+p+1_8@pCG3D3;Rzr<W4?x8;CDEpC}SyStO+b&1?s@qj&KeTm$BsA*d(|J(jXHC z!#J1#1%M7?$?380!OwuN$D#K)<c&k`aebg1wgI|~yAAGx2jF4A{&CL%J{X5@$Gs2u zbsT;jhhN7L$MJeFLtAJMouCVJg>K-19&iz$=XmrSPr2jCrSbS{{6v@z^8nwEzZQ1E zb#MdR413`zAjad-WBfaSF5^FfPv9^R-&}ObZ2`n57dvzDUoN`kwgGg@MYmjZ%RLX0 z0ljiBgkFGNx#*SK4+g*(D1@0n>~iPAd{_)iU^x)S+$&%k;J@6P0DW`OH}`J9m$?tZ z|KKrr0?<A8Q}`0T0eqPIBmAu>6Er}MO$dipV1!5@2PU)ybf1t2-2vSvp!)>kI3WxA z0=iEa2NPiqtb;x95Ih2p!IOX=C!oUwVmRR!Mac_;j^G3rP)1$~P}lMXLk>{q@<zc} z7!Q-60w^aBzvL~1Dp(3DU=?hDjj#oFz-~aFynS#x)WH3KetGDZ_bj{sF9UwcBgT2e zI1fMN{Rzhuj%GkJh=H@99dv+BK)&V2gBz$D`4>SkkYD*%!cKS`us<K4=i~E&D6oM8 z@Nq$VKvn_1F6au#EI?)fG7HF=f`Ncf3h+t6Fc=BsN&!A8$b&+_HwBbiFcqf3GN9~& zd*BJcu0j)Zgbc`qd2ktQ2Ygg`BisV`st{il^4&swRfw+&9|7zrB$kCo6s3rG6;XZ> zJ}=q?*jjWoTmzI_gx`zy19FP+dC{GKPmAzr5k8%WPbW499fZTVfXs<$&>Jp>0gw&D z0GlU{2JD=OofAu-6!7cBH{oq~4?a|sNqm3OP{77X1aDFiOa^>2iMUL{?nw(^F)V@Q zfE|<8z}@hvqD(eJI+Vkuunn$-U2q-T0Mxz7cL26c##fW^)#L}^S$GLvf!6@tCcg_G zz(?>E{0{hG^52S590vHI7(W!B39Wz}DR#jHa3Q1u`V?bV@p#CCLckxzQvf}St6(Ky zNAV><Y>TM}#an?G7w-V{FDA~##HRRF_yLGXF}ff|nbHglKyFTH3+<s3bb+owZcag` zDd;o>ou;7EluYOY{a^r~%M^Sz<siHRM-^r2*>E1j0d`F#)>FytslDK0;CoZcpc2r1 z>PA54spREU^qu+{d=Kb5^(R1P2|AW^0CXrB1te7o{wSFY7*jF_mcVjY1#4kFY=CV* zJWKFL3Gpns0d9u9@UEgv3kUR@hRkW30e?-q4<3a7!DH|wJPq%|=kN`n<23Y}_KTuS z$CuOf&;nY43COGI(O`pfpgW-d^ua)$Pbbf(kAVr04@H1Y(`Uds*aTO?)qsDd-wL<E z0XPKYZz;Ym#n+|iUrL-xiBl<czO*+Cgdsp4m5u=XR!Ui=lu?TOQv6VQ2iyw}z{5b@ zFMSc-gAd^o_zb=TY%ay-(qoE(ipq@Upangg0WG05B)}k;4fuWr@@ISmU%|KV1K_tA zN8xWpnTd~Pwo{a{y|5q9sf>Ioy9@Yk8M>9BTiK)V1Q3U^=Kwv+UV+!)Eg+U<AHc_O z7`}k7;XC*dh*KGLvFr%^r6}cLpaJwRCvN4$t=tHa5Cz1o+yQN&J#>OD&=tBtJh%bh zmlNCap3n=3ad{T>h5mpq%Cmu(mlN}HVqQKT@}LliNBI<(1~|679PnNFJXipWVF@gU zRj?M;!v@$0TVN}YBjr0_H|&8M;TG5jw?hrw3HQML@DLF1^2gyRcotrOm*F*d6W)RM zf%uhw3ZDaUEGLfTKfurM8~h36MTG+7MTHK?i3)O}!T{8V3JX{v2F`-Bp(C6F=Rqtu zApw%W13lm(NP|r11N~qi41u9A0!G6)m;ePZ5sIM%N}&v9!Ca_>MIc}qtb{di30wwO zz-G7#w!yWq3$BA3;AXfLZi54G2=0da;6eBwJO)p~Gw?jT1h2vy@HV^$AHpZ_8GH%f z!1wSI{0e`-QTR(yX6c~?oDYeR0)t@`jD^`ip3EXoW})LOben~4vnY2K<;|kJS;S~I zv6)S5X19l~&<%z|F66^fSO=HFUN{JM0ea3xzuD+FhZxQwc5{f`9O5ts|IfkybI89r zdw{%~gROHYa}GAnje@p7nRAKZT)s1x*v*{>=sR~g@SVB0Lk&>YT*{hDS@WWy9dv-6 zkOh5VGRy=LZXWTPN1Wynr+LI+9=@N4@8|st#}s8gIXNF)=f{E*asZ#r$L9H~U;}If zd^Vpr&PT@lx8P$qtSFWEzS0PhK%Q16KoVrb7#I&L0H0M}4#=qdAD~C&M?ih4{8mvG zSl}$ccMEy|zF5!)CIUISpbRd9s{nfz+yjrm<M1g+89yk>LKDOQvKEpD3sWHj$n}M@ zU@mNh-LMDHV<9=X@Fh5^D2ucZ4t#&nIe<-z$fHHXe^C*v1oT*hUl$RNMfbx)fKL|T zlSPLWWw8OsgT?5v7=J9rp2Zgd{#aZHlVA}bYw;SW2J&g~es}}Oi^ZP+@u||m8Gs&D z$g0A(RimK*CIT|5(5DK0s*q7dPF9hVRj<N(fGn;qS43-w0OBl=Av}N_fgFJxu^zSn zz7fP&JO<>6_yT@}Ule6Y2cV8EiGv&%3*^a?#XznsSqnD+xw3@%wS>4VAudaZ%TjW6 zDY?278B2%4IG6w{;8M68@aIzexfFjc{StnHUlnB;-&=MrQ1-IkFc>I**?d?E$XK=y z?ga8;*<tt&(0jQFh{N);fP7j$1So&`0$2{{y&S(S$8XE=+w%9}b09BQw1OzG!AQsh z;<sWq+ya!j;!PlrS77T(Js2Sp65&Ef1^l$K2qwc4z)vgj_e$(tiM=bacO^1bQszqh zwTd!VwT1SO2?GJWS5?45sDhnv6QKL57vU{<S5a2;-PL?|HQ!y0k5^BGV%P)dyZUzc z9{zx%in69Vq(c@EgEd#fHSh``Z_NjavbGa+gLpvR+EOS3^k0kqYtesQGdL4k1G=so z4V1rbJ5ctz8{tDBuIs*0luM`|mz)h90pDJd2l)09%D<!<u7`I3zg|K-*7N!Ge11Kj zUta(vfFA2_fZN~z`~ZK#F-5u52_EPHGhsd~1blGmoj{&kimxyI4fxJweC{%QeOVuv z4dnD?OW+VZ2>*j0;RyVtC>xNyAr1J>hDull)Wr>aegmK1z~?X5fdNb~0EWXT*a-OL z@*VIod=1|z$`ua4*H?4_a{LNDd&O8-2b<tZcmdvocNAsg8G!7K7C`<+<Zt9V8`r}Y z*b2|X8}PQGY(k$+=(CCMY(oAfKD!C|n{Ea4-gGzo3V$ogX5zUS+cpmb;<*`_n~}L0 znVTPl=io&}+0qK4zy>2=0uY}q+u%ANK3lMF%P;V|qFmVxlA$}40lvF(5#X;Yp8@o} zswH64RaVG`F)$v;p{s6(8u%XmfTN1CwKK$l3rb-wAa^TeZ@mr3jjcbxpFnP0odg#F z@w>Vl769?S`Yw1Fux}f6c$)*-!W7_h+h)V9fUmaUt8Lh`Jq$F^1Mt^&@@IP$tOnw? zom|-dBw*V$3J|kvu<x3lkOh4K`>!E)u2}>3z$5TD98r{Ok$tTm`0TZV0DoM21#E+B z;RE;rzE+eSDUb>ofDSuW13K*33kL!Fb{vN9;73K-i5@#`V22oJ1LrBquANW~*TYS~ z_jm1wI{-PmkhAMvcmVL%F8sCY33wXFi(TZ!u2<l7cnjVI^xQ?R@1p!&=(`JjccI5F z^w>pi?82A3uy@yAin1G@?#Axj*uA?2kYl@zKumT=0Xpv{HoJ+<?)K0Lx<FSTzjnui z8_2WW-2q?k?gi<9A9v&P-TeW7?#7?Hhrvh~1LWE6JSc=oFa@T;3?K(~lLNcw!2(ze zOJF&yg0-+7Ho!*M0$X7_?10^{2X2J_*V26eS5>az0$y9B_k<E4Ktck65Ndz`A&mfm zgaDy;QNW;p*u^ebP>%(B$A;O`q)3w{RRol-pddv=lp;-#qIe(gy=Ue*&YA42|NY<Z zTbVO+X7-uQToz!TKVHgmR<VZlY-BUvvYlOg&kyY9AU|`I-#Eb^*!7S9<S(x9PY@Vq zFufQhD2>@quSf({iNX#{uR|>HB#=lGnv+Z$+R=dwI?|c0<k5oy`Z9pQ3}XZ%xtUuS z#{}-=9wzc2k1&ZRn8LF>&s1LFb>8A#-sdAe;ZtVu8S`1l5|*)&)vV(yHt`MHf}p4i z-RMqF>_d@#D6$Vl_Myl=6xoNOQ50eyitIy?eJHXIMfRb{J`~x9BKuG@8T(LVAByZl zk$ot#4@LH&$UYR=ha&q>WFLw?ridBLW-j)j$UYR=ha&q>WFLy`L(zIRVjqg^Ly>(b zvJXY}p~yZI*@q(gQ1mnQp~yZI*@q(gP-Gv9>_d@#D6$Vl_91K^!o?^-Y06O%`w+Gd zVfzra4`KTdwhv+Z5Kh28gzZDvK7{Q<*gk~qL)boq?L)XD_91K^!uBC-AHwz_Y#+k* zA#5MQ_91K^!XvqvTNuX#>_gZ-gzZDvK7{Q<*gk}xU<&pjY#+k*A#5MQ_91K^!uBC- zAHpADAHwz_Y#+k*A#5MQ_91K^!uBC-AHwz_ypFHf#5ZhXC*QG`eH`F0zi^D>oZ<}U zxyWVy=HDRr^g4=Din3IoGF7NfO==TE91Unh63u8yYub`ZI$3lghg|aMMIZVzh@srT zO^jv?W4VnxxSM-<oF{pj|8bUUK`_HU%qWI^nBf^S%wmS$o8k9n+{X|6%5R+Dk06*S z-^{MaG*hOTGR^d$nTuJ<a#jVwtQxrItcEnEDQ{v<v%<_|P7utlh0n}RqzTP=j<<M+ zX?)1lAed8%GL)whPhlVCyoP7b@%hh6Q;jG*`?EScf_s1VJX7&IpIr`ux$ZsJGv}7Y z%;vs~eVXgMxzmwzo}bP0ta)ZQ&kX08;k*Z!!ZXM^??rSoPsVxw1i^g0&e!Ywk=%~` zo^QYBPh<;w`H`PE6a)**altK&<u=S<fuAop#_ycubP#;r6QBKjI5#qiZ}HjB_j8b+ zgJ5BMa_B~P{N6(MS~#1}5OAS)W0Bol6puMAYD5ycS@Z!PVOEPi4T8nxFwe#MT&&N< zu{_HgnA75S@%+W-gJ6lfFS(B5=yr+wFL{_pnT$PL@^=s{EsbuM>V0Wt+<mEjmOg;b zFMSMmS?b<P&+;dK1;G~+cnCB7ViHeqf=gUM|I1`prkiDYTy_`Ufo1ozf=z5;D?5T< zd2`appd+2p!Ezle{|Fr{*TD++SrI`M^tPfV_u>2%_He~BJjYSaA@2%#SID$-JP#oE zN<FO9!%AnbJisB2@M{pP$|N82TGg9=tU}&Z=Dcb<yMo}$7Nq0zUuM&V1$@aG*0V7P zR>$MBtCML%JKSfr&#pHA)k|0w1Z&)9jnA&J2W#xX8hfzD{nyN4E<V3zQ4p;4nYEs` z*7MeS-dfLFJB?ZR?Am#J9t7)Jqsw)ju!rk%@%!u6vL4yiZ4QF<3ADnq)_d0a4mfwc zXRUYcdgre9dmCih;4>TAl8U=;cn5RYFcY8O;OwtTQ;jI>>Q{BR5%1Jjw{sWw@&{M3 zE20D&y{j9?V@4azXrmczG^4LW*w3#k5s7Di{XgF1ZQeuPP5RrUn@#%LB<m*qZIW-3 ze4FIkB;O|aHpkMG=IC&<J8gE>W_z>w1zzG+&hc*$Y;pdU>nX`S$h74NrtmDkaRGa_ z<qGceja~Sr5B(U(5Z1AsoqWgMAoy0--*zL99u)8uyYQKB|NG3oAlPa?TeGldTRnTL z-`P5!RjkIdxB9(piKJkT+dO+)25(V>9=6$$ZJ!0fc6Zud0iABw>2{rN*Zp?gZ`b{H zeQbBn?T0wUY4ow(J$Kx}BRt0AJjDqv;r=_^-xY(M!?=}kOyEx3Wv9M&9>;Tco(Y0o zc43$2?0S-?G230v*?k>)->vuEWsqz4Gx+&#bJ}fA-}%{hRgnL?8btFNA2FRUGlSs! zvP4mn+QjfN^H{(lmIlF|cv@gD_SlO(dfelAdpvKC=k4*lJ)XDMPVa3@6Pn}mdlzF4 zdpGbkTY}&R*?zEZKg7`hd-=m8<o{tRukbo2xy)6r1;LNz^P_%$e4ZD189Da3$3FMi z=N|jqW1oBM)7ifNe)a}$^B$hD-)HxirxIqo|6!iRp6~a}{hqo1&mj28Sw9t{1f>~; z8UJ(__i{hygW!Of9x#&w#VN%^%<RAvJokXC2Yu$CGY?iIf~vURL0upGgio0j1czih z<Q|9I<B)qCa*sp$Jv5)s(dD5pg5a><KU@!UIh;Tuqq&p2xsM0<iR0+;@M+Ek!Oyu2 zU=TyOft?8X^I?ABSP&d(MHbm~!Mk;24O`jHF1`<fU)tg4zjP&!9(=$Y=CXiAL2$G# zNi@YS9rgU9x;bh#N8jar?9<T`T;dA<1i`Pm`&IA1KEh)>&QqA>F?}7=>oK!D7Rh+r z`<Qp)*rQBl2ZnU)5J&L9-@4=ezxn&~+i-5=OTNMVe)BuO?GA$9b^LoX<o#XV-&6RE z<*Z~i>w@68`ycN^KL+Bt$9?Ab*KFonbauk5PI%6VHt6j{2WGL9Wq9TZ&perdj3;$@ zvVgwGcT&ES@|~3Lq<p8$=2S0w<Lpz;K4s>o%>2|z%>0y@|6zCkxP!a6m;3oM2u_D6 zMhWcr>2dhk=?BsG=}BA-f;0B|Oc`{2M%QQT+L=4K8@qN!=V$bK<~$cLzcYUCtUPCZ z_G}@yVm@ch;p{17J1g5+pFd|G&&hc1W^O@_bL(->bGxu-=Y9x+^NE<jdEK4Y-FZEo zH;?nWKCip;x;t+kf6l{y{!?dvu4O|ITxdZ$ndt3;nO*o8pS`evMVP}y&%f9SKfh?_ zFLuX_F8=p3GrH)x7oGE0M|x6#`TXS$f0_4R-?4`uF^fz6xC!^Wq=!p-xU>dyytEzn zyX1bC<-083W%(}4ciH)ur!$|=S<DwfaHTyt$aY1xD>7VJ!6vrgxmR`s!PPc+&ehI% zH?QU~4R^UZ2lu|}xqn|zWg@9Y4b1)T7nsT`ydDJqlqHIq)Fy@x(f>c5^^a%$BjYvw zUDMw+`LD@%O~z}^yQaHqa$Yl&Yi9DVd;Xh`{QvewPyas2%e=}Pyd8vs>!?U&s!*MW zd6wsRk(Yx|s05KzC5l?Sz&pIh2YeiauB%T=T9HC~-e)$8Sjuu%v4+ij%XW719eX$z zgo@Q5fu0Ox6yte-$9alpkh7Sa#ok1oV$+bPm^{TkVKv9N5QMI;O#_liBbPq(XAncV zfiaBbHg4xG?qMoR*uW_+2BG2sCDC7T&o3TB9L_1;2z?Z9O<VL)+_}Xw7|bMOFYcMe z<t(m?;_hGk7d*fC8P4<HIhTV_3G*sZoKlpbJQYc#0NG1SLCzBI5oRGP@%$3&_=-*F zyM(?=?Bz#(;viRoP{~-DF@O<_<6iV$Qr{(IF8MOAq4$y>G9BlYoPl|l{0!%mbcd4H zf>0@al=93{9q5AIOX<6m%%yH(G<q*}2X}KH_wx{s;9jL(!M#e&<Z~AD1uOWHui3&@ zwzCU&EOmerTna*^LtIZubXZ!4rK?ecXzJkprOmK(I&zi13%ga?9ZS#04wrUT=^gCG z%u4I9v<^%E%I}=y56*Hv2$iXTJt&in-74dbWgg>M-rxg1rU)ID(P5cIEX8?c%&?3Z zmRXB)%DO|@2-@SBW%C)#NN(m9#xa43Jcu64I<xHKJc%>QZbV0A{|Q3nN>GKmBq49P zwxptqa#`f!ta82RO+V~OxjT6aJ5X*LdpW`>>{R(;cz*fPl%pb1)I#UwV~C?ZO>wXC zohZP)$`4}%BXPg-?p5BI<?q3+lz#xbQr^AFzr;Iy%6t~Ggk|Wl{8wz^8|+H?9oUuf z=2f98a#YBpFT*jf3g%V8ITf5!;bHVx;TfLeMVwjTRbI!L72LnVuR*AyxmT=CJnmId zmlfTsVh*~jsLP7FtT>3Fcpoa>$SB;i;w0RoqFt|efMZ+;LX`r_V|Odr-AZ=1lDSo? zM`N5-sRhZj!5k}@UnS>N8i40l8qe+6?@IS_Ka<g6rKho*m7d4_D$PVsl@11>$|b2p zZ4z-tWoJ}wM+Y+KiViFH!2K%s!LC$xUgbCVgm3wtUpUR*K`5d)r6`N;A}Ui8XGPeN z2=|MqPXf(pPe*z(kRg~^gbpLzF~S`qoEhPc5q2eFB4!xzIPMkk7Ddcu0gG75a@Mnv z&DfQQZRjB4N6a?jEZ2fiq&_0cP@YOeVjhv^5h-tEJn}|1q9r<t>_%^N5-E42+>vre z7IG_cM^3<wN7}teStA!CQ{+i51feP+^i(B^Se#SEIaSQ0N)ybaikVb#UX^srze+aF zsba=eUco)9cxDy%s&as19Oo2gIFGqh`8Nnvy^iZCNogW5ld8_D>MY-15vuB}s^(wS zOsblHRr9Y}Kp*<!u2s#Z>NxJj9IASUs=8m*mwAmh`H<;^nZay6V+rf{7IUb21hc66 zJ9?>lnoC^eS`hMIyF%59VXvy$r)srmNDEq#f*q=sMi<PbT6g5GCU-Tts}1F5?&2XH zWimRf<~^zQ65jo4_PUyVs`f6^_<}?H5rnE&!#-4ROl$PxyD&o4om1U8)%!Al5sbun z)yFWF@i?dYTvl?F|DNfdQSKF0fyz{&IyH%-0gZ5GR8zb!QDzk7o>A@<<z7)Ya1*0( zUeq1j&3)XD`$j#&6x=b&y`pBZkR>cbrl{3y;v2THgWY`3LF`o2pFyZbh%%JNyHX<( z-PF)cje6840XtkH30>9DRgIq5of_Vg8pE+eHAbPE8n<IM{!gSrH74=^k296`C}IY) z(P51R*!vo*Si?HL;%klsp_=m5j3N{JP*Ybm&86lojAH`c%bL!sshgUUc!H;RhX3Kr zns&72z93Yq80GNHTJBh@8Er`=oh&+$PcNKTs~-ay%t)MD%RFjL=1J^BE$7sFfj4*? zcdhk4AK~4p^(DWe_vmPJ8{Lu&x{^l^>|b<WhT)#RM<Wz%AENC;^sVSN+C8J47yT;E zi*{bL^P)dMx6!(d)@}5B7P1)UM}LDIh}LWLNltT)3tS39wL@HwzbUm#Qx5xFyE?Jh z+uA9#Ck->HolSRo(i_=p4`2{?^A0lAwu7~QL<hCc^Edwnp*q)5oKjS#3eKxj13lHL zLpyX)=QdvFeP;6oYuUipY+);Va8{k4ILOcZ!YQr>p}Nkh>#VxYs_U$}HK|Pl8j*y% z)@?yD9q5ev)g8icZe$dN*!jBVQukga@*ofMCVH=H_v-4n?zJEkW1nN38>7z{?^R3_ zn&X_9He}Ed=f&iZi+*G5V2lo8>_E(YJjUZZ#WOs|YdAAT=P~c`0Ut4orRXYV8++Nu z0S=>^7~RC2!E9n=jk&~?AQW4SikL-geHzjj{lw}gwmoTNB6qCZv2w?HcVY)K68*&9 z&qF-QWS-;&UgA~EHTErJkDbl}bQf!`vE~|UuCY7V%}*TS2uJyi<H%kwpbX|(FNQeG zwVt`wGuL{pX-g_{*ULoidU^E4T<ht$-gxA$XRh_kwVvGd<gO=oy(v74&g+Gdt=|41 z6n8!4u}^XF=qFA;an6ZzPFyx!@UFz!r8qN<8-SkThBBHv(Nmn6#=VT0#=VJN;-=xe zxS7mhE_#Yv$V$Fq7yo5B$j|5}PCs#H`IEo6%-`6@_>x4Tt9Tv7>nOe%EzwncI$3l= z_V{k-DqdId!x_un*va?@c$mkKKVCoaFJi{=uVTjW?=zdltm7NDv6JtxoAGus{uhq% zJ16-A+3Sa>Ky~z7zc#YhH|P3E$X;Le`mIQz9p+o#KGq+`&D_E`CU7SY@(7c7oTqpi zx$94377JOzGIU*kHJgyXzWnufu$%AEeSMkhUkpMGicyY=L{OC|VzDC)5@<vcO_8~Q zt{e1V2%{*(PByTU4eVqC?@|Lh(!fqOkh#GV$lTyX-sWTG@dYdRlC^ALE3!6_wSlY+ zeqbN6Cg?JuF?|?{eN50#f_@V8li;ibXC+KwDzET5_A}uf-lK@m(NV%?cHx`^=OpY$ zHwpGJ;RJthhVxwDS`cbj3OzNfOGD&osF#K<Fw=%<WRgv1x{^yDMxdvL_wg8J*-$SH zpW!)PL)M0}Hk7sD2YiJ2HZ<FY>-m=L$lXxxhH^Lb9yRnHHI%#IaZYiXOF^j7b(n1< zGi_9hI+$&vc$(0hWLndf_Q>9-Cxf_|3Fx`eJxoO3jr80|&yAi%_C_ya9~+r(qfc1C za#pbh*&A&{c3<cmY9xE3z3k&Be&rnh1fj$-L{g0!M5FISeJAQWQQwJjC(4~DcVarZ z3_!<;Bau7Ndz3g1xfA71lsoZZbe}kx|M4a|PMph9WKNVhQRYOM6ZM@abE3?N-yw72 zj~qeIiC2P9<6@McH07vB6t&QI;~3(okL-=x(S@G$rXK?t!YI5?jc-Nv#uK=M2Y8BC zc$fE)yRohtf69FP4QOmn8h^nG+@rD18}Hx%$2gAMjn8nNzxg)^CE1gt>nVwQBt;;9 zQamkaPa2tIBY%?oN%AMjpQQVw!3<?IGABLA)4as1yusVNM-ela&1cN#bL39iz)tod zchX^gLH;DUljKgi$R(~~XPT5C5?wcGL=w$tNo&%{q7$+==|&zm^E~gcj&Jx8XEkwF z6K6GXR+G!<s%ddbQI_&lLRU>|k$|q6I;&|8cCu+cz378(n%=-ojG~ZRxD$KX^jTiv zb>8A#%(<!gHl2l@n$F{M7O|bbf>1M=nl+&f=F`lX&H6J4XEt+YGiNp%%WarVv%9#L ziA>@JbkJ-%VP-N1=QXoW%~tRw-V5I^7i#tu+xUTBIn6mPU@pzfrTO)gqzvV#NM&kL zpQfbJ34Jx!S995$>#Mo!&1G*cd-EF^g;_P9z(YL4%e=;$$liP!vNxB#x$Mp7vH<Tz z^ObDkdk*q5NBNBt{E04`U*T{54MHtK$ljs~u_V%j<|L!<78!J;Gw#sB9a?m!AF{U? z$35t|#e+P;B%bAYrs5tg+@po}qs0fzU@>2^mJNK(7Iw1-JKADD2RY1fE(W2N0p+Pi z4Wg+_JsP9)mUgtI{4M2g*_JHw8GxQ!j^}plNXvV<pUFJQ)5zXZ_LeWA`<5Rui>0h# zJsa7~w|tL1X(?~Z1IXL*2q(E1gp!M4Ka%Z7as*Y0B9?d(Xhah7C#T?VP_oR)gBgk4 zNWKMqC)<(aiRe37-^q{hIPxdk^JKe{?43%UkKIUK!ZPegvb|2WC&}Nil^yKjk08`a zu2ym6(U;+j<!<id0ldepoY(3Zo<m2iUgA|==Y3|d81rpqzOBr+mHD>X!fy6pzOD4t z%6wbttCjh-(pBqXltWjob=6v?*1Bq~tJb<|t*h3JNJ3YwyJ42C_0YPAxvaoFTf0|l zXS8-k>z_HwZ=B^%{^Bx!b1ew9DM=OT;`wb_)0R}y$s!kXY150|^kV=c&{Z3AX)}o@ zn1WquW0%_Krp;Tt%QQaZV`ihPHo9u_4d1bseH`F0x@mKYGo0fBviqMvLn&pDIVF}v zn$R5kpVEd5I?|aOa_NrTDK}x4Qe;lCODT^ady4ESGN(-C6<*^_-bUt>IoPL^b?7-| z6SAjlL-rKeQ)Ev$#1ZtKV!u+Z1fjM%Zd-{+s!@Yz>eG<MxI<faXxkFqx0T!XbB5Xu zr;uA2&+XjBLp;i4WN$l#XLy-uco*6(Vijvx&qg-0i|_INww1fB+->D<`#U;rcO7=I zT@<ybgRa}fBWF7~+a=SQwzMako(yF)W3U^(Cp6UV4j#aJ)b254ZucZIx0{N*?Pjr% zCFr@G_qN??^xRI*?eyGk2fLBI-9e7?XAo*1q73D!gr3{$xqV&gq38AqB$9;O?d?c= zJJG%$0~x|_Zsb;U-Co!2@8lltL$~d}K#%QDb14X=>MB)Nsk%zlRjRI1b(N~CR9&U& zDpgmh&P>%+s;*L<nQDHi&$58!*s0X*{KT)AMe0eMlX{M;Tnj=S+_gh7N>GZ*)WrQd zILmjNhB~yN9UbUQSMtcG7rk-c4rbKhPV7;Kr}-Z*@Di``9v|>ApYSO&`J68?mk!^t zmwg=IFvmH?8D#Hp0eh7eP@d}OCrv+TGN;L$CUct1X&sR{P3E**WKQeJKyG3J6M2wF zn8Xu2&s1LFHQwZHWKWxeol0AWp4049n(S%YkUdTIG}+S*afG9Ichjx}q4ev~ak`Gv zYZF5p4QNJ7T9ZP1be=AMx}MXAaWl6t4%yT7oi2O2?CG+nKh9I=KV9$X?=YSD$eg~C z)ySSMd%Dc&JJEak9)4s$GN<c0{qG=@QJM&<5=AZQU`KqvYbZnS8M0@zq!np&p$9`4 zMIpB`p4+*fhp;Oda%bo~L+*?hkvXFXdy%mMyOFV$4SdZGytf(hX8eG>8T!sRhW9t) z-yoD(4tX=>&6GD&-pp9!&6GFOo@C0Ksq0K#XJ*ok-rT?#{JqKa_a^fW?&e`0L&up< zqT|eGu_Kuu@)=9ebEcj%^_;2aOuLb(=gghRohf&w+?hXPFEXzNp)7lmRgyB4rxG=Y zrY^E)#nS*?XLUfwS$!Ca%vtt1Yc#TF$($u~)_v$Y>mlq&))Zc48vaIREkx!lnX_ch zk~zyhXUUu;bC#~NWX|$8GV35Gxg3N#UPp0CQI-l+rzW+Lxnn(K?x^pMDRd$qyWCOk zj{O;g+#TiaD0fFY(s4W!n8;*a<W1~FN4Y!dy5n@_Fb{juaS=;#kB&O;xSb!d6CKZR zo{RjK{qG=@Eqk`?*|KMsrxFp^mF$Mti|ll=kUKkvT;$G{J6rDTAq-~(-pTBHu^-vb z^Ez+wF7NXZ`p&i^+4GS(doeO+uR+(@`#H*QoWO2mpXCbw1ffm=*CBf+yV6PKPSMzj zPRVp2gN}5jD+Tmr05W$Pip-q~xr0ZTf<5jecc-bm!n?@bN$yU%?i6MQ>yfRK9y{B~ z&WW@klYIK)oX*bad;>QzmfLV%=exKUv+X>I7cke(&gkrn&NG?AJicHBU!tSV&hGpb zhl5ZTv+Gg~GwPCqJ9fE|TN%&oIID}Zx;)Bcp2S_dxNDc^c#RJ+moDbe#Ti|k(Pbl> z`Ihhbf&Codzq60vJ?QdR;QuO)3fTP|yPsqCb7F`iiDvjalhX?CKu$Z%C#NTR%DI^d z+{r!YCFen&K-L^tb7akVk(YRzkC8b?<{X)GWX_Q}N9G)vb7anuIY;IknR8^$kvT`^ zoXbI|YccFj*BV4qmwMEvDJ_t<Ya7~;N+)_Tm_qd1Rli;J+x31PLcd*~=6^iTR9<Ed zyZJc?bt^+8b!d!py6L4`d(yB+-TWQy)*T&nE1)m^u}|H`qN8q;&`~!Xb<<Hd=XHCX zw|JLne2A{P&E^a2PPc9B<U97Vk6$>(adgz}G-tUIgmSN^95v8Uu8wjWB73f`a%Inz zJy-VJ49qrHSGoD<Dpyyzy2{m6uC8)*m8+{<UFGU3S68{R=jtj~SGnGW+)r7=D$F-` zJsUCK++BRn56GTtzPX3^oj<u2g!0N#1v{Bn6FZq_C-WMSL^I4dPxpCkkUOtC0~p14 zWX_Y>cVCC{WX_w6%y}~B={ry6ycc<s>C9&tD_PAt^qr^gJbmZsJ8us^vY(^qIqz~1 z>Ry71L{OC|Y7tKYiOAi(8FF`TPYwkPN5|c7MQ-1l9qKN3cOCoA>`-^PyFbAco<Yam z?ML@dSio}h++EMz*RzrB=()R|yW5fOdhY%cmx54!U7FAjXXo3;{E67deCOmlCtpAL z`pJKtw{TwmH0)!(eaxTD5}cR+EzZk#UcU44&DD2jhw}B4{~O0Sg|70Q-{U&Ww?`DQ z#FK!IddStI4ejVaI$306zC8vp5*_upA0743Q4byUFxwvf7Wa6GSCPHPTfD<!+`q?( zAk;IGXc}N1J)P6DGhNA}2j<dqFvA$ZO^l`xXZL&nJ@uT*D>$pCvwFVEC)od<vzWs? z%&Dh2_1wTt%%kT44)Y7gIKz1^qNko$`6meVvRl1m?o}Hd^-87<?U22f-R~uPFWGy^ z-m4dVFyCJ0+v`^DW)jcxJaYGX1-W~@&qv7JE6hyHx7Q-pu!X(+8-xnXuAn%jC`$z@ z<6SNAt`^ip&I0dhK^!_R@Xi+4{Q_MVw4^mdxdFWvjAjgDxs5xJx8OeX?0djN1&{GK zPvIRXc#ao&8M7|<kdG;12D&XcfxRoxYr**-)Vm?h_Fdkg-t9@_P98-!z3qN)Gwr>C zO}KaOt?URwzEeBYCz7hz+dj3>bDv?jM<4g-;~st9Mu&Z5=%d3vb1~mOXOW?g+4i{{ zg!(om6&d<wlFdY(M25cR)YqK)u4NlC^xe&#Ak?oMHISiS9b)OvNMz`z%YM4-_W|~= zpA7vLV4nSs^A|Go`x`Uu--;|`=--8IJi`Bwp}$?}Z&&(%&3D*^{`=5z|HB-?a|V>6 zEOuf*CF;|bj&vr6uH?~!AxvO0x*y=)1DrMBT|Pwi0gG|}0pD{v2n{Sw1m-Z%90uxO zpbiGww}BmS&Om1jbjHAZ%w^zc3K_##ZsS4h)j)eS&>aUlcc42Ce4V#=hb63L9bfS^ zKXHhkaqoe@@;evN=^%SDs5E9Ys3MiIH@-hQG)TTd8R%n>oP*>Xl*`Rbz%CBDhx@SK zgI?q%UgkC4<P*YpM+eC_Xc;S!bC8^aHee=$%z4l$&TuXW4K7I;<QiNa^BFAH;27#r zpO&=7%m$~DPA2wYaCdrAfV_imL6?KaA^Tw22S3VW<Q^>ZV3`NYJXn{5-{T9`BI96P z4&KZ`e#Sd8_$a?|f=gWCpCB|u?jbS{k$H&BL#k4pcoImY3C(ebA+isVeTbbNlFdMd zFpS~c$SCf>-x=SH9rE4SA>WN18uBd9;|@b)A0qpZX?(yUmZI|^%UQ)5wz7i*9L8OS z9OF1Axq$l&xr+M?jldm-y2H>YYEg&AG$oaEvgkw(W-xR#c6X@UL**WNFaP5Ort%W6 z@&?lhvk-eSROX>8u_r^#VCWX)9xC_HUFdzN-iMyz56<#u5E>TZdMZ-|nTORR8kvW+ zN4{aX<kO2j^y3a5;9(xaZVZ!c*xPu=hrNehhkeXEK1aS`_ITJ=Y(maq-|{0rafl=Q zip<009QI$%zwrJIuYjz>?a6R?hs!&>CJES+;VHByjZEyv@Xp9Qd^lsdox9NQ@CSK> zNj#4H!{@S_eaJBUH0Lnq;pRNt-@+TNqd27~gY#|}h)!;J0MEMNDW2gu?Ar}5F^y07 zlv#YnB9^k8Rp{u3--FNycN-!92=C^I9`xl##^4?!Zo_#aCgL6=++&1$jBxe{XO3{@ zh_|sPBb+m0J_}ibb4ILTJsUBL5j*(-@9PM=J<`lan)%57jKY~C@5JAMk)A)&^GCkS zYrM%jxZg<k8tJ@|&Kv2xk<J^rjFo)JFF|NjX_6U+zc-^Ma37B$|0vHN^$MOlYBruX z%5z3}&Zrg0KWYnmF{e=nILv>~K8F0G{^AP%1fkIZ#VCQZN0%jvn$#u+@7U<~c%P3j zr<>jHX8-x-51EcG3$Ld#)u@4Yr7)Iw5@<v-+K@q4yf1}=ao@rbjK&-bby_$c`&jr8 zPvXqNH+UO)3S}vjrO?h4&g64+P-td_TiJnqEi}8r{TxIWg?cDFgZE~PdyjGFF%^(~ zjO=4%A0zviI><hz2{QXW?9dpQ$K=t2KJ;f0L%5M!k$H^FV`Loj0UuMu49slIToz!z zeRp<f%yP_a%o^6Sk<EOA>|@Mvj5&^x{gwiTqpMp+Vn=RS$98t|9cF)PdvfSTcX~31 zW$5VEFIgLe#=7I!#<=6y<|L!%v1U8=L#7iBLgT7Z4}FYFAQ7J#=RV`?;JEqN>G3u3 q^YLaqJ_++4@1El~;y&Yd2LJb8*I)Pl{#m=t|NH0v|M$@N-Tw!1e$xj4 diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp index 0bd62d550..9505682ce 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h index 16db9136b..15edb9076 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.cpp b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.cpp index 6d8b24be9..3f6c0f0ed 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index cd82e0118..39ee8960e 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index ffbde41f8..37b408f9d 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h index 0eeae822c..7b4251475 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_Decibels.h b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_Decibels.h index f01a3b1c4..4fad09dc1 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_Decibels.h +++ b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_Decibels.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_IIRFilter.cpp b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_IIRFilter.cpp index aecbbe8e6..e749e4598 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_IIRFilter.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_IIRFilter.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -30,73 +29,38 @@ #endif //============================================================================== -IIRFilter::IIRFilter() - : active (false), v1 (0), v2 (0) -{ -} - -IIRFilter::IIRFilter (const IIRFilter& other) - : active (other.active), v1 (0), v2 (0) +IIRCoefficients::IIRCoefficients() noexcept { - const SpinLock::ScopedLockType sl (other.processLock); - memcpy (coefficients, other.coefficients, sizeof (coefficients)); + zeromem (c, sizeof (c)); } -IIRFilter::~IIRFilter() -{ -} +IIRCoefficients::~IIRCoefficients() noexcept {} -//============================================================================== -void IIRFilter::reset() noexcept +IIRCoefficients::IIRCoefficients (const IIRCoefficients& other) noexcept { - const SpinLock::ScopedLockType sl (processLock); - v1 = v2 = 0; + memcpy (c, other.c, sizeof (c)); } -float IIRFilter::processSingleSampleRaw (const float in) noexcept +IIRCoefficients& IIRCoefficients::operator= (const IIRCoefficients& other) noexcept { - float out = coefficients[0] * in + v1; - - JUCE_SNAP_TO_ZERO (out); - - v1 = coefficients[1] * in - coefficients[3] * out + v2; - v2 = coefficients[2] * in - coefficients[4] * out; - - return out; + memcpy (c, other.c, sizeof (c)); + return *this; } -void IIRFilter::processSamples (float* const samples, - const int numSamples) noexcept +IIRCoefficients::IIRCoefficients (double c1, double c2, double c3, + double c4, double c5, double c6) noexcept { - const SpinLock::ScopedLockType sl (processLock); - - if (active) - { - const float c0 = coefficients[0]; - const float c1 = coefficients[1]; - const float c2 = coefficients[2]; - const float c3 = coefficients[3]; - const float c4 = coefficients[4]; - float lv1 = v1, lv2 = v2; - - for (int i = 0; i < numSamples; ++i) - { - const float in = samples[i]; - const float out = c0 * in + lv1; - samples[i] = out; - - lv1 = c1 * in - c3 * out + lv2; - lv2 = c2 * in - c4 * out; - } + const double a = 1.0 / c4; - JUCE_SNAP_TO_ZERO (lv1); v1 = lv1; - JUCE_SNAP_TO_ZERO (lv2); v2 = lv2; - } + c[0] = (float) (c1 * a); + c[1] = (float) (c2 * a); + c[2] = (float) (c3 * a); + c[3] = (float) (c5 * a); + c[4] = (float) (c6 * a); } -//============================================================================== -void IIRFilter::makeLowPass (const double sampleRate, - const double frequency) noexcept +IIRCoefficients IIRCoefficients::makeLowPass (const double sampleRate, + const double frequency) noexcept { jassert (sampleRate > 0); @@ -104,38 +68,38 @@ void IIRFilter::makeLowPass (const double sampleRate, const double nSquared = n * n; const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); - setCoefficients (c1, - c1 * 2.0f, - c1, - 1.0, - c1 * 2.0 * (1.0 - nSquared), - c1 * (1.0 - std::sqrt (2.0) * n + nSquared)); + return IIRCoefficients (c1, + c1 * 2.0f, + c1, + 1.0, + c1 * 2.0 * (1.0 - nSquared), + c1 * (1.0 - std::sqrt (2.0) * n + nSquared)); } -void IIRFilter::makeHighPass (const double sampleRate, - const double frequency) noexcept +IIRCoefficients IIRCoefficients::makeHighPass (const double sampleRate, + const double frequency) noexcept { const double n = tan (double_Pi * frequency / sampleRate); const double nSquared = n * n; const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); - setCoefficients (c1, - c1 * -2.0f, - c1, - 1.0, - c1 * 2.0 * (nSquared - 1.0), - c1 * (1.0 - std::sqrt (2.0) * n + nSquared)); + return IIRCoefficients (c1, + c1 * -2.0f, + c1, + 1.0, + c1 * 2.0 * (nSquared - 1.0), + c1 * (1.0 - std::sqrt (2.0) * n + nSquared)); } -void IIRFilter::makeLowShelf (const double sampleRate, - const double cutOffFrequency, - const double Q, - const float gainFactor) noexcept +IIRCoefficients IIRCoefficients::makeLowShelf (const double sampleRate, + const double cutOffFrequency, + const double Q, + const float gainFactor) noexcept { jassert (sampleRate > 0); jassert (Q > 0); - const double A = jmax (0.0f, gainFactor); + const double A = jmax (0.0f, std::sqrt (gainFactor)); const double aminus1 = A - 1.0; const double aplus1 = A + 1.0; const double omega = (double_Pi * 2.0 * jmax (cutOffFrequency, 2.0)) / sampleRate; @@ -143,23 +107,23 @@ void IIRFilter::makeLowShelf (const double sampleRate, const double beta = std::sin (omega) * std::sqrt (A) / Q; const double aminus1TimesCoso = aminus1 * coso; - setCoefficients (A * (aplus1 - aminus1TimesCoso + beta), - A * 2.0 * (aminus1 - aplus1 * coso), - A * (aplus1 - aminus1TimesCoso - beta), - aplus1 + aminus1TimesCoso + beta, - -2.0 * (aminus1 + aplus1 * coso), - aplus1 + aminus1TimesCoso - beta); + return IIRCoefficients (A * (aplus1 - aminus1TimesCoso + beta), + A * 2.0 * (aminus1 - aplus1 * coso), + A * (aplus1 - aminus1TimesCoso - beta), + aplus1 + aminus1TimesCoso + beta, + -2.0 * (aminus1 + aplus1 * coso), + aplus1 + aminus1TimesCoso - beta); } -void IIRFilter::makeHighShelf (const double sampleRate, - const double cutOffFrequency, - const double Q, - const float gainFactor) noexcept +IIRCoefficients IIRCoefficients::makeHighShelf (const double sampleRate, + const double cutOffFrequency, + const double Q, + const float gainFactor) noexcept { jassert (sampleRate > 0); jassert (Q > 0); - const double A = jmax (0.0f, gainFactor); + const double A = jmax (0.0f, std::sqrt (gainFactor)); const double aminus1 = A - 1.0; const double aplus1 = A + 1.0; const double omega = (double_Pi * 2.0 * jmax (cutOffFrequency, 2.0)) / sampleRate; @@ -167,73 +131,115 @@ void IIRFilter::makeHighShelf (const double sampleRate, const double beta = std::sin (omega) * std::sqrt (A) / Q; const double aminus1TimesCoso = aminus1 * coso; - setCoefficients (A * (aplus1 + aminus1TimesCoso + beta), - A * -2.0 * (aminus1 + aplus1 * coso), - A * (aplus1 + aminus1TimesCoso - beta), - aplus1 - aminus1TimesCoso + beta, - 2.0 * (aminus1 - aplus1 * coso), - aplus1 - aminus1TimesCoso - beta); + return IIRCoefficients (A * (aplus1 + aminus1TimesCoso + beta), + A * -2.0 * (aminus1 + aplus1 * coso), + A * (aplus1 + aminus1TimesCoso - beta), + aplus1 - aminus1TimesCoso + beta, + 2.0 * (aminus1 - aplus1 * coso), + aplus1 - aminus1TimesCoso - beta); } -void IIRFilter::makeBandPass (const double sampleRate, - const double centreFrequency, - const double Q, - const float gainFactor) noexcept +IIRCoefficients IIRCoefficients::makePeakFilter (const double sampleRate, + const double centreFrequency, + const double Q, + const float gainFactor) noexcept { jassert (sampleRate > 0); jassert (Q > 0); - const double A = jmax (0.0f, gainFactor); + const double A = jmax (0.0f, std::sqrt (gainFactor)); const double omega = (double_Pi * 2.0 * jmax (centreFrequency, 2.0)) / sampleRate; const double alpha = 0.5 * std::sin (omega) / Q; const double c2 = -2.0 * std::cos (omega); const double alphaTimesA = alpha * A; const double alphaOverA = alpha / A; - setCoefficients (1.0 + alphaTimesA, - c2, - 1.0 - alphaTimesA, - 1.0 + alphaOverA, - c2, - 1.0 - alphaOverA); + return IIRCoefficients (1.0 + alphaTimesA, + c2, + 1.0 - alphaTimesA, + 1.0 + alphaOverA, + c2, + 1.0 - alphaOverA); } +//============================================================================== +IIRFilter::IIRFilter() + : active (false), v1 (0), v2 (0) +{ +} + +IIRFilter::IIRFilter (const IIRFilter& other) + : active (other.active), v1 (0), v2 (0) +{ + const SpinLock::ScopedLockType sl (other.processLock); + coefficients = other.coefficients; +} + +IIRFilter::~IIRFilter() +{ +} + +//============================================================================== void IIRFilter::makeInactive() noexcept { const SpinLock::ScopedLockType sl (processLock); active = false; } -//============================================================================== -void IIRFilter::copyCoefficientsFrom (const IIRFilter& other) noexcept +void IIRFilter::setCoefficients (const IIRCoefficients& newCoefficients) noexcept { const SpinLock::ScopedLockType sl (processLock); - memcpy (coefficients, other.coefficients, sizeof (coefficients)); - active = other.active; + coefficients = newCoefficients; + active = true; } //============================================================================== -void IIRFilter::setCoefficients (double c1, double c2, double c3, - double c4, double c5, double c6) noexcept +void IIRFilter::reset() noexcept { - const double a = 1.0 / c4; + const SpinLock::ScopedLockType sl (processLock); + v1 = v2 = 0; +} + +float IIRFilter::processSingleSampleRaw (const float in) noexcept +{ + float out = coefficients.c[0] * in + v1; + + JUCE_SNAP_TO_ZERO (out); - c1 *= a; - c2 *= a; - c3 *= a; - c5 *= a; - c6 *= a; + v1 = coefficients.c[1] * in - coefficients.c[3] * out + v2; + v2 = coefficients.c[2] * in - coefficients.c[4] * out; + return out; +} + +void IIRFilter::processSamples (float* const samples, + const int numSamples) noexcept +{ const SpinLock::ScopedLockType sl (processLock); - coefficients[0] = (float) c1; - coefficients[1] = (float) c2; - coefficients[2] = (float) c3; - coefficients[3] = (float) c5; - coefficients[4] = (float) c6; + if (active) + { + const float c0 = coefficients.c[0]; + const float c1 = coefficients.c[1]; + const float c2 = coefficients.c[2]; + const float c3 = coefficients.c[3]; + const float c4 = coefficients.c[4]; + float lv1 = v1, lv2 = v2; - active = true; + for (int i = 0; i < numSamples; ++i) + { + const float in = samples[i]; + const float out = c0 * in + lv1; + samples[i] = out; + + lv1 = c1 * in - c3 * out + lv2; + lv2 = c2 * in - c4 * out; + } + + JUCE_SNAP_TO_ZERO (lv1); v1 = lv1; + JUCE_SNAP_TO_ZERO (lv2); v2 = lv2; + } } #undef JUCE_SNAP_TO_ZERO diff --git a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_IIRFilter.h b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_IIRFilter.h index 93e5c36d2..c85b90f82 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_IIRFilter.h +++ b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_IIRFilter.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -26,13 +25,83 @@ #ifndef __JUCE_IIRFILTER_JUCEHEADER__ #define __JUCE_IIRFILTER_JUCEHEADER__ +class IIRFilter; + +//============================================================================== +/** + A set of coefficients for use in an IIRFilter object. + + @see IIRFilter +*/ +class JUCE_API IIRCoefficients +{ +public: + //============================================================================== + /** Creates a null set of coefficients (which will produce silence). */ + IIRCoefficients() noexcept; + /** Creates a copy of another filter. */ + IIRCoefficients (const IIRCoefficients&) noexcept; + /** Creates a copy of another filter. */ + IIRCoefficients& operator= (const IIRCoefficients&) noexcept; + /** Destructor. */ + ~IIRCoefficients() noexcept; + + /** Returns the coefficients for a low-pass filter. */ + static IIRCoefficients makeLowPass (double sampleRate, + double frequency) noexcept; + + /** Returns the coefficients for a high-pass filter. */ + static IIRCoefficients makeHighPass (double sampleRate, + double frequency) noexcept; + + //============================================================================== + /** Returns the coefficients for a low-pass shelf filter with variable Q and gain. + + The gain is a scale factor that the low frequencies are multiplied by, so values + greater than 1.0 will boost the low frequencies, values less than 1.0 will + attenuate them. + */ + static IIRCoefficients makeLowShelf (double sampleRate, + double cutOffFrequency, + double Q, + float gainFactor) noexcept; + + /** Returns the coefficients for a high-pass shelf filter with variable Q and gain. + + The gain is a scale factor that the high frequencies are multiplied by, so values + greater than 1.0 will boost the high frequencies, values less than 1.0 will + attenuate them. + */ + static IIRCoefficients makeHighShelf (double sampleRate, + double cutOffFrequency, + double Q, + float gainFactor) noexcept; + + /** Returns the coefficients for a peak filter centred around a + given frequency, with a variable Q and gain. + + The gain is a scale factor that the centre frequencies are multiplied by, so + values greater than 1.0 will boost the centre frequencies, values less than + 1.0 will attenuate them. + */ + static IIRCoefficients makePeakFilter (double sampleRate, + double centreFrequency, + double Q, + float gainFactor) noexcept; + +private: + friend class IIRFilter; + IIRCoefficients (double, double, double, double, double, double) noexcept; + + float c[5]; +}; //============================================================================== /** An IIR filter that can perform low, high, or band-pass filtering on an audio signal. - @see IIRFilterAudioSource + @see IIRCoefficient, IIRFilterAudioSource */ class JUCE_API IIRFilter { @@ -41,8 +110,8 @@ public: /** Creates a filter. Initially the filter is inactive, so will have no effect on samples that - you process with it. Use the appropriate method to turn it into the type - of filter needed. + you process with it. Use the setCoefficients() method to turn it into the + type of filter needed. */ IIRFilter(); @@ -52,6 +121,16 @@ public: /** Destructor. */ ~IIRFilter(); + //============================================================================== + /** Clears the filter so that any incoming data passes through unchanged. */ + void makeInactive() noexcept; + + /** Applies a set of coefficients to this filter. */ + void setCoefficients (const IIRCoefficients& newCoefficients) noexcept; + + /** Returns the coefficients that this filter is using. */ + IIRCoefficients getCoefficients() const { return coefficients; } + //============================================================================== /** Resets the filter's processing pipeline, ready to start a new stream of data. @@ -61,10 +140,8 @@ public: */ void reset() noexcept; - /** Performs the filter operation on the given set of samples. - */ - void processSamples (float* samples, - int numSamples) noexcept; + /** Performs the filter operation on the given set of samples. */ + void processSamples (float* samples, int numSamples) noexcept; /** Processes a single sample, without any locking or checking. @@ -73,74 +150,13 @@ public: */ float processSingleSampleRaw (float sample) noexcept; - //============================================================================== - /** Sets the filter up to act as a low-pass filter. - */ - void makeLowPass (double sampleRate, - double frequency) noexcept; - - /** Sets the filter up to act as a high-pass filter. - */ - void makeHighPass (double sampleRate, - double frequency) noexcept; - - //============================================================================== - /** Sets the filter up to act as a low-pass shelf filter with variable Q and gain. - - The gain is a scale factor that the low frequencies are multiplied by, so values - greater than 1.0 will boost the low frequencies, values less than 1.0 will - attenuate them. - */ - void makeLowShelf (double sampleRate, - double cutOffFrequency, - double Q, - float gainFactor) noexcept; - - /** Sets the filter up to act as a high-pass shelf filter with variable Q and gain. - - The gain is a scale factor that the high frequencies are multiplied by, so values - greater than 1.0 will boost the high frequencies, values less than 1.0 will - attenuate them. - */ - void makeHighShelf (double sampleRate, - double cutOffFrequency, - double Q, - float gainFactor) noexcept; - - /** Sets the filter up to act as a band pass filter centred around a - frequency, with a variable Q and gain. - - The gain is a scale factor that the centre frequencies are multiplied by, so - values greater than 1.0 will boost the centre frequencies, values less than - 1.0 will attenuate them. - */ - void makeBandPass (double sampleRate, - double centreFrequency, - double Q, - float gainFactor) noexcept; - - /** Clears the filter's coefficients so that it becomes inactive. - */ - void makeInactive() noexcept; - - //============================================================================== - /** Makes this filter duplicate the set-up of another one. - */ - void copyCoefficientsFrom (const IIRFilter& other) noexcept; - - protected: //============================================================================== SpinLock processLock; - - void setCoefficients (double c1, double c2, double c3, - double c4, double c5, double c6) noexcept; - bool active; - float coefficients[5]; + IIRCoefficients coefficients; float v1, v2; - // (use the copyCoefficientsFrom() method instead of this operator) IIRFilter& operator= (const IIRFilter&); JUCE_LEAK_DETECTOR (IIRFilter) }; diff --git a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp index 63e8c5217..664996080 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -126,8 +125,8 @@ int LagrangeInterpolator::process (const double actualRatio, const float* in, pos += 1.0; } - *out++ = LagrangeHelpers::valueAtOffset (lastInputSamples, 1.0f - (float) pos); pos -= actualRatio; + *out++ = LagrangeHelpers::valueAtOffset (lastInputSamples, 1.0f - (float) pos); } } @@ -191,8 +190,8 @@ int LagrangeInterpolator::processAdding (const double actualRatio, const float* pos += 1.0; } - *out++ += gain * LagrangeHelpers::valueAtOffset (lastInputSamples, 1.0f - (float) pos); pos -= actualRatio; + *out++ += gain * LagrangeHelpers::valueAtOffset (lastInputSamples, jmax (0.0f, 1.0f - (float) pos)); } } diff --git a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h index 1c2e6c3cc..9ae626291 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h +++ b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_Reverb.h b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_Reverb.h index d5a713edd..d50d4790e 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/effects/juce_Reverb.h +++ b/JuceLibraryCode/modules/juce_audio_basics/effects/juce_Reverb.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -221,7 +220,10 @@ private: class CombFilter { public: - CombFilter() noexcept : bufferSize (0), bufferIndex (0) {} + CombFilter() noexcept + : bufferSize (0), bufferIndex (0), + feedback (0), last (0), damp1 (0), damp2 (0) + {} void setSize (const int size) { diff --git a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.cpp b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.cpp index 0f5c6897f..1819d7565 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -79,3 +78,10 @@ namespace juce // END_AUTOINCLUDE } +ce_ResamplingAudioSource.cpp" +#include "sources/juce_ReverbAudioSource.cpp" +#include "sources/juce_ToneGeneratorAudioSource.cpp" +#include "synthesisers/juce_Synthesiser.cpp" +// END_AUTOINCLUDE + +} diff --git a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h index 43ac33a0e..550f07d7f 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h +++ b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -104,3 +103,13 @@ namespace juce } #endif // __JUCE_AUDIO_BASICS_JUCEHEADER__ +oneGeneratorAudioSource.h" +#endif +#ifndef __JUCE_SYNTHESISER_JUCEHEADER__ + #include "synthesisers/juce_Synthesiser.h" +#endif +// END_AUTOINCLUDE + +} + +#endif // __JUCE_AUDIO_BASICS_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.mm b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.mm index 3feb355de..ee35a17f8 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.mm +++ b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.mm @@ -1,23 +1,29 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#include "juce_audio_basics.cpp" +e available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== diff --git a/JuceLibraryCode/modules/juce_audio_basics/juce_module_info b/JuceLibraryCode/modules/juce_audio_basics/juce_module_info index 0cbc34055..b05e66a4f 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/juce_module_info +++ b/JuceLibraryCode/modules/juce_audio_basics/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_audio_basics", "name": "JUCE audio and midi data classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for audio buffer manipulation, midi message handling, synthesis, etc", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", @@ -22,3 +22,4 @@ "OSXFrameworks": "Accelerate", "iOSFrameworks": "Accelerate" } + diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_AudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_AudioSource.h index 0e586e76f..cf6ea1b86 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_AudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_AudioSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp index d7f627a74..61c0e29eb 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -36,6 +35,7 @@ BufferingAudioSource::BufferingAudioSource (PositionableAudioSource* source_, bufferValidStart (0), bufferValidEnd (0), nextPlayPos (0), + sampleRate (0), wasSourceLooping (false), isPrepared (false) { @@ -209,42 +209,40 @@ bool BufferingAudioSource::readNextBufferChunk() } } - if (sectionToReadStart != sectionToReadEnd) - { - jassert (buffer.getNumSamples() > 0); - const int bufferIndexStart = (int) (sectionToReadStart % buffer.getNumSamples()); - const int bufferIndexEnd = (int) (sectionToReadEnd % buffer.getNumSamples()); + if (sectionToReadStart == sectionToReadEnd) + return false; - if (bufferIndexStart < bufferIndexEnd) - { - readBufferSection (sectionToReadStart, - (int) (sectionToReadEnd - sectionToReadStart), - bufferIndexStart); - } - else - { - const int initialSize = buffer.getNumSamples() - bufferIndexStart; + jassert (buffer.getNumSamples() > 0); + const int bufferIndexStart = (int) (sectionToReadStart % buffer.getNumSamples()); + const int bufferIndexEnd = (int) (sectionToReadEnd % buffer.getNumSamples()); - readBufferSection (sectionToReadStart, - initialSize, - bufferIndexStart); + if (bufferIndexStart < bufferIndexEnd) + { + readBufferSection (sectionToReadStart, + (int) (sectionToReadEnd - sectionToReadStart), + bufferIndexStart); + } + else + { + const int initialSize = buffer.getNumSamples() - bufferIndexStart; - readBufferSection (sectionToReadStart + initialSize, - (int) (sectionToReadEnd - sectionToReadStart) - initialSize, - 0); - } + readBufferSection (sectionToReadStart, + initialSize, + bufferIndexStart); + readBufferSection (sectionToReadStart + initialSize, + (int) (sectionToReadEnd - sectionToReadStart) - initialSize, + 0); + } + + { const ScopedLock sl2 (bufferStartPosLock); bufferValidStart = newBVS; bufferValidEnd = newBVE; - - return true; - } - else - { - return false; } + + return true; } void BufferingAudioSource::readBufferSection (const int64 start, const int length, const int bufferOffset) diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h index 16abdf9bb..961e5a30c 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp index 67ffc019b..af408b10b 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h index d6adbd191..8c3da8674 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp index a2bad7760..712a24b9d 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -36,10 +35,16 @@ IIRFilterAudioSource::IIRFilterAudioSource (AudioSource* const inputSource, IIRFilterAudioSource::~IIRFilterAudioSource() {} //============================================================================== -void IIRFilterAudioSource::setFilterParameters (const IIRFilter& newSettings) +void IIRFilterAudioSource::setCoefficients (const IIRCoefficients& newCoefficients) { for (int i = iirFilters.size(); --i >= 0;) - iirFilters.getUnchecked(i)->copyCoefficientsFrom (newSettings); + iirFilters.getUnchecked(i)->setCoefficients (newCoefficients); +} + +void IIRFilterAudioSource::makeInactive() +{ + for (int i = iirFilters.size(); --i >= 0;) + iirFilters.getUnchecked(i)->makeInactive(); } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h index 7df1ea9e4..04a8bf2b3 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -52,7 +51,10 @@ public: //============================================================================== /** Changes the filter to use the same parameters as the one being passed in. */ - void setFilterParameters (const IIRFilter& newSettings); + void setCoefficients (const IIRCoefficients& newCoefficients); + + /** Calls IIRFilter::makeInactive() on all the filters being used internally. */ + void makeInactive(); //============================================================================== void prepareToPlay (int samplesPerBlockExpected, double sampleRate); diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp index 61368b33e..f5a2f8fb0 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.h index 418043c3b..1cdb48410 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h index 2ffe737ae..755c0ede8 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp index 349eb3338..4f8c4cf25 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -30,10 +29,14 @@ ResamplingAudioSource::ResamplingAudioSource (AudioSource* const inputSource, ratio (1.0), lastRatio (1.0), buffer (numChannels_, 0), + bufferPos (0), sampsInBuffer (0), + subSampleOffset (0), numChannels (numChannels_) { jassert (input != nullptr); + + zeromem (coefficients, sizeof (coefficients)); } ResamplingAudioSource::~ResamplingAudioSource() {} diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h index 2f5a7c43e..cb5bc3258 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp index 55c16bced..fc38e6054 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h index d4db67140..11c286ae0 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp index 5629e5577..7bf4c4dd9 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h index 69e33b31f..0bbd5c8ad 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp b/JuceLibraryCode/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp index 2eb9df474..5a8e0f84e 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h b/JuceLibraryCode/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h index a6681d055..0fe263cb8 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h +++ b/JuceLibraryCode/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDBurner.h b/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDBurner.h index f56604bfa..2768bc716 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDBurner.h +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDBurner.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDReader.cpp b/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDReader.cpp index 58c87faef..ca9c5b0f2 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDReader.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDReader.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDReader.h b/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDReader.h index a939ed489..3b322a62c 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDReader.h +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_cd/juce_AudioCDReader.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index a42acf187..6806e5cea 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -94,8 +93,8 @@ AudioDeviceManager::AudioDeviceManager() numOutputChansNeeded (2), listNeedsScanning (true), useInputNames (false), - inputLevelMeasurementEnabledCount (0), inputLevel (0), + testSoundPosition (0), tempBuffer (2, 2), cpuUsageMs (0), timeToCpuScale (0) @@ -138,9 +137,9 @@ void AudioDeviceManager::audioDeviceListChanged() { if (currentAudioDevice != nullptr) { - currentSetup.sampleRate = currentAudioDevice->getCurrentSampleRate(); - currentSetup.bufferSize = currentAudioDevice->getCurrentBufferSizeSamples(); - currentSetup.inputChannels = currentAudioDevice->getActiveInputChannels(); + currentSetup.sampleRate = currentAudioDevice->getCurrentSampleRate(); + currentSetup.bufferSize = currentAudioDevice->getCurrentBufferSizeSamples(); + currentSetup.inputChannels = currentAudioDevice->getActiveInputChannels(); currentSetup.outputChannels = currentAudioDevice->getActiveOutputChannels(); } @@ -374,6 +373,13 @@ void AudioDeviceManager::setCurrentAudioDeviceType (const String& type, if (availableDeviceTypes.getUnchecked(i)->getTypeName() == type && currentDeviceType != type) { + if (currentAudioDevice != nullptr) + { + closeAudioDevice(); + Thread::sleep (1500); // allow a moment for OS devices to sort themselves out, to help + // avoid things like DirectSound/ASIO clashes + } + currentDeviceType = type; AudioDeviceSetup s (*lastDeviceTypeConfigs.getUnchecked(i)); @@ -390,8 +396,8 @@ void AudioDeviceManager::setCurrentAudioDeviceType (const String& type, AudioIODeviceType* AudioDeviceManager::getCurrentDeviceTypeObject() const { for (int i = 0; i < availableDeviceTypes.size(); ++i) - if (availableDeviceTypes[i]->getTypeName() == currentDeviceType) - return availableDeviceTypes[i]; + if (availableDeviceTypes.getUnchecked(i)->getTypeName() == currentDeviceType) + return availableDeviceTypes.getUnchecked(i); return availableDeviceTypes[0]; } @@ -447,7 +453,9 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup currentAudioDevice = type->createDevice (newOutputDeviceName, newInputDeviceName); if (currentAudioDevice == nullptr) - error = "Can't open the audio device!\n\nThis may be because another application is currently using the same device - if so, you should close any other applications and try again!"; + error = "Can't open the audio device!\n\n" + "This may be because another application is currently using the same device - " + "if so, you should close any other applications and try again!"; else error = currentAudioDevice->getLastError(); @@ -615,13 +623,9 @@ void AudioDeviceManager::updateXml() const StringArray availableMidiDevices (MidiInput::getDevices()); for (int i = 0; i < midiInsFromXml.size(); ++i) - { if (! availableMidiDevices.contains (midiInsFromXml[i], true)) - { lastExplicitSettings->createNewChildElement ("MIDIINPUT") ->setAttribute ("name", midiInsFromXml[i]); - } - } } if (defaultMidiOutputName.isNotEmpty()) @@ -670,7 +674,7 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat { const ScopedLock sl (audioCallbackLock); - if (inputLevelMeasurementEnabledCount > 0 && numInputChannels > 0) + if (inputLevelMeasurementEnabledCount.get() > 0 && numInputChannels > 0) { for (int j = 0; j < numSamples; ++j) { @@ -950,8 +954,6 @@ void AudioDeviceManager::playTestSound() void AudioDeviceManager::enableInputLevelMeasurement (const bool enableMeasurement) { - const ScopedLock sl (audioCallbackLock); - if (enableMeasurement) ++inputLevelMeasurementEnabledCount; else @@ -962,6 +964,6 @@ void AudioDeviceManager::enableInputLevelMeasurement (const bool enableMeasureme double AudioDeviceManager::getCurrentInputLevel() const { - jassert (inputLevelMeasurementEnabledCount > 0); // you need to call enableInputLevelMeasurement() before using this! + jassert (inputLevelMeasurementEnabledCount.get() > 0); // you need to call enableInputLevelMeasurement() before using this! return inputLevel; } diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h index ac9c8f9c1..e6cb4cfaf 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -166,9 +165,12 @@ public: This will attempt to open either a default audio device, or one that was previously saved as XML. - @param numInputChannelsNeeded a minimum number of input channels needed - by your app. - @param numOutputChannelsNeeded a minimum number of output channels to open + @param numInputChannelsNeeded the maximum number of input channels your app would like to + use (the actual number of channels opened may be less than + the number requested) + @param numOutputChannelsNeeded the maximum number of output channels your app would like to + use (the actual number of channels opened may be less than + the number requested) @param savedState either a previously-saved state that was produced by createStateXml(), or nullptr if you want the manager to choose the best device to open. @@ -460,7 +462,7 @@ private: ScopedPointer <XmlElement> lastExplicitSettings; mutable bool listNeedsScanning; bool useInputNames; - int inputLevelMeasurementEnabledCount; + Atomic<int> inputLevelMeasurementEnabledCount; double inputLevel; ScopedPointer <AudioSampleBuffer> testSound; int testSoundPosition; diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp index 93dbf80c8..1386d0c50 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h index 7e52852a4..01c0350da 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp index a32f080f7..80026e7ae 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h index 0407dd8c2..c61505144 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h new file mode 100644 index 000000000..946b38115 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h @@ -0,0 +1,60 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_SYSTEMAUDIOVOLUME_JUCEHEADER__ +#define __JUCE_SYSTEMAUDIOVOLUME_JUCEHEADER__ + +//============================================================================== +/** + Contains functions to control the system's master volume. +*/ +class JUCE_API SystemAudioVolume +{ +public: + //============================================================================== + /** Returns the operating system's current volume level in the range 0 to 1.0 */ + static float JUCE_CALLTYPE getGain(); + + /** Attempts to set the operating system's current volume level. + @param newGain the level, between 0 and 1.0 + @returns true if the operation succeeds + */ + static bool JUCE_CALLTYPE setGain (float newGain); + + /** Returns true if the system's audio output is currently muted. */ + static bool JUCE_CALLTYPE isMuted(); + + /** Attempts to mute the operating system's audio output. + @param shouldBeMuted true if you want it to be muted + @returns true if the operation succeeds + */ + static bool JUCE_CALLTYPE setMuted (bool shouldBeMuted); + +private: + SystemAudioVolume(); // Don't instantiate this class, just call its static fns. + JUCE_DECLARE_NON_COPYABLE (SystemAudioVolume) +}; + + +#endif // __JUCE_SYSTEMAUDIOVOLUME_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.cpp b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.cpp index 3094ae87f..114f24a11 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -46,6 +45,7 @@ #import <CoreAudio/AudioHardware.h> #import <CoreMIDI/MIDIServices.h> #import <DiscRecording/DiscRecording.h> + #import <AudioToolbox/AudioServices.h> #undef Point #undef Component @@ -57,14 +57,7 @@ //============================================================================== #elif JUCE_WINDOWS #if JUCE_WASAPI - #pragma warning (push) - #pragma warning (disable: 4201) #include <MMReg.h> - #include <Audioclient.h> - #include <Audiopolicy.h> - #include <Avrt.h> - #include <functiondiscoverykeys.h> - #pragma warning (pop) #endif #if JUCE_ASIO @@ -233,4 +226,11 @@ namespace juce #endif +#if ! JUCE_SYSTEMAUDIOVOL_IMPLEMENTED + // None of these methods are available. (On Windows you might need to enable WASAPI for this) + float JUCE_CALLTYPE SystemAudioVolume::getGain() { jassertfalse; return 0.0f; } + bool JUCE_CALLTYPE SystemAudioVolume::setGain (float) { jassertfalse; return false; } + bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { jassertfalse; return false; } + bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; } +#endif } diff --git a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h index 2f555307e..f68a4f0b5 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h +++ b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -111,6 +110,9 @@ namespace juce #ifndef __JUCE_AUDIOIODEVICETYPE_JUCEHEADER__ #include "audio_io/juce_AudioIODeviceType.h" #endif +#ifndef __JUCE_SYSTEMAUDIOVOLUME_JUCEHEADER__ + #include "audio_io/juce_SystemAudioVolume.h" +#endif #ifndef __JUCE_MIDIINPUT_JUCEHEADER__ #include "midi_io/juce_MidiInput.h" #endif diff --git a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.mm b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.mm index ea13a2f6e..a135119ce 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.mm +++ b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/juce_module_info b/JuceLibraryCode/modules/juce_audio_devices/juce_module_info index 9b55bc831..a6b9cc839 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/juce_module_info +++ b/JuceLibraryCode/modules/juce_audio_devices/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_audio_devices", "name": "JUCE audio and midi I/O device classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes to play and record from audio and midi i/o devices.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", @@ -23,5 +23,6 @@ "OSXFrameworks": "CoreAudio CoreMIDI DiscRecording", "iOSFrameworks": "AudioToolbox CoreMIDI", - "LinuxLibs": "asound" + "LinuxLibs": "asound", + "mingwLibs": "winmm" } diff --git a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiInput.h b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiInput.h index 0397c0873..674640a55 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiInput.h +++ b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiInput.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp index 8474a9301..28e81c0eb 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h index c7442232c..b4739209e 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h +++ b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp index 1bebd7842..0af7d1b7c 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiOutput.h b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiOutput.h index 81ccd63b6..7c8dd8c63 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiOutput.h +++ b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiOutput.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h b/JuceLibraryCode/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h index da5eee834..1c310d5f7 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_Audio.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_Audio.cpp index d3b6ce3ff..97d1047a2 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_Audio.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_Audio.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_Midi.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_Midi.cpp index b8a79bb6d..f84fc7177 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_Midi.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_Midi.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_OpenSL.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_OpenSL.cpp index 0775fa3d6..7ad9fad16 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_OpenSL.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_android_OpenSL.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_ios_Audio.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_ios_Audio.cpp index e7a29ef02..1dde3236b 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_ios_Audio.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_ios_Audio.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -345,7 +344,7 @@ private: Float32 bufferDuration = preferredBufferSize / sampleRate; UInt32 bufferDurationSize = sizeof (bufferDuration); - AudioSessionGetProperty (kAudioSessionProperty_CurrentHardwareIOBufferDuration, &bufferDurationSize, &bufferDurationSize); + AudioSessionGetProperty (kAudioSessionProperty_CurrentHardwareIOBufferDuration, &bufferDurationSize, &bufferDuration); actualBufferSize = (int) (sampleRate * bufferDuration + 0.5); AudioOutputUnitStart (audioUnit); @@ -381,7 +380,9 @@ private: { if (interruptionType == kAudioSessionBeginInterruption) { - close(); + isRunning = false; + AudioOutputUnitStop (audioUnit); + AudioSessionSetActive (false); const ScopedLock sl (callbackLock); diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_ALSA.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_ALSA.cpp index 782a749f5..958a47c8d 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_ALSA.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_ALSA.cpp @@ -1,134 +1,185 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ namespace { - void getDeviceSampleRates (snd_pcm_t* handle, Array <int>& rates) - { - const int ratesToTry[] = { 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000, 0 }; - snd_pcm_hw_params_t* hwParams; - snd_pcm_hw_params_alloca (&hwParams); +#ifndef JUCE_ALSA_LOGGING + #define JUCE_ALSA_LOGGING 0 +#endif + +#if JUCE_ALSA_LOGGING + #define JUCE_ALSA_LOG(dbgtext) { juce::String tempDbgBuf ("ALSA: "); tempDbgBuf << dbgtext; Logger::writeToLog (tempDbgBuf); DBG (tempDbgBuf) } + #define JUCE_CHECKED_RESULT(x) (logErrorMessage (x, __LINE__)) - for (int i = 0; ratesToTry[i] != 0; ++i) + static int logErrorMessage (int err, int lineNum) + { + if (err < 0) + JUCE_ALSA_LOG ("Error: line " << lineNum << ": code " << err << " (" << snd_strerror (err) << ")"); + + return err; + } +#else + #define JUCE_ALSA_LOG(x) + #define JUCE_CHECKED_RESULT(x) (x) +#endif + +#define JUCE_ALSA_FAILED(x) failed (x) + +void getDeviceSampleRates (snd_pcm_t* handle, Array <int>& rates) +{ + const int ratesToTry[] = { 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000, 0 }; + + snd_pcm_hw_params_t* hwParams; + snd_pcm_hw_params_alloca (&hwParams); + + for (int i = 0; ratesToTry[i] != 0; ++i) + { + if (snd_pcm_hw_params_any (handle, hwParams) >= 0 + && snd_pcm_hw_params_test_rate (handle, hwParams, ratesToTry[i], 0) == 0) { - if (snd_pcm_hw_params_any (handle, hwParams) >= 0 - && snd_pcm_hw_params_test_rate (handle, hwParams, ratesToTry[i], 0) == 0) - { - rates.addIfNotAlreadyThere (ratesToTry[i]); - } + rates.addIfNotAlreadyThere (ratesToTry[i]); } } +} + +void getDeviceNumChannels (snd_pcm_t* handle, unsigned int* minChans, unsigned int* maxChans) +{ + snd_pcm_hw_params_t *params; + snd_pcm_hw_params_alloca (¶ms); - void getDeviceNumChannels (snd_pcm_t* handle, unsigned int* minChans, unsigned int* maxChans) + if (snd_pcm_hw_params_any (handle, params) >= 0) { - snd_pcm_hw_params_t *params; - snd_pcm_hw_params_alloca (¶ms); + snd_pcm_hw_params_get_channels_min (params, minChans); + snd_pcm_hw_params_get_channels_max (params, maxChans); - if (snd_pcm_hw_params_any (handle, params) >= 0) - { - snd_pcm_hw_params_get_channels_min (params, minChans); - snd_pcm_hw_params_get_channels_max (params, maxChans); - } - } + JUCE_ALSA_LOG ("getDeviceNumChannels: " << (int) *minChans << " " << (int) *maxChans); - void getDeviceProperties (const String& deviceID, - unsigned int& minChansOut, - unsigned int& maxChansOut, - unsigned int& minChansIn, - unsigned int& maxChansIn, - Array <int>& rates) + // some virtual devices (dmix for example) report 10000 channels , we have to clamp these values + *maxChans = jmin (*maxChans, 32u); + *minChans = jmin (*minChans, *maxChans); + } + else { - if (deviceID.isEmpty()) - return; + JUCE_ALSA_LOG ("getDeviceNumChannels failed"); + } +} - snd_ctl_t* handle; +void getDeviceProperties (const String& deviceID, + unsigned int& minChansOut, + unsigned int& maxChansOut, + unsigned int& minChansIn, + unsigned int& maxChansIn, + Array <int>& rates, + bool testOutput = true, + bool testInput = true) +{ + minChansOut = maxChansOut = minChansIn = maxChansIn = 0; - if (snd_ctl_open (&handle, deviceID.upToLastOccurrenceOf (",", false, false).toUTF8(), SND_CTL_NONBLOCK) >= 0) - { - snd_pcm_info_t* info; - snd_pcm_info_alloca (&info); + if (deviceID.isEmpty()) + return; - snd_pcm_info_set_stream (info, SND_PCM_STREAM_PLAYBACK); - snd_pcm_info_set_device (info, deviceID.fromLastOccurrenceOf (",", false, false).getIntValue()); - snd_pcm_info_set_subdevice (info, 0); + JUCE_ALSA_LOG ("getDeviceProperties(" << deviceID.toUTF8().getAddress() << ")"); - if (snd_ctl_pcm_info (handle, info) >= 0) - { - snd_pcm_t* pcmHandle; - if (snd_pcm_open (&pcmHandle, deviceID.toUTF8(), SND_PCM_STREAM_PLAYBACK, SND_PCM_ASYNC | SND_PCM_NONBLOCK) >= 0) - { - getDeviceNumChannels (pcmHandle, &minChansOut, &maxChansOut); - getDeviceSampleRates (pcmHandle, rates); + snd_pcm_info_t* info; + snd_pcm_info_alloca (&info); - snd_pcm_close (pcmHandle); - } - } + if (testOutput) + { + snd_pcm_t* pcmHandle; - snd_pcm_info_set_stream (info, SND_PCM_STREAM_CAPTURE); + if (JUCE_CHECKED_RESULT (snd_pcm_open (&pcmHandle, deviceID.toUTF8().getAddress(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) >= 0) + { + getDeviceNumChannels (pcmHandle, &minChansOut, &maxChansOut); + getDeviceSampleRates (pcmHandle, rates); - if (snd_ctl_pcm_info (handle, info) >= 0) - { - snd_pcm_t* pcmHandle; - if (snd_pcm_open (&pcmHandle, deviceID.toUTF8(), SND_PCM_STREAM_CAPTURE, SND_PCM_ASYNC | SND_PCM_NONBLOCK) >= 0) - { - getDeviceNumChannels (pcmHandle, &minChansIn, &maxChansIn); + snd_pcm_close (pcmHandle); + } + } - if (rates.size() == 0) - getDeviceSampleRates (pcmHandle, rates); + if (testInput) + { + snd_pcm_t* pcmHandle; - snd_pcm_close (pcmHandle); - } - } + if (JUCE_CHECKED_RESULT (snd_pcm_open (&pcmHandle, deviceID.toUTF8(), SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK) >= 0)) + { + getDeviceNumChannels (pcmHandle, &minChansIn, &maxChansIn); + + if (rates.size() == 0) + getDeviceSampleRates (pcmHandle, rates); - snd_ctl_close (handle); + snd_pcm_close (pcmHandle); } } } +static void silentErrorHandler (const char*, int, const char*, int, const char*,...) {} + //============================================================================== class ALSADevice { public: - ALSADevice (const String& deviceID, bool forInput) + ALSADevice (const String& devID, bool forInput) : handle (0), bitDepth (16), numChannelsRunning (0), latency (0), + deviceID (devID), isInput (forInput), isInterleaved (true) { - failed (snd_pcm_open (&handle, deviceID.toUTF8(), - forInput ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, - SND_PCM_ASYNC)); + JUCE_ALSA_LOG ("snd_pcm_open (" << deviceID.toUTF8().getAddress() << ", forInput=" << forInput << ")"); + + int err = snd_pcm_open (&handle, deviceID.toUTF8(), + forInput ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, + SND_PCM_ASYNC); + if (err < 0) + { + if (-err == EBUSY) + error << "The device \"" << deviceID << "\" is busy (another application is using it)."; + else if (-err == ENOENT) + error << "The device \"" << deviceID << "\" is not available."; + else + error << "Could not open " << (forInput ? "input" : "output") << " device \"" << deviceID + << "\": " << snd_strerror(err) << " (" << err << ")"; + + JUCE_ALSA_LOG ("snd_pcm_open failed; " << error); + } } ~ALSADevice() + { + closeNow(); + } + + void closeNow() { if (handle != 0) + { snd_pcm_close (handle); + handle = 0; + } } bool setParameters (unsigned int sampleRate, int numChannels, int bufferSize) @@ -136,16 +187,24 @@ public: if (handle == 0) return false; + JUCE_ALSA_LOG ("ALSADevice::setParameters(" << deviceID << ", " + << (int) sampleRate << ", " << numChannels << ", " << bufferSize << ")"); + snd_pcm_hw_params_t* hwParams; snd_pcm_hw_params_alloca (&hwParams); - if (failed (snd_pcm_hw_params_any (handle, hwParams))) + if (snd_pcm_hw_params_any (handle, hwParams) < 0) + { + // this is the error message that aplay returns when an error happens here, + // it is a bit more explicit that "Invalid parameter" + error = "Broken configuration for this PCM: no configurations available"; return false; + } - if (snd_pcm_hw_params_set_access (handle, hwParams, SND_PCM_ACCESS_RW_NONINTERLEAVED) >= 0) - isInterleaved = false; - else if (snd_pcm_hw_params_set_access (handle, hwParams, SND_PCM_ACCESS_RW_INTERLEAVED) >= 0) + if (snd_pcm_hw_params_set_access (handle, hwParams, SND_PCM_ACCESS_RW_INTERLEAVED) >= 0) // works better for plughw.. isInterleaved = true; + else if (snd_pcm_hw_params_set_access (handle, hwParams, SND_PCM_ACCESS_RW_NONINTERLEAVED) >= 0) + isInterleaved = false; else { jassertfalse; @@ -172,6 +231,10 @@ public: const bool isFloat = (formatsToTry [i + 1] & isFloatBit) != 0; const bool isLittleEndian = (formatsToTry [i + 1] & isLittleEndianBit) != 0; converter = createConverter (isInput, bitDepth, isFloat, isLittleEndian, numChannels); + + JUCE_ALSA_LOG ("format: bitDepth=" << bitDepth << ", isFloat=" + << isFloat << ", isLittleEndian=" << isLittleEndian + << ", numChannels=" << numChannels); break; } } @@ -179,7 +242,7 @@ public: if (bitDepth == 0) { error = "device doesn't support a compatible PCM format"; - DBG ("ALSA error: " + error + "\n"); + JUCE_ALSA_LOG ("Error: " + error); return false; } @@ -187,45 +250,48 @@ public: unsigned int periods = 4; snd_pcm_uframes_t samplesPerPeriod = bufferSize; - if (failed (snd_pcm_hw_params_set_rate_near (handle, hwParams, &sampleRate, 0)) - || failed (snd_pcm_hw_params_set_channels (handle, hwParams, numChannels)) - || failed (snd_pcm_hw_params_set_periods_near (handle, hwParams, &periods, &dir)) - || failed (snd_pcm_hw_params_set_period_size_near (handle, hwParams, &samplesPerPeriod, &dir)) - || failed (snd_pcm_hw_params (handle, hwParams))) + if (JUCE_ALSA_FAILED (snd_pcm_hw_params_set_rate_near (handle, hwParams, &sampleRate, 0)) + || JUCE_ALSA_FAILED (snd_pcm_hw_params_set_channels (handle, hwParams, numChannels)) + || JUCE_ALSA_FAILED (snd_pcm_hw_params_set_periods_near (handle, hwParams, &periods, &dir)) + || JUCE_ALSA_FAILED (snd_pcm_hw_params_set_period_size_near (handle, hwParams, &samplesPerPeriod, &dir)) + || JUCE_ALSA_FAILED (snd_pcm_hw_params (handle, hwParams))) { return false; } snd_pcm_uframes_t frames = 0; - if (failed (snd_pcm_hw_params_get_period_size (hwParams, &frames, &dir)) - || failed (snd_pcm_hw_params_get_periods (hwParams, &periods, &dir))) + if (JUCE_ALSA_FAILED (snd_pcm_hw_params_get_period_size (hwParams, &frames, &dir)) + || JUCE_ALSA_FAILED (snd_pcm_hw_params_get_periods (hwParams, &periods, &dir))) latency = 0; else latency = frames * (periods - 1); // (this is the method JACK uses to guess the latency..) + JUCE_ALSA_LOG ("frames: " << (int) frames << ", periods: " << (int) periods + << ", samplesPerPeriod: " << (int) samplesPerPeriod); + snd_pcm_sw_params_t* swParams; snd_pcm_sw_params_alloca (&swParams); snd_pcm_uframes_t boundary; - if (failed (snd_pcm_sw_params_current (handle, swParams)) - || failed (snd_pcm_sw_params_get_boundary (swParams, &boundary)) - || failed (snd_pcm_sw_params_set_silence_threshold (handle, swParams, 0)) - || failed (snd_pcm_sw_params_set_silence_size (handle, swParams, boundary)) - || failed (snd_pcm_sw_params_set_start_threshold (handle, swParams, samplesPerPeriod)) - || failed (snd_pcm_sw_params_set_stop_threshold (handle, swParams, boundary)) - || failed (snd_pcm_sw_params (handle, swParams))) + if (JUCE_ALSA_FAILED (snd_pcm_sw_params_current (handle, swParams)) + || JUCE_ALSA_FAILED (snd_pcm_sw_params_get_boundary (swParams, &boundary)) + || JUCE_ALSA_FAILED (snd_pcm_sw_params_set_silence_threshold (handle, swParams, 0)) + || JUCE_ALSA_FAILED (snd_pcm_sw_params_set_silence_size (handle, swParams, boundary)) + || JUCE_ALSA_FAILED (snd_pcm_sw_params_set_start_threshold (handle, swParams, samplesPerPeriod)) + || JUCE_ALSA_FAILED (snd_pcm_sw_params_set_stop_threshold (handle, swParams, boundary)) + || JUCE_ALSA_FAILED (snd_pcm_sw_params (handle, swParams))) { return false; } - #if 0 + #if JUCE_ALSA_LOGGING // enable this to dump the config of the devices that get opened snd_output_t* out; snd_output_stdio_attach (&out, stderr, 0); snd_pcm_hw_params_dump (hwParams, out); snd_pcm_sw_params_dump (swParams, out); - #endif + #endif numChannelsRunning = numChannels; @@ -256,16 +322,11 @@ public: numDone = snd_pcm_writen (handle, (void**) data, numSamples); } - if (failed (numDone)) - { - if (numDone == -EPIPE) - { - if (failed (snd_pcm_prepare (handle))) - return false; - } - else if (numDone != -ESTRPIPE) - return false; - } + if (numDone < 0 && JUCE_ALSA_FAILED (snd_pcm_recover (handle, numDone, 1 /* silent */))) + return false; + + if (numDone < numSamples) + JUCE_ALSA_LOG ("Did not write all samples: numDone: " << numDone << ", numSamples: " << numSamples); return true; } @@ -282,16 +343,11 @@ public: snd_pcm_sframes_t num = snd_pcm_readi (handle, scratch.getData(), numSamples); - if (failed (num)) - { - if (num == -EPIPE) - { - if (failed (snd_pcm_prepare (handle))) - return false; - } - else if (num != -ESTRPIPE) - return false; - } + if (num < 0 && JUCE_ALSA_FAILED (snd_pcm_recover (handle, num, 1 /* silent */))) + return false; + + if (num < numSamples) + JUCE_ALSA_LOG ("Did not read all samples: num: " << num << ", numSamples: " << numSamples); for (int i = 0; i < numChannelsRunning; ++i) converter->convertSamples (data[i], 0, scratch.getData(), i, numSamples); @@ -300,9 +356,12 @@ public: { snd_pcm_sframes_t num = snd_pcm_readn (handle, (void**) data, numSamples); - if (failed (num) && num != -EPIPE && num != -ESTRPIPE) + if (num < 0 && JUCE_ALSA_FAILED (snd_pcm_recover (handle, num, 1 /* silent */))) return false; + if (num < numSamples) + JUCE_ALSA_LOG ("Did not read all samples: num: " << num << ", numSamples: " << numSamples); + for (int i = 0; i < numChannelsRunning; ++i) converter->convertSamples (data[i], data[i], numSamples); } @@ -315,8 +374,9 @@ public: String error; int bitDepth, numChannelsRunning, latency; - //============================================================================== private: + //============================================================================== + String deviceID; const bool isInput; bool isInterleaved; MemoryBlock scratch; @@ -334,8 +394,8 @@ private: if (isLittleEndian) return new AudioData::ConverterInstance <AudioData::Pointer <SampleType, AudioData::LittleEndian, AudioData::Interleaved, AudioData::Const>, DestType> (numInterleavedChannels, 1); - else - return new AudioData::ConverterInstance <AudioData::Pointer <SampleType, AudioData::BigEndian, AudioData::Interleaved, AudioData::Const>, DestType> (numInterleavedChannels, 1); + + return new AudioData::ConverterInstance <AudioData::Pointer <SampleType, AudioData::BigEndian, AudioData::Interleaved, AudioData::Const>, DestType> (numInterleavedChannels, 1); } else { @@ -343,8 +403,8 @@ private: if (isLittleEndian) return new AudioData::ConverterInstance <SourceType, AudioData::Pointer <SampleType, AudioData::LittleEndian, AudioData::Interleaved, AudioData::NonConst> > (1, numInterleavedChannels); - else - return new AudioData::ConverterInstance <SourceType, AudioData::Pointer <SampleType, AudioData::BigEndian, AudioData::Interleaved, AudioData::NonConst> > (1, numInterleavedChannels); + + return new AudioData::ConverterInstance <SourceType, AudioData::Pointer <SampleType, AudioData::BigEndian, AudioData::Interleaved, AudioData::NonConst> > (1, numInterleavedChannels); } } }; @@ -370,7 +430,7 @@ private: return false; error = snd_strerror (errorNum); - DBG ("ALSA error: " + error + "\n"); + JUCE_ALSA_LOG ("ALSA error: " << error); return true; } @@ -392,6 +452,7 @@ public: inputId (inputId_), outputId (outputId_), numCallbacks (0), + audioIoInProgress (false), inputChannelBuffer (1, 1), outputChannelBuffer (1, 1) { @@ -505,14 +566,12 @@ public: } if (outputDevice != nullptr && inputDevice != nullptr) - { snd_pcm_link (outputDevice->handle, inputDevice->handle); - } - if (inputDevice != nullptr && failed (snd_pcm_prepare (inputDevice->handle))) + if (inputDevice != nullptr && JUCE_ALSA_FAILED (snd_pcm_prepare (inputDevice->handle))) return; - if (outputDevice != nullptr && failed (snd_pcm_prepare (outputDevice->handle))) + if (outputDevice != nullptr && JUCE_ALSA_FAILED (snd_pcm_prepare (outputDevice->handle))) return; startThread (9); @@ -533,6 +592,25 @@ public: void close() { + if (isThreadRunning()) + { + // problem: when pulseaudio is suspended (with pasuspend) , the ALSAThread::run is just stuck in + // snd_pcm_writei -- no error, no nothing it just stays stuck. So the only way I found to exit "nicely" + // (that is without the "killing thread by force" of stopThread) , is to just call snd_pcm_close from + // here which will cause the thread to resume, and exit + signalThreadShouldExit(); + + const int callbacksToStop = numCallbacks; + + if ((! waitForThreadToExit (400)) && audioIoInProgress && numCallbacks == callbacksToStop) + { + JUCE_ALSA_LOG ("Thread is stuck in i/o.. Is pulseaudio suspended?"); + + if (outputDevice != nullptr) outputDevice->closeNow(); + if (inputDevice != nullptr) inputDevice->closeNow(); + } + } + stopThread (6000); inputDevice = nullptr; @@ -554,13 +632,17 @@ public: { while (! threadShouldExit()) { - if (inputDevice != nullptr) + if (inputDevice != nullptr && inputDevice->handle) { + audioIoInProgress = true; + if (! inputDevice->readFromInputDevice (inputChannelBuffer, bufferSize)) { - DBG ("ALSA: read failure"); + JUCE_ALSA_LOG ("Read failure"); break; } + + audioIoInProgress = false; } if (threadShouldExit()) @@ -585,22 +667,30 @@ public: } } - if (outputDevice != nullptr) + if (outputDevice != nullptr && outputDevice->handle) { - failed (snd_pcm_wait (outputDevice->handle, 2000)); + JUCE_ALSA_FAILED (snd_pcm_wait (outputDevice->handle, 2000)); if (threadShouldExit()) break; - failed (snd_pcm_avail_update (outputDevice->handle)); + snd_pcm_sframes_t avail = snd_pcm_avail_update (outputDevice->handle); + + if (avail < 0) + JUCE_ALSA_FAILED (snd_pcm_recover (outputDevice->handle, avail, 0)); + + audioIoInProgress = true; if (! outputDevice->writeToOutputDevice (outputChannelBuffer, bufferSize)) { - DBG ("ALSA: write failure"); + JUCE_ALSA_LOG ("write failure"); break; } + + audioIoInProgress = false; } } + audioIoInProgress = false; } int getBitDepth() const noexcept @@ -629,6 +719,7 @@ private: const String inputId, outputId; ScopedPointer<ALSADevice> outputDevice, inputDevice; int numCallbacks; + bool audioIoInProgress; CriticalSection callbackLock; @@ -644,7 +735,7 @@ private: return false; error = snd_strerror (errorNum); - DBG ("ALSA error: " + error + "\n"); + JUCE_ALSA_LOG ("ALSA error: " << error); return true; } @@ -659,8 +750,8 @@ private: maxChansIn = 0; unsigned int dummy = 0; - getDeviceProperties (inputId, dummy, dummy, minChansIn, maxChansIn, sampleRates); - getDeviceProperties (outputId, minChansOut, maxChansOut, dummy, dummy, sampleRates); + getDeviceProperties (inputId, dummy, dummy, minChansIn, maxChansIn, sampleRates, false, true); + getDeviceProperties (outputId, minChansOut, maxChansOut, dummy, dummy, sampleRates, true, false); for (unsigned int i = 0; i < maxChansOut; ++i) channelNamesOut.add ("channel " + String ((int) i + 1)); @@ -678,9 +769,10 @@ class ALSAAudioIODevice : public AudioIODevice { public: ALSAAudioIODevice (const String& deviceName, + const String& typeName, const String& inputId_, const String& outputId_) - : AudioIODevice (deviceName, "ALSA"), + : AudioIODevice (deviceName, typeName), inputId (inputId_), outputId (outputId_), isOpen_ (false), @@ -782,7 +874,7 @@ public: { AudioIODeviceCallback* const oldCallback = internal.callback; - start (0); + start (nullptr); if (oldCallback != nullptr) oldCallback->audioDeviceStopped(); @@ -800,15 +892,23 @@ private: class ALSAAudioIODeviceType : public AudioIODeviceType { public: - //============================================================================== - ALSAAudioIODeviceType() - : AudioIODeviceType ("ALSA"), - hasScanned (false) + ALSAAudioIODeviceType (bool onlySoundcards, const String &typeName) + : AudioIODeviceType (typeName), + hasScanned (false), + listOnlySoundcards (onlySoundcards) { + #if ! JUCE_ALSA_LOGGING + snd_lib_error_set_handler (&silentErrorHandler); + #endif } ~ALSAAudioIODeviceType() { + #if ! JUCE_ALSA_LOGGING + snd_lib_error_set_handler (nullptr); + #endif + + snd_config_update_free_global(); // prevent valgrind from screaming about alsa leaks } //============================================================================== @@ -823,82 +923,176 @@ public: outputNames.clear(); outputIds.clear(); -/* void** hints = 0; - if (snd_device_name_hint (-1, "pcm", &hints) >= 0) - { - for (void** hint = hints; *hint != 0; ++hint) - { - const String name (getHint (*hint, "NAME")); + JUCE_ALSA_LOG ("scanForDevices()"); - if (name.isNotEmpty()) - { - const String ioid (getHint (*hint, "IOID")); + if (listOnlySoundcards) + enumerateAlsaSoundcards(); + else + enumerateAlsaPCMDevices(); - String desc (getHint (*hint, "DESC")); - if (desc.isEmpty()) - desc = name; + inputNames.appendNumbersToDuplicates (false, true); + outputNames.appendNumbersToDuplicates (false, true); + } - desc = desc.replaceCharacters ("\n\r", " "); + StringArray getDeviceNames (bool wantInputNames) const + { + jassert (hasScanned); // need to call scanForDevices() before doing this - DBG ("name: " << name << "\ndesc: " << desc << "\nIO: " << ioid); + return wantInputNames ? inputNames : outputNames; + } - if (ioid.isEmpty() || ioid == "Input") - { - inputNames.add (desc); - inputIds.add (name); - } + int getDefaultDeviceIndex (bool forInput) const + { + jassert (hasScanned); // need to call scanForDevices() before doing this - if (ioid.isEmpty() || ioid == "Output") - { - outputNames.add (desc); - outputIds.add (name); - } - } + const int idx = (forInput ? inputIds : outputIds).indexOf ("default"); + return idx >= 0 ? idx : 0; + } + + bool hasSeparateInputsAndOutputs() const { return true; } + + int getIndexOfDevice (AudioIODevice* device, bool asInput) const + { + jassert (hasScanned); // need to call scanForDevices() before doing this + + if (ALSAAudioIODevice* d = dynamic_cast <ALSAAudioIODevice*> (device)) + return asInput ? inputIds.indexOf (d->inputId) + : outputIds.indexOf (d->outputId); + + return -1; + } + + AudioIODevice* createDevice (const String& outputDeviceName, + const String& inputDeviceName) + { + jassert (hasScanned); // need to call scanForDevices() before doing this + + const int inputIndex = inputNames.indexOf (inputDeviceName); + const int outputIndex = outputNames.indexOf (outputDeviceName); + + String deviceName (outputIndex >= 0 ? outputDeviceName + : inputDeviceName); + + if (inputIndex >= 0 || outputIndex >= 0) + return new ALSAAudioIODevice (deviceName, getTypeName(), + inputIds [inputIndex], + outputIds [outputIndex]); + + return nullptr; + } + +private: + //============================================================================== + StringArray inputNames, outputNames, inputIds, outputIds; + bool hasScanned, listOnlySoundcards; + + bool testDevice (const String &id, const String &outputName, const String &inputName) + { + unsigned int minChansOut = 0, maxChansOut = 0; + unsigned int minChansIn = 0, maxChansIn = 0; + Array <int> rates; + + bool isInput = inputName.isNotEmpty(), isOutput = outputName.isNotEmpty(); + getDeviceProperties (id, minChansOut, maxChansOut, minChansIn, maxChansIn, rates, isOutput, isInput); + + isInput = maxChansIn > 0; + isOutput = maxChansOut > 0; + + if ((isInput || isOutput) && rates.size() > 0) + { + JUCE_ALSA_LOG ("testDevice: '" << id.toUTF8().getAddress() << "' -> isInput: " + << isInput << ", isOutput: " << isOutput); + + if (isInput) + { + inputNames.add (inputName); + inputIds.add (id); } - snd_device_name_free_hint (hints); + if (isOutput) + { + outputNames.add (outputName); + outputIds.add (id); + } + + return isInput || isOutput; } -*/ + + return false; + } + + void enumerateAlsaSoundcards() + { snd_ctl_t* handle = nullptr; snd_ctl_card_info_t* info = nullptr; snd_ctl_card_info_alloca (&info); int cardNum = -1; - while (outputIds.size() + inputIds.size() <= 32) + while (outputIds.size() + inputIds.size() <= 64) { snd_card_next (&cardNum); if (cardNum < 0) break; - if (snd_ctl_open (&handle, ("hw:" + String (cardNum)).toUTF8(), SND_CTL_NONBLOCK) >= 0) + if (JUCE_CHECKED_RESULT (snd_ctl_open (&handle, ("hw:" + String (cardNum)).toUTF8(), SND_CTL_NONBLOCK)) >= 0) { - if (snd_ctl_card_info (handle, info) >= 0) + if (JUCE_CHECKED_RESULT (snd_ctl_card_info (handle, info)) >= 0) { String cardId (snd_ctl_card_info_get_id (info)); if (cardId.removeCharacters ("0123456789").isEmpty()) cardId = String (cardNum); + String cardName = snd_ctl_card_info_get_name (info); + + if (cardName.isEmpty()) + cardName = cardId; + int device = -1; + snd_pcm_info_t* pcmInfo; + snd_pcm_info_alloca (&pcmInfo); + for (;;) { if (snd_ctl_pcm_next_device (handle, &device) < 0 || device < 0) break; - String id, name; - id << "hw:" << cardId << ',' << device; - - bool isInput, isOutput; + snd_pcm_info_set_device (pcmInfo, device); - if (testDevice (id, isInput, isOutput)) + for (int subDevice = 0, nbSubDevice = 1; subDevice < nbSubDevice; ++subDevice) { - name << snd_ctl_card_info_get_name (info); + snd_pcm_info_set_subdevice (pcmInfo, subDevice); + snd_pcm_info_set_stream (pcmInfo, SND_PCM_STREAM_CAPTURE); + const bool isInput = (snd_ctl_pcm_info (handle, pcmInfo) >= 0); + + snd_pcm_info_set_stream (pcmInfo, SND_PCM_STREAM_PLAYBACK); + const bool isOutput = (snd_ctl_pcm_info (handle, pcmInfo) >= 0); + + if (! (isInput || isOutput)) + continue; - if (name.isEmpty()) - name = id; + if (nbSubDevice == 1) + nbSubDevice = snd_pcm_info_get_subdevices_count (pcmInfo); + + String id, name; + + if (nbSubDevice == 1) + { + id << "hw:" << cardId << "," << device; + name << cardName << ", " << snd_pcm_info_get_name (pcmInfo); + } + else + { + id << "hw:" << cardId << "," << device << "," << subDevice; + name << cardName << ", " << snd_pcm_info_get_name (pcmInfo) + << " {" << snd_pcm_info_get_subdevice_name (pcmInfo) << "}"; + } + + JUCE_ALSA_LOG ("Soundcard ID: " << id << ", name: '" << name + << ", isInput:" << isInput << ", isOutput:" << isOutput << "\n"); if (isInput) { @@ -915,97 +1109,117 @@ public: } } - snd_ctl_close (handle); + JUCE_CHECKED_RESULT (snd_ctl_close (handle)); } } - - inputNames.appendNumbersToDuplicates (false, true); - outputNames.appendNumbersToDuplicates (false, true); } - StringArray getDeviceNames (bool wantInputNames) const + /* Enumerates all ALSA output devices (as output by the command aplay -L) + Does not try to open the devices (with "testDevice" for example), + so that it also finds devices that are busy and not yet available. + */ + void enumerateAlsaPCMDevices() { - jassert (hasScanned); // need to call scanForDevices() before doing this + void** hints = nullptr; - return wantInputNames ? inputNames : outputNames; - } + if (JUCE_CHECKED_RESULT (snd_device_name_hint (-1, "pcm", &hints)) == 0) + { + for (char** h = (char**) hints; *h; ++h) + { + const String id (hintToString (*h, "NAME")); + const String description (hintToString (*h, "DESC")); + const String ioid (hintToString (*h, "IOID")); - int getDefaultDeviceIndex (bool /* forInput */) const - { - jassert (hasScanned); // need to call scanForDevices() before doing this - return 0; - } + JUCE_ALSA_LOG ("ID: " << id << "; desc: " << description << "; ioid: " << ioid); - bool hasSeparateInputsAndOutputs() const { return true; } + String ss = id.fromFirstOccurrenceOf ("=", false, false) + .upToFirstOccurrenceOf (",", false, false); - int getIndexOfDevice (AudioIODevice* device, bool asInput) const - { - jassert (hasScanned); // need to call scanForDevices() before doing this + if (id.isEmpty() + || id.startsWith ("default:") || id.startsWith ("sysdefault:") + || id.startsWith ("plughw:") || id == "null") + continue; - ALSAAudioIODevice* d = dynamic_cast <ALSAAudioIODevice*> (device); - if (d == nullptr) - return -1; + String name (description.replace ("\n", "; ")); - return asInput ? inputIds.indexOf (d->inputId) - : outputIds.indexOf (d->outputId); - } + if (name.isEmpty()) + name = id; - AudioIODevice* createDevice (const String& outputDeviceName, - const String& inputDeviceName) - { - jassert (hasScanned); // need to call scanForDevices() before doing this + bool isOutput = (ioid != "Input"); + bool isInput = (ioid != "Output"); - const int inputIndex = inputNames.indexOf (inputDeviceName); - const int outputIndex = outputNames.indexOf (outputDeviceName); + // alsa is stupid here, it advertises dmix and dsnoop as input/output devices, but + // opening dmix as input, or dsnoop as output will trigger errors.. + isInput = isInput && ! id.startsWith ("dmix"); + isOutput = isOutput && ! id.startsWith ("dsnoop"); - String deviceName (outputIndex >= 0 ? outputDeviceName - : inputDeviceName); + if (isInput) + { + inputNames.add (name); + inputIds.add (id); + } - if (inputIndex >= 0 || outputIndex >= 0) - return new ALSAAudioIODevice (deviceName, - inputIds [inputIndex], - outputIds [outputIndex]); + if (isOutput) + { + outputNames.add (name); + outputIds.add (id); + } + } - return nullptr; - } + snd_device_name_free_hint (hints); + } - //============================================================================== -private: - StringArray inputNames, outputNames, inputIds, outputIds; - bool hasScanned; + // sometimes the "default" device is not listed, but it is nice to see it explicitely in the list + if (! outputIds.contains ("default")) + testDevice ("default", "Default ALSA Output", "Default ALSA Input"); - static bool testDevice (const String& id, bool& isInput, bool& isOutput) - { - unsigned int minChansOut = 0, maxChansOut = 0; - unsigned int minChansIn = 0, maxChansIn = 0; - Array <int> rates; + // same for the pulseaudio plugin + if (! outputIds.contains ("pulse")) + testDevice ("pulse", "Pulseaudio output", "Pulseaudio input"); - getDeviceProperties (id, minChansOut, maxChansOut, minChansIn, maxChansIn, rates); + // make sure the default device is listed first, and followed by the pulse device (if present) + int idx = outputIds.indexOf ("pulse"); + outputIds.move (idx, 0); + outputNames.move (idx, 0); - DBG ("ALSA device: " + id - + " outs=" + String ((int) minChansOut) + "-" + String ((int) maxChansOut) - + " ins=" + String ((int) minChansIn) + "-" + String ((int) maxChansIn) - + " rates=" + String (rates.size())); + idx = inputIds.indexOf ("pulse"); + inputIds.move (idx, 0); + inputNames.move (idx, 0); - isInput = maxChansIn > 0; - isOutput = maxChansOut > 0; + idx = outputIds.indexOf ("default"); + outputIds.move (idx, 0); + outputNames.move (idx, 0); - return (isInput || isOutput) && rates.size() > 0; + idx = inputIds.indexOf ("default"); + inputIds.move (idx, 0); + inputNames.move (idx, 0); } - /*static String getHint (void* hint, const char* type) + static String hintToString (const void* hints, const char* type) { - char* const n = snd_device_name_get_hint (hint, type); - const String s ((const char*) n); - free (n); + char* const hint = snd_device_name_get_hint (hints, type); + const String s (hint); + ::free (hint); return s; - }*/ + } JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ALSAAudioIODeviceType) }; +} + //============================================================================== +AudioIODeviceType* createAudioIODeviceType_ALSA_Soundcards() +{ + return new ALSAAudioIODeviceType (true, "ALSA HW"); +} + +AudioIODeviceType* createAudioIODeviceType_ALSA_PCMDevices() +{ + return new ALSAAudioIODeviceType (false, "ALSA"); +} + AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ALSA() { - return new ALSAAudioIODeviceType(); + return createAudioIODeviceType_ALSA_PCMDevices(); } diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_AudioCDReader.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_AudioCDReader.cpp index 8ff14ca13..a64533301 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_AudioCDReader.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_AudioCDReader.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp index 4bbcb599c..08962a0b4 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -83,19 +82,23 @@ namespace std::cerr << s << std::endl; } - void dumpJackErrorMessage (const jack_status_t status) + const char* getJackErrorMessage (const jack_status_t status) { - if (status & JackServerFailed || status & JackServerError) jack_Log ("Unable to connect to JACK server"); - if (status & JackVersionError) jack_Log ("Client's protocol version does not match"); - if (status & JackInvalidOption) jack_Log ("The operation contained an invalid or unsupported option"); - if (status & JackNameNotUnique) jack_Log ("The desired client name was not unique"); - if (status & JackNoSuchClient) jack_Log ("Requested client does not exist"); - if (status & JackInitFailure) jack_Log ("Unable to initialize client"); + if (status & JackServerFailed + || status & JackServerError) return "Unable to connect to JACK server"; + if (status & JackVersionError) return "Client's protocol version does not match"; + if (status & JackInvalidOption) return "The operation contained an invalid or unsupported option"; + if (status & JackNameNotUnique) return "The desired client name was not unique"; + if (status & JackNoSuchClient) return "Requested client does not exist"; + if (status & JackInitFailure) return "Unable to initialize client"; + return nullptr; } } + #define JUCE_JACK_LOG_STATUS(x) { if (const char* m = getJackErrorMessage (x)) jack_Log (m); } + #define JUCE_JACK_LOG(x) jack_Log(x) #else - #define dumpJackErrorMessage(a) {} - #define jack_Log(...) {} + #define JUCE_JACK_LOG_STATUS(x) {} + #define JUCE_JACK_LOG(x) {} #endif @@ -104,14 +107,37 @@ namespace #define JUCE_JACK_CLIENT_NAME "JUCEJack" #endif -static const char** getJackPorts (jack_client_t* const client, const bool forInput) +struct JackPortIterator { - if (client != nullptr) - return juce::jack_get_ports (client, nullptr, nullptr, - forInput ? JackPortIsOutput : JackPortIsInput); - // (NB: This looks like it's the wrong way round, but it is correct!) - return nullptr; -} + JackPortIterator (jack_client_t* const client, const bool forInput) + : ports (nullptr), index (-1) + { + if (client != nullptr) + ports = juce::jack_get_ports (client, nullptr, nullptr, + forInput ? JackPortIsOutput : JackPortIsInput); + // (NB: This looks like it's the wrong way round, but it is correct!) + } + + ~JackPortIterator() + { + ::free (ports); + } + + bool next() + { + if (ports == nullptr || ports [index + 1] == nullptr) + return false; + + name = CharPointer_UTF8 (ports[++index]); + clientName = name.upToFirstOccurrenceOf (":", false, false); + return true; + } + + const char** ports; + int index; + String name; + String clientName; +}; class JackAudioIODeviceType; static Array<JackAudioIODeviceType*> activeDeviceTypes; @@ -126,7 +152,7 @@ public: : AudioIODevice (deviceName, "JACK"), inputId (inId), outputId (outId), - isOpen_ (false), + deviceIsOpen (false), callback (nullptr), totalNumberOfInputChannels (0), totalNumberOfOutputChannels (0) @@ -138,7 +164,7 @@ public: if (client == nullptr) { - dumpJackErrorMessage (status); + JUCE_JACK_LOG_STATUS (status); } else { @@ -184,18 +210,10 @@ public: StringArray getChannelNames (bool forInput) const { StringArray names; - if (const char** const ports = getJackPorts (client, forInput)) - { - for (int j = 0; ports[j] != nullptr; ++j) - { - const String portName (ports [j]); - if (portName.upToFirstOccurrenceOf (":", false, false) == getName()) - names.add (portName.fromFirstOccurrenceOf (":", false, false)); - } - - free (ports); - } + for (JackPortIterator i (client, forInput); i.next();) + if (i.clientName == getName()) + names.add (i.name.fromFirstOccurrenceOf (":", false, false)); return names; } @@ -224,49 +242,31 @@ public: juce::jack_set_port_connect_callback (client, portConnectCallback, this); juce::jack_on_shutdown (client, shutdownCallback, this); juce::jack_activate (client); - isOpen_ = true; + deviceIsOpen = true; if (! inputChannels.isZero()) { - if (const char** const ports = getJackPorts (client, true)) + for (JackPortIterator i (client, true); i.next();) { - const int numInputChannels = inputChannels.getHighestBit() + 1; - - for (int i = 0; i < numInputChannels; ++i) + if (inputChannels [i.index] && i.clientName == getName()) { - const String portName (ports[i]); - - if (inputChannels[i] && portName.upToFirstOccurrenceOf (":", false, false) == getName()) - { - int error = juce::jack_connect (client, ports[i], juce::jack_port_name ((jack_port_t*) inputPorts[i])); - if (error != 0) - jack_Log ("Cannot connect input port " + String (i) + " (" + String (ports[i]) + "), error " + String (error)); - } + int error = juce::jack_connect (client, i.ports[i.index], juce::jack_port_name ((jack_port_t*) inputPorts[i.index])); + if (error != 0) + JUCE_JACK_LOG ("Cannot connect input port " + String (i.index) + " (" + i.name + "), error " + String (error)); } - - free (ports); } } if (! outputChannels.isZero()) { - if (const char** const ports = getJackPorts (client, false)) + for (JackPortIterator i (client, false); i.next();) { - const int numOutputChannels = outputChannels.getHighestBit() + 1; - - for (int i = 0; i < numOutputChannels; ++i) + if (outputChannels [i.index] && i.clientName == getName()) { - const String portName (ports[i]); - - if (outputChannels[i] && portName.upToFirstOccurrenceOf (":", false, false) == getName()) - { - int error = juce::jack_connect (client, juce::jack_port_name ((jack_port_t*) outputPorts[i]), ports[i]); - if (error != 0) - jack_Log ("Cannot connect output port " + String (i) + " (" + String (ports[i]) + "), error " + String (error)); - } + int error = juce::jack_connect (client, juce::jack_port_name ((jack_port_t*) outputPorts[i.index]), i.ports[i.index]); + if (error != 0) + JUCE_JACK_LOG ("Cannot connect output port " + String (i.index) + " (" + i.name + "), error " + String (error)); } - - free (ports); } } @@ -285,12 +285,12 @@ public: juce::jack_on_shutdown (client, shutdownCallback, nullptr); } - isOpen_ = false; + deviceIsOpen = false; } void start (AudioIODeviceCallback* newCallback) { - if (isOpen_ && newCallback != callback) + if (deviceIsOpen && newCallback != callback) { if (newCallback != nullptr) newCallback->audioDeviceAboutToStart (this); @@ -312,7 +312,7 @@ public: start (nullptr); } - bool isOpen() { return isOpen_; } + bool isOpen() { return deviceIsOpen; } bool isPlaying() { return callback != nullptr; } int getCurrentBufferSizeSamples() { return getBufferSizeSamples (0); } double getCurrentSampleRate() { return getSampleRate (0); } @@ -425,12 +425,12 @@ private: static void threadInitCallback (void* /* callbackArgument */) { - jack_Log ("JackAudioIODevice::initialise"); + JUCE_JACK_LOG ("JackAudioIODevice::initialise"); } static void shutdownCallback (void* callbackArgument) { - jack_Log ("JackAudioIODevice::shutdown"); + JUCE_JACK_LOG ("JackAudioIODevice::shutdown"); if (JackAudioIODevice* device = (JackAudioIODevice*) callbackArgument) { @@ -441,12 +441,12 @@ private: static void errorCallback (const char* msg) { - jack_Log ("JackAudioIODevice::errorCallback " + String (msg)); + JUCE_JACK_LOG ("JackAudioIODevice::errorCallback " + String (msg)); } static void sendDeviceChangedCallback(); - bool isOpen_; + bool deviceIsOpen; jack_client_t* client; String lastError; AudioIODeviceCallback* callback; @@ -498,46 +498,30 @@ public: if (jack_client_t* const client = juce::jack_client_open ("JuceJackDummy", JackNoStartServer, &status)) { // scan for output devices - if (const char** const ports = getJackPorts (client, false)) + for (JackPortIterator i (client, false); i.next();) { - for (int j = 0; ports[j] != nullptr; ++j) + if (i.clientName != (JUCE_JACK_CLIENT_NAME) && ! inputNames.contains (i.clientName)) { - String clientName (ports[j]); - clientName = clientName.upToFirstOccurrenceOf (":", false, false); - - if (clientName != (JUCE_JACK_CLIENT_NAME) && ! inputNames.contains (clientName)) - { - inputNames.add (clientName); - inputIds.add (ports [j]); - } + inputNames.add (i.clientName); + inputIds.add (i.ports [i.index]); } - - free (ports); } // scan for input devices - if (const char** const ports = getJackPorts (client, true)) + for (JackPortIterator i (client, true); i.next();) { - for (int j = 0; ports[j] != nullptr; ++j) + if (i.clientName != (JUCE_JACK_CLIENT_NAME) && ! outputNames.contains (i.clientName)) { - String clientName (ports[j]); - clientName = clientName.upToFirstOccurrenceOf (":", false, false); - - if (clientName != (JUCE_JACK_CLIENT_NAME) && ! outputNames.contains (clientName)) - { - outputNames.add (clientName); - outputIds.add (ports [j]); - } + outputNames.add (i.clientName); + outputIds.add (i.ports [i.index]); } - - free (ports); } juce::jack_client_close (client); } else { - dumpJackErrorMessage (status); + JUCE_JACK_LOG_STATUS (status); } } diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_Midi.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_Midi.cpp index 88586b1b9..81d75d28d 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_Midi.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_Midi.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -34,171 +33,390 @@ #define JUCE_ALSA_MIDI_OUTPUT_NAME "Juce Midi Output" #endif -#ifndef JUCE_ALSA_MIDI_INPUT_PORT_NAME - #define JUCE_ALSA_MIDI_INPUT_PORT_NAME "Juce Midi In Port" -#endif +//============================================================================== +namespace +{ -#ifndef JUCE_ALSA_MIDI_OUTPUT_PORT_NAME - #define JUCE_ALSA_MIDI_OUTPUT_PORT_NAME "Juce Midi Out Port" -#endif +class AlsaPortAndCallback; //============================================================================== -namespace +class AlsaClient : public ReferenceCountedObject { - snd_seq_t* iterateMidiClient (snd_seq_t* seqHandle, - snd_seq_client_info_t* clientInfo, - const bool forInput, - StringArray& deviceNamesFound, - const int deviceIndexToOpen) +public: + typedef ReferenceCountedObjectPtr<AlsaClient> Ptr; + + AlsaClient (bool forInput) + : input (forInput), handle (nullptr) + { + snd_seq_open (&handle, "default", forInput ? SND_SEQ_OPEN_INPUT + : SND_SEQ_OPEN_OUTPUT, 0); + } + + ~AlsaClient() { - snd_seq_t* returnedHandle = nullptr; + if (handle != nullptr) + { + snd_seq_close (handle); + handle = nullptr; + } + + jassert (activeCallbacks.size() == 0); - snd_seq_port_info_t* portInfo; - if (snd_seq_port_info_malloc (&portInfo) == 0) + if (inputThread) { - int numPorts = snd_seq_client_info_get_num_ports (clientInfo); - const int client = snd_seq_client_info_get_client (clientInfo); + inputThread->stopThread (3000); + inputThread = nullptr; + } + } + + bool isInput() const noexcept { return input; } - snd_seq_port_info_set_client (portInfo, client); - snd_seq_port_info_set_port (portInfo, -1); + void setName (const String& name) + { + snd_seq_set_client_name (handle, name.toUTF8()); + } - while (--numPorts >= 0) + void registerCallback (AlsaPortAndCallback* cb) + { + if (cb != nullptr) + { { - if (snd_seq_query_next_port (seqHandle, portInfo) == 0 - && (snd_seq_port_info_get_capability (portInfo) - & (forInput ? SND_SEQ_PORT_CAP_READ - : SND_SEQ_PORT_CAP_WRITE)) != 0) - { - deviceNamesFound.add (snd_seq_client_info_get_name (clientInfo)); + const ScopedLock sl (callbackLock); + activeCallbacks.add (cb); + + if (inputThread == nullptr) + inputThread = new MidiInputThread (*this); + } - if (deviceNamesFound.size() == deviceIndexToOpen + 1) + inputThread->startThread(); + } + } + + void unregisterCallback (AlsaPortAndCallback* cb) + { + const ScopedLock sl (callbackLock); + + jassert (activeCallbacks.contains (cb)); + activeCallbacks.removeAllInstancesOf (cb); + + if (activeCallbacks.size() == 0 && inputThread->isThreadRunning()) + inputThread->signalThreadShouldExit(); + } + + void handleIncomingMidiMessage (const MidiMessage& message, int port); + + snd_seq_t* get() const noexcept { return handle; } + +private: + bool input; + snd_seq_t* handle; + + Array<AlsaPortAndCallback*> activeCallbacks; + CriticalSection callbackLock; + + //============================================================================== + class MidiInputThread : public Thread + { + public: + MidiInputThread (AlsaClient& c) + : Thread ("Juce MIDI Input"), client (c) + { + jassert (client.input && client.get() != nullptr); + } + + void run() + { + const int maxEventSize = 16 * 1024; + snd_midi_event_t* midiParser; + snd_seq_t* seqHandle = client.get(); + + if (snd_midi_event_new (maxEventSize, &midiParser) >= 0) + { + const int numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN); + HeapBlock<pollfd> pfd (numPfds); + snd_seq_poll_descriptors (seqHandle, pfd, numPfds, POLLIN); + + HeapBlock <uint8> buffer (maxEventSize); + + while (! threadShouldExit()) + { + if (poll (pfd, numPfds, 100) > 0) // there was a "500" here which is a bit long when we exit the program and have to wait for a timeout on this poll call { - const int sourcePort = snd_seq_port_info_get_port (portInfo); - const int sourceClient = snd_seq_client_info_get_client (clientInfo); + if (threadShouldExit()) + break; - if (sourcePort != -1) + snd_seq_nonblock (seqHandle, 1); + + do { - if (forInput) + snd_seq_event_t* inputEvent = nullptr; + + if (snd_seq_event_input (seqHandle, &inputEvent) >= 0) { - snd_seq_set_client_name (seqHandle, JUCE_ALSA_MIDI_INPUT_NAME); + // xxx what about SYSEXes that are too big for the buffer? + const int numBytes = snd_midi_event_decode (midiParser, buffer, + maxEventSize, inputEvent); - const int portId = snd_seq_create_simple_port (seqHandle, JUCE_ALSA_MIDI_INPUT_PORT_NAME, - SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE, - SND_SEQ_PORT_TYPE_MIDI_GENERIC); + snd_midi_event_reset_decode (midiParser); - snd_seq_connect_from (seqHandle, portId, sourceClient, sourcePort); - } - else - { - snd_seq_set_client_name (seqHandle, JUCE_ALSA_MIDI_OUTPUT_NAME); + if (numBytes > 0) + { + const MidiMessage message ((const uint8*) buffer, numBytes, + Time::getMillisecondCounter() * 0.001); - const int portId = snd_seq_create_simple_port (seqHandle, JUCE_ALSA_MIDI_OUTPUT_PORT_NAME, - SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ, - SND_SEQ_PORT_TYPE_MIDI_GENERIC); + client.handleIncomingMidiMessage (message, inputEvent->dest.port); + } - snd_seq_connect_to (seqHandle, portId, sourceClient, sourcePort); + snd_seq_free_event (inputEvent); } - - returnedHandle = seqHandle; } + while (snd_seq_event_input_pending (seqHandle, 0) > 0); } } + + snd_midi_event_free (midiParser); } + }; + + private: + AlsaClient& client; + }; + + ScopedPointer<MidiInputThread> inputThread; +}; + + +static AlsaClient::Ptr globalAlsaSequencerIn() +{ + static AlsaClient::Ptr global (new AlsaClient (true)); + return global; +} + +static AlsaClient::Ptr globalAlsaSequencerOut() +{ + static AlsaClient::Ptr global (new AlsaClient (false)); + return global; +} + +static AlsaClient::Ptr globalAlsaSequencer (bool input) +{ + return input ? globalAlsaSequencerIn() + : globalAlsaSequencerOut(); +} + +//============================================================================== +// represents an input or output port of the supplied AlsaClient +class AlsaPort +{ +public: + AlsaPort() noexcept : portId (-1) {} + AlsaPort (const AlsaClient::Ptr& c, int port) noexcept : client (c), portId (port) {} - snd_seq_port_info_free (portInfo); + void createPort (const AlsaClient::Ptr& c, const String& name, bool forInput) + { + client = c; + + if (snd_seq_t* handle = client->get()) + portId = snd_seq_create_simple_port (handle, name.toUTF8(), + forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) + : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), + SND_SEQ_PORT_TYPE_MIDI_GENERIC); + } + + void deletePort() + { + if (isValid()) + { + snd_seq_delete_simple_port (client->get(), portId); + portId = -1; } + } + + void connectWith (int sourceClient, int sourcePort) + { + if (client->isInput()) + snd_seq_connect_from (client->get(), portId, sourceClient, sourcePort); + else + snd_seq_connect_to (client->get(), portId, sourceClient, sourcePort); + } - return returnedHandle; + bool isValid() const noexcept + { + return client != nullptr && client->get() != nullptr && portId >= 0; } - snd_seq_t* iterateMidiDevices (const bool forInput, + AlsaClient::Ptr client; + int portId; +}; + +//============================================================================== +class AlsaPortAndCallback +{ +public: + AlsaPortAndCallback (AlsaPort p, MidiInput* in, MidiInputCallback* cb) + : port (p), midiInput (in), callback (cb), callbackEnabled (false) + { + } + + ~AlsaPortAndCallback() + { + enableCallback (false); + port.deletePort(); + } + + void enableCallback (bool enable) + { + if (callbackEnabled != enable) + { + callbackEnabled = enable; + + if (enable) + port.client->registerCallback (this); + else + port.client->unregisterCallback (this); + } + } + + void handleIncomingMidiMessage (const MidiMessage& message) const + { + callback->handleIncomingMidiMessage (midiInput, message); + } + +private: + AlsaPort port; + MidiInput* midiInput; + MidiInputCallback* callback; + bool callbackEnabled; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AlsaPortAndCallback) +}; + +void AlsaClient::handleIncomingMidiMessage (const MidiMessage& message, int port) +{ + const ScopedLock sl (callbackLock); + + if (AlsaPortAndCallback* const cb = activeCallbacks[port]) + cb->handleIncomingMidiMessage (message); +} + +//============================================================================== +static AlsaPort iterateMidiClient (const AlsaClient::Ptr& seq, + snd_seq_client_info_t* clientInfo, + const bool forInput, StringArray& deviceNamesFound, const int deviceIndexToOpen) +{ + AlsaPort port; + + snd_seq_t* seqHandle = seq->get(); + snd_seq_port_info_t* portInfo = nullptr; + + if (snd_seq_port_info_malloc (&portInfo) == 0) { - snd_seq_t* returnedHandle = nullptr; - snd_seq_t* seqHandle = nullptr; + int numPorts = snd_seq_client_info_get_num_ports (clientInfo); + const int client = snd_seq_client_info_get_client (clientInfo); - if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT - : SND_SEQ_OPEN_OUTPUT, 0) == 0) - { - snd_seq_system_info_t* systemInfo = nullptr; - snd_seq_client_info_t* clientInfo = nullptr; + snd_seq_port_info_set_client (portInfo, client); + snd_seq_port_info_set_port (portInfo, -1); - if (snd_seq_system_info_malloc (&systemInfo) == 0) + while (--numPorts >= 0) + { + if (snd_seq_query_next_port (seqHandle, portInfo) == 0 + && (snd_seq_port_info_get_capability (portInfo) & (forInput ? SND_SEQ_PORT_CAP_READ + : SND_SEQ_PORT_CAP_WRITE)) != 0) { - if (snd_seq_system_info (seqHandle, systemInfo) == 0 - && snd_seq_client_info_malloc (&clientInfo) == 0) - { - int numClients = snd_seq_system_info_get_cur_clients (systemInfo); + deviceNamesFound.add (snd_seq_client_info_get_name (clientInfo)); - while (--numClients >= 0 && returnedHandle == 0) - if (snd_seq_query_next_client (seqHandle, clientInfo) == 0) - returnedHandle = iterateMidiClient (seqHandle, clientInfo, - forInput, deviceNamesFound, - deviceIndexToOpen); + if (deviceNamesFound.size() == deviceIndexToOpen + 1) + { + const int sourcePort = snd_seq_port_info_get_port (portInfo); + const int sourceClient = snd_seq_client_info_get_client (clientInfo); - snd_seq_client_info_free (clientInfo); + if (sourcePort != -1) + { + const String name (forInput ? JUCE_ALSA_MIDI_INPUT_NAME + : JUCE_ALSA_MIDI_OUTPUT_NAME); + seq->setName (name); + port.createPort (seq, name, forInput); + port.connectWith (sourceClient, sourcePort); + } } - - snd_seq_system_info_free (systemInfo); } - - if (returnedHandle == 0) - snd_seq_close (seqHandle); } - deviceNamesFound.appendNumbersToDuplicates (true, true); - - return returnedHandle; + snd_seq_port_info_free (portInfo); } - snd_seq_t* createMidiDevice (const bool forInput, const String& deviceNameToOpen) + return port; +} + +static AlsaPort iterateMidiDevices (const bool forInput, + StringArray& deviceNamesFound, + const int deviceIndexToOpen) +{ + AlsaPort port; + const AlsaClient::Ptr client (globalAlsaSequencer (forInput)); + + if (snd_seq_t* const seqHandle = client->get()) { - snd_seq_t* seqHandle = nullptr; + snd_seq_system_info_t* systemInfo = nullptr; + snd_seq_client_info_t* clientInfo = nullptr; - if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT - : SND_SEQ_OPEN_OUTPUT, 0) == 0) + if (snd_seq_system_info_malloc (&systemInfo) == 0) { - snd_seq_set_client_name (seqHandle, - (deviceNameToOpen + (forInput ? " Input" : " Output")).toUTF8()); - - const int portId - = snd_seq_create_simple_port (seqHandle, - forInput ? "in" - : "out", - forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) - : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), - forInput ? SND_SEQ_PORT_TYPE_APPLICATION - : SND_SEQ_PORT_TYPE_MIDI_GENERIC); - - if (portId < 0) + if (snd_seq_system_info (seqHandle, systemInfo) == 0 + && snd_seq_client_info_malloc (&clientInfo) == 0) { - snd_seq_close (seqHandle); - seqHandle = nullptr; + int numClients = snd_seq_system_info_get_cur_clients (systemInfo); + + while (--numClients >= 0 && ! port.isValid()) + if (snd_seq_query_next_client (seqHandle, clientInfo) == 0) + port = iterateMidiClient (client, clientInfo, forInput, + deviceNamesFound, deviceIndexToOpen); + + snd_seq_client_info_free (clientInfo); } + + snd_seq_system_info_free (systemInfo); } - return seqHandle; } + + deviceNamesFound.appendNumbersToDuplicates (true, true); + + return port; } +AlsaPort createMidiDevice (const bool forInput, const String& deviceNameToOpen) +{ + AlsaPort port; + AlsaClient::Ptr client (new AlsaClient (forInput)); + + if (client->get()) + { + client->setName (deviceNameToOpen + (forInput ? " Input" : " Output")); + port.createPort (client, forInput ? "in" : "out", forInput); + } + + return port; +} //============================================================================== class MidiOutputDevice { public: - MidiOutputDevice (MidiOutput* output, snd_seq_t* handle) - : midiOutput (output), seqHandle (handle), + MidiOutputDevice (MidiOutput* const output, const AlsaPort& p) + : midiOutput (output), port (p), maxEventSize (16 * 1024) { - jassert (seqHandle != 0 && midiOutput != 0); + jassert (port.isValid() && midiOutput != nullptr); snd_midi_event_new (maxEventSize, &midiParser); } ~MidiOutputDevice() { snd_midi_event_free (midiParser); - snd_seq_close (seqHandle); + port.deletePort(); } void sendMessageNow (const MidiMessage& message) @@ -216,6 +434,8 @@ public: long numBytes = (long) message.getRawDataSize(); const uint8* data = message.getRawData(); + snd_seq_t* seqHandle = port.client->get(); + while (numBytes > 0) { const long numSent = snd_midi_event_encode (midiParser, data, numBytes, &event); @@ -238,13 +458,15 @@ public: private: MidiOutput* const midiOutput; - snd_seq_t* const seqHandle; + AlsaPort port; snd_midi_event_t* midiParser; int maxEventSize; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiOutputDevice) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiOutputDevice); }; +} // namespace + StringArray MidiOutput::getDevices() { StringArray devices; @@ -260,12 +482,14 @@ int MidiOutput::getDefaultDeviceIndex() MidiOutput* MidiOutput::openDevice (int deviceIndex) { MidiOutput* newDevice = nullptr; + StringArray devices; + AlsaPort port (iterateMidiDevices (false, devices, deviceIndex)); - if (snd_seq_t* const handle = iterateMidiDevices (false, devices, deviceIndex)) + if (port.isValid()) { newDevice = new MidiOutput(); - newDevice->internal = new MidiOutputDevice (newDevice, handle); + newDevice->internal = new MidiOutputDevice (newDevice, port); } return newDevice; @@ -275,10 +499,12 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName) { MidiOutput* newDevice = nullptr; - if (snd_seq_t* const handle = createMidiDevice (false, deviceName)) + AlsaPort port (createMidiDevice (false, deviceName)); + + if (port.isValid()) { newDevice = new MidiOutput(); - newDevice->internal = new MidiOutputDevice (newDevice, handle); + newDevice->internal = new MidiOutputDevice (newDevice, port); } return newDevice; @@ -294,79 +520,6 @@ void MidiOutput::sendMessageNow (const MidiMessage& message) static_cast <MidiOutputDevice*> (internal)->sendMessageNow (message); } - -//============================================================================== -class MidiInputThread : public Thread -{ -public: - MidiInputThread (MidiInput* input, snd_seq_t* handle, MidiInputCallback* cb) - : Thread ("Juce MIDI Input"), - midiInput (input), seqHandle (handle), callback (cb) - { - jassert (seqHandle != nullptr && callback != nullptr && midiInput != nullptr); - } - - ~MidiInputThread() - { - snd_seq_close (seqHandle); - } - - void run() - { - const int maxEventSize = 16 * 1024; - snd_midi_event_t* midiParser; - - if (snd_midi_event_new (maxEventSize, &midiParser) >= 0) - { - HeapBlock <uint8> buffer (maxEventSize); - - const int numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN); - HeapBlock <pollfd> pfd (numPfds); - - snd_seq_poll_descriptors (seqHandle, pfd, numPfds, POLLIN); - - while (! threadShouldExit()) - { - if (poll (pfd, numPfds, 500) > 0) - { - snd_seq_event_t* inputEvent = nullptr; - snd_seq_nonblock (seqHandle, 1); - - do - { - if (snd_seq_event_input (seqHandle, &inputEvent) >= 0) - { - // xxx what about SYSEXes that are too big for the buffer? - const int numBytes = snd_midi_event_decode (midiParser, buffer, maxEventSize, inputEvent); - - snd_midi_event_reset_decode (midiParser); - - if (numBytes > 0) - callback->handleIncomingMidiMessage (midiInput, - MidiMessage ((const uint8*) buffer, numBytes, - Time::getMillisecondCounter() * 0.001)); - - snd_seq_free_event (inputEvent); - } - } - while (snd_seq_event_input_pending (seqHandle, 0) > 0); - - snd_seq_free_event (inputEvent); - } - } - - snd_midi_event_free (midiParser); - } - }; - -private: - MidiInput* const midiInput; - snd_seq_t* const seqHandle; - MidiInputCallback* const callback; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiInputThread) -}; - //============================================================================== MidiInput::MidiInput (const String& nm) : name (nm), internal (nullptr) @@ -376,11 +529,18 @@ MidiInput::MidiInput (const String& nm) MidiInput::~MidiInput() { stop(); - delete static_cast <MidiInputThread*> (internal); + delete static_cast <AlsaPortAndCallback*> (internal); } -void MidiInput::start() { static_cast <MidiInputThread*> (internal)->startThread(); } -void MidiInput::stop() { static_cast <MidiInputThread*> (internal)->stopThread (3000); } +void MidiInput::start() +{ + static_cast<AlsaPortAndCallback*> (internal)->enableCallback (true); +} + +void MidiInput::stop() +{ + static_cast<AlsaPortAndCallback*> (internal)->enableCallback (false); +} int MidiInput::getDefaultDeviceIndex() { @@ -397,12 +557,14 @@ StringArray MidiInput::getDevices() MidiInput* MidiInput::openDevice (int deviceIndex, MidiInputCallback* callback) { MidiInput* newDevice = nullptr; + StringArray devices; + AlsaPort port (iterateMidiDevices (true, devices, deviceIndex)); - if (snd_seq_t* const handle = iterateMidiDevices (true, devices, deviceIndex)) + if (port.isValid()) { newDevice = new MidiInput (devices [deviceIndex]); - newDevice->internal = new MidiInputThread (newDevice, handle, callback); + newDevice->internal = new AlsaPortAndCallback (port, newDevice, callback); } return newDevice; @@ -412,10 +574,12 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba { MidiInput* newDevice = nullptr; - if (snd_seq_t* const handle = createMidiDevice (true, deviceName)) + AlsaPort port (createMidiDevice (true, deviceName)); + + if (port.isValid()) { newDevice = new MidiInput (deviceName); - newDevice->internal = new MidiInputThread (newDevice, handle, callback); + newDevice->internal = new AlsaPortAndCallback (port, newDevice, callback); } return newDevice; @@ -434,7 +598,7 @@ MidiOutput* MidiOutput::createNewDevice (const String&) { return nul MidiOutput::~MidiOutput() {} void MidiOutput::sendMessageNow (const MidiMessage&) {} -MidiInput::MidiInput (const String& name_) : name (name_), internal (0) {} +MidiInput::MidiInput (const String& nm) : name (nm), internal (nullptr) {} MidiInput::~MidiInput() {} void MidiInput::start() {} void MidiInput::stop() {} diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm b/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm index cc5b1c765..1373393e6 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm b/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm index 702e23c6f..447c98b88 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -236,7 +235,9 @@ bool AudioCDReader::isCDStillPresent() const void AudioCDReader::ejectDisk() { JUCE_AUTORELEASEPOOL - [[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath: juceStringToNS (volumeDir.getFullPathName())]; + { + [[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath: juceStringToNS (volumeDir.getFullPathName())]; + } } bool AudioCDReader::isTrackAudio (int trackNum) const diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index 7503f87a7..e6751a861 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -29,6 +28,108 @@ #define JUCE_COREAUDIOLOG(a) #endif +//============================================================================== +struct SystemVol +{ + SystemVol (AudioObjectPropertySelector selector) + : outputDeviceID (kAudioObjectUnknown) + { + addr.mScope = kAudioObjectPropertyScopeGlobal; + addr.mElement = kAudioObjectPropertyElementMaster; + addr.mSelector = kAudioHardwarePropertyDefaultOutputDevice; + + if (AudioHardwareServiceHasProperty (kAudioObjectSystemObject, &addr)) + { + UInt32 deviceIDSize = sizeof (outputDeviceID); + OSStatus status = AudioHardwareServiceGetPropertyData (kAudioObjectSystemObject, &addr, 0, + nullptr, &deviceIDSize, &outputDeviceID); + + if (status == noErr) + { + addr.mElement = kAudioObjectPropertyElementMaster; + addr.mSelector = selector; + addr.mScope = kAudioDevicePropertyScopeOutput; + + if (! AudioHardwareServiceHasProperty (outputDeviceID, &addr)) + outputDeviceID = kAudioObjectUnknown; + } + } + } + + float getGain() + { + Float32 gain = 0; + + if (outputDeviceID != kAudioObjectUnknown) + { + UInt32 size = sizeof (gain); + AudioHardwareServiceGetPropertyData (outputDeviceID, &addr, + 0, nullptr, &size, &gain); + } + + return (float) gain; + } + + bool setGain (float gain) + { + if (outputDeviceID != kAudioObjectUnknown && canSetVolume()) + { + Float32 newVolume = gain; + UInt32 size = sizeof (newVolume); + + return AudioHardwareServiceSetPropertyData (outputDeviceID, &addr, 0, nullptr, + size, &newVolume) == noErr; + } + + return false; + } + + bool isMuted() + { + UInt32 muted = 0; + + if (outputDeviceID != kAudioObjectUnknown) + { + UInt32 size = sizeof (muted); + AudioHardwareServiceGetPropertyData (outputDeviceID, &addr, + 0, nullptr, &size, &muted); + } + + return muted != 0; + } + + bool setMuted (bool mute) + { + if (outputDeviceID != kAudioObjectUnknown && canSetVolume()) + { + UInt32 newMute = mute ? 1 : 0; + UInt32 size = sizeof (newMute); + + return AudioHardwareServiceSetPropertyData (outputDeviceID, &addr, 0, nullptr, + size, &newMute) == noErr; + } + + return false; + } + +private: + AudioDeviceID outputDeviceID; + AudioObjectPropertyAddress addr; + + bool canSetVolume() + { + Boolean isSettable = NO; + return AudioHardwareServiceIsPropertySettable (outputDeviceID, &addr, &isSettable) == noErr + && isSettable; + } +}; + +#define JUCE_SYSTEMAUDIOVOL_IMPLEMENTED 1 +float JUCE_CALLTYPE SystemAudioVolume::getGain() { return SystemVol (kAudioHardwareServiceDeviceProperty_VirtualMasterVolume).getGain(); } +bool JUCE_CALLTYPE SystemAudioVolume::setGain (float gain) { return SystemVol (kAudioHardwareServiceDeviceProperty_VirtualMasterVolume).setGain (gain); } +bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { return SystemVol (kAudioDevicePropertyMute).isMuted(); } +bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool mute) { return SystemVol (kAudioDevicePropertyMute).setMuted (mute); } + //============================================================================== class CoreAudioInternal : private Timer { diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index 2a8b80b90..7e4fb2cd1 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index fde0e3c6c..39491df2a 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_ASIO.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -52,7 +51,7 @@ namespace ASIODebugging switch (error) { - case 0: return; + case ASE_OK: return; case ASE_NotPresent: err = "Not Present"; break; case ASE_HWMalfunction: err = "Hardware Malfunction"; break; case ASE_InvalidParameter: err = "Invalid Parameter"; break; @@ -192,7 +191,7 @@ private: { while (--numSamples >= 0) { - *(uint16*) dest = ByteOrder::swapIfBigEndian ((uint16) (short) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++))); + *(uint16*) dest = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++))); dest += dstStrideBytes; } } @@ -200,7 +199,7 @@ private: { while (--numSamples >= 0) { - *(uint16*) dest = ByteOrder::swapIfLittleEndian ((uint16) (short) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++))); + *(uint16*) dest = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++))); dest += dstStrideBytes; } } @@ -238,7 +237,7 @@ private: { while (--numSamples >= 0) { - ByteOrder::littleEndian24BitToChars ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++)), dest); + ByteOrder::littleEndian24BitToChars ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++)), dest); dest += dstStrideBytes; } } @@ -246,7 +245,7 @@ private: { while (--numSamples >= 0) { - ByteOrder::bigEndian24BitToChars ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++)), dest); + ByteOrder::bigEndian24BitToChars ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++)), dest); dest += dstStrideBytes; } } @@ -284,7 +283,7 @@ private: { while (--numSamples >= 0) { - *(uint32*) dest = ByteOrder::swapIfBigEndian ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++))); + *(uint32*) dest = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++))); dest += dstStrideBytes; } } @@ -292,7 +291,7 @@ private: { while (--numSamples >= 0) { - *(uint32*) dest = ByteOrder::swapIfLittleEndian ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++))); + *(uint32*) dest = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++))); dest += dstStrideBytes; } } @@ -313,20 +312,31 @@ class ASIOAudioIODevice : public AudioIODevice, private Timer { public: - ASIOAudioIODevice (ASIOAudioIODeviceType* ownerType, - const String& devName, const CLSID clsID, - const int slotNumber, const String& dllForDirectLoading) + ASIOAudioIODevice (ASIOAudioIODeviceType* ownerType, const String& devName, + const CLSID clsID, const int slotNumber) : AudioIODevice (devName, "ASIO"), owner (ownerType), asioObject (nullptr), classId (clsID), - optionalDllForDirectLoading (dllForDirectLoading), + inputLatency (0), + outputLatency (0), + minSize (0), maxSize (0), + preferredSize (0), + granularity (0), + currentBlockSizeSamples (0), currentBitDepth (16), currentSampleRate (0), + currentCallback (nullptr), + bufferIndex (0), + numActiveInputChans (0), + numActiveOutputChans (0), deviceIsOpen (false), isStarted (false), buffersCreated (false), + calledback (false), + littleEndian (false), postOutput (true), + needToReset (false), insideControlPanelModalLoop (false), shouldUsePreferredSize (false) { @@ -355,32 +365,37 @@ public: { // find a list of sample rates.. const int possibleSampleRates[] = { 44100, 48000, 88200, 96000, 176400, 192000 }; - sampleRates.clear(); + Array<int> newRates; if (asioObject != nullptr) { for (int index = 0; index < numElementsInArray (possibleSampleRates); ++index) - { - const long err = asioObject->canSampleRate ((double) possibleSampleRates[index]); - JUCE_ASIO_LOG_ERROR ("canSampleRate " + String (possibleSampleRates[index]), err); + if (asioObject->canSampleRate ((double) possibleSampleRates[index]) == 0) + newRates.add (possibleSampleRates[index]); + } - if (err == 0) - { - sampleRates.add (possibleSampleRates[index]); - JUCE_ASIO_LOG ("rate: " + String (possibleSampleRates[index])); - } - } + if (newRates.size() == 0) + { + double cr = 0; + const long err = asioObject->getSampleRate (&cr); + JUCE_ASIO_LOG ("No sample rates supported - current rate: " + String ((int) cr)); + JUCE_ASIO_LOG_ERROR ("getSampleRate", err); - if (sampleRates.size() == 0) - { - double cr = 0; - const long err = asioObject->getSampleRate (&cr); - JUCE_ASIO_LOG ("No sample rates supported - current rate: " + String ((int) cr)); - JUCE_ASIO_LOG_ERROR ("getSampleRate", err); + if (err == 0) + newRates.add ((int) cr); + } - if (err == 0) - sampleRates.add ((int) cr); - } + if (sampleRates != newRates) + { + sampleRates.swapWithArray (newRates); + + #if JUCE_ASIO_DEBUGGING + StringArray s; + for (int i = 0; i < sampleRates.size(); ++i) + s.add (String (sampleRates.getUnchecked(i))); + + JUCE_ASIO_LOG ("Rates: " + s.joinIntoString (" ")); + #endif } } @@ -396,19 +411,21 @@ public: String open (const BigInteger& inputChannels, const BigInteger& outputChannels, - double sr, - int bufferSizeSamples) + double sr, int bufferSizeSamples) { - close(); - currentCallback = nullptr; + if (isOpen()) + close(); - if (bufferSizeSamples <= 0) + jassert (currentCallback == nullptr); + + if (bufferSizeSamples < 8 || bufferSizeSamples > 16384) shouldUsePreferredSize = true; + if (asioObject == nullptr) { const String openingError (openDevice()); - if (asioObject == nullptr || ! isASIOOpen) + if (asioObject == nullptr) return openingError; } @@ -427,6 +444,9 @@ public: if (preferredSize != 0 && newPreferredSize != 0 && newPreferredSize != preferredSize) shouldUsePreferredSize = true; + if (bufferSizeSamples < minSize || bufferSizeSamples > maxSize) + shouldUsePreferredSize = true; + preferredSize = newPreferredSize; } @@ -452,7 +472,7 @@ public: shouldUsePreferredSize = false; } - int sampleRate = roundDoubleToInt (sr); + int sampleRate = roundToInt (sr); currentSampleRate = sampleRate; currentBlockSizeSamples = bufferSizeSamples; currentChansOut.clear(); @@ -557,24 +577,18 @@ public: err = asioObject->disposeBuffers(); JUCE_ASIO_LOG ("creating buffers: " + String (totalBuffers) + ", " + String (currentBlockSizeSamples)); - err = asioObject->createBuffers (bufferInfos, - totalBuffers, - currentBlockSizeSamples, - &callbacks); + err = asioObject->createBuffers (bufferInfos, totalBuffers, currentBlockSizeSamples, &callbacks); - if (err != 0) + if (err != ASE_OK) { currentBlockSizeSamples = preferredSize; JUCE_ASIO_LOG_ERROR ("create buffers 2", err); asioObject->disposeBuffers(); - err = asioObject->createBuffers (bufferInfos, - totalBuffers, - currentBlockSizeSamples, - &callbacks); + err = asioObject->createBuffers (bufferInfos, totalBuffers, currentBlockSizeSamples, &callbacks); } - if (err == 0) + if (err == ASE_OK) { buffersCreated = true; @@ -705,7 +719,7 @@ public: stopTimer(); stop(); - if (isASIOOpen && deviceIsOpen) + if (asioObject != nullptr && deviceIsOpen) { const ScopedLock sl (callbackLock); @@ -728,7 +742,7 @@ public: } bool isOpen() { return deviceIsOpen || insideControlPanelModalLoop; } - bool isPlaying() { return isASIOOpen && (currentCallback != nullptr); } + bool isPlaying() { return asioObject != nullptr && currentCallback != nullptr; } int getCurrentBufferSizeSamples() { return currentBlockSizeSamples; } double getCurrentSampleRate() { return currentSampleRate; } @@ -813,7 +827,6 @@ public: { stopTimer(); - // used to cause a reset JUCE_ASIO_LOG ("restart request!"); AudioIODeviceCallback* const oldCallback = currentCallback; @@ -844,7 +857,6 @@ private: ASIOCallbacks callbacks; CLSID classId; - const String optionalDllForDirectLoading; String error; long totalNumInputChans, totalNumOutputChans; @@ -870,7 +882,6 @@ private: int volatile bufferIndex, numActiveInputChans, numActiveOutputChans; bool deviceIsOpen, isStarted, buffersCreated; - bool volatile isASIOOpen; bool volatile calledback; bool volatile littleEndian, postOutput, needToReset; bool volatile insideControlPanelModalLoop; @@ -954,6 +965,36 @@ private: return numActiveInputChans + numActiveOutputChans; } + void addBufferSizes (long minSize, long maxSize, long preferredSize, long granularity) + { + // find a list of buffer sizes.. + JUCE_ASIO_LOG (String ((int) minSize) + "->" + String ((int) maxSize) + ", " + + String ((int) preferredSize) + ", " + String ((int) granularity)); + + if (granularity >= 0) + { + granularity = jmax (16, (int) granularity); + + for (int i = jmax ((int) (minSize + 15) & ~15, (int) granularity); i < jmin (6400, (int) maxSize); i += granularity) + bufferSizes.addIfNotAlreadyThere (granularity * (i / granularity)); + } + else if (granularity < 0) + { + for (int i = 0; i < 18; ++i) + { + const int s = (1 << i); + + if (s >= minSize && s <= maxSize) + bufferSizes.add (s); + } + } + + bufferSizes.addIfNotAlreadyThere (preferredSize); + + DefaultElementComparator <int> comparator; + bufferSizes.sort (comparator); + } + void removeCurrentDriver() { if (asioObject != nullptr) @@ -967,45 +1008,28 @@ private: { removeCurrentDriver(); - JUCE_TRY - { - if (CoCreateInstance (classId, 0, CLSCTX_INPROC_SERVER, - classId, (void**) &asioObject) == S_OK) - { - return true; - } - - // If a class isn't registered but we have a path for it, we can fallback to - // doing a direct load of the COM object (only available via the juce_createASIOAudioIODeviceForGUID function). - if (optionalDllForDirectLoading.isNotEmpty()) - { - HMODULE h = LoadLibrary (optionalDllForDirectLoading.toWideCharPointer()); - - if (h != 0) - { - typedef HRESULT (CALLBACK* DllGetClassObjectFunc) (REFCLSID clsid, REFIID iid, LPVOID* ppv); - DllGetClassObjectFunc dllGetClassObject = (DllGetClassObjectFunc) GetProcAddress (h, "DllGetClassObject"); + bool crashed = false; + bool ok = tryCreatingDriver (crashed); - if (dllGetClassObject != 0) - { - IClassFactory* classFactory = nullptr; - HRESULT hr = dllGetClassObject (classId, IID_IClassFactory, (void**) &classFactory); + if (crashed) + JUCE_ASIO_LOG ("** Driver crashed while being opened"); - if (classFactory != nullptr) - { - hr = classFactory->CreateInstance (0, classId, (void**) &asioObject); - classFactory->Release(); - } + return ok; + } - return asioObject != nullptr; - } - } - } + bool tryCreatingDriver (bool& crashed) + { + #if ! JUCE_MINGW + __try + #endif + { + return CoCreateInstance (classId, 0, CLSCTX_INPROC_SERVER, + classId, (void**) &asioObject) == S_OK; } - JUCE_CATCH_ALL - - asioObject = nullptr; + #if ! JUCE_MINGW + __except (EXCEPTION_EXECUTE_HANDLER) { crashed = true; } return false; + #endif } String getLastDriverError() const @@ -1051,7 +1075,6 @@ private: inputChannelNames.clear(); bufferSizes.clear(); sampleRates.clear(); - isASIOOpen = false; deviceIsOpen = false; totalNumInputChans = 0; totalNumOutputChans = 0; @@ -1089,29 +1112,7 @@ private: if ((err = asioObject->getBufferSize (&minSize, &maxSize, &preferredSize, &granularity)) == 0) { - // find a list of buffer sizes.. - JUCE_ASIO_LOG (String ((int) minSize) + " " + String ((int) maxSize) + " " + String ((int) preferredSize) + " " + String ((int) granularity)); - - if (granularity >= 0) - { - granularity = jmax (16, (int) granularity); - - for (int i = jmax ((int) (minSize + 15) & ~15, (int) granularity); i < jmin (6400, (int) maxSize); i += granularity) - bufferSizes.addIfNotAlreadyThere (granularity * (i / granularity)); - } - else if (granularity < 0) - { - for (int i = 0; i < 18; ++i) - { - const int s = (1 << i); - - if (s >= minSize && s <= maxSize) - bufferSizes.add (s); - } - } - - if (! bufferSizes.contains (preferredSize)) - bufferSizes.insert (0, preferredSize); + addBufferSizes (minSize, maxSize, preferredSize, granularity); double currentRate = 0; asioObject->getSampleRate (¤tRate); @@ -1216,7 +1217,7 @@ private: // ignore an error here, as it might start later after setting other stuff up JUCE_ASIO_LOG_ERROR ("start", err); - Thread::sleep (100); + Thread::sleep (80); asioObject->stop(); } else @@ -1240,16 +1241,15 @@ private: JUCE_ASIO_LOG_ERROR (error, err); disposeBuffers(); removeCurrentDriver(); - isASIOOpen = false; } else { - isASIOOpen = true; JUCE_ASIO_LOG ("device open"); } deviceIsOpen = false; needToReset = false; + stopTimer(); return error; } @@ -1365,27 +1365,16 @@ private: switch (selector) { case kAsioSelectorSupported: - if (value == kAsioResetRequest - || value == kAsioEngineVersion - || value == kAsioResyncRequest - || value == kAsioLatenciesChanged - || value == kAsioSupportsInputMonitor) + if (value == kAsioResetRequest || value == kAsioEngineVersion || value == kAsioResyncRequest + || value == kAsioLatenciesChanged || value == kAsioSupportsInputMonitor) return 1; break; - case kAsioBufferSizeChange: - case kAsioResetRequest: - case kAsioResyncRequest: - if (currentASIODev[deviceIndex] != nullptr) - currentASIODev[deviceIndex]->resetRequest(); - - return 1; - - case kAsioLatenciesChanged: - return 1; - - case kAsioEngineVersion: - return 2; + case kAsioBufferSizeChange: JUCE_ASIO_LOG ("kAsioBufferSizeChange"); return sendResetRequest (deviceIndex); + case kAsioResetRequest: JUCE_ASIO_LOG ("kAsioResetRequest"); return sendResetRequest (deviceIndex); + case kAsioResyncRequest: JUCE_ASIO_LOG ("kAsioResyncRequest"); return sendResetRequest (deviceIndex); + case kAsioLatenciesChanged: JUCE_ASIO_LOG ("kAsioLatenciesChanged"); return 1; + case kAsioEngineVersion: return 2; case kAsioSupportsTimeInfo: case kAsioSupportsTimeCode: @@ -1395,6 +1384,14 @@ private: return 0; } + static long sendResetRequest (int deviceIndex) + { + if (currentASIODev[deviceIndex] != nullptr) + currentASIODev[deviceIndex]->resetRequest(); + + return 1; + } + static void JUCE_ASIOCALLBACK sampleRateChangedCallback (ASIOSampleRate) { } @@ -1410,7 +1407,6 @@ public: : AudioIODeviceType ("ASIO"), hasScanned (false) { - CoInitialize (0); } ~ASIOAudioIODeviceType() @@ -1499,7 +1495,8 @@ public: const int freeSlot = findFreeSlot(); if (freeSlot >= 0) - return new ASIOAudioIODevice (this, outputDeviceName, *(classIds [index]), freeSlot, String::empty); + return new ASIOAudioIODevice (this, outputDeviceName, + classIds.getReference (index), freeSlot); } return nullptr; @@ -1514,7 +1511,7 @@ public: private: StringArray deviceNames; - OwnedArray <CLSID> classIds; + Array<CLSID> classIds; bool hasScanned; @@ -1593,7 +1590,7 @@ private: JUCE_ASIO_LOG ("found " + deviceName); deviceNames.add (deviceName); - classIds.add (new CLSID (classId)); + classIds.add (classId); } } @@ -1615,14 +1612,3 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ASIO() { return new ASIOAudioIODeviceType(); } - -AudioIODevice* juce_createASIOAudioIODeviceForGUID (const String& name, void* guid, - const String& optionalDllForDirectLoading) -{ - const int freeSlot = ASIOAudioIODeviceType::findFreeSlot(); - - if (freeSlot < 0) - return nullptr; - - return new ASIOAudioIODevice (nullptr, name, *(CLSID*) guid, freeSlot, optionalDllForDirectLoading); -} diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_AudioCDBurner.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_AudioCDBurner.cpp index efb3a0b18..05802ff77 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_AudioCDBurner.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_AudioCDBurner.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp index ff022e23c..064ca9148 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp index 195358194..30a995a4a 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -531,13 +530,11 @@ public: void close() { - HRESULT hr; - if (pInputBuffer != nullptr) { JUCE_DS_LOG ("closing input: " + name); - hr = pInputBuffer->Stop(); - JUCE_DS_LOG_ERROR (hr); + HRESULT hr = pInputBuffer->Stop(); + JUCE_DS_LOG_ERROR (hr); (void) hr; pInputBuffer->Release(); pInputBuffer = nullptr; diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_Midi.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_Midi.cpp index 143855f13..8f8dd17bd 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_Midi.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_Midi.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -81,7 +80,10 @@ public: activeMidiCollectors.addIfNotAlreadyThere (this); for (int i = 0; i < (int) numHeaders; ++i) + { + headers[i].prepare (deviceHandle); headers[i].write (deviceHandle); + } startTime = Time::getMillisecondCounterHiRes(); MMRESULT res = midiInStart (deviceHandle); @@ -139,28 +141,15 @@ private: class MidiHeader { public: - MidiHeader() + MidiHeader() {} + + void prepare (HMIDIIN deviceHandle) { zerostruct (hdr); hdr.lpData = data; hdr.dwBufferLength = (DWORD) numElementsInArray (data); - } - void write (HMIDIIN deviceHandle) - { - hdr.dwBytesRecorded = 0; - MMRESULT res = midiInPrepareHeader (deviceHandle, &hdr, sizeof (hdr)); - res = midiInAddBuffer (deviceHandle, &hdr, sizeof (hdr)); - } - - void writeIfFinished (HMIDIIN deviceHandle) - { - if ((hdr.dwFlags & WHDR_DONE) != 0) - { - MMRESULT res = midiInUnprepareHeader (deviceHandle, &hdr, sizeof (hdr)); - (void) res; - write (deviceHandle); - } + midiInPrepareHeader (deviceHandle, &hdr, sizeof (hdr)); } void unprepare (HMIDIIN deviceHandle) @@ -175,6 +164,18 @@ private: } } + void write (HMIDIIN deviceHandle) + { + hdr.dwBytesRecorded = 0; + midiInAddBuffer (deviceHandle, &hdr, sizeof (hdr)); + } + + void writeIfFinished (HMIDIIN deviceHandle) + { + if ((hdr.dwFlags & WHDR_DONE) != 0) + write (deviceHandle); + } + private: MIDIHDR hdr; char data [256]; diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 733b41e78..4981937fe 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -44,36 +43,38 @@ void logFailure (HRESULT hr) switch (hr) { - case E_POINTER: m = "E_POINTER"; break; - case E_INVALIDARG: m = "E_INVALIDARG"; break; - case AUDCLNT_E_NOT_INITIALIZED: m = "AUDCLNT_E_NOT_INITIALIZED"; break; - case AUDCLNT_E_ALREADY_INITIALIZED: m = "AUDCLNT_E_ALREADY_INITIALIZED"; break; - case AUDCLNT_E_WRONG_ENDPOINT_TYPE: m = "AUDCLNT_E_WRONG_ENDPOINT_TYPE"; break; - case AUDCLNT_E_DEVICE_INVALIDATED: m = "AUDCLNT_E_DEVICE_INVALIDATED"; break; - case AUDCLNT_E_NOT_STOPPED: m = "AUDCLNT_E_NOT_STOPPED"; break; - case AUDCLNT_E_BUFFER_TOO_LARGE: m = "AUDCLNT_E_BUFFER_TOO_LARGE"; break; - case AUDCLNT_E_OUT_OF_ORDER: m = "AUDCLNT_E_OUT_OF_ORDER"; break; - case AUDCLNT_E_UNSUPPORTED_FORMAT: m = "AUDCLNT_E_UNSUPPORTED_FORMAT"; break; - case AUDCLNT_E_INVALID_SIZE: m = "AUDCLNT_E_INVALID_SIZE"; break; - case AUDCLNT_E_DEVICE_IN_USE: m = "AUDCLNT_E_DEVICE_IN_USE"; break; - case AUDCLNT_E_BUFFER_OPERATION_PENDING: m = "AUDCLNT_E_BUFFER_OPERATION_PENDING"; break; - case AUDCLNT_E_THREAD_NOT_REGISTERED: m = "AUDCLNT_E_THREAD_NOT_REGISTERED"; break; - case AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED: m = "AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED"; break; - case AUDCLNT_E_ENDPOINT_CREATE_FAILED: m = "AUDCLNT_E_ENDPOINT_CREATE_FAILED"; break; - case AUDCLNT_E_SERVICE_NOT_RUNNING: m = "AUDCLNT_E_SERVICE_NOT_RUNNING"; break; - case AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED: m = "AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED"; break; - case AUDCLNT_E_EXCLUSIVE_MODE_ONLY: m = "AUDCLNT_E_EXCLUSIVE_MODE_ONLY"; break; - case AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL: m = "AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL"; break; - case AUDCLNT_E_EVENTHANDLE_NOT_SET: m = "AUDCLNT_E_EVENTHANDLE_NOT_SET"; break; - case AUDCLNT_E_INCORRECT_BUFFER_SIZE: m = "AUDCLNT_E_INCORRECT_BUFFER_SIZE"; break; - case AUDCLNT_E_BUFFER_SIZE_ERROR: m = "AUDCLNT_E_BUFFER_SIZE_ERROR"; break; - case AUDCLNT_E_CPUUSAGE_EXCEEDED: m = "AUDCLNT_E_CPUUSAGE_EXCEEDED"; break; - case AUDCLNT_E_BUFFER_ERROR: m = "AUDCLNT_E_BUFFER_ERROR"; break; - case AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED: m = "AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED"; break; - case AUDCLNT_E_INVALID_DEVICE_PERIOD: m = "AUDCLNT_E_INVALID_DEVICE_PERIOD"; break; - case AUDCLNT_S_BUFFER_EMPTY: m = "AUDCLNT_S_BUFFER_EMPTY"; break; - case AUDCLNT_S_THREAD_ALREADY_REGISTERED: m = "AUDCLNT_S_THREAD_ALREADY_REGISTERED"; break; - default: break; + case E_POINTER: m = "E_POINTER"; break; + case E_INVALIDARG: m = "E_INVALIDARG"; break; + + #define JUCE_WASAPI_ERR(desc, n) \ + case MAKE_HRESULT(1, 0x889, n): m = #desc; break; + + JUCE_WASAPI_ERR (AUDCLNT_E_NOT_INITIALIZED, 0x001) + JUCE_WASAPI_ERR (AUDCLNT_E_ALREADY_INITIALIZED, 0x002) + JUCE_WASAPI_ERR (AUDCLNT_E_WRONG_ENDPOINT_TYPE, 0x003) + JUCE_WASAPI_ERR (AUDCLNT_E_DEVICE_INVALIDATED, 0x004) + JUCE_WASAPI_ERR (AUDCLNT_E_NOT_STOPPED, 0x005) + JUCE_WASAPI_ERR (AUDCLNT_E_BUFFER_TOO_LARGE, 0x006) + JUCE_WASAPI_ERR (AUDCLNT_E_OUT_OF_ORDER, 0x007) + JUCE_WASAPI_ERR (AUDCLNT_E_UNSUPPORTED_FORMAT, 0x008) + JUCE_WASAPI_ERR (AUDCLNT_E_INVALID_SIZE, 0x009) + JUCE_WASAPI_ERR (AUDCLNT_E_DEVICE_IN_USE, 0x00a) + JUCE_WASAPI_ERR (AUDCLNT_E_BUFFER_OPERATION_PENDING, 0x00b) + JUCE_WASAPI_ERR (AUDCLNT_E_THREAD_NOT_REGISTERED, 0x00c) + JUCE_WASAPI_ERR (AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED, 0x00e) + JUCE_WASAPI_ERR (AUDCLNT_E_ENDPOINT_CREATE_FAILED, 0x00f) + JUCE_WASAPI_ERR (AUDCLNT_E_SERVICE_NOT_RUNNING, 0x010) + JUCE_WASAPI_ERR (AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED, 0x011) + JUCE_WASAPI_ERR (AUDCLNT_E_EXCLUSIVE_MODE_ONLY, 0x012) + JUCE_WASAPI_ERR (AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL, 0x013) + JUCE_WASAPI_ERR (AUDCLNT_E_EVENTHANDLE_NOT_SET, 0x014) + JUCE_WASAPI_ERR (AUDCLNT_E_INCORRECT_BUFFER_SIZE, 0x015) + JUCE_WASAPI_ERR (AUDCLNT_E_BUFFER_SIZE_ERROR, 0x016) + JUCE_WASAPI_ERR (AUDCLNT_E_CPUUSAGE_EXCEEDED, 0x017) + JUCE_WASAPI_ERR (AUDCLNT_E_BUFFER_ERROR, 0x018) + JUCE_WASAPI_ERR (AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED, 0x019) + JUCE_WASAPI_ERR (AUDCLNT_E_INVALID_DEVICE_PERIOD, 0x020) + default: break; } Logger::writeToLog ("WASAPI error: " + (m != nullptr ? String (m) @@ -91,63 +92,212 @@ bool check (HRESULT hr) } //============================================================================== -namespace +} + +#if JUCE_MINGW + #define JUCE_COMCLASS(name, guid) \ + struct name; \ + template<> struct UUIDGetter<name> { static CLSID get() { return uuidFromString (guid); } }; \ + struct name + + struct PROPERTYKEY + { + GUID fmtid; + DWORD pid; + }; + + WINOLEAPI PropVariantClear (PROPVARIANT*); +#else + #define JUCE_COMCLASS(name, guid) struct __declspec (uuid (guid)) name +#endif + +#ifndef KSDATAFORMAT_SUBTYPE_PCM + #define KSDATAFORMAT_SUBTYPE_PCM uuidFromString ("00000001-0000-0010-8000-00aa00389b71") + #define KSDATAFORMAT_SUBTYPE_IEEE_FLOAT uuidFromString ("00000003-0000-0010-8000-00aa00389b71") +#endif + +#define JUCE_IUNKNOWNCLASS(name, guid) JUCE_COMCLASS(name, guid) : public IUnknown +#define JUCE_COMCALL virtual HRESULT STDMETHODCALLTYPE + +enum EDataFlow { - enum EDataFlow - { - eRender = 0, - eCapture = (eRender + 1), - eAll = (eCapture + 1) - }; + eRender = 0, + eCapture = (eRender + 1), + eAll = (eCapture + 1) +}; - enum { DEVICE_STATE_ACTIVE = 1 }; +enum { DEVICE_STATE_ACTIVE = 1 }; - struct __declspec (uuid ("D666063F-1587-4E43-81F1-B948E807363F")) IMMDevice : public IUnknown - { - virtual HRESULT STDMETHODCALLTYPE Activate(REFIID, DWORD, PROPVARIANT*, void**) = 0; - virtual HRESULT STDMETHODCALLTYPE OpenPropertyStore(DWORD, IPropertyStore**) = 0; - virtual HRESULT STDMETHODCALLTYPE GetId(LPWSTR*) = 0; - virtual HRESULT STDMETHODCALLTYPE GetState(DWORD*) = 0; - }; +JUCE_IUNKNOWNCLASS (IPropertyStore, "886d8eeb-8cf2-4446-8d02-cdba1dbdcf99") +{ + JUCE_COMCALL GetCount (DWORD*) = 0; + JUCE_COMCALL GetAt (DWORD, PROPERTYKEY*) = 0; + JUCE_COMCALL GetValue (const PROPERTYKEY&, PROPVARIANT*) = 0; + JUCE_COMCALL SetValue (const PROPERTYKEY&, const PROPVARIANT&) = 0; + JUCE_COMCALL Commit() = 0; +}; - struct __declspec (uuid ("1BE09788-6894-4089-8586-9A2A6C265AC5")) IMMEndpoint : public IUnknown - { - virtual HRESULT STDMETHODCALLTYPE GetDataFlow(EDataFlow*) = 0; - }; +JUCE_IUNKNOWNCLASS (IMMDevice, "D666063F-1587-4E43-81F1-B948E807363F") +{ + JUCE_COMCALL Activate (REFIID, DWORD, PROPVARIANT*, void**) = 0; + JUCE_COMCALL OpenPropertyStore (DWORD, IPropertyStore**) = 0; + JUCE_COMCALL GetId (LPWSTR*) = 0; + JUCE_COMCALL GetState (DWORD*) = 0; +}; - struct IMMDeviceCollection : public IUnknown - { - virtual HRESULT STDMETHODCALLTYPE GetCount(UINT*) = 0; - virtual HRESULT STDMETHODCALLTYPE Item(UINT, IMMDevice**) = 0; - }; +JUCE_IUNKNOWNCLASS (IMMEndpoint, "1BE09788-6894-4089-8586-9A2A6C265AC5") +{ + JUCE_COMCALL GetDataFlow (EDataFlow*) = 0; +}; - enum ERole - { - eConsole = 0, - eMultimedia = (eConsole + 1), - eCommunications = (eMultimedia + 1) - }; +struct IMMDeviceCollection : public IUnknown +{ + JUCE_COMCALL GetCount (UINT*) = 0; + JUCE_COMCALL Item (UINT, IMMDevice**) = 0; +}; - struct __declspec (uuid ("7991EEC9-7E89-4D85-8390-6C703CEC60C0")) IMMNotificationClient : public IUnknown - { - virtual HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR, DWORD) = 0; - virtual HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR) = 0; - virtual HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR) = 0; - virtual HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow, ERole, LPCWSTR) = 0; - virtual HRESULT STDMETHODCALLTYPE OnPropertyValueChanged(LPCWSTR, const PROPERTYKEY) = 0; - }; +enum ERole +{ + eConsole = 0, + eMultimedia = (eConsole + 1), + eCommunications = (eMultimedia + 1) +}; - struct __declspec (uuid ("A95664D2-9614-4F35-A746-DE8DB63617E6")) IMMDeviceEnumerator : public IUnknown - { - virtual HRESULT STDMETHODCALLTYPE EnumAudioEndpoints(EDataFlow, DWORD, IMMDeviceCollection**) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDefaultAudioEndpoint(EDataFlow, ERole, IMMDevice**) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDevice(LPCWSTR, IMMDevice**) = 0; - virtual HRESULT STDMETHODCALLTYPE RegisterEndpointNotificationCallback(IMMNotificationClient*) = 0; - virtual HRESULT STDMETHODCALLTYPE UnregisterEndpointNotificationCallback(IMMNotificationClient*) = 0; - }; +JUCE_IUNKNOWNCLASS (IMMNotificationClient, "7991EEC9-7E89-4D85-8390-6C703CEC60C0") +{ + JUCE_COMCALL OnDeviceStateChanged (LPCWSTR, DWORD) = 0; + JUCE_COMCALL OnDeviceAdded (LPCWSTR) = 0; + JUCE_COMCALL OnDeviceRemoved (LPCWSTR) = 0; + JUCE_COMCALL OnDefaultDeviceChanged (EDataFlow, ERole, LPCWSTR) = 0; + JUCE_COMCALL OnPropertyValueChanged (LPCWSTR, const PROPERTYKEY) = 0; +}; - struct __declspec (uuid ("BCDE0395-E52F-467C-8E3D-C4579291692E")) MMDeviceEnumerator; -} +JUCE_IUNKNOWNCLASS (IMMDeviceEnumerator, "A95664D2-9614-4F35-A746-DE8DB63617E6") +{ + JUCE_COMCALL EnumAudioEndpoints (EDataFlow, DWORD, IMMDeviceCollection**) = 0; + JUCE_COMCALL GetDefaultAudioEndpoint (EDataFlow, ERole, IMMDevice**) = 0; + JUCE_COMCALL GetDevice (LPCWSTR, IMMDevice**) = 0; + JUCE_COMCALL RegisterEndpointNotificationCallback (IMMNotificationClient*) = 0; + JUCE_COMCALL UnregisterEndpointNotificationCallback (IMMNotificationClient*) = 0; +}; + +JUCE_COMCLASS (MMDeviceEnumerator, "BCDE0395-E52F-467C-8E3D-C4579291692E"); + +typedef LONGLONG REFERENCE_TIME; + +enum AVRT_PRIORITY +{ + AVRT_PRIORITY_LOW = -1, + AVRT_PRIORITY_NORMAL, + AVRT_PRIORITY_HIGH, + AVRT_PRIORITY_CRITICAL +}; + +enum AUDCLNT_SHAREMODE +{ + AUDCLNT_SHAREMODE_SHARED, + AUDCLNT_SHAREMODE_EXCLUSIVE +}; + +JUCE_IUNKNOWNCLASS (IAudioClient, "1CB9AD4C-DBFA-4c32-B178-C2F568A703B2") +{ + JUCE_COMCALL Initialize (AUDCLNT_SHAREMODE, DWORD, REFERENCE_TIME, REFERENCE_TIME, const WAVEFORMATEX*, LPCGUID) = 0; + JUCE_COMCALL GetBufferSize (UINT32*) = 0; + JUCE_COMCALL GetStreamLatency (REFERENCE_TIME*) = 0; + JUCE_COMCALL GetCurrentPadding (UINT32*) = 0; + JUCE_COMCALL IsFormatSupported (AUDCLNT_SHAREMODE, const WAVEFORMATEX*, WAVEFORMATEX**) = 0; + JUCE_COMCALL GetMixFormat (WAVEFORMATEX**) = 0; + JUCE_COMCALL GetDevicePeriod (REFERENCE_TIME*, REFERENCE_TIME*) = 0; + JUCE_COMCALL Start() = 0; + JUCE_COMCALL Stop() = 0; + JUCE_COMCALL Reset() = 0; + JUCE_COMCALL SetEventHandle (HANDLE) = 0; + JUCE_COMCALL GetService (REFIID, void**) = 0; +}; + +JUCE_IUNKNOWNCLASS (IAudioCaptureClient, "C8ADBD64-E71E-48a0-A4DE-185C395CD317") +{ + JUCE_COMCALL GetBuffer (BYTE**, UINT32*, DWORD*, UINT64*, UINT64*) = 0; + JUCE_COMCALL ReleaseBuffer (UINT32) = 0; + JUCE_COMCALL GetNextPacketSize (UINT32*) = 0; +}; + +JUCE_IUNKNOWNCLASS (IAudioRenderClient, "F294ACFC-3146-4483-A7BF-ADDCA7C260E2") +{ + JUCE_COMCALL GetBuffer (UINT32, BYTE**) = 0; + JUCE_COMCALL ReleaseBuffer (UINT32, DWORD) = 0; +}; + +JUCE_IUNKNOWNCLASS (IAudioEndpointVolume, "5CDF2C82-841E-4546-9722-0CF74078229A") +{ + JUCE_COMCALL RegisterControlChangeNotify (void*) = 0; + JUCE_COMCALL UnregisterControlChangeNotify (void*) = 0; + JUCE_COMCALL GetChannelCount (UINT*) = 0; + JUCE_COMCALL SetMasterVolumeLevel (float, LPCGUID) = 0; + JUCE_COMCALL SetMasterVolumeLevelScalar (float, LPCGUID) = 0; + JUCE_COMCALL GetMasterVolumeLevel (float*) = 0; + JUCE_COMCALL GetMasterVolumeLevelScalar (float*) = 0; + JUCE_COMCALL SetChannelVolumeLevel (UINT, float, LPCGUID) = 0; + JUCE_COMCALL SetChannelVolumeLevelScalar (UINT, float, LPCGUID) = 0; + JUCE_COMCALL GetChannelVolumeLevel (UINT, float*) = 0; + JUCE_COMCALL GetChannelVolumeLevelScalar (UINT, float*) = 0; + JUCE_COMCALL SetMute (BOOL, LPCGUID) = 0; + JUCE_COMCALL GetMute (BOOL*) = 0; + JUCE_COMCALL GetVolumeStepInfo (UINT*, UINT*) = 0; + JUCE_COMCALL VolumeStepUp (LPCGUID) = 0; + JUCE_COMCALL VolumeStepDown (LPCGUID) = 0; + JUCE_COMCALL QueryHardwareSupport (DWORD*) = 0; + JUCE_COMCALL GetVolumeRange (float*, float*, float*) = 0; +}; + +enum AudioSessionDisconnectReason +{ + DisconnectReasonDeviceRemoval = 0, + DisconnectReasonServerShutdown = 1, + DisconnectReasonFormatChanged = 2, + DisconnectReasonSessionLogoff = 3, + DisconnectReasonSessionDisconnected = 4, + DisconnectReasonExclusiveModeOverride = 5 +}; + +enum AudioSessionState +{ + AudioSessionStateInactive = 0, + AudioSessionStateActive = 1, + AudioSessionStateExpired = 2 +}; + +JUCE_IUNKNOWNCLASS (IAudioSessionEvents, "24918ACC-64B3-37C1-8CA9-74A66E9957A8") +{ + JUCE_COMCALL OnDisplayNameChanged (LPCWSTR, LPCGUID) = 0; + JUCE_COMCALL OnIconPathChanged (LPCWSTR, LPCGUID) = 0; + JUCE_COMCALL OnSimpleVolumeChanged (float, BOOL, LPCGUID) = 0; + JUCE_COMCALL OnChannelVolumeChanged (DWORD, float*, DWORD, LPCGUID) = 0; + JUCE_COMCALL OnGroupingParamChanged (LPCGUID, LPCGUID) = 0; + JUCE_COMCALL OnStateChanged (AudioSessionState) = 0; + JUCE_COMCALL OnSessionDisconnected (AudioSessionDisconnectReason) = 0; +}; + +JUCE_IUNKNOWNCLASS (IAudioSessionControl, "F4B1A599-7266-4319-A8CA-E70ACB11E8CD") +{ + JUCE_COMCALL GetState (AudioSessionState*) = 0; + JUCE_COMCALL GetDisplayName (LPWSTR*) = 0; + JUCE_COMCALL SetDisplayName (LPCWSTR, LPCGUID) = 0; + JUCE_COMCALL GetIconPath (LPWSTR*) = 0; + JUCE_COMCALL SetIconPath (LPCWSTR, LPCGUID) = 0; + JUCE_COMCALL GetGroupingParam (GUID*) = 0; + JUCE_COMCALL SetGroupingParam (LPCGUID, LPCGUID) = 0; + JUCE_COMCALL RegisterAudioSessionNotification (IAudioSessionEvents*) = 0; + JUCE_COMCALL UnregisterAudioSessionNotification (IAudioSessionEvents*) = 0; +}; + +#undef JUCE_COMCALL +#undef JUCE_COMCLASS +#undef JUCE_IUNKNOWNCLASS + +//============================================================================== +namespace WasapiClasses +{ String getDeviceID (IMMDevice* const device) { @@ -175,7 +325,7 @@ EDataFlow getDataFlow (const ComSmartPtr<IMMDevice>& device) int refTimeToSamples (const REFERENCE_TIME& t, const double sampleRate) noexcept { - return roundDoubleToInt (sampleRate * ((double) t) * 0.0000001); + return roundToInt (sampleRate * ((double) t) * 0.0000001); } void copyWavFormat (WAVEFORMATEXTENSIBLE& dest, const WAVEFORMATEX* const src) noexcept @@ -222,6 +372,7 @@ public: defaultSampleRate = format.Format.nSamplesPerSec; minBufferSize = refTimeToSamples (minPeriod, defaultSampleRate); defaultBufferSize = refTimeToSamples (defaultPeriod, defaultSampleRate); + mixFormatChannelMask = format.dwChannelMask; rates.addUsingDefaultSort (defaultSampleRate); @@ -241,7 +392,7 @@ public: } } - ~WASAPIDeviceBase() + virtual ~WASAPIDeviceBase() { device = nullptr; CloseHandle (clientEvent); @@ -307,6 +458,7 @@ public: double sampleRate, defaultSampleRate; int numChannels, actualNumChannels; int minBufferSize, defaultBufferSize, latencySamples; + DWORD mixFormatChannelMask; const bool useExclusiveMode; Array <double> rates; HANDLE clientEvent; @@ -323,7 +475,7 @@ private: class SessionEventCallback : public ComBaseClassHelper <IAudioSessionEvents> { public: - SessionEventCallback (WASAPIDeviceBase& owner_) : owner (owner_) {} + SessionEventCallback (WASAPIDeviceBase& d) : owner (d) {} JUCE_COMRESULT OnDisplayNameChanged (LPCWSTR, LPCGUID) { return S_OK; } JUCE_COMRESULT OnIconPathChanged (LPCWSTR, LPCGUID) { return S_OK; } @@ -389,7 +541,8 @@ private: bool tryInitialisingWithFormat (const bool useFloat, const int bytesPerSampleToTry) { - WAVEFORMATEXTENSIBLE format = { 0 }; + WAVEFORMATEXTENSIBLE format; + zerostruct (format); if (numChannels <= 2 && bytesPerSampleToTry <= 2) { @@ -401,28 +554,21 @@ private: format.Format.cbSize = sizeof (WAVEFORMATEXTENSIBLE) - sizeof (WAVEFORMATEX); } - format.Format.nSamplesPerSec = (DWORD) roundDoubleToInt (sampleRate); - format.Format.nChannels = (WORD) numChannels; - format.Format.wBitsPerSample = (WORD) (8 * bytesPerSampleToTry); - format.Format.nAvgBytesPerSec = (DWORD) (format.Format.nSamplesPerSec * numChannels * bytesPerSampleToTry); - format.Format.nBlockAlign = (WORD) (numChannels * bytesPerSampleToTry); - format.SubFormat = useFloat ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM; + format.Format.nSamplesPerSec = (DWORD) sampleRate; + format.Format.nChannels = (WORD) numChannels; + format.Format.wBitsPerSample = (WORD) (8 * bytesPerSampleToTry); + format.Format.nAvgBytesPerSec = (DWORD) (format.Format.nSamplesPerSec * numChannels * bytesPerSampleToTry); + format.Format.nBlockAlign = (WORD) (numChannels * bytesPerSampleToTry); + format.SubFormat = useFloat ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM; format.Samples.wValidBitsPerSample = format.Format.wBitsPerSample; - - switch (numChannels) - { - case 1: format.dwChannelMask = SPEAKER_FRONT_CENTER; break; - case 2: format.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; break; - case 4: format.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; break; - case 6: format.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; break; - case 8: format.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER; break; - default: break; - } + format.dwChannelMask = mixFormatChannelMask; WAVEFORMATEXTENSIBLE* nearestFormat = nullptr; - HRESULT hr = client->IsFormatSupported (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE : AUDCLNT_SHAREMODE_SHARED, - (WAVEFORMATEX*) &format, useExclusiveMode ? nullptr : (WAVEFORMATEX**) &nearestFormat); + HRESULT hr = client->IsFormatSupported (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE + : AUDCLNT_SHAREMODE_SHARED, + (WAVEFORMATEX*) &format, + useExclusiveMode ? nullptr : (WAVEFORMATEX**) &nearestFormat); logFailure (hr); if (hr == S_FALSE && format.Format.nSamplesPerSec == nearestFormat->Format.nSamplesPerSec) @@ -440,7 +586,7 @@ private: GUID session; if (hr == S_OK && check (client->Initialize (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE : AUDCLNT_SHAREMODE_SHARED, - AUDCLNT_STREAMFLAGS_EVENTCALLBACK, + 0x40000 /*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/, defaultPeriod, defaultPeriod, (WAVEFORMATEX*) &format, &session))) { actualNumChannels = format.Format.nChannels; @@ -1242,7 +1388,11 @@ private: continue; PROPVARIANT value; - PropVariantInit (&value); + zerostruct (value); + + const PROPERTYKEY PKEY_Device_FriendlyName + = { { 0xa45c254e, 0xdf1c, 0x4efd, { 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0 } }, 14 }; + if (check (properties->GetValue (PKEY_Device_FriendlyName, &value))) name = value.pwszVal; @@ -1294,6 +1444,54 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WASAPIAudioIODeviceType) }; +//============================================================================== +struct MMDeviceMasterVolume +{ + MMDeviceMasterVolume() + { + ComSmartPtr<IMMDeviceEnumerator> enumerator; + if (check (enumerator.CoCreateInstance (__uuidof (MMDeviceEnumerator)))) + { + ComSmartPtr<IMMDevice> device; + if (check (enumerator->GetDefaultAudioEndpoint (eRender, eConsole, device.resetAndGetPointerAddress()))) + check (device->Activate (__uuidof (IAudioEndpointVolume), CLSCTX_INPROC_SERVER, nullptr, + (void**) endpointVolume.resetAndGetPointerAddress())); + } + } + + float getGain() const + { + float vol = 0.0f; + if (endpointVolume != nullptr) + check (endpointVolume->GetMasterVolumeLevelScalar (&vol)); + + return vol; + } + + bool setGain (float newGain) const + { + return endpointVolume != nullptr + && check (endpointVolume->SetMasterVolumeLevelScalar (jlimit (0.0f, 1.0f, newGain), nullptr)); + } + + bool isMuted() const + { + BOOL mute = 0; + return endpointVolume != nullptr + && check (endpointVolume->GetMute (&mute)) && mute != 0; + } + + bool setMuted (bool shouldMute) const + { + return endpointVolume != nullptr + && check (endpointVolume->SetMute (shouldMute, nullptr)); + } + + ComSmartPtr<IAudioEndpointVolume> endpointVolume; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MMDeviceMasterVolume) +}; + } //============================================================================== @@ -1304,3 +1502,10 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI() return nullptr; } + +//============================================================================== +#define JUCE_SYSTEMAUDIOVOL_IMPLEMENTED 1 +float JUCE_CALLTYPE SystemAudioVolume::getGain() { return WasapiClasses::MMDeviceMasterVolume().getGain(); } +bool JUCE_CALLTYPE SystemAudioVolume::setGain (float gain) { return WasapiClasses::MMDeviceMasterVolume().setGain (gain); } +bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { return WasapiClasses::MMDeviceMasterVolume().isMuted(); } +bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool mute) { return WasapiClasses::MMDeviceMasterVolume().setMuted (mute); } diff --git a/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp b/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp index 795cfebe2..ecfccb2f3 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h b/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h index 898e6fa42..f95b4e9b4 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h +++ b/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp b/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp index 847f30c52..624e9a64e 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioTransportSource.h b/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioTransportSource.h index ea3eb22f9..d4cb5f490 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioTransportSource.h +++ b/JuceLibraryCode/modules/juce_audio_devices/sources/juce_AudioTransportSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index fd2188026..9a8d8dd2e 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -27,6 +26,16 @@ static const char* const aiffFormatName = "AIFF file"; static const char* const aiffExtensions[] = { ".aiff", ".aif", 0 }; +//============================================================================== +const char* const AiffAudioFormat::appleOneShot = "apple one shot"; +const char* const AiffAudioFormat::appleRootSet = "apple root set"; +const char* const AiffAudioFormat::appleRootNote = "apple root note"; +const char* const AiffAudioFormat::appleBeats = "apple beats"; +const char* const AiffAudioFormat::appleDenominator = "apple denominator"; +const char* const AiffAudioFormat::appleNumerator = "apple numerator"; +const char* const AiffAudioFormat::appleTag = "apple tag"; +const char* const AiffAudioFormat::appleKey = "apple key"; + //============================================================================== namespace AiffFileHelpers { @@ -113,10 +122,122 @@ namespace AiffFileHelpers } JUCE_PACKED; + //============================================================================== + struct BASCChunk + { + enum Key + { + minor = 1, + major = 2, + neither = 3, + both = 4 + }; + + BASCChunk (InputStream& input) + { + zerostruct (*this); + + flags = input.readIntBigEndian(); + numBeats = input.readIntBigEndian(); + rootNote = input.readShortBigEndian(); + key = input.readShortBigEndian(); + timeSigNum = input.readShortBigEndian(); + timeSigDen = input.readShortBigEndian(); + oneShot = input.readShortBigEndian(); + input.read (unknown, sizeof (unknown)); + } + + void addToMetadata (StringPairArray& metadata) const + { + const bool rootNoteSet = rootNote != 0; + + setBoolFlag (metadata, AiffAudioFormat::appleOneShot, oneShot == 2); + setBoolFlag (metadata, AiffAudioFormat::appleRootSet, rootNoteSet); + + if (rootNoteSet) + metadata.set (AiffAudioFormat::appleRootNote, String (rootNote)); + + metadata.set (AiffAudioFormat::appleBeats, String (numBeats)); + metadata.set (AiffAudioFormat::appleDenominator, String (timeSigDen)); + metadata.set (AiffAudioFormat::appleNumerator, String (timeSigNum)); + + const char* keyString = nullptr; + + switch (key) + { + case minor: keyString = "major"; break; + case major: keyString = "major"; break; + case neither: keyString = "neither"; break; + case both: keyString = "both"; break; + } + + if (keyString != nullptr) + metadata.set (AiffAudioFormat::appleKey, keyString); + } + + void setBoolFlag (StringPairArray& values, const char* name, bool shouldBeSet) const + { + values.set (name, shouldBeSet ? "1" : "0"); + } + + uint32 flags; + uint32 numBeats; + uint16 rootNote; + uint16 key; + uint16 timeSigNum; + uint16 timeSigDen; + uint16 oneShot; + uint8 unknown[66]; + } JUCE_PACKED; + #if JUCE_MSVC #pragma pack (pop) #endif + //============================================================================== + static String readCATEChunk (InputStream& input, const uint32 length) + { + MemoryBlock mb; + input.skipNextBytes (4); + input.readIntoMemoryBlock (mb, length - 4); + + static const char* appleGenres[] = + { + "Rock/Blues", + "Electronic/Dance", + "Jazz", + "Urban", + "World/Ethnic", + "Cinematic/New Age", + "Orchestral", + "Country/Folk", + "Experimental", + "Other Genre", + nullptr + }; + + const StringArray genres (appleGenres); + StringArray tagsArray; + + int bytesLeft = (int) mb.getSize(); + const char* data = static_cast <const char*> (mb.getData()); + + while (bytesLeft > 0) + { + const String tag (CharPointer_UTF8 (data), + CharPointer_UTF8 (data + bytesLeft)); + + if (tag.isNotEmpty()) + tagsArray.add (data); + + const int numBytesInTag = genres.contains (tag) ? 118 : 50; + data += numBytesInTag; + bytesLeft -= numBytesInTag; + } + + return tagsArray.joinIntoString (";"); + } + //============================================================================== namespace MarkChunk { @@ -392,6 +513,15 @@ public: input->read (inst, (int) length); inst->copyTo (metadataValues); } + else if (type == chunkName ("basc")) + { + AiffFileHelpers::BASCChunk (*input).addToMetadata (metadataValues); + } + else if (type == chunkName ("cate")) + { + metadataValues.set (AiffAudioFormat::appleTag, + AiffFileHelpers::readCATEChunk (*input, length));; + } else if ((hasGotVer && hasGotData && hasGotType) || chunkEnd < input->getPosition() || input->isExhausted()) diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h index 4893a1ace..518bce5bc 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -39,6 +38,24 @@ public: /** Destructor. */ ~AiffAudioFormat(); + //============================================================================== + /** Metadata property name used when reading a aiff file with a basc chunk. */ + static const char* const appleOneShot; + /** Metadata property name used when reading a aiff file with a basc chunk. */ + static const char* const appleRootSet; + /** Metadata property name used when reading a aiff file with a basc chunk. */ + static const char* const appleRootNote; + /** Metadata property name used when reading a aiff file with a basc chunk. */ + static const char* const appleBeats; + /** Metadata property name used when reading a aiff file with a basc chunk. */ + static const char* const appleDenominator; + /** Metadata property name used when reading a aiff file with a basc chunk. */ + static const char* const appleNumerator; + /** Metadata property name used when reading a aiff file with a basc chunk. */ + static const char* const appleTag; + /** Metadata property name used when reading a aiff file with a basc chunk. */ + static const char* const appleKey; + //============================================================================== Array<int> getPossibleSampleRates(); Array<int> getPossibleBitDepths(); diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp index 042db3953..fb1e1b156 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -50,6 +49,243 @@ namespace } } +//============================================================================== +const char* const CoreAudioFormat::midiDataBase64 = "midiDataBase64"; +const char* const CoreAudioFormat::tempo = "tempo"; +const char* const CoreAudioFormat::timeSig = "time signature"; + +//============================================================================== +struct CoreAudioFormatMetatdata +{ + static uint32 chunkName (const char* const name) noexcept { return ByteOrder::bigEndianInt (name); } + + //============================================================================== + struct FileHeader + { + FileHeader (InputStream& input) + { + fileType = input.readIntBigEndian(); + fileVersion = input.readShortBigEndian(); + fileFlags = input.readShortBigEndian(); + } + + uint32 fileType; + uint16 fileVersion; + uint16 fileFlags; + }; + + //============================================================================== + struct ChunkHeader + { + ChunkHeader (InputStream& input) + { + chunkType = input.readIntBigEndian(); + chunkSize = input.readInt64BigEndian(); + } + + uint32 chunkType; + int64 chunkSize; + }; + + //============================================================================== + struct AudioDescriptionChunk + { + AudioDescriptionChunk (InputStream& input) + { + sampleRate = input.readDoubleBigEndian(); + formatID = input.readIntBigEndian(); + formatFlags = input.readIntBigEndian(); + bytesPerPacket = input.readIntBigEndian(); + framesPerPacket = input.readIntBigEndian(); + channelsPerFrame = input.readIntBigEndian(); + bitsPerChannel = input.readIntBigEndian(); + } + + double sampleRate; + uint32 formatID; + uint32 formatFlags; + uint32 bytesPerPacket; + uint32 framesPerPacket; + uint32 channelsPerFrame; + uint32 bitsPerChannel; + }; + + //============================================================================== + struct UserDefinedChunk + { + UserDefinedChunk (InputStream& input, int64 size) + { + // a user defined chunk contains 16 bytes of a UUID first + uuid[1] = input.readInt64BigEndian(); + uuid[0] = input.readInt64BigEndian(); + + input.skipNextBytes (size - 16); + } + + int64 uuid[2]; + }; + + //============================================================================== + static StringPairArray parseMidiChunk (InputStream& input, int64 size) + { + const int64 originalPosition = input.getPosition(); + + MemoryBlock midiBlock; + input.readIntoMemoryBlock (midiBlock, (ssize_t) size); + MemoryInputStream midiInputStream (midiBlock, false); + + StringPairArray midiMetadata; + MidiFile midiFile; + + if (midiFile.readFrom (midiInputStream)) + { + midiMetadata.set (CoreAudioFormat::midiDataBase64, midiBlock.toBase64Encoding()); + + findTempoEvents (midiFile, midiMetadata); + findTimeSigEvents (midiFile, midiMetadata); + } + + input.setPosition (originalPosition + size); + return midiMetadata; + } + + static void findTempoEvents (MidiFile& midiFile, StringPairArray& midiMetadata) + { + MidiMessageSequence tempoEvents; + midiFile.findAllTempoEvents (tempoEvents); + + const int numTempoEvents = tempoEvents.getNumEvents(); + MemoryOutputStream tempoSequence; + + for (int i = 0; i < numTempoEvents; ++i) + { + const double tempo = getTempoFromTempoMetaEvent (tempoEvents.getEventPointer (i)); + + if (tempo > 0.0) + { + if (i == 0) + midiMetadata.set (CoreAudioFormat::tempo, String (tempo)); + + if (numTempoEvents > 1) + tempoSequence << String (tempo) << ',' << tempoEvents.getEventTime (i) << ';'; + } + } + + if (tempoSequence.getDataSize() > 0) + midiMetadata.set ("tempo sequence", tempoSequence.toString()); + } + + static double getTempoFromTempoMetaEvent (MidiMessageSequence::MidiEventHolder* holder) + { + if (holder != nullptr) + { + const MidiMessage& midiMessage = holder->message; + + if (midiMessage.isTempoMetaEvent()) + { + const double tempoSecondsPerQuarterNote = midiMessage.getTempoSecondsPerQuarterNote(); + + if (tempoSecondsPerQuarterNote > 0.0) + return 60.0 / tempoSecondsPerQuarterNote; + } + } + + return 0.0; + } + + static void findTimeSigEvents (MidiFile& midiFile, StringPairArray& midiMetadata) + { + MidiMessageSequence timeSigEvents; + midiFile.findAllTimeSigEvents (timeSigEvents); + const int numTimeSigEvents = timeSigEvents.getNumEvents(); + + MemoryOutputStream timeSigSequence; + + for (int i = 0; i < numTimeSigEvents; ++i) + { + int numerator, denominator; + timeSigEvents.getEventPointer(i)->message.getTimeSignatureInfo (numerator, denominator); + + String timeSigString; + timeSigString << numerator << '/' << denominator; + + if (i == 0) + midiMetadata.set (CoreAudioFormat::timeSig, timeSigString); + + if (numTimeSigEvents > 1) + timeSigSequence << timeSigString << ',' << timeSigEvents.getEventTime (i) << ';'; + } + + if (timeSigSequence.getDataSize() > 0) + midiMetadata.set ("time signature sequence", timeSigSequence.toString()); + } + + //============================================================================== + static StringPairArray parseInformationChunk (InputStream& input) + { + StringPairArray infoStrings; + const uint32 numEntries = (uint32) input.readIntBigEndian(); + + for (uint32 i = 0; i < numEntries; ++i) + infoStrings.set (input.readString(), input.readString()); + + return infoStrings; + } + + //============================================================================== + static bool read (InputStream& input, StringPairArray& metadataValues) + { + const int64 originalPos = input.getPosition(); + + const FileHeader cafFileHeader (input); + const bool isCafFile = cafFileHeader.fileType == chunkName ("caff"); + + if (isCafFile) + { + while (! input.isExhausted()) + { + const ChunkHeader chunkHeader (input); + + if (chunkHeader.chunkType == chunkName ("desc")) + { + AudioDescriptionChunk audioDescriptionChunk (input); + } + else if (chunkHeader.chunkType == chunkName ("uuid")) + { + UserDefinedChunk userDefinedChunk (input, chunkHeader.chunkSize); + } + else if (chunkHeader.chunkType == chunkName ("data")) + { + // -1 signifies an unknown data size so the data has to be at the + // end of the file so we must have finished the header + + if (chunkHeader.chunkSize == -1) + break; + + input.skipNextBytes (chunkHeader.chunkSize); + } + else if (chunkHeader.chunkType == chunkName ("midi")) + { + metadataValues.addArray (parseMidiChunk (input, chunkHeader.chunkSize)); + } + else if (chunkHeader.chunkType == chunkName ("info")) + { + metadataValues.addArray (parseInformationChunk (input)); + } + else + { + // we aren't decoding this chunk yet so just skip over it + input.skipNextBytes (chunkHeader.chunkSize); + } + } + } + + input.setPosition (originalPos); + + return isCafFile; + } +}; + //============================================================================== class CoreAudioReader : public AudioFormatReader { @@ -61,6 +297,9 @@ public: usesFloatingPointData = true; bitsPerSample = 32; + if (input != nullptr) + CoreAudioFormatMetatdata::read (*input, metadataValues); + OSStatus status = AudioFileOpenWithCallbacks (this, &readCallback, nullptr, // write needs to be null to avoid permisisions errors diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h index 12aca3b15..fab035702 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -44,6 +43,14 @@ public: /** Destructor. */ ~CoreAudioFormat(); + //============================================================================== + /** Metadata property name used when reading a caf file with a MIDI chunk. */ + static const char* const midiDataBase64; + /** Metadata property name used when reading a caf file with tempo information. */ + static const char* const tempo; + /** Metadata property name used when reading a caf file time signature information. */ + static const char* const timeSig; + //============================================================================== Array<int> getPossibleSampleRates(); Array<int> getPossibleBitDepths(); @@ -51,10 +58,10 @@ public: bool canDoMono(); //============================================================================== - AudioFormatReader* createReaderFor (InputStream* sourceStream, + AudioFormatReader* createReaderFor (InputStream*, bool deleteStreamIfOpeningFails); - AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo, + AudioFormatWriter* createWriterFor (OutputStream*, double sampleRateToUse, unsigned int numberOfChannels, int bitsPerSample, diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index bcc6f3643..ceac5a8ff 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h index 0f47d3b5f..e6a4b0293 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp index 0689c5b59..b7311c7cb 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h index 3382ffaae..3b0dd2742 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp index 5a5b3c411..618fe51f5 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h index e781cf7a0..310a9ab25 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index d72542000..a4d66d3b3 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -418,7 +417,7 @@ private: const String s (metadata [name]); if (s.isNotEmpty()) - vorbis_comment_add_tag (&vc, vorbisName, const_cast <char*> (s.toUTF8().getAddress())); + vorbis_comment_add_tag (&vc, vorbisName, const_cast <char*> (s.toRawUTF8())); } JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OggWriter) diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h index 2d741deeb..9c803842a 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp index 060a466e6..355bbb9d4 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -84,225 +83,231 @@ public: dataHandle (0) { JUCE_AUTORELEASEPOOL - bufferList.calloc (256, 1); + { + bufferList.calloc (256, 1); - #if JUCE_WINDOWS - if (InitializeQTML (0) != noErr) - return; - #endif + #if JUCE_WINDOWS + if (InitializeQTML (0) != noErr) + return; + #endif - if (EnterMovies() != noErr) - return; + if (EnterMovies() != noErr) + return; - bool opened = juce_OpenQuickTimeMovieFromStream (input_, movie, dataHandle); + bool opened = juce_OpenQuickTimeMovieFromStream (input_, movie, dataHandle); - if (! opened) - return; + if (! opened) + return; - { - const int numTracks = GetMovieTrackCount (movie); - int trackCount = 0; - - for (int i = 1; i <= numTracks; ++i) { - track = GetMovieIndTrack (movie, i); - media = GetTrackMedia (track); - - OSType mediaType; - GetMediaHandlerDescription (media, &mediaType, 0, 0); + const int numTracks = GetMovieTrackCount (movie); + int trackCount = 0; - if (mediaType == SoundMediaType - && trackCount++ == trackNum_) + for (int i = 1; i <= numTracks; ++i) { - ok = true; - break; + track = GetMovieIndTrack (movie, i); + media = GetTrackMedia (track); + + OSType mediaType; + GetMediaHandlerDescription (media, &mediaType, 0, 0); + + if (mediaType == SoundMediaType + && trackCount++ == trackNum_) + { + ok = true; + break; + } } } - } - if (! ok) - return; + if (! ok) + return; + + ok = false; + + lengthInSamples = GetMediaDecodeDuration (media); + usesFloatingPointData = false; - ok = false; + samplesPerFrame = (int) (GetMediaDecodeDuration (media) / GetMediaSampleCount (media)); - lengthInSamples = GetMediaDecodeDuration (media); - usesFloatingPointData = false; + trackUnitsPerFrame = GetMovieTimeScale (movie) * samplesPerFrame + / GetMediaTimeScale (media); - samplesPerFrame = (int) (GetMediaDecodeDuration (media) / GetMediaSampleCount (media)); + OSStatus err = MovieAudioExtractionBegin (movie, 0, &extractor); - trackUnitsPerFrame = GetMovieTimeScale (movie) * samplesPerFrame - / GetMediaTimeScale (media); + unsigned long output_layout_size; + err = MovieAudioExtractionGetPropertyInfo (extractor, + kQTPropertyClass_MovieAudioExtraction_Audio, + kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, + 0, &output_layout_size, 0); + if (err != noErr) + return; + + HeapBlock <AudioChannelLayout> qt_audio_channel_layout; + qt_audio_channel_layout.calloc (output_layout_size, 1); + + err = MovieAudioExtractionGetProperty (extractor, + kQTPropertyClass_MovieAudioExtraction_Audio, + kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, + output_layout_size, qt_audio_channel_layout, 0); - OSStatus err = MovieAudioExtractionBegin (movie, 0, &extractor); + qt_audio_channel_layout[0].mChannelLayoutTag = kAudioChannelLayoutTag_Stereo; - unsigned long output_layout_size; - err = MovieAudioExtractionGetPropertyInfo (extractor, + err = MovieAudioExtractionSetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, - 0, &output_layout_size, 0); - if (err != noErr) - return; - - HeapBlock <AudioChannelLayout> qt_audio_channel_layout; - qt_audio_channel_layout.calloc (output_layout_size, 1); - - err = MovieAudioExtractionGetProperty (extractor, - kQTPropertyClass_MovieAudioExtraction_Audio, - kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, - output_layout_size, qt_audio_channel_layout, 0); - - qt_audio_channel_layout[0].mChannelLayoutTag = kAudioChannelLayoutTag_Stereo; - - err = MovieAudioExtractionSetProperty (extractor, - kQTPropertyClass_MovieAudioExtraction_Audio, - kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, - output_layout_size, - qt_audio_channel_layout); - - err = MovieAudioExtractionGetProperty (extractor, - kQTPropertyClass_MovieAudioExtraction_Audio, - kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, - sizeof (inputStreamDesc), - &inputStreamDesc, 0); - if (err != noErr) - return; - - inputStreamDesc.mFormatFlags = kAudioFormatFlagIsSignedInteger - | kAudioFormatFlagIsPacked - | kAudioFormatFlagsNativeEndian; - inputStreamDesc.mBitsPerChannel = sizeof (SInt16) * 8; - inputStreamDesc.mChannelsPerFrame = jmin ((UInt32) 2, inputStreamDesc.mChannelsPerFrame); - inputStreamDesc.mBytesPerFrame = sizeof (SInt16) * inputStreamDesc.mChannelsPerFrame; - inputStreamDesc.mBytesPerPacket = inputStreamDesc.mBytesPerFrame; - - err = MovieAudioExtractionSetProperty (extractor, - kQTPropertyClass_MovieAudioExtraction_Audio, - kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, - sizeof (inputStreamDesc), - &inputStreamDesc); - if (err != noErr) - return; - - Boolean allChannelsDiscrete = false; - err = MovieAudioExtractionSetProperty (extractor, - kQTPropertyClass_MovieAudioExtraction_Movie, - kQTMovieAudioExtractionMoviePropertyID_AllChannelsDiscrete, - sizeof (allChannelsDiscrete), - &allChannelsDiscrete); - - if (err != noErr) - return; - - bufferList->mNumberBuffers = 1; - bufferList->mBuffers[0].mNumberChannels = inputStreamDesc.mChannelsPerFrame; - bufferList->mBuffers[0].mDataByteSize = jmax ((UInt32) 4096, (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16); - - dataBuffer.malloc (bufferList->mBuffers[0].mDataByteSize); - bufferList->mBuffers[0].mData = dataBuffer; - - sampleRate = inputStreamDesc.mSampleRate; - bitsPerSample = 16; - numChannels = inputStreamDesc.mChannelsPerFrame; - - detachThread(); - ok = true; + output_layout_size, + qt_audio_channel_layout); + + err = MovieAudioExtractionGetProperty (extractor, + kQTPropertyClass_MovieAudioExtraction_Audio, + kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, + sizeof (inputStreamDesc), + &inputStreamDesc, 0); + if (err != noErr) + return; + + inputStreamDesc.mFormatFlags = kAudioFormatFlagIsSignedInteger + | kAudioFormatFlagIsPacked + | kAudioFormatFlagsNativeEndian; + inputStreamDesc.mBitsPerChannel = sizeof (SInt16) * 8; + inputStreamDesc.mChannelsPerFrame = jmin ((UInt32) 2, inputStreamDesc.mChannelsPerFrame); + inputStreamDesc.mBytesPerFrame = sizeof (SInt16) * inputStreamDesc.mChannelsPerFrame; + inputStreamDesc.mBytesPerPacket = inputStreamDesc.mBytesPerFrame; + + err = MovieAudioExtractionSetProperty (extractor, + kQTPropertyClass_MovieAudioExtraction_Audio, + kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, + sizeof (inputStreamDesc), + &inputStreamDesc); + if (err != noErr) + return; + + Boolean allChannelsDiscrete = false; + err = MovieAudioExtractionSetProperty (extractor, + kQTPropertyClass_MovieAudioExtraction_Movie, + kQTMovieAudioExtractionMoviePropertyID_AllChannelsDiscrete, + sizeof (allChannelsDiscrete), + &allChannelsDiscrete); + + if (err != noErr) + return; + + bufferList->mNumberBuffers = 1; + bufferList->mBuffers[0].mNumberChannels = inputStreamDesc.mChannelsPerFrame; + bufferList->mBuffers[0].mDataByteSize = jmax ((UInt32) 4096, (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16); + + dataBuffer.malloc (bufferList->mBuffers[0].mDataByteSize); + bufferList->mBuffers[0].mData = dataBuffer; + + sampleRate = inputStreamDesc.mSampleRate; + bitsPerSample = 16; + numChannels = inputStreamDesc.mChannelsPerFrame; + + detachThread(); + ok = true; + } } ~QTAudioReader() { JUCE_AUTORELEASEPOOL - checkThreadIsAttached(); + { + checkThreadIsAttached(); - if (dataHandle != nullptr) - DisposeHandle (dataHandle); + if (dataHandle != nullptr) + DisposeHandle (dataHandle); - if (extractor != nullptr) - { - MovieAudioExtractionEnd (extractor); - extractor = nullptr; - } + if (extractor != nullptr) + { + MovieAudioExtractionEnd (extractor); + extractor = nullptr; + } - DisposeMovie (movie); + DisposeMovie (movie); - #if JUCE_MAC - ExitMoviesOnThread (); - #endif + #if JUCE_MAC + ExitMoviesOnThread (); + #endif + } } bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) { JUCE_AUTORELEASEPOOL - checkThreadIsAttached(); - bool readOk = true; - - while (numSamples > 0) { - if (lastSampleRead != startSampleInFile) + checkThreadIsAttached(); + bool readOk = true; + + while (numSamples > 0) { - TimeRecord time; - time.scale = (TimeScale) inputStreamDesc.mSampleRate; - time.base = 0; - time.value.hi = 0; - time.value.lo = (UInt32) startSampleInFile; + if (lastSampleRead != startSampleInFile) + { + TimeRecord time; + time.scale = (TimeScale) inputStreamDesc.mSampleRate; + time.base = 0; + time.value.hi = 0; + time.value.lo = (UInt32) startSampleInFile; + + OSStatus err = MovieAudioExtractionSetProperty (extractor, + kQTPropertyClass_MovieAudioExtraction_Movie, + kQTMovieAudioExtractionMoviePropertyID_CurrentTime, + sizeof (time), &time); + + if (err != noErr) + { + readOk = false; + break; + } + } - OSStatus err = MovieAudioExtractionSetProperty (extractor, - kQTPropertyClass_MovieAudioExtraction_Movie, - kQTMovieAudioExtractionMoviePropertyID_CurrentTime, - sizeof (time), &time); + int framesToDo = jmin (numSamples, (int) (bufferList->mBuffers[0].mDataByteSize / inputStreamDesc.mBytesPerFrame)); + bufferList->mBuffers[0].mDataByteSize = inputStreamDesc.mBytesPerFrame * framesToDo; + UInt32 outFlags = 0; + UInt32 actualNumFrames = framesToDo; + OSStatus err = MovieAudioExtractionFillBuffer (extractor, &actualNumFrames, bufferList, &outFlags); if (err != noErr) { readOk = false; break; } - } - int framesToDo = jmin (numSamples, (int) (bufferList->mBuffers[0].mDataByteSize / inputStreamDesc.mBytesPerFrame)); - bufferList->mBuffers[0].mDataByteSize = inputStreamDesc.mBytesPerFrame * framesToDo; + lastSampleRead = startSampleInFile + actualNumFrames; + const int samplesReceived = actualNumFrames; - UInt32 outFlags = 0; - UInt32 actualNumFrames = framesToDo; - OSStatus err = MovieAudioExtractionFillBuffer (extractor, &actualNumFrames, bufferList, &outFlags); - if (err != noErr) - { - readOk = false; - break; - } - - lastSampleRead = startSampleInFile + actualNumFrames; - const int samplesReceived = actualNumFrames; - - for (int j = numDestChannels; --j >= 0;) - { - if (destSamples[j] != nullptr) + for (int j = numDestChannels; --j >= 0;) { - const short* src = ((const short*) bufferList->mBuffers[0].mData) + j; - - for (int i = 0; i < samplesReceived; ++i) + if (destSamples[j] != nullptr) { - destSamples[j][startOffsetInDestBuffer + i] = (*src << 16); - src += numChannels; + const short* src = ((const short*) bufferList->mBuffers[0].mData) + j; + + for (int i = 0; i < samplesReceived; ++i) + { + destSamples[j][startOffsetInDestBuffer + i] = (*src << 16); + src += numChannels; + } } } - } - startOffsetInDestBuffer += samplesReceived; - startSampleInFile += samplesReceived; - numSamples -= samplesReceived; + startOffsetInDestBuffer += samplesReceived; + startSampleInFile += samplesReceived; + numSamples -= samplesReceived; - if (((outFlags & kQTMovieAudioExtractionComplete) != 0 || samplesReceived == 0) && numSamples > 0) - { - for (int j = numDestChannels; --j >= 0;) - if (destSamples[j] != nullptr) - zeromem (destSamples[j] + startOffsetInDestBuffer, sizeof (int) * numSamples); + if (((outFlags & kQTMovieAudioExtractionComplete) != 0 || samplesReceived == 0) && numSamples > 0) + { + for (int j = numDestChannels; --j >= 0;) + if (destSamples[j] != nullptr) + zeromem (destSamples[j] + startOffsetInDestBuffer, sizeof (int) * numSamples); - break; + break; + } } - } - detachThread(); - return readOk; + detachThread(); + return readOk; + } } bool ok; diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.h index d1e9cf343..6ef6a4edb 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 2cc3eac66..a6a9269df 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -38,7 +37,7 @@ const char* const WavAudioFormat::bwavCodingHistory = "bwav coding history"; StringPairArray WavAudioFormat::createBWAVMetadata (const String& description, const String& originator, const String& originatorRef, - const Time& date, + const Time date, const int64 timeReferenceSamples, const String& codingHistory) { @@ -55,6 +54,17 @@ StringPairArray WavAudioFormat::createBWAVMetadata (const String& description, return m; } +const char* const WavAudioFormat::acidOneShot = "acid one shot"; +const char* const WavAudioFormat::acidRootSet = "acid root set"; +const char* const WavAudioFormat::acidStretch = "acid stretch"; +const char* const WavAudioFormat::acidDiskBased = "acid disk based"; +const char* const WavAudioFormat::acidizerFlag = "acidizer flag"; +const char* const WavAudioFormat::acidRootNote = "acid root note"; +const char* const WavAudioFormat::acidBeats = "acid beats"; +const char* const WavAudioFormat::acidDenominator = "acid denominator"; +const char* const WavAudioFormat::acidNumerator = "acid numerator"; +const char* const WavAudioFormat::acidTempo = "acid tempo"; + //============================================================================== namespace WavFileHelpers @@ -457,6 +467,49 @@ namespace WavFileHelpers } } + //============================================================================== + struct AcidChunk + { + /** Reads an acid RIFF chunk from a stream positioned just after the size byte. */ + AcidChunk (InputStream& input, int length) + { + zerostruct (*this); + input.read (this, jmin ((int) sizeof (*this), length)); + } + + void addToMetadata (StringPairArray& values) const + { + setBoolFlag (values, WavAudioFormat::acidOneShot, 0x01); + setBoolFlag (values, WavAudioFormat::acidRootSet, 0x02); + setBoolFlag (values, WavAudioFormat::acidStretch, 0x04); + setBoolFlag (values, WavAudioFormat::acidDiskBased, 0x08); + setBoolFlag (values, WavAudioFormat::acidizerFlag, 0x10); + + if (flags & 0x02) // root note set + values.set (WavAudioFormat::acidRootNote, String (rootNote)); + + values.set (WavAudioFormat::acidBeats, String (numBeats)); + values.set (WavAudioFormat::acidDenominator, String (meterDenominator)); + values.set (WavAudioFormat::acidNumerator, String (meterNumerator)); + values.set (WavAudioFormat::acidTempo, String (tempo)); + } + + void setBoolFlag (StringPairArray& values, const char* name, int32 mask) const + { + values.set (name, (flags & mask) ? "1" : "0"); + } + + int32 flags; + int16 rootNote; + int16 reserved1; + float reserved2; + int32 numBeats; + int16 meterDenominator; + int16 meterNumerator; + float tempo; + + } JUCE_PACKED; + //============================================================================== struct ExtensibleWavSubFormat { @@ -693,6 +746,10 @@ public: } } } + else if (chunkType == chunkName ("acid")) + { + AcidChunk (*input, length).addToMetadata (metadataValues); + } else if (chunkEnd <= input->getPosition()) { break; diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h index 45b569a37..1f35537cc 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -106,10 +105,32 @@ public: static StringPairArray createBWAVMetadata (const String& description, const String& originator, const String& originatorRef, - const Time& dateAndTime, + const Time dateAndTime, const int64 timeReferenceSamples, const String& codingHistory); + //============================================================================== + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidOneShot; + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidRootSet; + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidStretch; + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidDiskBased; + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidizerFlag; + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidRootNote; + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidBeats; + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidDenominator; + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidNumerator; + /** Metadata property name used when reading a WAV file with an acid chunk. */ + static const char* const acidTempo; + //============================================================================== Array<int> getPossibleSampleRates(); Array<int> getPossibleBitDepths(); diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp index 6321df24f..7c8215d07 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h index 174ac368d..e50c2d657 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormat.cpp index 93ebdb8a7..ff04da441 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormat.h index 94320a290..6c801460c 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp index 24d410a8f..f0196c863 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatManager.h b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatManager.h index f0df4b667..fa1556487 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatManager.h +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatManager.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index 74856ab23..91572e2ee 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -395,7 +394,7 @@ bool MemoryMappedAudioFormatReader::mapEntireFile() return mapSectionOfFile (Range<int64> (0, lengthInSamples)); } -bool MemoryMappedAudioFormatReader::mapSectionOfFile (const Range<int64>& samplesToMap) +bool MemoryMappedAudioFormatReader::mapSectionOfFile (Range<int64> samplesToMap) { if (map == nullptr || samplesToMap != mappedSection) { diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReader.h b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReader.h index 4c762c842..9b186487d 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReader.h +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReader.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp index 879a51d34..abd5a6a4a 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h index c2a61caff..6b25f65e2 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp index bea404a35..2a5f7cf7d 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.h b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.h index c062d883f..c7a2e9cb4 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.h +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp index 34d660200..bbe1ebd79 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h index 3c2d1de87..4c6919dca 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp index cb4d06857..2463257c4 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h b/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h index 36c985a16..9d52aae4a 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h b/JuceLibraryCode/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h index 28155f7f0..d7b9ad390 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -62,16 +61,16 @@ public: bool mapEntireFile(); /** Attempts to map a section of the file into memory. */ - bool mapSectionOfFile (const Range<int64>& samplesToMap); + bool mapSectionOfFile (Range<int64> samplesToMap); /** Returns the sample range that's currently memory-mapped and available for reading. */ - const Range<int64>& getMappedSection() const noexcept { return mappedSection; } + Range<int64> getMappedSection() const noexcept { return mappedSection; } /** Touches the memory for the given sample, to force it to be loaded into active memory. */ void touchSample (int64 sample) const noexcept; /** Returns the number of bytes currently being mapped */ - size_t getNumBytesUsed() const { return map != nullptr ? map->getSize() : 0; } + size_t getNumBytesUsed() const { return map != nullptr ? map->getSize() : 0; } protected: File file; diff --git a/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.cpp b/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.cpp index a9a673099..b78d381d3 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h b/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h index 3eac50d2e..18dbe801c 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h +++ b/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.mm b/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.mm index c625cb22a..9b32ae5af 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.mm +++ b/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_formats/juce_module_info b/JuceLibraryCode/modules/juce_audio_formats/juce_module_info index c8fd8a6dc..7a6367a5b 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/juce_module_info +++ b/JuceLibraryCode/modules/juce_audio_formats/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_audio_formats", "name": "JUCE audio file format codecs", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for reading and writing various audio file formats.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_audio_formats/sampler/juce_Sampler.cpp b/JuceLibraryCode/modules/juce_audio_formats/sampler/juce_Sampler.cpp index 8f7290dd9..23fa7c279 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/sampler/juce_Sampler.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/sampler/juce_Sampler.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -74,10 +73,9 @@ bool SamplerSound::appliesToChannel (const int /*midiChannel*/) SamplerVoice::SamplerVoice() : pitchRatio (0.0), sourceSamplePosition (0.0), - lgain (0.0f), - rgain (0.0f), - isInAttack (false), - isInRelease (false) + lgain (0.0f), rgain (0.0f), + attackReleaseLevel (0), attackDelta (0), releaseDelta (0), + isInAttack (false), isInRelease (false) { } diff --git a/JuceLibraryCode/modules/juce_audio_formats/sampler/juce_Sampler.h b/JuceLibraryCode/modules/juce_audio_formats/sampler/juce_Sampler.h index d7418583f..f51f01f4d 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/sampler/juce_Sampler.h +++ b/JuceLibraryCode/modules/juce_audio_formats/sampler/juce_Sampler.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/JuceLibraryCode/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp new file mode 100644 index 000000000..a51ac6788 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -0,0 +1,892 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +#if JucePlugin_Build_AAX && (JUCE_INCLUDED_AAX_IN_MM || defined (_WIN32) || defined (_WIN64)) + +#ifdef _MSC_VER + #include <windows.h> +#else + #include <Cocoa/Cocoa.h> +#endif + +#include "../utility/juce_IncludeModuleHeaders.h" +#undef Component + +#ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#endif + +#include "AAX_Exports.cpp" +#include "AAX_ICollection.h" +#include "AAX_IComponentDescriptor.h" +#include "AAX_IEffectDescriptor.h" +#include "AAX_IPropertyMap.h" +#include "AAX_CEffectParameters.h" +#include "AAX_Errors.h" +#include "AAX_CBinaryTaperDelegate.h" +#include "AAX_CBinaryDisplayDelegate.h" +#include "AAX_CLinearTaperDelegate.h" +#include "AAX_CNumberDisplayDelegate.h" +#include "AAX_CEffectGUI.h" +#include "AAX_IViewContainer.h" +#include "AAX_ITransport.h" +#include "AAX_IMIDINode.h" +#include "AAX_UtilsNative.h" +#include "AAX_Enums.h" + +#ifdef __clang__ + #pragma clang diagnostic pop +#endif + +#if JUCE_WINDOWS + #ifndef JucePlugin_AAXLibs_path + #error "You need to define the JucePlugin_AAXLibs_path macro. (This is best done via the introjucer)" + #endif + + #if JUCE_64BIT + #define JUCE_AAX_LIB "AAXLibrary_x64" + #else + #define JUCE_AAX_LIB "AAXLibrary" + #endif + + #if JUCE_DEBUG + #define JUCE_AAX_LIB_PATH "\\Debug\\" + #define JUCE_AAX_LIB_SUFFIX "_D" + #else + #define JUCE_AAX_LIB_PATH "\\Release\\" + #define JUCE_AAX_LIB_SUFFIX "" + #endif + + #pragma comment(lib, JucePlugin_AAXLibs_path JUCE_AAX_LIB_PATH JUCE_AAX_LIB JUCE_AAX_LIB_SUFFIX ".lib") +#endif + +using juce::Component; + +const int32_t juceChunkType = 'juce'; + +//============================================================================== +struct AAXClasses +{ + static void check (AAX_Result result) + { + jassert (result == AAX_SUCCESS); (void) result; + } + + static AAX_EStemFormat getFormatForChans (const int numChans) noexcept + { + switch (numChans) + { + case 0: return AAX_eStemFormat_None; + case 1: return AAX_eStemFormat_Mono; + case 2: return AAX_eStemFormat_Stereo; + case 3: return AAX_eStemFormat_LCR; + case 4: return AAX_eStemFormat_Quad; + case 5: return AAX_eStemFormat_5_0; + case 6: return AAX_eStemFormat_5_1; + case 7: return AAX_eStemFormat_6_1; + case 8: return AAX_eStemFormat_7_1_DTS; + + default: jassertfalse; break; // hmm - not a valid number of chans.. + } + + return AAX_eStemFormat_None; + } + + static int getNumChannelsForStemFormat (AAX_EStemFormat format) noexcept + { + switch (format) + { + case AAX_eStemFormat_None: return 0; + case AAX_eStemFormat_Mono: return 1; + case AAX_eStemFormat_Stereo: return 2; + case AAX_eStemFormat_LCR: return 3; + case AAX_eStemFormat_Quad: return 4; + case AAX_eStemFormat_5_0: return 5; + case AAX_eStemFormat_5_1: return 6; + case AAX_eStemFormat_6_1: return 7; + case AAX_eStemFormat_7_1_DTS: return 8; + default: jassertfalse; break; // hmm - not a valid number of chans.. + } + + return 0; + } + + //============================================================================== + struct JUCELibraryRefCount + { + JUCELibraryRefCount() { if (getCount()++ == 0) initialise(); } + ~JUCELibraryRefCount() { if (--getCount() == 0) shutdown(); } + + private: + static void initialise() + { + initialiseJuce_GUI(); + } + + static void shutdown() + { + shutdownJuce_GUI(); + } + + int& getCount() noexcept + { + static int count = 0; + return count; + } + }; + + //============================================================================== + class JuceAAX_Processor; + + struct PluginInstanceInfo + { + PluginInstanceInfo (JuceAAX_Processor& p) : parameters (p) {} + + JuceAAX_Processor& parameters; + + JUCE_DECLARE_NON_COPYABLE (PluginInstanceInfo) + }; + + //============================================================================== + struct JUCEAlgorithmContext + { + float** inputChannels; + float** outputChannels; + int32_t* bufferSize; + int32_t* bypass; + + #if JucePlugin_WantsMidiInput + AAX_IMIDINode* midiNodeIn; + #endif + + #if JucePlugin_ProducesMidiOutput + AAX_IMIDINode* midiNodeOut; + #endif + + PluginInstanceInfo* pluginInstance; + int32_t* isPrepared; + }; + + struct JUCEAlgorithmIDs + { + enum + { + inputChannels = AAX_FIELD_INDEX (JUCEAlgorithmContext, inputChannels), + outputChannels = AAX_FIELD_INDEX (JUCEAlgorithmContext, outputChannels), + bufferSize = AAX_FIELD_INDEX (JUCEAlgorithmContext, bufferSize), + bypass = AAX_FIELD_INDEX (JUCEAlgorithmContext, bypass), + + #if JucePlugin_WantsMidiInput + midiNodeIn = AAX_FIELD_INDEX (JUCEAlgorithmContext, midiNodeIn), + #endif + + #if JucePlugin_ProducesMidiOutput + midiNodeOut = AAX_FIELD_INDEX (JUCEAlgorithmContext, midiNodeOut), + #endif + + pluginInstance = AAX_FIELD_INDEX (JUCEAlgorithmContext, pluginInstance), + preparedFlag = AAX_FIELD_INDEX (JUCEAlgorithmContext, isPrepared) + }; + }; + + #if JucePlugin_WantsMidiInput + static AAX_IMIDINode* getMidiNodeIn (const JUCEAlgorithmContext& c) noexcept { return c.midiNodeIn; } + #else + static AAX_IMIDINode* getMidiNodeIn (const JUCEAlgorithmContext&) noexcept { return nullptr; } + #endif + + #if JucePlugin_ProducesMidiOutput + AAX_IMIDINode* midiNodeOut; + static AAX_IMIDINode* getMidiNodeOut (const JUCEAlgorithmContext& c) noexcept { return c.midiNodeOut; } + #else + static AAX_IMIDINode* getMidiNodeOut (const JUCEAlgorithmContext&) noexcept { return nullptr; } + #endif + + //============================================================================== + class JuceAAX_GUI : public AAX_CEffectGUI + { + public: + JuceAAX_GUI() {} + virtual ~JuceAAX_GUI() { DeleteViewContainer(); } + + static AAX_IEffectGUI* AAX_CALLBACK Create() { return new JuceAAX_GUI(); } + + void CreateViewContents() + { + if (component == nullptr) + { + if (JuceAAX_Processor* params = dynamic_cast <JuceAAX_Processor*> (GetEffectParameters())) + component = new ContentWrapperComponent (*this, params->getPluginInstance()); + else + jassertfalse; + } + } + + void CreateViewContainer() + { + CreateViewContents(); + + if (void* nativeViewToAttachTo = GetViewContainerPtr()) + { + #if JUCE_MAC + if (GetViewContainerType() == AAX_eViewContainer_Type_NSView) + #else + if (GetViewContainerType() == AAX_eViewContainer_Type_HWND) + #endif + { + component->setVisible (true); + component->addToDesktop (0, nativeViewToAttachTo); + } + } + } + + void DeleteViewContainer() + { + if (component != nullptr) + { + JUCE_AUTORELEASEPOOL + { + component->removeFromDesktop(); + component = nullptr; + } + } + } + + virtual AAX_Result GetViewSize (AAX_Point* viewSize) const + { + if (component != nullptr) + { + viewSize->horz = (float) component->getWidth(); + viewSize->vert = (float) component->getHeight(); + return AAX_SUCCESS; + } + + return AAX_ERROR_NULL_OBJECT; + } + + AAX_Result ParameterUpdated (AAX_CParamID /*paramID*/) + { + return AAX_SUCCESS; + } + + AAX_Result SetControlHighlightInfo (AAX_CParamID /*paramID*/, AAX_CBoolean /*isHighlighted*/, AAX_EHighlightColor) + { + return AAX_SUCCESS; + } + + private: + class ContentWrapperComponent : public juce::Component + { + public: + ContentWrapperComponent (JuceAAX_GUI& gui, AudioProcessor& plugin) + : owner (gui) + { + setOpaque (true); + addAndMakeVisible (pluginEditor = plugin.createEditorIfNeeded()); + setBounds (pluginEditor->getLocalBounds()); + setBroughtToFrontOnMouseClick (true); + } + + ~ContentWrapperComponent() + { + if (pluginEditor != nullptr) + { + PopupMenu::dismissAllActiveMenus(); + pluginEditor->getAudioProcessor()->editorBeingDeleted (pluginEditor); + } + } + + void paint (Graphics& g) + { + g.fillAll (Colours::black); + } + + void childBoundsChanged (Component*) + { + if (pluginEditor != nullptr) + { + const int w = pluginEditor->getWidth(); + const int h = pluginEditor->getHeight(); + setSize (w, h); + + AAX_Point newSize ((float) h, (float) w); + owner.GetViewContainer()->SetViewSize (newSize); + } + } + + private: + ScopedPointer<AudioProcessorEditor> pluginEditor; + JuceAAX_GUI& owner; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ContentWrapperComponent) + }; + + ScopedPointer<ContentWrapperComponent> component; + + JUCELibraryRefCount juceCount; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceAAX_GUI) + }; + + //============================================================================== + class JuceAAX_Processor : public AAX_CEffectParameters, + public juce::AudioPlayHead, + public AudioProcessorListener + { + public: + JuceAAX_Processor() : sampleRate (0), lastBufferSize (1024) + { + pluginInstance = createPluginFilterOfType (AudioProcessor::wrapperType_AAX); + pluginInstance->setPlayHead (this); + pluginInstance->addListener (this); + + AAX_CEffectParameters::GetNumberOfChunks (&juceChunkIndex); + } + + static AAX_CEffectParameters* AAX_CALLBACK Create() { return new JuceAAX_Processor(); } + + AAX_Result EffectInit() + { + check (Controller()->GetSampleRate (&sampleRate)); + + preparePlugin(); + addBypassParameter(); + addAudioProcessorParameters(); + + return AAX_SUCCESS; + } + + AAX_Result GetNumberOfChunks (int32_t* numChunks) const + { + // The juceChunk is the last chunk. + *numChunks = juceChunkIndex + 1; + return AAX_SUCCESS; + } + + AAX_Result GetChunkIDFromIndex (int32_t index, AAX_CTypeID* chunkID) const + { + if (index != juceChunkIndex) + return AAX_CEffectParameters::GetChunkIDFromIndex (index, chunkID); + + *chunkID = juceChunkType; + return AAX_SUCCESS; + } + + AAX_Result GetChunkSize (AAX_CTypeID chunkID, uint32_t* oSize) const + { + if (chunkID != juceChunkType) + return AAX_CEffectParameters::GetChunkSize (chunkID, oSize); + + tempFilterData.setSize (0); + pluginInstance->getStateInformation (tempFilterData); + *oSize = (uint32_t) tempFilterData.getSize(); + return AAX_SUCCESS; + } + + AAX_Result GetChunk (AAX_CTypeID chunkID, AAX_SPlugInChunk* oChunk) const + { + if (chunkID != juceChunkType) + return AAX_CEffectParameters::GetChunk (chunkID, oChunk); + + if (tempFilterData.getSize() == 0) + pluginInstance->getStateInformation (tempFilterData); + + oChunk->fSize = (uint32_t) tempFilterData.getSize(); + tempFilterData.copyTo (oChunk->fData, 0, tempFilterData.getSize()); + tempFilterData.setSize (0); + + return AAX_SUCCESS; + } + + AAX_Result SetChunk (AAX_CTypeID chunkID, const AAX_SPlugInChunk* chunk) + { + if (chunkID != juceChunkType) + return AAX_CEffectParameters::SetChunk (chunkID, chunk); + + pluginInstance->setStateInformation ((void*) chunk->fData, chunk->fSize); + return AAX_SUCCESS; + } + + AAX_Result ResetFieldData (AAX_CFieldIndex fieldIndex, void* data, uint32_t dataSize) const + { + switch (fieldIndex) + { + case JUCEAlgorithmIDs::pluginInstance: + { + const size_t numObjects = dataSize / sizeof (PluginInstanceInfo); + PluginInstanceInfo* const objects = static_cast <PluginInstanceInfo*> (data); + + jassert (numObjects == 1); // not sure how to handle more than one.. + + for (size_t i = 0; i < numObjects; ++i) + new (objects + i) PluginInstanceInfo (const_cast<JuceAAX_Processor&> (*this)); + + break; + } + + case JUCEAlgorithmIDs::preparedFlag: + { + const_cast<JuceAAX_Processor*>(this)->preparePlugin(); + + const size_t numObjects = dataSize / sizeof (uint32_t); + uint32_t* const objects = static_cast <uint32_t*> (data); + + for (size_t i = 0; i < numObjects; ++i) + new (objects + i) uint32_t (1); + + break; + } + } + + return AAX_SUCCESS; + //return AAX_ERROR_INVALID_FIELD_INDEX; + } + + AAX_Result UpdateParameterNormalizedValue (AAX_CParamID paramID, double value, AAX_EUpdateSource source) + { + AAX_Result result = AAX_CEffectParameters::UpdateParameterNormalizedValue (paramID, value, source); + + if (AAX::IsParameterIDEqual (paramID, cDefaultMasterBypassID) == false) + { + const int parameterIndex = atoi (paramID); + pluginInstance->setParameter (parameterIndex, (float) value); + } + + return result; + } + + AudioProcessor& getPluginInstance() const noexcept { return *pluginInstance; } + + bool getCurrentPosition (juce::AudioPlayHead::CurrentPositionInfo& info) + { + const AAX_ITransport& transport = *Transport(); + + info.bpm = 0.0; + check (transport.GetCurrentTempo (&info.bpm)); + + int32_t num = 4, den = 4; + transport.GetCurrentMeter (&num, &den); + info.timeSigNumerator = (int) num; + info.timeSigDenominator = (int) den; + + info.timeInSamples = 0; + + if (transport.IsTransportPlaying (&info.isPlaying) != AAX_SUCCESS) + info.isPlaying = false; + + if (info.isPlaying + || transport.GetTimelineSelectionStartPosition (&info.timeInSamples) != AAX_SUCCESS) + check (transport.GetCurrentNativeSampleLocation (&info.timeInSamples)); + + info.timeInSeconds = info.timeInSamples / sampleRate; + + int64_t ticks = 0; + check (transport.GetCurrentTickPosition (&ticks)); + info.ppqPosition = ticks / 960000.0; + + info.isLooping = false; + int64_t loopStartTick = 0, loopEndTick = 0; + check (transport.GetCurrentLoopPosition (&info.isLooping, &loopStartTick, &loopEndTick)); + info.ppqLoopStart = loopStartTick / 960000.0; + info.ppqLoopEnd = loopEndTick / 960000.0; + + info.editOriginTime = 0; + info.frameRate = AudioPlayHead::fpsUnknown; + + AAX_EFrameRate frameRate; + int32_t offset; + + if (transport.GetTimeCodeInfo (&frameRate, &offset) == AAX_SUCCESS) + { + double framesPerSec = 24.0; + + switch (frameRate) + { + case AAX_eFrameRate_Undeclared: break; + case AAX_eFrameRate_24Frame: info.frameRate = AudioPlayHead::fps24; break; + case AAX_eFrameRate_25Frame: info.frameRate = AudioPlayHead::fps25; framesPerSec = 25.0; break; + case AAX_eFrameRate_2997NonDrop: info.frameRate = AudioPlayHead::fps2997; framesPerSec = 29.97002997; break; + case AAX_eFrameRate_2997DropFrame: info.frameRate = AudioPlayHead::fps2997drop; framesPerSec = 29.97002997; break; + case AAX_eFrameRate_30NonDrop: info.frameRate = AudioPlayHead::fps30; framesPerSec = 30.0; break; + case AAX_eFrameRate_30DropFrame: info.frameRate = AudioPlayHead::fps30drop; framesPerSec = 30.0; break; + case AAX_eFrameRate_23976: info.frameRate = AudioPlayHead::fps24; framesPerSec = 23.976; break; + default: break; + } + + info.editOriginTime = offset / framesPerSec; + } + + // No way to get these: (?) + info.isRecording = false; + info.ppqPositionOfLastBarStart = 0; + + return true; + } + + void audioProcessorParameterChanged (AudioProcessor* /*processor*/, int parameterIndex, float newValue) + { + SetParameterNormalizedValue (IndexAsParamID (parameterIndex), (double) newValue); + } + + void audioProcessorChanged (AudioProcessor* processor) + { + check (Controller()->SetSignalLatency (processor->getLatencySamples())); + } + + void audioProcessorParameterChangeGestureBegin (AudioProcessor* /*processor*/, int parameterIndex) + { + TouchParameter (IndexAsParamID (parameterIndex)); + } + + void audioProcessorParameterChangeGestureEnd (AudioProcessor* /*processor*/, int parameterIndex) + { + ReleaseParameter (IndexAsParamID (parameterIndex)); + } + + AAX_Result NotificationReceived (AAX_CTypeID type, const void* data, uint32_t size) + { + if (type == AAX_eNotificationEvent_EnteringOfflineMode) pluginInstance->setNonRealtime (true); + if (type == AAX_eNotificationEvent_ExitingOfflineMode) pluginInstance->setNonRealtime (false); + + return AAX_CEffectParameters::NotificationReceived (type, data, size); + } + + void process (const float* const* inputs, float* const* outputs, const int bufferSize, + const bool bypass, AAX_IMIDINode* midiNodeIn, AAX_IMIDINode* midiNodeOut) + { + const int numIns = pluginInstance->getNumInputChannels(); + const int numOuts = pluginInstance->getNumOutputChannels(); + + if (numOuts >= numIns) + { + for (int i = 0; i < numIns; ++i) + memcpy (outputs[i], inputs[i], bufferSize * sizeof (float)); + + process (outputs, numOuts, bufferSize, bypass, midiNodeIn, midiNodeOut); + } + else + { + if (channelList.size() <= numIns) + channelList.insertMultiple (-1, nullptr, 1 + numIns - channelList.size()); + + float** channels = channelList.getRawDataPointer(); + + for (int i = 0; i < numOuts; ++i) + { + memcpy (outputs[i], inputs[i], bufferSize * sizeof (float)); + channels[i] = outputs[i]; + } + + for (int i = numOuts; i < numIns; ++i) + channels[i] = const_cast <float*> (inputs[i]); + + process (channels, numIns, bufferSize, bypass, midiNodeIn, midiNodeOut); + } + } + + private: + struct IndexAsParamID + { + inline explicit IndexAsParamID (int i) noexcept : index (i) {} + + operator AAX_CParamID() noexcept + { + jassert (index >= 0); + + char* t = name + sizeof (name); + *--t = 0; + int v = index; + + do + { + *--t = (char) ('0' + (v % 10)); + v /= 10; + + } while (v > 0); + + return static_cast <AAX_CParamID> (t); + } + + private: + int index; + char name[32]; + + JUCE_DECLARE_NON_COPYABLE (IndexAsParamID) + }; + + void process (float* const* channels, const int numChans, const int bufferSize, + const bool bypass, AAX_IMIDINode* midiNodeIn, AAX_IMIDINode* midiNodeOut) + { + AudioSampleBuffer buffer (channels, numChans, bufferSize); + + midiBuffer.clear(); + + #if JucePlugin_WantsMidiInput + { + AAX_CMidiStream* const midiStream = midiNodeIn->GetNodeBuffer(); + const uint32_t numMidiEvents = midiStream->mBufferSize; + + for (uint32_t i = 0; i < numMidiEvents; ++i) + { + // (This 8-byte alignment is a workaround to a bug in the AAX SDK. Hopefully can be + // removed in future when the packet structure size is fixed) + const AAX_CMidiPacket& m = *addBytesToPointer (midiStream->mBuffer, + i * ((sizeof (AAX_CMidiPacket) + 7) & ~7)); + jassert ((int) m.mTimestamp < bufferSize); + midiBuffer.addEvent (m.mData, (int) m.mLength, + jlimit (0, (int) bufferSize - 1, (int) m.mTimestamp)); + } + } + #endif + + { + if (lastBufferSize != bufferSize) + { + lastBufferSize = bufferSize; + pluginInstance->prepareToPlay (sampleRate, bufferSize); + } + + const ScopedLock sl (pluginInstance->getCallbackLock()); + + if (bypass) + pluginInstance->processBlockBypassed (buffer, midiBuffer); + else + pluginInstance->processBlock (buffer, midiBuffer); + } + + #if JucePlugin_ProducesMidiOutput + { + const juce::uint8* midiEventData; + int midiEventSize, midiEventPosition; + MidiBuffer::Iterator i (midiBuffer); + + AAX_CMidiPacket packet; + packet.mIsImmediate = false; + + while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition)) + { + jassert (isPositiveAndBelow (midiEventPosition, bufferSize)); + + if (midiEventSize <= 4) + { + packet.mTimestamp = (uint32_t) midiEventPosition; + packet.mLength = (uint32_t) midiEventSize; + memcpy (packet.mData, midiEventData, midiEventSize); + + check (midiNodeOut->PostMIDIPacket (&packet)); + } + } + } + #endif + } + + void addBypassParameter() + { + AAX_IParameter* masterBypass = new AAX_CParameter<bool> (cDefaultMasterBypassID, + AAX_CString ("Master Bypass"), + false, + AAX_CBinaryTaperDelegate<bool>(), + AAX_CBinaryDisplayDelegate<bool> ("bypass", "on"), + true); + masterBypass->SetNumberOfSteps (2); + masterBypass->SetType (AAX_eParameterType_Discrete); + mParameterManager.AddParameter (masterBypass); + mPacketDispatcher.RegisterPacket (cDefaultMasterBypassID, JUCEAlgorithmIDs::bypass); + } + + void addAudioProcessorParameters() + { + AudioProcessor& audioProcessor = getPluginInstance(); + const int numParameters = audioProcessor.getNumParameters(); + + for (int parameterIndex = 0; parameterIndex < numParameters; ++parameterIndex) + { + AAX_IParameter* parameter + = new AAX_CParameter<float> (IndexAsParamID (parameterIndex), + audioProcessor.getParameterName (parameterIndex).toRawUTF8(), + audioProcessor.getParameter (parameterIndex), + AAX_CLinearTaperDelegate<float, 0>(), + AAX_CNumberDisplayDelegate<float, 3>(), + audioProcessor.isParameterAutomatable (parameterIndex)); + + parameter->SetNumberOfSteps (0x7fffffff); + parameter->SetType (AAX_eParameterType_Continuous); + mParameterManager.AddParameter (parameter); + } + } + + void preparePlugin() + { + AAX_EStemFormat inputStemFormat = AAX_eStemFormat_None; + check (Controller()->GetInputStemFormat (&inputStemFormat)); + const int numberOfInputChannels = getNumChannelsForStemFormat (inputStemFormat); + + AAX_EStemFormat outputStemFormat = AAX_eStemFormat_None; + check (Controller()->GetOutputStemFormat (&outputStemFormat)); + const int numberOfOutputChannels = getNumChannelsForStemFormat (outputStemFormat); + + AudioProcessor& audioProcessor = getPluginInstance(); + + audioProcessor.setPlayConfigDetails (numberOfInputChannels, numberOfOutputChannels, sampleRate, lastBufferSize); + audioProcessor.prepareToPlay (sampleRate, lastBufferSize); + + check (Controller()->SetSignalLatency (audioProcessor.getLatencySamples())); + } + + JUCELibraryRefCount juceCount; + + ScopedPointer<AudioProcessor> pluginInstance; + MidiBuffer midiBuffer; + Array<float*> channelList; + int32_t juceChunkIndex; + AAX_CSampleRate sampleRate; + int lastBufferSize; + + // tempFilterData is initialized in GetChunkSize. + // To avoid generating it again in GetChunk, we keep it as a member. + mutable juce::MemoryBlock tempFilterData; + + JUCE_DECLARE_NON_COPYABLE (JuceAAX_Processor) + }; + + //============================================================================== + static void AAX_CALLBACK algorithmProcessCallback (JUCEAlgorithmContext* const instancesBegin[], + const void* const instancesEnd) + { + for (JUCEAlgorithmContext* const* iter = instancesBegin; iter < instancesEnd; ++iter) + { + const JUCEAlgorithmContext& i = **iter; + + i.pluginInstance->parameters.process (i.inputChannels, i.outputChannels, + *(i.bufferSize), *(i.bypass) != 0, + getMidiNodeIn(i), getMidiNodeOut(i)); + } + } + + //============================================================================== + static void createDescriptor (AAX_IComponentDescriptor& desc, int channelConfigIndex, + int numInputs, int numOutputs) + { + check (desc.AddAudioIn (JUCEAlgorithmIDs::inputChannels)); + check (desc.AddAudioOut (JUCEAlgorithmIDs::outputChannels)); + check (desc.AddAudioBufferLength (JUCEAlgorithmIDs::bufferSize)); + check (desc.AddDataInPort (JUCEAlgorithmIDs::bypass, sizeof (int32_t))); + + #if JucePlugin_WantsMidiInput + check (desc.AddMIDINode (JUCEAlgorithmIDs::midiNodeIn, AAX_eMIDINodeType_LocalInput, + JucePlugin_Name, 0xffff)); + #endif + + #if JucePlugin_ProducesMidiOutput + check (desc.AddMIDINode (JUCEAlgorithmIDs::midiNodeOut, AAX_eMIDINodeType_LocalOutput, + JucePlugin_Name " Out", 0xffff)); + #endif + + check (desc.AddPrivateData (JUCEAlgorithmIDs::pluginInstance, sizeof (PluginInstanceInfo))); + + // Create a property map + AAX_IPropertyMap* const properties = desc.NewPropertyMap(); + jassert (properties != nullptr); + + properties->AddProperty (AAX_eProperty_ManufacturerID, JucePlugin_AAXManufacturerCode); + properties->AddProperty (AAX_eProperty_ProductID, JucePlugin_AAXProductId); + + #if JucePlugin_AAXDisableBypass + properties->AddProperty (AAX_eProperty_CanBypass, false); + #else + properties->AddProperty (AAX_eProperty_CanBypass, true); + #endif + + properties->AddProperty (AAX_eProperty_InputStemFormat, getFormatForChans (numInputs)); + properties->AddProperty (AAX_eProperty_OutputStemFormat, getFormatForChans (numOutputs)); + + // This value needs to match the RTAS wrapper's Type ID, so that + // the host knows that the RTAS/AAX plugins are equivalent. + properties->AddProperty (AAX_eProperty_PlugInID_Native, 'jcaa' + channelConfigIndex); + + check (desc.AddProcessProc_Native (algorithmProcessCallback, properties)); + } + + static void getPlugInDescription (AAX_IEffectDescriptor& descriptor) + { + descriptor.AddName (JucePlugin_Desc); + descriptor.AddName (JucePlugin_Name); + descriptor.AddCategory (JucePlugin_AAXCategory); + + check (descriptor.AddProcPtr ((void*) JuceAAX_GUI::Create, kAAX_ProcPtrID_Create_EffectGUI)); + check (descriptor.AddProcPtr ((void*) JuceAAX_Processor::Create, kAAX_ProcPtrID_Create_EffectParameters)); + + const short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations }; + const int numConfigs = numElementsInArray (channelConfigs); + + // You need to actually add some configurations to the JucePlugin_PreferredChannelConfigurations + // value in your JucePluginCharacteristics.h file.. + jassert (numConfigs > 0); + + for (int i = 0; i < numConfigs; ++i) + { + if (AAX_IComponentDescriptor* const desc = descriptor.NewComponentDescriptor()) + { + const int numIns = channelConfigs [i][0]; + const int numOuts = channelConfigs [i][1]; + + if (numIns <= 8 && numOuts <= 8) // AAX doesn't seem to handle more than 8 chans + { + createDescriptor (*desc, i, numIns, numOuts); + check (descriptor.AddComponent (desc)); + } + } + } + } +}; + +//============================================================================== +AAX_Result JUCE_CDECL GetEffectDescriptions (AAX_ICollection*); +AAX_Result JUCE_CDECL GetEffectDescriptions (AAX_ICollection* collection) +{ + AAXClasses::JUCELibraryRefCount libraryRefCount; + + if (AAX_IEffectDescriptor* const descriptor = collection->NewDescriptor()) + { + AAXClasses::getPlugInDescription (*descriptor); + collection->AddEffect (JUCE_STRINGIFY (JucePlugin_AAXIdentifier), descriptor); + + collection->SetManufacturerName (JucePlugin_Manufacturer); + collection->AddPackageName (JucePlugin_Desc); + collection->AddPackageName (JucePlugin_Name); + collection->SetPackageVersion (JucePlugin_VersionCode); + + return AAX_SUCCESS; + } + + return AAX_ERROR_NULL_OBJECT; +} + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.mm b/JuceLibraryCode/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.mm new file mode 100644 index 000000000..5c450cb5a --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.mm @@ -0,0 +1,26 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#define JUCE_INCLUDED_AAX_IN_MM 1 +#include "juce_AAX_Wrapper.cpp" diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/AU/juce_AU_Resources.r b/JuceLibraryCode/modules/juce_audio_plugin_client/AU/juce_AU_Resources.r new file mode 100644 index 000000000..18673593b --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/AU/juce_AU_Resources.r @@ -0,0 +1,70 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +#define UseExtendedThingResource 1 +#include <AudioUnit/AudioUnit.r> + +//============================================================================== +/* The AppConfig.h file should be a file in your project, containing info to describe the + plugin's name, type, etc. The introjucer will generate this file automatically for you. + + You may need to adjust the include path of your project to make sure it can be + found by this include statement. (Don't hack this file to change the include path) +*/ +#include "AppConfig.h" + + +//============================================================================== +// component resources for Audio Unit +#define RES_ID 1000 +#define COMP_TYPE JucePlugin_AUMainType +#define COMP_SUBTYPE JucePlugin_AUSubType +#define COMP_MANUF JucePlugin_AUManufacturerCode +#define VERSION JucePlugin_VersionCode +#define NAME JucePlugin_Manufacturer ": " JucePlugin_Name +#define DESCRIPTION JucePlugin_Desc +#define ENTRY_POINT JucePlugin_AUExportPrefixQuoted "Entry" + +#include "AUResources.r" + +//============================================================================== +// component resources for Audio Unit Carbon View + +#ifndef BUILD_AU_CARBON_UI + #define BUILD_AU_CARBON_UI 1 +#endif + +#if BUILD_AU_CARBON_UI + #define RES_ID 2000 + #define COMP_TYPE kAudioUnitCarbonViewComponentType + #define COMP_SUBTYPE JucePlugin_AUSubType + #define COMP_MANUF JucePlugin_AUManufacturerCode + #define VERSION JucePlugin_VersionCode + #define NAME JucePlugin_Manufacturer ": " JucePlugin_Name " View" + #define DESCRIPTION NAME + #define ENTRY_POINT JucePlugin_AUExportPrefixQuoted "ViewEntry" + + #include "AUResources.r" +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/JuceLibraryCode/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm new file mode 100644 index 000000000..054cc1c0c --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -0,0 +1,1462 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +#if JucePlugin_Build_AU + +#if __LP64__ + #undef JUCE_SUPPORT_CARBON + #define JUCE_SUPPORT_CARBON 0 +#endif + +#ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wshorten-64-to-32" +#endif + +#include "../utility/juce_IncludeSystemHeaders.h" + +#include <AudioUnit/AUCocoaUIView.h> +#include <AudioUnit/AudioUnit.h> +#include <AudioToolbox/AudioUnitUtilities.h> + +#if JUCE_SUPPORT_CARBON + #define Point CarbonDummyPointName + #define Component CarbonDummyCompName +#endif +#include "AUMIDIEffectBase.h" +#include "MusicDeviceBase.h" +#undef Point +#undef Component + +/** The BUILD_AU_CARBON_UI flag lets you specify whether old-school carbon hosts are supported as + well as ones that can open a cocoa view. If this is enabled, you'll need to also add the AUCarbonBase + files to your project. +*/ +#if ! (defined (BUILD_AU_CARBON_UI) || JUCE_64BIT) + #define BUILD_AU_CARBON_UI 1 +#endif + +#ifdef __LP64__ + #undef BUILD_AU_CARBON_UI // (not possible in a 64-bit build) +#endif + +#if BUILD_AU_CARBON_UI + #undef Button + #define Point CarbonDummyPointName + #include "AUCarbonViewBase.h" + #undef Point +#endif + +#ifdef __clang__ + #pragma clang diagnostic pop +#endif + +#define JUCE_MAC_WINDOW_VISIBITY_BODGE 1 + +#include "../utility/juce_IncludeModuleHeaders.h" +#include "../utility/juce_FakeMouseMoveGenerator.h" +#include "../utility/juce_CarbonVisibility.h" +#include "../utility/juce_PluginHostType.h" +#include "../../juce_core/native/juce_osx_ObjCHelpers.h" + +//============================================================================== +static Array<void*> activePlugins, activeUIs; + +static const AudioUnitPropertyID juceFilterObjectPropertyID = 0x1a45ffe9; + +static const short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations }; +static const int numChannelConfigs = sizeof (channelConfigs) / sizeof (*channelConfigs); + +#if JucePlugin_IsSynth + typedef MusicDeviceBase JuceAUBaseClass; +#else + typedef AUMIDIEffectBase JuceAUBaseClass; +#endif + +// This macro can be set if you need to override this internal name for some reason.. +#ifndef JUCE_STATE_DICTIONARY_KEY + #define JUCE_STATE_DICTIONARY_KEY CFSTR("jucePluginState") +#endif + +//============================================================================== +class JuceAU : public JuceAUBaseClass, + public AudioProcessorListener, + public AudioPlayHead, + public ComponentListener +{ +public: + //============================================================================== + JuceAU (AudioUnit component) + #if JucePlugin_IsSynth + : MusicDeviceBase (component, 0, 1), + #else + : AUMIDIEffectBase (component), + #endif + bufferSpace (2, 16), + prepared (false) + { + if (activePlugins.size() + activeUIs.size() == 0) + { + #if BUILD_AU_CARBON_UI + NSApplicationLoad(); + #endif + + initialiseJuce_GUI(); + } + + juceFilter = createPluginFilterOfType (AudioProcessor::wrapperType_AudioUnit); + + juceFilter->setPlayHead (this); + juceFilter->addListener (this); + + Globals()->UseIndexedParameters (juceFilter->getNumParameters()); + + activePlugins.add (this); + + zerostruct (auEvent); + auEvent.mArgument.mParameter.mAudioUnit = GetComponentInstance(); + auEvent.mArgument.mParameter.mScope = kAudioUnitScope_Global; + auEvent.mArgument.mParameter.mElement = 0; + + CreateElements(); + + CAStreamBasicDescription streamDescription; + streamDescription.mSampleRate = GetSampleRate(); + streamDescription.SetCanonical ((UInt32) channelConfigs[0][1], false); + Outputs().GetIOElement(0)->SetStreamFormat (streamDescription); + + #if ! JucePlugin_IsSynth + streamDescription.SetCanonical ((UInt32) channelConfigs[0][0], false); + Inputs().GetIOElement(0)->SetStreamFormat (streamDescription); + #endif + } + + ~JuceAU() + { + deleteActiveEditors(); + juceFilter = nullptr; + clearPresetsArray(); + + jassert (activePlugins.contains (this)); + activePlugins.removeFirstMatchingValue (this); + + if (activePlugins.size() + activeUIs.size() == 0) + shutdownJuce_GUI(); + } + + void deleteActiveEditors() + { + for (int i = activeUIs.size(); --i >= 0;) + { + id ui = (id) activeUIs.getUnchecked(i); + + if (JuceUIViewClass::getAU (ui) == this) + JuceUIViewClass::deleteEditor (ui); + } + } + + //============================================================================== + ComponentResult GetPropertyInfo (AudioUnitPropertyID inID, + AudioUnitScope inScope, + AudioUnitElement inElement, + UInt32& outDataSize, + Boolean& outWritable) + { + if (inScope == kAudioUnitScope_Global) + { + if (inID == juceFilterObjectPropertyID) + { + outWritable = false; + outDataSize = sizeof (void*) * 2; + return noErr; + } + else if (inID == kAudioUnitProperty_OfflineRender) + { + outWritable = true; + outDataSize = sizeof (UInt32); + return noErr; + } + else if (inID == kMusicDeviceProperty_InstrumentCount) + { + outDataSize = sizeof (UInt32); + outWritable = false; + return noErr; + } + else if (inID == kAudioUnitProperty_CocoaUI) + { + #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 + // (On 10.4, there's a random obj-c dispatching crash when trying to load a cocoa UI) + if (SystemStats::getOperatingSystemType() >= SystemStats::MacOSX_10_5) + #endif + { + outDataSize = sizeof (AudioUnitCocoaViewInfo); + outWritable = true; + return noErr; + } + } + } + + return JuceAUBaseClass::GetPropertyInfo (inID, inScope, inElement, outDataSize, outWritable); + } + + ComponentResult GetProperty (AudioUnitPropertyID inID, + AudioUnitScope inScope, + AudioUnitElement inElement, + void* outData) + { + if (inScope == kAudioUnitScope_Global) + { + if (inID == juceFilterObjectPropertyID) + { + ((void**) outData)[0] = (void*) static_cast <AudioProcessor*> (juceFilter); + ((void**) outData)[1] = (void*) this; + return noErr; + } + else if (inID == kAudioUnitProperty_OfflineRender) + { + *(UInt32*) outData = (juceFilter != nullptr && juceFilter->isNonRealtime()) ? 1 : 0; + return noErr; + } + else if (inID == kMusicDeviceProperty_InstrumentCount) + { + *(UInt32*) outData = 1; + return noErr; + } + else if (inID == kAudioUnitProperty_CocoaUI) + { + #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 + // (On 10.4, there's a random obj-c dispatching crash when trying to load a cocoa UI) + if (SystemStats::getOperatingSystemType() >= SystemStats::MacOSX_10_5) + #endif + { + JUCE_AUTORELEASEPOOL + { + static JuceUICreationClass cls; + + // (NB: this may be the host's bundle, not necessarily the component's) + NSBundle* bundle = [NSBundle bundleForClass: cls.cls]; + + AudioUnitCocoaViewInfo* info = static_cast <AudioUnitCocoaViewInfo*> (outData); + info->mCocoaAUViewClass[0] = (CFStringRef) [juceStringToNS (class_getName (cls.cls)) retain]; + info->mCocoaAUViewBundleLocation = (CFURLRef) [[NSURL fileURLWithPath: [bundle bundlePath]] retain]; + } + + return noErr; + } + } + } + + return JuceAUBaseClass::GetProperty (inID, inScope, inElement, outData); + } + + ComponentResult SetProperty (AudioUnitPropertyID inID, + AudioUnitScope inScope, + AudioUnitElement inElement, + const void* inData, + UInt32 inDataSize) + { + if (inScope == kAudioUnitScope_Global && inID == kAudioUnitProperty_OfflineRender) + { + if (juceFilter != nullptr) + juceFilter->setNonRealtime ((*(UInt32*) inData) != 0); + + return noErr; + } + + return JuceAUBaseClass::SetProperty (inID, inScope, inElement, inData, inDataSize); + } + + ComponentResult SaveState (CFPropertyListRef* outData) + { + ComponentResult err = JuceAUBaseClass::SaveState (outData); + + if (err != noErr) + return err; + + jassert (CFGetTypeID (*outData) == CFDictionaryGetTypeID()); + + CFMutableDictionaryRef dict = (CFMutableDictionaryRef) *outData; + + if (juceFilter != nullptr) + { + juce::MemoryBlock state; + juceFilter->getCurrentProgramStateInformation (state); + + if (state.getSize() > 0) + { + CFDataRef ourState = CFDataCreate (kCFAllocatorDefault, (const UInt8*) state.getData(), (CFIndex) state.getSize()); + CFDictionarySetValue (dict, JUCE_STATE_DICTIONARY_KEY, ourState); + CFRelease (ourState); + } + } + + return noErr; + } + + ComponentResult RestoreState (CFPropertyListRef inData) + { + { + // Remove the data entry from the state to prevent the superclass loading the parameters + CFMutableDictionaryRef copyWithoutData = CFDictionaryCreateMutableCopy (nullptr, 0, (CFDictionaryRef) inData); + CFDictionaryRemoveValue (copyWithoutData, CFSTR (kAUPresetDataKey)); + ComponentResult err = JuceAUBaseClass::RestoreState (copyWithoutData); + CFRelease (copyWithoutData); + + if (err != noErr) + return err; + } + + if (juceFilter != nullptr) + { + CFDictionaryRef dict = (CFDictionaryRef) inData; + CFDataRef data = 0; + + if (CFDictionaryGetValueIfPresent (dict, JUCE_STATE_DICTIONARY_KEY, (const void**) &data)) + { + if (data != 0) + { + const int numBytes = (int) CFDataGetLength (data); + const juce::uint8* const rawBytes = CFDataGetBytePtr (data); + + if (numBytes > 0) + juceFilter->setCurrentProgramStateInformation (rawBytes, numBytes); + } + } + } + + return noErr; + } + + UInt32 SupportedNumChannels (const AUChannelInfo** outInfo) + { + // If you hit this, then you need to add some configurations to your + // JucePlugin_PreferredChannelConfigurations setting.. + jassert (numChannelConfigs > 0); + + if (outInfo != nullptr) + { + *outInfo = channelInfo; + + for (int i = 0; i < numChannelConfigs; ++i) + { + #if JucePlugin_IsSynth + channelInfo[i].inChannels = 0; + #else + channelInfo[i].inChannels = channelConfigs[i][0]; + #endif + channelInfo[i].outChannels = channelConfigs[i][1]; + } + } + + return numChannelConfigs; + } + + //============================================================================== + ComponentResult GetParameterInfo (AudioUnitScope inScope, + AudioUnitParameterID inParameterID, + AudioUnitParameterInfo& outParameterInfo) + { + const int index = (int) inParameterID; + + if (inScope == kAudioUnitScope_Global + && juceFilter != nullptr + && index < juceFilter->getNumParameters()) + { + outParameterInfo.flags = (UInt32) (kAudioUnitParameterFlag_IsWritable + | kAudioUnitParameterFlag_IsReadable + | kAudioUnitParameterFlag_HasCFNameString); + + const String name (juceFilter->getParameterName (index)); + + // set whether the param is automatable (unnamed parameters aren't allowed to be automated) + if (name.isEmpty() || ! juceFilter->isParameterAutomatable (index)) + outParameterInfo.flags |= kAudioUnitParameterFlag_NonRealTime; + + if (juceFilter->isMetaParameter (index)) + outParameterInfo.flags |= kAudioUnitParameterFlag_IsGlobalMeta; + + AUBase::FillInParameterName (outParameterInfo, name.toCFString(), true); + + outParameterInfo.minValue = 0.0f; + outParameterInfo.maxValue = 1.0f; + outParameterInfo.defaultValue = 0.0f; + outParameterInfo.unit = kAudioUnitParameterUnit_Generic; + + return noErr; + } + + return kAudioUnitErr_InvalidParameter; + } + + ComponentResult GetParameter (AudioUnitParameterID inID, + AudioUnitScope inScope, + AudioUnitElement inElement, + Float32& outValue) + { + if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) + { + outValue = juceFilter->getParameter ((int) inID); + return noErr; + } + + return AUBase::GetParameter (inID, inScope, inElement, outValue); + } + + ComponentResult SetParameter (AudioUnitParameterID inID, + AudioUnitScope inScope, + AudioUnitElement inElement, + Float32 inValue, + UInt32 inBufferOffsetInFrames) + { + if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) + { + juceFilter->setParameter ((int) inID, inValue); + return noErr; + } + + return AUBase::SetParameter (inID, inScope, inElement, inValue, inBufferOffsetInFrames); + } + + //============================================================================== + ComponentResult Version() { return JucePlugin_VersionCode; } + bool SupportsTail() { return true; } + Float64 GetTailTime() { return juceFilter->getTailLengthSeconds(); } + Float64 GetSampleRate() { return GetOutput(0)->GetStreamFormat().mSampleRate; } + + Float64 GetLatency() + { + jassert (GetSampleRate() > 0); + + if (GetSampleRate() <= 0) + return 0.0; + + return juceFilter->getLatencySamples() / GetSampleRate(); + } + + //============================================================================== + #if BUILD_AU_CARBON_UI + int GetNumCustomUIComponents() + { + return PluginHostType().isDigitalPerformer() ? 0 : 1; + } + + void GetUIComponentDescs (ComponentDescription* inDescArray) + { + inDescArray[0].componentType = kAudioUnitCarbonViewComponentType; + inDescArray[0].componentSubType = JucePlugin_AUSubType; + inDescArray[0].componentManufacturer = JucePlugin_AUManufacturerCode; + inDescArray[0].componentFlags = 0; + inDescArray[0].componentFlagsMask = 0; + } + #endif + + //============================================================================== + bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info) + { + info.timeSigNumerator = 0; + info.timeSigDenominator = 0; + info.timeInSamples = 0; + info.timeInSeconds = 0; + info.editOriginTime = 0; + info.ppqPositionOfLastBarStart = 0; + info.isPlaying = false; + info.isRecording = false; + info.isLooping = false; + info.ppqLoopStart = 0; + info.ppqLoopEnd = 0; + + switch (lastSMPTETime.mType) + { + case kSMPTETimeType24: info.frameRate = AudioPlayHead::fps24; break; + case kSMPTETimeType25: info.frameRate = AudioPlayHead::fps25; break; + case kSMPTETimeType30Drop: info.frameRate = AudioPlayHead::fps30drop; break; + case kSMPTETimeType30: info.frameRate = AudioPlayHead::fps30; break; + case kSMPTETimeType2997: info.frameRate = AudioPlayHead::fps2997; break; + case kSMPTETimeType2997Drop: info.frameRate = AudioPlayHead::fps2997drop; break; + //case kSMPTETimeType60: + //case kSMPTETimeType5994: + default: info.frameRate = AudioPlayHead::fpsUnknown; break; + } + + if (CallHostBeatAndTempo (&info.ppqPosition, &info.bpm) != noErr) + { + info.ppqPosition = 0; + info.bpm = 0; + } + + UInt32 outDeltaSampleOffsetToNextBeat; + double outCurrentMeasureDownBeat; + float num; + UInt32 den; + + if (CallHostMusicalTimeLocation (&outDeltaSampleOffsetToNextBeat, &num, &den, + &outCurrentMeasureDownBeat) == noErr) + { + info.timeSigNumerator = (int) num; + info.timeSigDenominator = (int) den; + info.ppqPositionOfLastBarStart = outCurrentMeasureDownBeat; + } + + double outCurrentSampleInTimeLine, outCycleStartBeat, outCycleEndBeat; + Boolean playing, playchanged, looping; + + if (CallHostTransportState (&playing, + &playchanged, + &outCurrentSampleInTimeLine, + &looping, + &outCycleStartBeat, + &outCycleEndBeat) == noErr) + { + info.isPlaying = playing; + info.timeInSamples = (int64) outCurrentSampleInTimeLine; + info.timeInSeconds = outCurrentSampleInTimeLine / GetSampleRate(); + } + + return true; + } + + void sendAUEvent (const AudioUnitEventType type, const int index) + { + if (AUEventListenerNotify != 0) + { + auEvent.mEventType = type; + auEvent.mArgument.mParameter.mParameterID = (AudioUnitParameterID) index; + AUEventListenerNotify (0, 0, &auEvent); + } + } + + void audioProcessorParameterChanged (AudioProcessor*, int index, float /*newValue*/) + { + sendAUEvent (kAudioUnitEvent_ParameterValueChange, index); + } + + void audioProcessorParameterChangeGestureBegin (AudioProcessor*, int index) + { + sendAUEvent (kAudioUnitEvent_BeginParameterChangeGesture, index); + } + + void audioProcessorParameterChangeGestureEnd (AudioProcessor*, int index) + { + sendAUEvent (kAudioUnitEvent_EndParameterChangeGesture, index); + } + + void audioProcessorChanged (AudioProcessor*) + { + PropertyChanged (kAudioUnitProperty_Latency, kAudioUnitScope_Global, 0); + } + + bool StreamFormatWritable (AudioUnitScope, AudioUnitElement) + { + return ! IsInitialized(); + } + + // (these two slightly different versions are because the definition changed between 10.4 and 10.5) + ComponentResult StartNote (MusicDeviceInstrumentID, MusicDeviceGroupID, NoteInstanceID&, UInt32, const MusicDeviceNoteParams&) { return noErr; } + ComponentResult StartNote (MusicDeviceInstrumentID, MusicDeviceGroupID, NoteInstanceID*, UInt32, const MusicDeviceNoteParams&) { return noErr; } + ComponentResult StopNote (MusicDeviceGroupID, NoteInstanceID, UInt32) { return noErr; } + + //============================================================================== + ComponentResult Initialize() + { + #if ! JucePlugin_IsSynth + const int numIns = GetInput(0) != 0 ? (int) GetInput(0)->GetStreamFormat().mChannelsPerFrame : 0; + #endif + const int numOuts = GetOutput(0) != 0 ? (int) GetOutput(0)->GetStreamFormat().mChannelsPerFrame : 0; + + bool isValidChannelConfig = false; + + for (int i = 0; i < numChannelConfigs; ++i) + #if JucePlugin_IsSynth + if (numOuts == channelConfigs[i][1]) + #else + if (numIns == channelConfigs[i][0] && numOuts == channelConfigs[i][1]) + #endif + isValidChannelConfig = true; + + if (! isValidChannelConfig) + return kAudioUnitErr_FormatNotSupported; + + JuceAUBaseClass::Initialize(); + prepareToPlay(); + return noErr; + } + + void Cleanup() + { + JuceAUBaseClass::Cleanup(); + + if (juceFilter != nullptr) + juceFilter->releaseResources(); + + bufferSpace.setSize (2, 16); + midiEvents.clear(); + incomingEvents.clear(); + prepared = false; + } + + ComponentResult Reset (AudioUnitScope inScope, AudioUnitElement inElement) + { + if (! prepared) + prepareToPlay(); + + if (juceFilter != nullptr) + juceFilter->reset(); + + return JuceAUBaseClass::Reset (inScope, inElement); + } + + void prepareToPlay() + { + if (juceFilter != nullptr) + { + juceFilter->setPlayConfigDetails ( + #if ! JucePlugin_IsSynth + (int) GetInput(0)->GetStreamFormat().mChannelsPerFrame, + #else + 0, + #endif + (int) GetOutput(0)->GetStreamFormat().mChannelsPerFrame, + GetSampleRate(), + (int) GetMaxFramesPerSlice()); + + bufferSpace.setSize (juceFilter->getNumInputChannels() + juceFilter->getNumOutputChannels(), + (int) GetMaxFramesPerSlice() + 32); + + juceFilter->prepareToPlay (GetSampleRate(), (int) GetMaxFramesPerSlice()); + + midiEvents.ensureSize (2048); + midiEvents.clear(); + incomingEvents.ensureSize (2048); + incomingEvents.clear(); + + channels.calloc ((size_t) jmax (juceFilter->getNumInputChannels(), + juceFilter->getNumOutputChannels()) + 4); + + prepared = true; + } + } + + ComponentResult Render (AudioUnitRenderActionFlags &ioActionFlags, + const AudioTimeStamp& inTimeStamp, + UInt32 nFrames) + { + lastSMPTETime = inTimeStamp.mSMPTETime; + + #if ! JucePlugin_IsSynth + return JuceAUBaseClass::Render (ioActionFlags, inTimeStamp, nFrames); + #else + // synths can't have any inputs.. + AudioBufferList inBuffer; + inBuffer.mNumberBuffers = 0; + + return ProcessBufferLists (ioActionFlags, inBuffer, GetOutput(0)->GetBufferList(), nFrames); + #endif + } + + OSStatus ProcessBufferLists (AudioUnitRenderActionFlags& ioActionFlags, + const AudioBufferList& inBuffer, + AudioBufferList& outBuffer, + UInt32 numSamples) + { + if (juceFilter != nullptr) + { + jassert (prepared); + + int numOutChans = 0; + int nextSpareBufferChan = 0; + bool needToReinterleave = false; + const int numIn = juceFilter->getNumInputChannels(); + const int numOut = juceFilter->getNumOutputChannels(); + + for (unsigned int i = 0; i < outBuffer.mNumberBuffers; ++i) + { + AudioBuffer& buf = outBuffer.mBuffers[i]; + + if (buf.mNumberChannels == 1) + { + channels [numOutChans++] = (float*) buf.mData; + } + else + { + needToReinterleave = true; + + for (unsigned int subChan = 0; subChan < buf.mNumberChannels && numOutChans < numOut; ++subChan) + channels [numOutChans++] = bufferSpace.getSampleData (nextSpareBufferChan++); + } + + if (numOutChans >= numOut) + break; + } + + int numInChans = 0; + + for (unsigned int i = 0; i < inBuffer.mNumberBuffers; ++i) + { + const AudioBuffer& buf = inBuffer.mBuffers[i]; + + if (buf.mNumberChannels == 1) + { + if (numInChans < numOutChans) + memcpy (channels [numInChans], (const float*) buf.mData, sizeof (float) * numSamples); + else + channels [numInChans] = (float*) buf.mData; + + ++numInChans; + } + else + { + // need to de-interleave.. + for (unsigned int subChan = 0; subChan < buf.mNumberChannels && numInChans < numIn; ++subChan) + { + float* dest; + + if (numInChans < numOutChans) + { + dest = channels [numInChans++]; + } + else + { + dest = bufferSpace.getSampleData (nextSpareBufferChan++); + channels [numInChans++] = dest; + } + + const float* src = ((const float*) buf.mData) + subChan; + + for (int j = (int) numSamples; --j >= 0;) + { + *dest++ = *src; + src += buf.mNumberChannels; + } + } + } + + if (numInChans >= numIn) + break; + } + + { + const ScopedLock sl (incomingMidiLock); + midiEvents.clear(); + incomingEvents.swapWith (midiEvents); + } + + { + AudioSampleBuffer buffer (channels, jmax (numIn, numOut), (int) numSamples); + + const ScopedLock sl (juceFilter->getCallbackLock()); + + if (juceFilter->isSuspended()) + { + for (int j = 0; j < numOut; ++j) + zeromem (channels [j], sizeof (float) * numSamples); + } + #if ! JucePlugin_IsSynth + else if (ShouldBypassEffect()) + { + juceFilter->processBlockBypassed (buffer, midiEvents); + } + #endif + else + { + juceFilter->processBlock (buffer, midiEvents); + } + } + + if (! midiEvents.isEmpty()) + { + #if JucePlugin_ProducesMidiOutput + const juce::uint8* midiEventData; + int midiEventSize, midiEventPosition; + MidiBuffer::Iterator i (midiEvents); + + while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition)) + { + jassert (isPositiveAndBelow (midiEventPosition, (int) numSamples)); + + + + //xxx + } + #else + // if your plugin creates midi messages, you'll need to set + // the JucePlugin_ProducesMidiOutput macro to 1 in your + // JucePluginCharacteristics.h file + //jassert (midiEvents.getNumEvents() <= numMidiEventsComingIn); + #endif + + midiEvents.clear(); + } + + if (needToReinterleave) + { + nextSpareBufferChan = 0; + + for (unsigned int i = 0; i < outBuffer.mNumberBuffers; ++i) + { + AudioBuffer& buf = outBuffer.mBuffers[i]; + + if (buf.mNumberChannels > 1) + { + for (unsigned int subChan = 0; subChan < buf.mNumberChannels; ++subChan) + { + const float* src = bufferSpace.getSampleData (nextSpareBufferChan++); + float* dest = ((float*) buf.mData) + subChan; + + for (int j = (int) numSamples; --j >= 0;) + { + *dest = *src++; + dest += buf.mNumberChannels; + } + } + } + } + } + + #if ! JucePlugin_SilenceInProducesSilenceOut + ioActionFlags &= (AudioUnitRenderActionFlags) ~kAudioUnitRenderAction_OutputIsSilence; + #endif + } + + return noErr; + } + + OSStatus HandleMidiEvent (UInt8 nStatus, UInt8 inChannel, UInt8 inData1, UInt8 inData2, + #if defined (MAC_OS_X_VERSION_10_5) + UInt32 inStartFrame) + #else + long inStartFrame) + #endif + { + #if JucePlugin_WantsMidiInput + const ScopedLock sl (incomingMidiLock); + const juce::uint8 data[] = { (juce::uint8) (nStatus | inChannel), + (juce::uint8) inData1, + (juce::uint8) inData2 }; + + incomingEvents.addEvent (data, 3, (int) inStartFrame); + #endif + + return noErr; + } + + OSStatus HandleSysEx (const UInt8* inData, UInt32 inLength) + { + #if JucePlugin_WantsMidiInput + const ScopedLock sl (incomingMidiLock); + incomingEvents.addEvent (inData, (int) inLength, 0); + #endif + return noErr; + } + + //============================================================================== + ComponentResult GetPresets (CFArrayRef* outData) const + { + if (outData != nullptr) + { + const int numPrograms = juceFilter->getNumPrograms(); + + clearPresetsArray(); + presetsArray.insertMultiple (0, AUPreset(), numPrograms); + + CFMutableArrayRef presetsArrayRef = CFArrayCreateMutable (0, numPrograms, 0); + + for (int i = 0; i < numPrograms; ++i) + { + String name (juceFilter->getProgramName(i)); + if (name.isEmpty()) + name = "Untitled"; + + AUPreset& p = presetsArray.getReference(i); + p.presetNumber = i; + p.presetName = name.toCFString(); + + CFArrayAppendValue (presetsArrayRef, &p); + } + + *outData = (CFArrayRef) presetsArrayRef; + } + + return noErr; + } + + OSStatus NewFactoryPresetSet (const AUPreset& inNewFactoryPreset) + { + const int numPrograms = juceFilter->getNumPrograms(); + const SInt32 chosenPresetNumber = (int) inNewFactoryPreset.presetNumber; + + if (chosenPresetNumber >= numPrograms) + return kAudioUnitErr_InvalidProperty; + + AUPreset chosenPreset; + chosenPreset.presetNumber = chosenPresetNumber; + chosenPreset.presetName = juceFilter->getProgramName (chosenPresetNumber).toCFString(); + + juceFilter->setCurrentProgram (chosenPresetNumber); + SetAFactoryPresetAsCurrent (chosenPreset); + + return noErr; + } + + void componentMovedOrResized (Component& component, bool /*wasMoved*/, bool /*wasResized*/) + { + NSView* view = (NSView*) component.getWindowHandle(); + NSRect r = [[view superview] frame]; + r.origin.y = r.origin.y + r.size.height - component.getHeight(); + r.size.width = component.getWidth(); + r.size.height = component.getHeight(); + [[view superview] setFrame: r]; + [view setFrame: NSMakeRect (0, 0, component.getWidth(), component.getHeight())]; + [view setNeedsDisplay: YES]; + } + + //============================================================================== + class EditorCompHolder : public Component + { + public: + EditorCompHolder (AudioProcessorEditor* const editor) + { + setSize (editor->getWidth(), editor->getHeight()); + addAndMakeVisible (editor); + + #if ! JucePlugin_EditorRequiresKeyboardFocus + setWantsKeyboardFocus (false); + #else + setWantsKeyboardFocus (true); + #endif + } + + ~EditorCompHolder() + { + deleteAllChildren(); // note that we can't use a ScopedPointer because the editor may + // have been transferred to another parent which takes over ownership. + } + + static NSView* createViewFor (AudioProcessor* filter, JuceAU* au, AudioProcessorEditor* const editor) + { + EditorCompHolder* editorCompHolder = new EditorCompHolder (editor); + NSRect r = NSMakeRect (0, 0, editorCompHolder->getWidth(), editorCompHolder->getHeight()); + + static JuceUIViewClass cls; + NSView* view = [[cls.createInstance() initWithFrame: r] autorelease]; + + JuceUIViewClass::setFilter (view, filter); + JuceUIViewClass::setAU (view, au); + JuceUIViewClass::setEditor (view, editorCompHolder); + + [view setHidden: NO]; + [view setPostsFrameChangedNotifications: YES]; + + [[NSNotificationCenter defaultCenter] addObserver: view + selector: @selector (applicationWillTerminate:) + name: NSApplicationWillTerminateNotification + object: nil]; + activeUIs.add (view); + + editorCompHolder->addToDesktop (0, (void*) view); + editorCompHolder->setVisible (view); + return view; + } + + void childBoundsChanged (Component*) + { + if (Component* editor = getChildComponent(0)) + { + const int w = jmax (32, editor->getWidth()); + const int h = jmax (32, editor->getHeight()); + + if (getWidth() != w || getHeight() != h) + setSize (w, h); + + NSView* view = (NSView*) getWindowHandle(); + NSRect r = [[view superview] frame]; + r.size.width = editor->getWidth(); + r.size.height = editor->getHeight(); + [[view superview] setFrame: r]; + [view setFrame: NSMakeRect (0, 0, editor->getWidth(), editor->getHeight())]; + [view setNeedsDisplay: YES]; + } + } + + bool keyPressed (const KeyPress&) + { + if (PluginHostType().isAbletonLive()) + { + static NSTimeInterval lastEventTime = 0; // check we're not recursively sending the same event + NSTimeInterval eventTime = [[NSApp currentEvent] timestamp]; + + if (lastEventTime != eventTime) + { + lastEventTime = eventTime; + + NSView* view = (NSView*) getWindowHandle(); + NSView* hostView = [view superview]; + NSWindow* hostWindow = [hostView window]; + + [hostWindow makeFirstResponder: hostView]; + [hostView keyDown: [NSApp currentEvent]]; + [hostWindow makeFirstResponder: view]; + } + } + + return false; + } + + private: + JUCE_DECLARE_NON_COPYABLE (EditorCompHolder) + }; + + //============================================================================== + struct JuceUIViewClass : public ObjCClass <NSView> + { + JuceUIViewClass() : ObjCClass <NSView> ("JUCEAUView_") + { + addIvar<AudioProcessor*> ("filter"); + addIvar<JuceAU*> ("au"); + addIvar<EditorCompHolder*> ("editor"); + + addMethod (@selector (dealloc), dealloc, "v@:"); + addMethod (@selector (applicationWillTerminate:), applicationWillTerminate, "v@:@"); + addMethod (@selector (viewDidMoveToWindow), viewDidMoveToWindow, "v@:"); + addMethod (@selector (mouseDownCanMoveWindow), mouseDownCanMoveWindow, "c@:"); + + registerClass(); + } + + static void deleteEditor (id self) + { + ScopedPointer<EditorCompHolder> editorComp (getEditor (self)); + + if (editorComp != nullptr) + { + if (editorComp->getChildComponent(0) != nullptr + && activePlugins.contains (getAU (self))) // plugin may have been deleted before the UI + { + AudioProcessor* const filter = getIvar<AudioProcessor*> (self, "filter"); + filter->editorBeingDeleted ((AudioProcessorEditor*) editorComp->getChildComponent(0)); + } + + editorComp = nullptr; + setEditor (self, nullptr); + } + } + + static JuceAU* getAU (id self) { return getIvar<JuceAU*> (self, "au"); } + static EditorCompHolder* getEditor (id self) { return getIvar<EditorCompHolder*> (self, "editor"); } + + static void setFilter (id self, AudioProcessor* filter) { object_setInstanceVariable (self, "filter", filter); } + static void setAU (id self, JuceAU* au) { object_setInstanceVariable (self, "au", au); } + static void setEditor (id self, EditorCompHolder* e) { object_setInstanceVariable (self, "editor", e); } + + private: + static void dealloc (id self, SEL) + { + if (activeUIs.contains (self)) + shutdown (self); + + sendSuperclassMessage (self, @selector (dealloc)); + } + + static void applicationWillTerminate (id self, SEL, NSNotification*) + { + shutdown (self); + } + + static void shutdown (id self) + { + // there's some kind of component currently modal, but the host + // is trying to delete our plugin.. + jassert (Component::getCurrentlyModalComponent() == nullptr); + + [[NSNotificationCenter defaultCenter] removeObserver: self]; + deleteEditor (self); + + jassert (activeUIs.contains (self)); + activeUIs.removeFirstMatchingValue (self); + if (activePlugins.size() + activeUIs.size() == 0) + shutdownJuce_GUI(); + } + + static void viewDidMoveToWindow (id self, SEL) + { + if (NSWindow* w = [(NSView*) self window]) + { + [w setAcceptsMouseMovedEvents: YES]; + + if (EditorCompHolder* const editorComp = getEditor (self)) + [w makeFirstResponder: (NSView*) editorComp->getWindowHandle()]; + } + } + + static BOOL mouseDownCanMoveWindow (id, SEL) + { + return NO; + } + }; + + //============================================================================== + struct JuceUICreationClass : public ObjCClass <NSObject> + { + JuceUICreationClass() : ObjCClass <NSObject> ("JUCE_AUCocoaViewClass_") + { + addMethod (@selector (interfaceVersion), interfaceVersion, @encode (unsigned int), "@:"); + addMethod (@selector (description), description, @encode (NSString*), "@:"); + addMethod (@selector (uiViewForAudioUnit:withSize:), uiViewForAudioUnit, @encode (NSView*), "@:", @encode (AudioUnit), @encode (NSSize)); + + addProtocol (@protocol (AUCocoaUIBase)); + + registerClass(); + } + + private: + static unsigned int interfaceVersion (id, SEL) { return 0; } + + static NSString* description (id, SEL) + { + return [NSString stringWithString: nsStringLiteral (JucePlugin_Name)]; + } + + static NSView* uiViewForAudioUnit (id, SEL, AudioUnit inAudioUnit, NSSize) + { + void* pointers[2]; + UInt32 propertySize = sizeof (pointers); + + if (AudioUnitGetProperty (inAudioUnit, juceFilterObjectPropertyID, + kAudioUnitScope_Global, 0, pointers, &propertySize) == noErr) + { + if (AudioProcessor* filter = static_cast <AudioProcessor*> (pointers[0])) + if (AudioProcessorEditor* editorComp = filter->createEditorIfNeeded()) + return EditorCompHolder::createViewFor (filter, static_cast <JuceAU*> (pointers[1]), editorComp); + } + + return nil; + } + }; + +private: + //============================================================================== + ScopedPointer<AudioProcessor> juceFilter; + AudioSampleBuffer bufferSpace; + HeapBlock <float*> channels; + MidiBuffer midiEvents, incomingEvents; + bool prepared; + SMPTETime lastSMPTETime; + AUChannelInfo channelInfo [numChannelConfigs]; + AudioUnitEvent auEvent; + mutable Array<AUPreset> presetsArray; + CriticalSection incomingMidiLock; + + void clearPresetsArray() const + { + for (int i = presetsArray.size(); --i >= 0;) + CFRelease (presetsArray.getReference(i).presetName); + + presetsArray.clear(); + } + + JUCE_DECLARE_NON_COPYABLE (JuceAU) +}; + + +//============================================================================== +#if BUILD_AU_CARBON_UI + +class JuceAUView : public AUCarbonViewBase +{ +public: + JuceAUView (AudioUnitCarbonView auview) + : AUCarbonViewBase (auview), + juceFilter (nullptr) + { + } + + ~JuceAUView() + { + deleteUI(); + } + + ComponentResult CreateUI (Float32 /*inXOffset*/, Float32 /*inYOffset*/) + { + JUCE_AUTORELEASEPOOL + { + if (juceFilter == nullptr) + { + void* pointers[2]; + UInt32 propertySize = sizeof (pointers); + + AudioUnitGetProperty (GetEditAudioUnit(), + juceFilterObjectPropertyID, + kAudioUnitScope_Global, + 0, + pointers, + &propertySize); + + juceFilter = (AudioProcessor*) pointers[0]; + } + + if (juceFilter != nullptr) + { + deleteUI(); + + AudioProcessorEditor* editorComp = juceFilter->createEditorIfNeeded(); + editorComp->setOpaque (true); + windowComp = new ComponentInHIView (editorComp, mCarbonPane); + } + else + { + jassertfalse // can't get a pointer to our effect + } + } + + return noErr; + } + + AudioUnitCarbonViewEventListener getEventListener() const { return mEventListener; } + void* getEventListenerUserData() const { return mEventListenerUserData; } + +private: + //============================================================================== + AudioProcessor* juceFilter; + ScopedPointer<Component> windowComp; + FakeMouseMoveGenerator fakeMouseGenerator; + + void deleteUI() + { + if (windowComp != nullptr) + { + PopupMenu::dismissAllActiveMenus(); + + /* This assertion is triggered when there's some kind of modal component active, and the + host is trying to delete our plugin. + If you must use modal components, always use them in a non-blocking way, by never + calling runModalLoop(), but instead using enterModalState() with a callback that + will be performed on completion. (Note that this assertion could actually trigger + a false alarm even if you're doing it correctly, but is here to catch people who + aren't so careful) */ + jassert (Component::getCurrentlyModalComponent() == nullptr); + + if (JuceAU::EditorCompHolder* editorCompHolder = dynamic_cast <JuceAU::EditorCompHolder*> (windowComp->getChildComponent(0))) + if (AudioProcessorEditor* audioProcessEditor = dynamic_cast <AudioProcessorEditor*> (editorCompHolder->getChildComponent(0))) + juceFilter->editorBeingDeleted (audioProcessEditor); + + windowComp = nullptr; + } + } + + //============================================================================== + // Uses a child NSWindow to sit in front of a HIView and display our component + class ComponentInHIView : public Component + { + public: + ComponentInHIView (AudioProcessorEditor* const editor_, HIViewRef parentHIView) + : parentView (parentHIView), + editor (editor_), + recursive (false) + { + JUCE_AUTORELEASEPOOL + { + jassert (editor_ != nullptr); + addAndMakeVisible (&editor); + setOpaque (true); + setVisible (true); + setBroughtToFrontOnMouseClick (true); + + setSize (editor.getWidth(), editor.getHeight()); + SizeControl (parentHIView, (SInt16) editor.getWidth(), (SInt16) editor.getHeight()); + + WindowRef windowRef = HIViewGetWindow (parentHIView); + hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef]; + + [hostWindow retain]; + [hostWindow setCanHide: YES]; + [hostWindow setReleasedWhenClosed: YES]; + + updateWindowPos(); + + #if ! JucePlugin_EditorRequiresKeyboardFocus + addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); + setWantsKeyboardFocus (false); + #else + addToDesktop (ComponentPeer::windowIsTemporary); + setWantsKeyboardFocus (true); + #endif + + setVisible (true); + toFront (false); + + addSubWindow(); + + NSWindow* pluginWindow = [((NSView*) getWindowHandle()) window]; + [pluginWindow setNextResponder: hostWindow]; + + attachWindowHidingHooks (this, (WindowRef) windowRef, hostWindow); + } + } + + ~ComponentInHIView() + { + JUCE_AUTORELEASEPOOL + { + removeWindowHidingHooks (this); + + NSWindow* pluginWindow = [((NSView*) getWindowHandle()) window]; + [hostWindow removeChildWindow: pluginWindow]; + removeFromDesktop(); + + [hostWindow release]; + hostWindow = nil; + } + } + + void updateWindowPos() + { + HIPoint f; + f.x = f.y = 0; + HIPointConvert (&f, kHICoordSpaceView, parentView, kHICoordSpaceScreenPixel, 0); + setTopLeftPosition ((int) f.x, (int) f.y); + } + + void addSubWindow() + { + NSWindow* pluginWindow = [((NSView*) getWindowHandle()) window]; + [pluginWindow setExcludedFromWindowsMenu: YES]; + [pluginWindow setCanHide: YES]; + + [hostWindow addChildWindow: pluginWindow + ordered: NSWindowAbove]; + [hostWindow orderFront: nil]; + [pluginWindow orderFront: nil]; + } + + void resized() + { + if (Component* const child = getChildComponent (0)) + child->setBounds (getLocalBounds()); + } + + void paint (Graphics&) {} + + void childBoundsChanged (Component*) + { + if (! recursive) + { + recursive = true; + + const int w = jmax (32, editor.getWidth()); + const int h = jmax (32, editor.getHeight()); + + SizeControl (parentView, (SInt16) w, (SInt16) h); + + if (getWidth() != w || getHeight() != h) + setSize (w, h); + + editor.repaint(); + + updateWindowPos(); + addSubWindow(); // (need this for AULab) + + recursive = false; + } + } + + bool keyPressed (const KeyPress& kp) + { + if (! kp.getModifiers().isCommandDown()) + { + // If we have an unused keypress, move the key-focus to a host window + // and re-inject the event.. + static NSTimeInterval lastEventTime = 0; // check we're not recursively sending the same event + NSTimeInterval eventTime = [[NSApp currentEvent] timestamp]; + + if (lastEventTime != eventTime) + { + lastEventTime = eventTime; + + [[hostWindow parentWindow] makeKeyWindow]; + [NSApp postEvent: [NSApp currentEvent] atStart: YES]; + } + } + + return false; + } + + private: + HIViewRef parentView; + NSWindow* hostWindow; + JuceAU::EditorCompHolder editor; + bool recursive; + }; +}; + +#endif + +//============================================================================== +#define JUCE_COMPONENT_ENTRYX(Class, Name, Suffix) \ + extern "C" __attribute__((visibility("default"))) ComponentResult Name ## Suffix (ComponentParameters* params, Class* obj); \ + extern "C" __attribute__((visibility("default"))) ComponentResult Name ## Suffix (ComponentParameters* params, Class* obj) \ + { \ + return ComponentEntryPoint<Class>::Dispatch (params, obj); \ + } + +#if JucePlugin_ProducesMidiOutput || JucePlugin_WantsMidiInput + #define FACTORY_BASE_CLASS AUMIDIEffectFactory +#else + #define FACTORY_BASE_CLASS AUBaseFactory +#endif + +#define JUCE_FACTORY_ENTRYX(Class, Name) \ + extern "C" __attribute__((visibility("default"))) void* Name ## Factory (const AudioComponentDescription* desc); \ + extern "C" __attribute__((visibility("default"))) void* Name ## Factory (const AudioComponentDescription* desc) \ + { \ + return FACTORY_BASE_CLASS<Class>::Factory (desc); \ + } + +#define JUCE_COMPONENT_ENTRY(Class, Name, Suffix) JUCE_COMPONENT_ENTRYX(Class, Name, Suffix) +#define JUCE_FACTORY_ENTRY(Class, Name) JUCE_FACTORY_ENTRYX(Class, Name) + +//============================================================================== +JUCE_COMPONENT_ENTRY (JuceAU, JucePlugin_AUExportPrefix, Entry) + +#ifndef AUDIOCOMPONENT_ENTRY + #define JUCE_DISABLE_AU_FACTORY_ENTRY 1 +#endif + +#if ! JUCE_DISABLE_AU_FACTORY_ENTRY // (You might need to disable this for old Xcode 3 builds) +JUCE_FACTORY_ENTRY (JuceAU, JucePlugin_AUExportPrefix) +#endif + +#if BUILD_AU_CARBON_UI + JUCE_COMPONENT_ENTRY (JuceAUView, JucePlugin_AUExportPrefix, ViewEntry) +#endif + +#if ! JUCE_DISABLE_AU_FACTORY_ENTRY + #include "AUPlugInDispatch.cpp" +#endif + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp new file mode 100644 index 000000000..dddda73aa --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp @@ -0,0 +1,64 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +#if JucePlugin_Build_RTAS + +#include "juce_RTAS_DigiCode_Header.h" + +/* + This file is used to include and build the required digidesign CPP files without your project + needing to reference the files directly. Because these files will be found via your include path, + this means that the project doesn't have to change to cope with people's SDKs being in different + locations. + + Important note on Windows: In your project settings for the three juce_RTAS_DigiCode.cpp files and + the juce_RTAS_Wrapper.cpp file, you need to set the calling convention to "__stdcall". + If you don't do this, you'll get some unresolved externals and will spend a long time wondering what's + going on... All the other files in your project can be set to use the normal __cdecl convention. + + If you get an error building the includes statements below, check your paths - there's a full + list of the necessary Digidesign paths in juce_RTAS_Wrapper.cpp +*/ + +#if WINDOWS_VERSION + #undef _UNICODE + #undef UNICODE +#endif + +#include <CEffectGroup.cpp> +#include <CEffectGroupMIDI.cpp> +#include <CEffectMIDIUtils.cpp> +#include <CEffectProcess.cpp> +#include <CEffectProcessAS.cpp> +#include <CEffectType.cpp> +#include <CEffectTypeRTAS.cpp> +#include <ChunkDataParser.cpp> + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp new file mode 100644 index 000000000..dfdc25215 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp @@ -0,0 +1,53 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +#if JucePlugin_Build_RTAS + +#include "juce_RTAS_DigiCode_Header.h" + +/* + This file is used to include and build the required digidesign CPP files without your project + needing to reference the files directly. Because these files will be found via your include path, + this means that the project doesn't have to change to cope with people's SDKs being in different + locations. + + Important note on Windows: In your project settings for the three juce_RTAS_DigiCode.cpp files and + the juce_RTAS_Wrapper.cpp file, you need to set the calling convention to "__stdcall". + If you don't do this, you'll get some unresolved externals and will spend a long time wondering what's + going on... All the other files in your project can be set to use the normal __cdecl convention. + + If you get an error building the includes statements below, check your paths - there's a full + list of the necessary Digidesign paths in juce_RTAS_Wrapper.cpp +*/ + +#include <CEffectProcessMIDI.cpp> +#include <PlugInUtils.cpp> + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp new file mode 100644 index 000000000..9c6a87346 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp @@ -0,0 +1,71 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +#if JucePlugin_Build_RTAS + + #include "juce_RTAS_DigiCode_Header.h" + + /* + This file is used to include and build the required digidesign CPP files without your project + needing to reference the files directly. Because these files will be found via your include path, + this means that the project doesn't have to change to cope with people's SDKs being in different + locations. + + Important note on Windows: In your project settings for the three juce_RTAS_DigiCode.cpp files and + the juce_RTAS_Wrapper.cpp file, you need to set the calling convention to "__stdcall". + If you don't do this, you'll get some unresolved externals and will spend a long time wondering what's + going on... All the other files in your project can be set to use the normal __cdecl convention. + + If you get an error building the includes statements below, check your paths - there's a full + list of the necessary Digidesign paths in juce_RTAS_Wrapper.cpp + */ + + #if WINDOWS_VERSION + #undef _UNICODE + #undef UNICODE + + #define DllMain DllMainRTAS + #include <DLLMain.cpp> + #undef DllMain + #include <DefaultSwap.cpp> + + #else + #include <PlugInInitialize.cpp> + #include <Dispatcher.cpp> + #endif + + #else + + #if _MSC_VER + short __stdcall NewPlugIn (void*) { return 0; } + short __stdcall _PI_GetRoutineDescriptor (long, void*) { return 0; } + #endif + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h new file mode 100644 index 000000000..83a22a747 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h @@ -0,0 +1,73 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_RTAS_DIGICODE_HEADER_JUCEHEADER__ +#define __JUCE_RTAS_DIGICODE_HEADER_JUCEHEADER__ + +#if JucePlugin_Build_RTAS + +//============================================================================== +#if JucePlugin_Build_RTAS +#ifdef _MSC_VER + + #define kCompileAsCodeResource 0 + #define kBuildStandAlone 0 + #define kNoDSP 0 + #define kNoDAE 0 + #define kNoSDS 0 + #define kNoViews 0 + #define kUseDSPCodeDecode 0 + + #define WIN32 1 + #define WINDOWS_VERSION 1 + #define PLUGIN_SDK_BUILD 1 + #define PLUGIN_SDK_DIRECTMIDI 1 + + // the Digidesign projects all use a struct alignment of 2.. + #pragma pack (2) + #pragma warning (disable: 4267 4996 4311 4312 4103 4121 4100 4127 4189 4245 4389 4512 4701) + + #include <ForcedInclude.h> + +#else + + #define kCompileAsCodeResource 0 + #define kNoDSP 1 + #define kNoDAE 0 + #define kNoSDS 0 + #define kNoViews 0 + #define kUseDSPCodeDecode 0 + + #define MAC_VERSION 1 + #define PLUGIN_SDK_BUILD 1 + #define PLUGIN_SDK_DIRECTMIDI 1 + #define DIGI_PASCAL + + #include <MacAlwaysInclude.h> + +#endif +#endif +#endif + +#endif // __JUCE_RTAS_DIGICODE_HEADER_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_MacResources.r b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_MacResources.r new file mode 100644 index 000000000..a40e1f397 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_MacResources.r @@ -0,0 +1,6 @@ + +/* + This dummy file is added to the resources section of the project to + force XCode to create some resources for the dpm. If there aren't any + resources, PT will refuse to load the plugin.. +*/ diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_MacUtilities.mm b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_MacUtilities.mm new file mode 100644 index 000000000..53b840be9 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_MacUtilities.mm @@ -0,0 +1,165 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +#if JucePlugin_Build_RTAS + +// Horrible carbon-based fix for a cocoa bug, where an NSWindow that wraps a carbon +// window fails to keep its position updated when the user drags the window around.. +#define WINDOWPOSITION_BODGE 1 +#define JUCE_MAC_WINDOW_VISIBITY_BODGE 1 + +#include "../utility/juce_IncludeSystemHeaders.h" +#include "../utility/juce_IncludeModuleHeaders.h" +#include "../utility/juce_CarbonVisibility.h" + +//============================================================================== +void initialiseMacRTAS() +{ + #if ! JUCE_64BIT + NSApplicationLoad(); + #endif +} + +void* attachSubWindow (void* hostWindowRef, Component* comp) +{ + JUCE_AUTORELEASEPOOL + { + #if 0 + // This was suggested as a way to improve passing keypresses to the host, but + // a side-effect seems to be occasional rendering artifacts. + HIWindowChangeClass ((WindowRef) hostWindowRef, kFloatingWindowClass); + #endif + + NSWindow* hostWindow = [[NSWindow alloc] initWithWindowRef: hostWindowRef]; + [hostWindow retain]; + [hostWindow setCanHide: YES]; + [hostWindow setReleasedWhenClosed: YES]; + NSRect oldWindowFrame = [hostWindow frame]; + + NSView* content = [hostWindow contentView]; + NSRect f = [content frame]; + f.size.width = comp->getWidth(); + f.size.height = comp->getHeight(); + [content setFrame: f]; + + const int mainScreenHeight = [[[NSScreen screens] objectAtIndex: 0] frame].size.height; + + #if WINDOWPOSITION_BODGE + { + Rect winBounds; + GetWindowBounds ((WindowRef) hostWindowRef, kWindowContentRgn, &winBounds); + NSRect w = [hostWindow frame]; + w.origin.x = winBounds.left; + w.origin.y = mainScreenHeight - winBounds.bottom; + [hostWindow setFrame: w display: NO animate: NO]; + } + #endif + + NSPoint windowPos = [hostWindow convertBaseToScreen: f.origin]; + windowPos.x = windowPos.x + jmax (0.0f, (oldWindowFrame.size.width - f.size.width) / 2.0f); + windowPos.y = mainScreenHeight - (windowPos.y + f.size.height); + + comp->setTopLeftPosition ((int) windowPos.x, (int) windowPos.y); + + #if ! JucePlugin_EditorRequiresKeyboardFocus + comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); + #else + comp->addToDesktop (ComponentPeer::windowIsTemporary); + #endif + + comp->setVisible (true); + + NSView* pluginView = (NSView*) comp->getWindowHandle(); + NSWindow* pluginWindow = [pluginView window]; + + [hostWindow addChildWindow: pluginWindow + ordered: NSWindowAbove]; + [hostWindow orderFront: nil]; + [pluginWindow orderFront: nil]; + + attachWindowHidingHooks (comp, (WindowRef) hostWindowRef, hostWindow); + + return hostWindow; + } +} + +void removeSubWindow (void* nsWindow, Component* comp) +{ + JUCE_AUTORELEASEPOOL + { + NSView* pluginView = (NSView*) comp->getWindowHandle(); + NSWindow* hostWindow = (NSWindow*) nsWindow; + NSWindow* pluginWindow = [pluginView window]; + + removeWindowHidingHooks (comp); + [hostWindow removeChildWindow: pluginWindow]; + comp->removeFromDesktop(); + [hostWindow release]; + } +} + +namespace +{ + bool isJuceWindow (WindowRef w) + { + for (int i = ComponentPeer::getNumPeers(); --i >= 0;) + { + ComponentPeer* peer = ComponentPeer::getPeer(i); + NSView* view = (NSView*) peer->getNativeHandle(); + + if ([[view window] windowRef] == w) + return true; + } + + return false; + } +} + +void forwardCurrentKeyEventToHostWindow() +{ + WindowRef w = FrontNonFloatingWindow(); + WindowRef original = w; + + while (IsValidWindowPtr (w) && isJuceWindow (w)) + { + w = GetNextWindowOfClass (w, kDocumentWindowClass, true); + + if (w == original) + break; + } + + if (! isJuceWindow (w)) + { + ActivateWindow (w, true); + [NSApp postEvent: [NSApp currentEvent] atStart: YES]; + } +} + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinExports.def b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinExports.def new file mode 100644 index 000000000..31b09258e --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinExports.def @@ -0,0 +1,3 @@ +EXPORTS + NewPlugIn @1 + _PI_GetRoutineDescriptor @2 diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinResources.rsr b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinResources.rsr new file mode 100644 index 0000000000000000000000000000000000000000..d8bfb4a1c8594d8faf551d09f1b3c7a07f875fce GIT binary patch literal 3198 zcmd^BO>7%Q6n<M;g%l@-Tcxz>gjND65S;QOf{;QW6h$pb6cQS#C@9$Lbdh6Qc7Dhy zD;gxYRN|UTZwNSY$_eNd#SN#3i(|L+=-8I3G+le`;k}t1k9V7-;=qY#@4olG_dm0< zHh=*D&kX^b#>>F#e@9nNy}&vFI^XOc=pXp%^~m5mE$J2Z)4<^1Td!V<L<ZQ1HE+et ztTmrxqseGL8%`wHq&0tIG0P^+teIIhWBs^<u*P}QMuD!|#SZ6oHSE}tkYS%WBd<`z zu)|fu?kEZ$;Y%`MWK(_^L$Q=Y<@*hD7XjcN{~hlC%pWwS*EiPq`u9V8ed8I<9~g-9 z|Cp*?{fC^FuvBvmZ$rqjeu?S>oP@sP$?1E19661?$Idb2lD*`S_G=+Ndr3JcbIB2Q z4=%OYm1nyh>quB})c%#-OVAeXk3VD(Uw+4PP|XGFx8X_*#4EVP19rJEEo)%Dr}if& zJ90i{P#o*{>MLCFfL+5{67hOFz0Nh@v+KE(gTKDEw<L^r+~cU>G@6a$$Zhf(9)u$a z?PP0JbX>nH+7YR>$mMlKP$Nqd51q#9ytco;@7Czc-F<Z6O(Z=6e}sfL`F(`N>lm*m z;I)H;1Gh$B-aHV!VMCNd5>@jETxG^8n*99(oCpHB(3X#OLwO%nLObzze1R|_NIgzE z;_-!w@RvG)Qs2P<x{lKG7$9Oif02vam5#MUxYC8K%^uW){?wcBk^KbgJ*~g?d1!2@ zBgc8gGEi<Ic=>fdxw4NcyLvN(RB8CPpi+e{ir)2Lw2Newe132D&s`{RzDLx6?qWGy zEOv7)3b<R_TkiJOHab*@8e4Zu<!zUK26V-0fwG1L;N{1kKM1_#8-dq4>Ub#SDIh`G z1t4yoKOJ1*bV$5DLMR>X@5`rBiNa6hbL#p`kW|;tx|ph2mxqqm-MR}do+9Zl+&FM? ztkkNYie!6F{oS10x<ZZ~xSe<*m*2_f7xKvQq09?T9;7So;htYBPTKQcojq^8n+P|{ z#bN<>tqS3Am#|l9pWfr#Ha5?#_ujl?8@6%t&U)|WIosg82)wrT&H0*YImm^bpQm@( z+0n62r;r<$CqKL_O4_3zj9rit;UslTjeNW!Ajn7rt{D@MFupr^V*H9Q^uPreH*S49 zId#LzvSl-qwNgozinG}WLm-t*tg_{~gcW07n2Rf>nPjsAY%UpNvzPkWM8cfQnrtZ@ zn_D#5YHBINqN((%499<8&<!u+=SSnOo|)<C$Z14AlkJGR=&?;F(MYePqXA6dPhjsp zKbpjT7hfA$N++x+c0l2H>A%li7sobxyAe8Tya*v04&^Vsby~KfiMLVz8u=T@Z&}eS z=^MyN{{cCz=P&P%ja)_ktGD8Rcq_g$GCD>0{o$*Vv=ilMJTs5H2Dp<91wl5a$8KE9 z#wS`nbxq41*R}lY=WX)eTJC&F$l})dQ5#NuK+g=->J&M9W+04mPWa%90p&v1#R=#h cUrCx7mNB!qSy8iVIGtuw)`A&h<4cSG0Paa_uK)l5 literal 0 HcmV?d00001 diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp new file mode 100644 index 000000000..7395136f6 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp @@ -0,0 +1,140 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +// (these functions are in their own file because of problems including windows.h +// at the same time as the Digi headers) + +#if JucePlugin_Build_RTAS + +#define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY // (workaround for a VC build problem) + +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 +#undef STRICT +#define STRICT +#include <intrin.h> +#include <windows.h> + +#pragma pack (push, 8) +#include "../utility/juce_IncludeModuleHeaders.h" +#pragma pack (pop) + +//============================================================================== +void JUCE_CALLTYPE attachSubWindow (void* hostWindow, + int& titleW, int& titleH, + Component* comp) +{ + RECT clientRect; + GetClientRect ((HWND) hostWindow, &clientRect); + + titleW = clientRect.right - clientRect.left; + titleH = jmax (0, (int) (clientRect.bottom - clientRect.top) - comp->getHeight()); + comp->setTopLeftPosition (0, titleH); + + comp->addToDesktop (0); + + HWND plugWnd = (HWND) comp->getWindowHandle(); + SetParent (plugWnd, (HWND) hostWindow); + + DWORD val = GetWindowLong (plugWnd, GWL_STYLE); + val = (val & ~WS_POPUP) | WS_CHILD; + SetWindowLong (plugWnd, GWL_STYLE, val); + + val = GetWindowLong ((HWND) hostWindow, GWL_STYLE); + SetWindowLong ((HWND) hostWindow, GWL_STYLE, val | WS_CLIPCHILDREN); +} + +void JUCE_CALLTYPE resizeHostWindow (void* hostWindow, + int& titleW, int& titleH, + Component* comp) +{ + RECT clientRect, windowRect; + GetClientRect ((HWND) hostWindow, &clientRect); + GetWindowRect ((HWND) hostWindow, &windowRect); + const int borderW = (windowRect.right - windowRect.left) - (clientRect.right - clientRect.left); + const int borderH = (windowRect.bottom - windowRect.top) - (clientRect.bottom - clientRect.top); + + SetWindowPos ((HWND) hostWindow, 0, 0, 0, + borderW + jmax (titleW, comp->getWidth()), + borderH + comp->getHeight() + titleH, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER); +} + +#if ! JucePlugin_EditorRequiresKeyboardFocus + +namespace +{ + HWND findMDIParentOf (HWND w) + { + const int frameThickness = GetSystemMetrics (SM_CYFIXEDFRAME); + + while (w != 0) + { + HWND parent = GetParent (w); + + if (parent == 0) + break; + + TCHAR windowType [32] = { 0 }; + GetClassName (parent, windowType, 31); + + if (String (windowType).equalsIgnoreCase ("MDIClient")) + { + w = parent; + break; + } + + RECT windowPos, parentPos; + GetWindowRect (w, &windowPos); + GetWindowRect (parent, &parentPos); + + int dw = (parentPos.right - parentPos.left) - (windowPos.right - windowPos.left); + int dh = (parentPos.bottom - parentPos.top) - (windowPos.bottom - windowPos.top); + + if (dw > 100 || dh > 100) + break; + + w = parent; + + if (dw == 2 * frameThickness) + break; + } + + return w; + } +} + +void JUCE_CALLTYPE passFocusToHostWindow (void* hostWindow) +{ + SetFocus (findMDIParentOf ((HWND) hostWindow)); +} + +#endif +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp new file mode 100644 index 000000000..f8848fd17 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp @@ -0,0 +1,1010 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +#if JucePlugin_Build_RTAS + +#ifdef _MSC_VER + // (this is a workaround for a build problem in VC9) + #define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY + #include <intrin.h> +#endif + +#include "juce_RTAS_DigiCode_Header.h" + +#ifdef _MSC_VER + #include <Mac2Win.H> +#endif + +/* Note about include paths + ------------------------ + + To be able to include all the Digidesign headers correctly, you'll need to add this + lot to your include path: + + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\EffectClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\ProcessClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\ProcessClasses\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Utilities + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\RTASP_Adapt + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\CoreClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Controls + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Meters + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\ViewClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\DSPClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\common + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\common\Platform + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\SignalProcessing\Public + C:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugIns\DSPManager\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\SADriver\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\DigiPublic\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\Fic\Interfaces\DAEClient + c:\yourdirectory\PT_80_SDK\AlturaPorts\NewFileLibs\Cmn + c:\yourdirectory\PT_80_SDK\AlturaPorts\NewFileLibs\DOA + c:\yourdirectory\PT_80_SDK\AlturaPorts\AlturaSource\PPC_H + c:\yourdirectory\PT_80_SDK\AlturaPorts\AlturaSource\AppSupport + c:\yourdirectory\PT_80_SDK\AlturaPorts\DigiPublic + c:\yourdirectory\PT_80_SDK\AvidCode\AVX2sdk\AVX\avx2\avx2sdk\inc + c:\yourdirectory\PT_80_SDK\xplat\AVX\avx2\avx2sdk\inc + + NB. If you hit a huge pile of bugs around here, make sure that you've not got the + Apple QuickTime headers before the PT headers in your path, because there are + some filename clashes between them. + +*/ +#include <CEffectGroupMIDI.h> +#include <CEffectProcessMIDI.h> +#include <CEffectProcessRTAS.h> +#include <CCustomView.h> +#include <CEffectTypeRTAS.h> +#include <CPluginControl.h> +#include <CPluginControl_OnOff.h> +#include <FicProcessTokens.h> +#include <ExternalVersionDefines.h> + +//============================================================================== +#ifdef _MSC_VER + #pragma pack (push, 8) + #pragma warning (disable: 4263 4264) +#endif + +#include "../utility/juce_IncludeModuleHeaders.h" + +#ifdef _MSC_VER + #pragma pack (pop) + + #if JUCE_DEBUGxxx // (the debug lib in the 8.0 SDK fails to link, so we'll stick to the release one...) + #define PT_LIB_PATH JucePlugin_WinBag_path "\\Debug\\lib\\" + #else + #define PT_LIB_PATH JucePlugin_WinBag_path "\\Release\\lib\\" + #endif + + #pragma comment(lib, PT_LIB_PATH "DAE.lib") + #pragma comment(lib, PT_LIB_PATH "DigiExt.lib") + #pragma comment(lib, PT_LIB_PATH "DSI.lib") + #pragma comment(lib, PT_LIB_PATH "PluginLib.lib") + #pragma comment(lib, PT_LIB_PATH "DSPManager.lib") + #pragma comment(lib, PT_LIB_PATH "DSPManagerClientLib.lib") + #pragma comment(lib, PT_LIB_PATH "RTASClientLib.lib") +#endif + +#undef Component +#undef MemoryBlock + +//============================================================================== +#if JUCE_WINDOWS + extern void JUCE_CALLTYPE attachSubWindow (void* hostWindow, int& titleW, int& titleH, juce::Component* comp); + extern void JUCE_CALLTYPE resizeHostWindow (void* hostWindow, int& titleW, int& titleH, juce::Component* comp); + #if ! JucePlugin_EditorRequiresKeyboardFocus + extern void JUCE_CALLTYPE passFocusToHostWindow (void* hostWindow); + #endif +#else + extern void* attachSubWindow (void* hostWindowRef, juce::Component* comp); + extern void removeSubWindow (void* nsWindow, juce::Component* comp); + extern void forwardCurrentKeyEventToHostWindow(); +#endif + +#if ! (JUCE_DEBUG || defined (JUCE_RTAS_PLUGINGESTALT_IS_CACHEABLE)) + #define JUCE_RTAS_PLUGINGESTALT_IS_CACHEABLE 1 +#endif + +const int midiBufferSize = 1024; +const OSType juceChunkType = 'juce'; +static const int bypassControlIndex = 1; + +static int numInstances = 0; + +//============================================================================== +class JucePlugInProcess : public CEffectProcessMIDI, + public CEffectProcessRTAS, + public AudioProcessorListener, + public AudioPlayHead +{ +public: + //============================================================================== + JucePlugInProcess() + : prepared (false), + sampleRate (44100.0) + { + asyncUpdater = new InternalAsyncUpdater (*this); + juceFilter = createPluginFilterOfType (AudioProcessor::wrapperType_RTAS); + + AddChunk (juceChunkType, "Juce Audio Plugin Data"); + + ++numInstances; + } + + ~JucePlugInProcess() + { + JUCE_AUTORELEASEPOOL + { + if (mLoggedIn) + MIDILogOut(); + + midiBufferNode = nullptr; + midiTransport = nullptr; + + if (prepared) + juceFilter->releaseResources(); + + juceFilter = nullptr; + asyncUpdater = nullptr; + + if (--numInstances == 0) + { + #if JUCE_MAC + // Hack to allow any NSWindows to clear themselves up before returning to PT.. + for (int i = 20; --i >= 0;) + MessageManager::getInstance()->runDispatchLoopUntil (1); + #endif + + shutdownJuce_GUI(); + } + } + } + + //============================================================================== + class JuceCustomUIView : public CCustomView, + public Timer + { + public: + //============================================================================== + JuceCustomUIView (AudioProcessor* const filter_, + JucePlugInProcess* const process_) + : filter (filter_), + process (process_) + { + // setting the size in here crashes PT for some reason, so keep it simple.. + } + + ~JuceCustomUIView() + { + deleteEditorComp(); + } + + //============================================================================== + void updateSize() + { + if (editorComp == nullptr) + { + editorComp = filter->createEditorIfNeeded(); + jassert (editorComp != nullptr); + } + + if (editorComp->getWidth() != 0 && editorComp->getHeight() != 0) + { + Rect oldRect; + GetRect (&oldRect); + + Rect r; + r.left = 0; + r.top = 0; + r.right = editorComp->getWidth(); + r.bottom = editorComp->getHeight(); + SetRect (&r); + + if ((oldRect.right != r.right) || (oldRect.bottom != r.bottom)) + startTimer (50); + } + } + + void timerCallback() + { + if (! juce::Component::isMouseButtonDownAnywhere()) + { + stopTimer(); + + // Send a token to the host to tell it about the resize + SSetProcessWindowResizeToken token (process->fRootNameId, process->fRootNameId); + FicSDSDispatchToken (&token); + } + } + + void attachToWindow (GrafPtr port) + { + if (port != 0) + { + JUCE_AUTORELEASEPOOL + { + updateSize(); + + #if JUCE_WINDOWS + void* const hostWindow = (void*) ASI_GethWnd ((WindowPtr) port); + #else + void* const hostWindow = (void*) GetWindowFromPort (port); + #endif + wrapper = nullptr; + wrapper = new EditorCompWrapper (hostWindow, editorComp, this); + + process->touchAllParameters(); + } + } + else + { + deleteEditorComp(); + } + } + + void DrawContents (Rect*) + { + #if JUCE_WINDOWS + if (wrapper != nullptr) + { + if (ComponentPeer* const peer = wrapper->getPeer()) + peer->repaint (wrapper->getLocalBounds()); // (seems to be required in PT6.4, but not in 7.x) + } + #endif + } + + void DrawBackground (Rect*) {} + + //============================================================================== + private: + AudioProcessor* const filter; + JucePlugInProcess* const process; + ScopedPointer<juce::Component> wrapper; + ScopedPointer<AudioProcessorEditor> editorComp; + + void deleteEditorComp() + { + if (editorComp != nullptr || wrapper != nullptr) + { + JUCE_AUTORELEASEPOOL + { + PopupMenu::dismissAllActiveMenus(); + + if (juce::Component* const modalComponent = juce::Component::getCurrentlyModalComponent()) + modalComponent->exitModalState (0); + + filter->editorBeingDeleted (editorComp); + + editorComp = nullptr; + wrapper = nullptr; + } + } + } + + //============================================================================== + // A component to hold the AudioProcessorEditor, and cope with some housekeeping + // chores when it changes or repaints. + class EditorCompWrapper : public juce::Component + #if ! JUCE_MAC + , public FocusChangeListener + #endif + { + public: + EditorCompWrapper (void* const hostWindow_, + Component* const editorComp, + JuceCustomUIView* const owner_) + : hostWindow (hostWindow_), + owner (owner_), + titleW (0), + titleH (0) + { + #if ! JucePlugin_EditorRequiresKeyboardFocus + setMouseClickGrabsKeyboardFocus (false); + setWantsKeyboardFocus (false); + #endif + setOpaque (true); + setBroughtToFrontOnMouseClick (true); + setBounds (editorComp->getBounds()); + editorComp->setTopLeftPosition (0, 0); + addAndMakeVisible (editorComp); + + #if JUCE_WINDOWS + attachSubWindow (hostWindow, titleW, titleH, this); + #else + nsWindow = attachSubWindow (hostWindow, this); + #endif + setVisible (true); + + #if JUCE_WINDOWS && ! JucePlugin_EditorRequiresKeyboardFocus + Desktop::getInstance().addFocusChangeListener (this); + #endif + } + + ~EditorCompWrapper() + { + removeChildComponent (getEditor()); + + #if JUCE_WINDOWS && ! JucePlugin_EditorRequiresKeyboardFocus + Desktop::getInstance().removeFocusChangeListener (this); + #endif + + #if JUCE_MAC + removeSubWindow (nsWindow, this); + #endif + } + + void paint (Graphics&) {} + + void resized() + { + if (juce::Component* const ed = getEditor()) + ed->setBounds (getLocalBounds()); + + repaint(); + } + + #if JUCE_WINDOWS + void globalFocusChanged (juce::Component*) + { + #if ! JucePlugin_EditorRequiresKeyboardFocus + if (hasKeyboardFocus (true)) + passFocusToHostWindow (hostWindow); + #endif + } + #endif + + void childBoundsChanged (juce::Component* child) + { + setSize (child->getWidth(), child->getHeight()); + child->setTopLeftPosition (0, 0); + + #if JUCE_WINDOWS + resizeHostWindow (hostWindow, titleW, titleH, this); + #endif + owner->updateSize(); + } + + void userTriedToCloseWindow() {} + + #if JUCE_MAC && JucePlugin_EditorRequiresKeyboardFocus + bool keyPressed (const KeyPress& kp) + { + owner->updateSize(); + forwardCurrentKeyEventToHostWindow(); + return true; + } + #endif + + private: + //============================================================================== + void* const hostWindow; + void* nsWindow; + JuceCustomUIView* const owner; + int titleW, titleH; + + Component* getEditor() const { return getChildComponent (0); } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EditorCompWrapper) + }; + }; + + JuceCustomUIView* getView() const + { + return dynamic_cast <JuceCustomUIView*> (fOurPlugInView); + } + + void GetViewRect (Rect* size) + { + if (JuceCustomUIView* const v = getView()) + v->updateSize(); + + CEffectProcessRTAS::GetViewRect (size); + } + + CPlugInView* CreateCPlugInView() + { + return new JuceCustomUIView (juceFilter, this); + } + + void SetViewPort (GrafPtr port) + { + CEffectProcessRTAS::SetViewPort (port); + + if (JuceCustomUIView* const v = getView()) + v->attachToWindow (port); + } + + //============================================================================== +protected: + ComponentResult GetDelaySamplesLong (long* aNumSamples) + { + if (aNumSamples != nullptr) + *aNumSamples = juceFilter != nullptr ? juceFilter->getLatencySamples() : 0; + + return noErr; + } + + //============================================================================== + void EffectInit() + { + SFicPlugInStemFormats stems; + GetProcessType()->GetStemFormats (&stems); + + juceFilter->setPlayConfigDetails (fNumInputs, fNumOutputs, + juceFilter->getSampleRate(), juceFilter->getBlockSize()); + + AddControl (new CPluginControl_OnOff ('bypa', "Master Bypass\nMastrByp\nMByp\nByp", false, true)); + DefineMasterBypassControlIndex (bypassControlIndex); + + for (int i = 0; i < juceFilter->getNumParameters(); ++i) + AddControl (new JucePluginControl (juceFilter, i)); + + // we need to do this midi log-in to get timecode, regardless of whether + // the plugin actually uses midi... + if (MIDILogIn() == noErr) + { + #if JucePlugin_WantsMidiInput + if (CEffectType* const type = dynamic_cast <CEffectType*> (this->GetProcessType())) + { + char nodeName [64]; + type->GetProcessTypeName (63, nodeName); + p2cstrcpy (nodeName, reinterpret_cast <unsigned char*> (nodeName)); + + midiBufferNode = new CEffectMIDIOtherBufferedNode (&mMIDIWorld, + 8192, + eLocalNode, + nodeName, + midiBuffer); + + midiBufferNode->Initialize (0xffff, true); + } + #endif + } + + midiTransport = new CEffectMIDITransport (&mMIDIWorld); + + juceFilter->setPlayHead (this); + juceFilter->addListener (this); + + midiEvents.ensureSize (2048); + } + + void handleAsyncUpdate() + { + if (! prepared) + { + sampleRate = gProcessGroup->GetSampleRate(); + jassert (sampleRate > 0); + + channels.calloc (jmax (juceFilter->getNumInputChannels(), + juceFilter->getNumOutputChannels())); + + juceFilter->setPlayConfigDetails (fNumInputs, fNumOutputs, + sampleRate, mRTGlobals->mHWBufferSizeInSamples); + + juceFilter->prepareToPlay (sampleRate, mRTGlobals->mHWBufferSizeInSamples); + + prepared = true; + } + } + + void RenderAudio (float** inputs, float** outputs, long numSamples) + { + if (! prepared) + { + asyncUpdater->triggerAsyncUpdate(); + bypassBuffers (inputs, outputs, numSamples); + return; + } + + #if JucePlugin_WantsMidiInput + midiEvents.clear(); + + const Cmn_UInt32 bufferSize = mRTGlobals->mHWBufferSizeInSamples; + + if (midiBufferNode != nullptr) + { + if (midiBufferNode->GetAdvanceScheduleTime() != bufferSize) + midiBufferNode->SetAdvanceScheduleTime (bufferSize); + + if (midiBufferNode->FillMIDIBuffer (mRTGlobals->mRunningTime, numSamples) == noErr) + { + jassert (midiBufferNode->GetBufferPtr() != nullptr); + const int numMidiEvents = midiBufferNode->GetBufferSize(); + + for (int i = 0; i < numMidiEvents; ++i) + { + const DirectMidiPacket& m = midiBuffer[i]; + + jassert ((int) m.mTimestamp < numSamples); + + midiEvents.addEvent (m.mData, m.mLength, + jlimit (0, (int) numSamples - 1, (int) m.mTimestamp)); + } + } + } + #endif + + #if JUCE_DEBUG || JUCE_LOG_ASSERTIONS + const int numMidiEventsComingIn = midiEvents.getNumEvents(); + (void) numMidiEventsComingIn; + #endif + + { + const ScopedLock sl (juceFilter->getCallbackLock()); + + const int numIn = juceFilter->getNumInputChannels(); + const int numOut = juceFilter->getNumOutputChannels(); + const int totalChans = jmax (numIn, numOut); + + if (juceFilter->isSuspended()) + { + for (int i = 0; i < numOut; ++i) + FloatVectorOperations::clear (outputs [i], numSamples); + } + else + { + { + int i; + for (i = 0; i < numOut; ++i) + { + channels[i] = outputs [i]; + + if (i < numIn && inputs != outputs) + FloatVectorOperations::copy (outputs [i], inputs[i], numSamples); + } + + for (; i < numIn; ++i) + channels [i] = inputs [i]; + } + + AudioSampleBuffer chans (channels, totalChans, numSamples); + + if (mBypassed) + juceFilter->processBlockBypassed (chans, midiEvents); + else + juceFilter->processBlock (chans, midiEvents); + } + } + + if (! midiEvents.isEmpty()) + { + #if JucePlugin_ProducesMidiOutput + const juce::uint8* midiEventData; + int midiEventSize, midiEventPosition; + MidiBuffer::Iterator i (midiEvents); + + while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition)) + { + //jassert (midiEventPosition >= 0 && midiEventPosition < (int) numSamples); + } + #elif JUCE_DEBUG || JUCE_LOG_ASSERTIONS + // if your plugin creates midi messages, you'll need to set + // the JucePlugin_ProducesMidiOutput macro to 1 in your + // JucePluginCharacteristics.h file + jassert (midiEvents.getNumEvents() <= numMidiEventsComingIn); + #endif + + midiEvents.clear(); + } + } + + //============================================================================== + ComponentResult GetChunkSize (OSType chunkID, long* size) + { + if (chunkID == juceChunkType) + { + tempFilterData.setSize (0); + juceFilter->getStateInformation (tempFilterData); + + *size = sizeof (SFicPlugInChunkHeader) + tempFilterData.getSize(); + return noErr; + } + + return CEffectProcessMIDI::GetChunkSize (chunkID, size); + } + + ComponentResult GetChunk (OSType chunkID, SFicPlugInChunk* chunk) + { + if (chunkID == juceChunkType) + { + if (tempFilterData.getSize() == 0) + juceFilter->getStateInformation (tempFilterData); + + chunk->fSize = sizeof (SFicPlugInChunkHeader) + tempFilterData.getSize(); + tempFilterData.copyTo ((void*) chunk->fData, 0, tempFilterData.getSize()); + + tempFilterData.setSize (0); + + return noErr; + } + + return CEffectProcessMIDI::GetChunk (chunkID, chunk); + } + + ComponentResult SetChunk (OSType chunkID, SFicPlugInChunk* chunk) + { + if (chunkID == juceChunkType) + { + tempFilterData.setSize (0); + + if (chunk->fSize - sizeof (SFicPlugInChunkHeader) > 0) + { + juceFilter->setStateInformation ((void*) chunk->fData, + chunk->fSize - sizeof (SFicPlugInChunkHeader)); + } + + return noErr; + } + + return CEffectProcessMIDI::SetChunk (chunkID, chunk); + } + + //============================================================================== + ComponentResult UpdateControlValue (long controlIndex, long value) + { + if (controlIndex != bypassControlIndex) + juceFilter->setParameter (controlIndex - 2, longToFloat (value)); + else + mBypassed = (value > 0); + + return CProcess::UpdateControlValue (controlIndex, value); + } + + //============================================================================== + bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info) + { + // this method can only be called while the plugin is running + jassert (prepared); + + Cmn_Float64 bpm = 120.0; + Cmn_Int32 num = 4, denom = 4; + Cmn_Int64 ticks = 0; + Cmn_Bool isPlaying = false; + + if (midiTransport != nullptr) + { + midiTransport->GetCurrentTempo (&bpm); + midiTransport->IsTransportPlaying (&isPlaying); + midiTransport->GetCurrentMeter (&num, &denom); + + // (The following is a work-around because GetCurrentTickPosition() doesn't work correctly). + Cmn_Int64 sampleLocation; + + if (isPlaying) + midiTransport->GetCurrentRTASSampleLocation (&sampleLocation); + else + midiTransport->GetCurrentTDMSampleLocation (&sampleLocation); + + midiTransport->GetCustomTickPosition (&ticks, sampleLocation); + + info.timeInSamples = (int64) sampleLocation; + info.timeInSeconds = sampleLocation / sampleRate; + } + else + { + info.timeInSamples = 0; + info.timeInSeconds = 0; + } + + info.bpm = bpm; + info.timeSigNumerator = num; + info.timeSigDenominator = denom; + info.isPlaying = isPlaying; + info.isRecording = false; + info.ppqPosition = ticks / 960000.0; + info.ppqPositionOfLastBarStart = 0; //xxx no idea how to get this correctly.. + info.isLooping = false; + info.ppqLoopStart = 0; + info.ppqLoopEnd = 0; + + double framesPerSec = 24.0; + + switch (fTimeCodeInfo.mFrameRate) + { + case ficFrameRate_24Frame: info.frameRate = AudioPlayHead::fps24; break; + case ficFrameRate_25Frame: info.frameRate = AudioPlayHead::fps25; framesPerSec = 25.0; break; + case ficFrameRate_2997NonDrop: info.frameRate = AudioPlayHead::fps2997; framesPerSec = 29.97002997; break; + case ficFrameRate_2997DropFrame: info.frameRate = AudioPlayHead::fps2997drop; framesPerSec = 29.97002997; break; + case ficFrameRate_30NonDrop: info.frameRate = AudioPlayHead::fps30; framesPerSec = 30.0; break; + case ficFrameRate_30DropFrame: info.frameRate = AudioPlayHead::fps30drop; framesPerSec = 30.0; break; + case ficFrameRate_23976: info.frameRate = AudioPlayHead::fps24; framesPerSec = 23.976; break; + default: info.frameRate = AudioPlayHead::fpsUnknown; break; + } + + info.editOriginTime = fTimeCodeInfo.mFrameOffset / framesPerSec; + + return true; + } + + void audioProcessorParameterChanged (AudioProcessor*, int index, float newValue) + { + SetControlValue (index + 2, floatToLong (newValue)); + } + + void audioProcessorParameterChangeGestureBegin (AudioProcessor*, int index) + { + TouchControl (index + 2); + } + + void audioProcessorParameterChangeGestureEnd (AudioProcessor*, int index) + { + ReleaseControl (index + 2); + } + + void audioProcessorChanged (AudioProcessor*) + { + // xxx is there an RTAS equivalent? + } + + void touchAllParameters() + { + for (int i = 0; i < juceFilter->getNumParameters(); ++i) + { + audioProcessorParameterChangeGestureBegin (0, i); + audioProcessorParameterChanged (0, i, juceFilter->getParameter (i)); + audioProcessorParameterChangeGestureEnd (0, i); + } + } + +public: + // Need to use an intermediate class here rather than inheriting from AsyncUpdater, so that it can + // be deleted before shutting down juce in our destructor. + class InternalAsyncUpdater : public AsyncUpdater + { + public: + InternalAsyncUpdater (JucePlugInProcess& owner_) : owner (owner_) {} + void handleAsyncUpdate() { owner.handleAsyncUpdate(); } + + private: + JucePlugInProcess& owner; + }; + + //============================================================================== +private: + ScopedPointer<AudioProcessor> juceFilter; + MidiBuffer midiEvents; + ScopedPointer<CEffectMIDIOtherBufferedNode> midiBufferNode; + ScopedPointer<CEffectMIDITransport> midiTransport; + DirectMidiPacket midiBuffer [midiBufferSize]; + + ScopedPointer<InternalAsyncUpdater> asyncUpdater; + + juce::MemoryBlock tempFilterData; + HeapBlock <float*> channels; + bool prepared; + double sampleRate; + + static float longToFloat (const long n) noexcept + { + return (float) ((((double) n) + (double) 0x80000000) / (double) 0xffffffff); + } + + static long floatToLong (const float n) noexcept + { + return roundToInt (jlimit (-(double) 0x80000000, (double) 0x7fffffff, + n * (double) 0xffffffff - (double) 0x80000000)); + } + + void bypassBuffers (float** const inputs, float** const outputs, const long numSamples) const + { + for (int i = fNumOutputs; --i >= 0;) + { + if (i < fNumInputs) + FloatVectorOperations::copy (outputs[i], inputs[i], numSamples); + else + FloatVectorOperations::clear (outputs[i], numSamples); + } + } + + //============================================================================== + class JucePluginControl : public CPluginControl + { + public: + //============================================================================== + JucePluginControl (AudioProcessor* const juceFilter_, const int index_) + : juceFilter (juceFilter_), + index (index_) + { + } + + //============================================================================== + OSType GetID() const { return index + 1; } + long GetDefaultValue() const { return floatToLong (0); } + void SetDefaultValue (long) {} + long GetNumSteps() const { return 0xffffffff; } + + long ConvertStringToValue (const char* valueString) const + { + return floatToLong (String (valueString).getFloatValue()); + } + + Cmn_Bool IsKeyValid (long key) const { return true; } + + void GetNameOfLength (char* name, int maxLength, OSType inControllerType) const + { + // Pro-tools expects all your parameters to have valid names! + jassert (juceFilter->getParameterName (index).isNotEmpty()); + + juceFilter->getParameterName (index).copyToUTF8 (name, (size_t) maxLength); + } + + long GetPriority() const { return kFicCooperativeTaskPriority; } + + long GetOrientation() const + { + return kDAE_LeftMinRightMax | kDAE_BottomMinTopMax + | kDAE_RotarySingleDotMode | kDAE_RotaryLeftMinRightMax; + } + + long GetControlType() const { return kDAE_ContinuousValues; } + + void GetValueString (char* valueString, int maxLength, long value) const + { + juceFilter->getParameterText (index).copyToUTF8 (valueString, (size_t) maxLength); + } + + Cmn_Bool IsAutomatable() const + { + return juceFilter->isParameterAutomatable (index); + } + + private: + //============================================================================== + AudioProcessor* const juceFilter; + const int index; + + JUCE_DECLARE_NON_COPYABLE (JucePluginControl) + }; +}; + +//============================================================================== +class JucePlugInGroup : public CEffectGroupMIDI +{ +public: + //============================================================================== + JucePlugInGroup() + { + DefineManufacturerNamesAndID (JucePlugin_Manufacturer, JucePlugin_RTASManufacturerCode); + DefinePlugInNamesAndVersion (createRTASName().toUTF8(), JucePlugin_VersionCode); + + #if JUCE_RTAS_PLUGINGESTALT_IS_CACHEABLE + AddGestalt (pluginGestalt_IsCacheable); + #endif + } + + ~JucePlugInGroup() + { + shutdownJuce_GUI(); + } + + //============================================================================== + void CreateEffectTypes() + { + const short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations }; + const int numConfigs = numElementsInArray (channelConfigs); + + // You need to actually add some configurations to the JucePlugin_PreferredChannelConfigurations + // value in your JucePluginCharacteristics.h file.. + jassert (numConfigs > 0); + + for (int i = 0; i < numConfigs; ++i) + { + CEffectType* const type + = new CEffectTypeRTAS ('jcaa' + i, + JucePlugin_RTASProductId, + JucePlugin_RTASCategory); + + type->DefineTypeNames (createRTASName().toRawUTF8()); + type->DefineSampleRateSupport (eSupports48kAnd96kAnd192k); + + type->DefineStemFormats (getFormatForChans (channelConfigs [i][0] != 0 ? channelConfigs [i][0] : channelConfigs [i][1]), + getFormatForChans (channelConfigs [i][1] != 0 ? channelConfigs [i][1] : channelConfigs [i][0])); + + #if ! JucePlugin_RTASDisableBypass + type->AddGestalt (pluginGestalt_CanBypass); + #endif + + #if JucePlugin_RTASDisableMultiMono + type->AddGestalt (pluginGestalt_DoesntSupportMultiMono); + #endif + + type->AddGestalt (pluginGestalt_SupportsVariableQuanta); + type->AttachEffectProcessCreator (createNewProcess); + + AddEffectType (type); + } + } + + void Initialize() + { + CEffectGroupMIDI::Initialize(); + } + + //============================================================================== +private: + static CEffectProcess* createNewProcess() + { + #if JUCE_WINDOWS + Process::setCurrentModuleInstanceHandle (gThisModule); + #endif + + initialiseJuce_GUI(); + + return new JucePlugInProcess(); + } + + static String createRTASName() + { + return String (JucePlugin_Name) + "\n" + + String (JucePlugin_Desc); + } + + static EPlugIn_StemFormat getFormatForChans (const int numChans) noexcept + { + switch (numChans) + { + case 0: return ePlugIn_StemFormat_Generic; + case 1: return ePlugIn_StemFormat_Mono; + case 2: return ePlugIn_StemFormat_Stereo; + case 3: return ePlugIn_StemFormat_LCR; + case 4: return ePlugIn_StemFormat_Quad; + case 5: return ePlugIn_StemFormat_5dot0; + case 6: return ePlugIn_StemFormat_5dot1; + case 7: return ePlugIn_StemFormat_6dot1; + + #if PT_VERS_MAJOR >= 9 + case 8: return ePlugIn_StemFormat_7dot1DTS; + #else + case 8: return ePlugIn_StemFormat_7dot1; + #endif + + default: jassertfalse; break; // hmm - not a valid number of chans for RTAS.. + } + + return ePlugIn_StemFormat_Generic; + } +}; + +void initialiseMacRTAS(); + +CProcessGroupInterface* CProcessGroup::CreateProcessGroup() +{ + #if JUCE_MAC + initialiseMacRTAS(); + #endif + + return new JucePlugInGroup(); +} + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/JuceLibraryCode/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h new file mode 100644 index 000000000..e1dfad550 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -0,0 +1,304 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_STANDALONEFILTERWINDOW_JUCEHEADER__ +#define __JUCE_STANDALONEFILTERWINDOW_JUCEHEADER__ + +extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); + +//============================================================================== +/** + A class that can be used to run a simple standalone application containing your filter. + + Just create one of these objects in your JUCEApplication::initialise() method, and + let it do its work. It will create your filter object using the same createFilter() function + that the other plugin wrappers use. +*/ +class StandaloneFilterWindow : public DocumentWindow, + public ButtonListener // (can't use Button::Listener due to idiotic VC2005 bug) +{ +public: + //============================================================================== + /** Creates a window with a given title and colour. + The settings object can be a PropertySet that the class should use to + store its settings - the object that is passed-in will be owned by this + class and deleted automatically when no longer needed. (It can also be null) + */ + StandaloneFilterWindow (const String& title, + const Colour& backgroundColour, + PropertySet* settingsToUse) + : DocumentWindow (title, backgroundColour, DocumentWindow::minimiseButton | DocumentWindow::closeButton), + settings (settingsToUse), + optionsButton ("options") + { + setTitleBarButtonsRequired (DocumentWindow::minimiseButton | DocumentWindow::closeButton, false); + + Component::addAndMakeVisible (&optionsButton); + optionsButton.addListener (this); + optionsButton.setTriggeredOnMouseDown (true); + + createFilter(); + + if (filter == nullptr) + { + jassertfalse // Your filter didn't create correctly! In a standalone app that's not too great. + JUCEApplication::quit(); + } + + filter->setPlayConfigDetails (JucePlugin_MaxNumInputChannels, + JucePlugin_MaxNumOutputChannels, + 44100, 512); + + deviceManager = new AudioDeviceManager(); + deviceManager->addAudioCallback (&player); + deviceManager->addMidiInputCallback (String::empty, &player); + + player.setProcessor (filter); + + ScopedPointer<XmlElement> savedState; + + if (settings != nullptr) + savedState = settings->getXmlValue ("audioSetup"); + + deviceManager->initialise (filter->getNumInputChannels(), + filter->getNumOutputChannels(), + savedState, + true); + + if (settings != nullptr) + { + MemoryBlock data; + + if (data.fromBase64Encoding (settings->getValue ("filterState")) + && data.getSize() > 0) + { + filter->setStateInformation (data.getData(), data.getSize()); + } + } + + setContentOwned (filter->createEditorIfNeeded(), true); + + if (settings != nullptr) + { + const int x = settings->getIntValue ("windowX", -100); + const int y = settings->getIntValue ("windowY", -100); + + if (x != -100 && y != -100) + setBoundsConstrained (Rectangle<int> (x, y, getWidth(), getHeight())); + else + centreWithSize (getWidth(), getHeight()); + } + else + { + centreWithSize (getWidth(), getHeight()); + } + } + + ~StandaloneFilterWindow() + { + if (settings != nullptr) + { + settings->setValue ("windowX", getX()); + settings->setValue ("windowY", getY()); + + if (deviceManager != nullptr) + { + ScopedPointer<XmlElement> xml (deviceManager->createStateXml()); + settings->setValue ("audioSetup", xml); + } + } + + deviceManager->removeMidiInputCallback (String::empty, &player); + deviceManager->removeAudioCallback (&player); + deviceManager = nullptr; + + if (settings != nullptr && filter != nullptr) + { + MemoryBlock data; + filter->getStateInformation (data); + + settings->setValue ("filterState", data.toBase64Encoding()); + } + + deleteFilter(); + } + + //============================================================================== + AudioProcessor* getAudioProcessor() const noexcept { return filter; } + AudioDeviceManager* getDeviceManager() const noexcept { return deviceManager; } + + void createFilter() + { + AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::wrapperType_Standalone); + filter = createPluginFilter(); + AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::wrapperType_Undefined); + } + + /** Deletes and re-creates the filter and its UI. */ + void resetFilter() + { + deleteFilter(); + createFilter(); + + if (filter != nullptr) + { + if (deviceManager != nullptr) + player.setProcessor (filter); + + setContentOwned (filter->createEditorIfNeeded(), true); + } + + if (settings != nullptr) + settings->removeValue ("filterState"); + } + + /** Pops up a dialog letting the user save the filter's state to a file. */ + void saveState() + { + FileChooser fc (TRANS("Save current state"), + settings != nullptr ? File (settings->getValue ("lastStateFile")) + : File::nonexistent); + + if (fc.browseForFileToSave (true)) + { + MemoryBlock data; + filter->getStateInformation (data); + + if (! fc.getResult().replaceWithData (data.getData(), data.getSize())) + { + AlertWindow::showMessageBox (AlertWindow::WarningIcon, + TRANS("Error whilst saving"), + TRANS("Couldn't write to the specified file!")); + } + } + } + + /** Pops up a dialog letting the user re-load the filter's state from a file. */ + void loadState() + { + FileChooser fc (TRANS("Load a saved state"), + settings != nullptr ? File (settings->getValue ("lastStateFile")) + : File::nonexistent); + + if (fc.browseForFileToOpen()) + { + MemoryBlock data; + + if (fc.getResult().loadFileAsData (data)) + { + filter->setStateInformation (data.getData(), data.getSize()); + } + else + { + AlertWindow::showMessageBox (AlertWindow::WarningIcon, + TRANS("Error whilst loading"), + TRANS("Couldn't read from the specified file!")); + } + } + } + + /** Shows the audio properties dialog box modally. */ + virtual void showAudioSettingsDialog() + { + DialogWindow::LaunchOptions o; + o.content.setOwned (new AudioDeviceSelectorComponent (*deviceManager, + filter->getNumInputChannels(), + filter->getNumInputChannels(), + filter->getNumOutputChannels(), + filter->getNumOutputChannels(), + true, false, true, false)); + o.content->setSize (500, 450); + + o.dialogTitle = TRANS("Audio Settings"); + o.dialogBackgroundColour = Colours::lightgrey; + o.escapeKeyTriggersCloseButton = true; + o.useNativeTitleBar = true; + o.resizable = false; + + o.launchAsync(); + } + + //============================================================================== + /** @internal */ + void closeButtonPressed() + { + JUCEApplication::quit(); + } + + /** @internal */ + void buttonClicked (Button*) + { + if (filter != nullptr) + { + PopupMenu m; + m.addItem (1, TRANS("Audio Settings...")); + m.addSeparator(); + m.addItem (2, TRANS("Save current state...")); + m.addItem (3, TRANS("Load a saved state...")); + m.addSeparator(); + m.addItem (4, TRANS("Reset to default state")); + + switch (m.showAt (&optionsButton)) + { + case 1: showAudioSettingsDialog(); break; + case 2: saveState(); break; + case 3: loadState(); break; + case 4: resetFilter(); break; + default: break; + } + } + } + + /** @internal */ + void resized() + { + DocumentWindow::resized(); + optionsButton.setBounds (8, 6, 60, getTitleBarHeight() - 8); + } + +private: + //============================================================================== + ScopedPointer<PropertySet> settings; + ScopedPointer<AudioProcessor> filter; + ScopedPointer<AudioDeviceManager> deviceManager; + AudioProcessorPlayer player; + TextButton optionsButton; + + void deleteFilter() + { + player.setProcessor (nullptr); + + if (filter != nullptr && getContentComponent() != nullptr) + { + filter->editorBeingDeleted (dynamic_cast <AudioProcessorEditor*> (getContentComponent())); + clearContentComponent(); + } + + filter = nullptr; + } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StandaloneFilterWindow) +}; + +#endif // __JUCE_STANDALONEFILTERWINDOW_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/JuceLibraryCode/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp new file mode 100644 index 000000000..9625fd08d --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -0,0 +1,1616 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +#if JucePlugin_Build_VST + +#ifdef _MSC_VER + #pragma warning (disable : 4996 4100) +#endif + +#ifdef _WIN32 + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x500 + #undef STRICT + #define STRICT 1 + #include <windows.h> + + #ifdef __MINGW32__ + struct MOUSEHOOKSTRUCTEX : public MOUSEHOOKSTRUCT + { + DWORD mouseData; + }; + #endif +#elif defined (LINUX) + #include <X11/Xlib.h> + #include <X11/Xutil.h> + #include <X11/Xatom.h> + #undef KeyPress +#else + #include <Carbon/Carbon.h> +#endif + +#ifdef PRAGMA_ALIGN_SUPPORTED + #undef PRAGMA_ALIGN_SUPPORTED + #define PRAGMA_ALIGN_SUPPORTED 1 +#endif + +//============================================================================== +/* These files come with the Steinberg VST SDK - to get them, you'll need to + visit the Steinberg website and jump through some hoops to sign up as a + VST developer. + + Then, you'll need to make sure your include path contains your "vstsdk2.4" directory. +*/ +#ifndef _MSC_VER + #define __cdecl +#endif + +#ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wconversion" + #pragma clang diagnostic ignored "-Wshadow" +#endif + +// VSTSDK V2.4 includes.. +#include <public.sdk/source/vst2.x/audioeffectx.h> +#include <public.sdk/source/vst2.x/aeffeditor.h> +#include <public.sdk/source/vst2.x/audioeffectx.cpp> +#include <public.sdk/source/vst2.x/audioeffect.cpp> + +#if ! VST_2_4_EXTENSIONS + #error "It looks like you're trying to include an out-of-date VSTSDK version - make sure you have at least version 2.4" +#endif + +#ifdef __clang__ + #pragma clang diagnostic pop +#endif + +//============================================================================== +#ifdef _MSC_VER + #pragma pack (push, 8) +#endif + +#include "../utility/juce_IncludeModuleHeaders.h" +#include "../utility/juce_FakeMouseMoveGenerator.h" +#include "../utility/juce_PluginHostType.h" + +#ifdef _MSC_VER + #pragma pack (pop) +#endif + +#undef MemoryBlock + +class JuceVSTWrapper; +static bool recursionCheck = false; +static juce::uint32 lastMasterIdleCall = 0; + +namespace juce +{ + #if JUCE_MAC + extern void initialiseMac(); + extern void* attachComponentToWindowRef (Component* component, void* windowRef); + extern void detachComponentFromWindowRef (Component* component, void* nsWindow); + extern void setNativeHostWindowSize (void* nsWindow, Component* editorComp, int newWidth, int newHeight, const PluginHostType& host); + extern void checkWindowVisibility (void* nsWindow, Component* component); + extern bool forwardCurrentKeyEventToHost (Component* component); + #endif + + #if JUCE_LINUX + extern Display* display; + #endif +} + + +//============================================================================== +#if JUCE_WINDOWS + +namespace +{ + HWND findMDIParentOf (HWND w) + { + const int frameThickness = GetSystemMetrics (SM_CYFIXEDFRAME); + + while (w != 0) + { + HWND parent = GetParent (w); + + if (parent == 0) + break; + + TCHAR windowType[32] = { 0 }; + GetClassName (parent, windowType, 31); + + if (String (windowType).equalsIgnoreCase ("MDIClient")) + return parent; + + RECT windowPos, parentPos; + GetWindowRect (w, &windowPos); + GetWindowRect (parent, &parentPos); + + const int dw = (parentPos.right - parentPos.left) - (windowPos.right - windowPos.left); + const int dh = (parentPos.bottom - parentPos.top) - (windowPos.bottom - windowPos.top); + + if (dw > 100 || dh > 100) + break; + + w = parent; + + if (dw == 2 * frameThickness) + break; + } + + return w; + } + + //============================================================================== + static HHOOK mouseWheelHook = 0; + static int mouseHookUsers = 0; + + LRESULT CALLBACK mouseWheelHookCallback (int nCode, WPARAM wParam, LPARAM lParam) + { + if (nCode >= 0 && wParam == WM_MOUSEWHEEL) + { + const MOUSEHOOKSTRUCTEX& hs = *(MOUSEHOOKSTRUCTEX*) lParam; + + if (Component* const comp = Desktop::getInstance().findComponentAt (Point<int> (hs.pt.x, hs.pt.y))) + if (comp->getWindowHandle() != 0) + return PostMessage ((HWND) comp->getWindowHandle(), WM_MOUSEWHEEL, + hs.mouseData & 0xffff0000, (hs.pt.x & 0xffff) | (hs.pt.y << 16)); + } + + return CallNextHookEx (mouseWheelHook, nCode, wParam, lParam); + } + + void registerMouseWheelHook() + { + if (mouseHookUsers++ == 0) + mouseWheelHook = SetWindowsHookEx (WH_MOUSE, mouseWheelHookCallback, + (HINSTANCE) Process::getCurrentModuleInstanceHandle(), + GetCurrentThreadId()); + } + + void unregisterMouseWheelHook() + { + if (--mouseHookUsers == 0 && mouseWheelHook != 0) + { + UnhookWindowsHookEx (mouseWheelHook); + mouseWheelHook = 0; + } + } + + //============================================================================== + static HHOOK keyboardHook = 0; + static int keyboardHookUsers = 0; + + LRESULT CALLBACK keyboardHookCallback (int nCode, WPARAM wParam, LPARAM lParam) + { + if (nCode == 0) + { + const MSG& msg = *(const MSG*) lParam; + + if (msg.message == WM_CHAR) + { + Desktop& desktop = Desktop::getInstance(); + HWND focused = GetFocus(); + + for (int i = desktop.getNumComponents(); --i >= 0;) + { + if ((HWND) desktop.getComponent (i)->getWindowHandle() == focused) + { + SendMessage (focused, msg.message, msg.wParam, msg.lParam); + break; + } + } + } + } + + return CallNextHookEx (mouseWheelHook, nCode, wParam, lParam); + } + + void registerKeyboardHook() + { + if (keyboardHookUsers++ == 0) + keyboardHook = SetWindowsHookEx (WH_GETMESSAGE, keyboardHookCallback, + (HINSTANCE) Process::getCurrentModuleInstanceHandle(), + GetCurrentThreadId()); + } + + void unregisterKeyboardHook() + { + if (--keyboardHookUsers == 0 && keyboardHook != 0) + { + UnhookWindowsHookEx (keyboardHook); + keyboardHook = 0; + } + } + + #if JUCE_WINDOWS + static bool messageThreadIsDefinitelyCorrect = false; + #endif +} + +//============================================================================== +#elif JUCE_LINUX + +class SharedMessageThread : public Thread +{ +public: + SharedMessageThread() + : Thread ("VstMessageThread"), + initialised (false) + { + startThread (7); + + while (! initialised) + sleep (1); + } + + ~SharedMessageThread() + { + signalThreadShouldExit(); + JUCEApplication::quit(); + waitForThreadToExit (5000); + clearSingletonInstance(); + } + + void run() + { + initialiseJuce_GUI(); + initialised = true; + + MessageManager::getInstance()->setCurrentThreadAsMessageThread(); + + while ((! threadShouldExit()) && MessageManager::getInstance()->runDispatchLoopUntil (250)) + {} + } + + juce_DeclareSingleton (SharedMessageThread, false); + +private: + bool initialised; +}; + +juce_ImplementSingleton (SharedMessageThread) + +#endif + +static Array<void*> activePlugins; + +//============================================================================== +/** + This is an AudioEffectX object that holds and wraps our AudioProcessor... +*/ +class JuceVSTWrapper : public AudioEffectX, + private Timer, + public AudioProcessorListener, + public AudioPlayHead +{ +public: + //============================================================================== + JuceVSTWrapper (audioMasterCallback audioMaster, AudioProcessor* const af) + : AudioEffectX (audioMaster, af->getNumPrograms(), af->getNumParameters()), + filter (af), + chunkMemoryTime (0), + speakerIn (kSpeakerArrEmpty), + speakerOut (kSpeakerArrEmpty), + numInChans (JucePlugin_MaxNumInputChannels), + numOutChans (JucePlugin_MaxNumOutputChannels), + isProcessing (false), + isBypassed (false), + hasShutdown (false), + firstProcessCallback (true), + shouldDeleteEditor (false), + hostWindow (0) + { + filter->setPlayConfigDetails (numInChans, numOutChans, 0, 0); + filter->setPlayHead (this); + filter->addListener (this); + + cEffect.flags |= effFlagsHasEditor; + cEffect.version = convertHexVersionToDecimal (JucePlugin_VersionCode); + + setUniqueID ((int) (JucePlugin_VSTUniqueID)); + + setNumInputs (numInChans); + setNumOutputs (numOutChans); + + canProcessReplacing (true); + + isSynth ((JucePlugin_IsSynth) != 0); + noTail (filter->getTailLengthSeconds() <= 0); + setInitialDelay (filter->getLatencySamples()); + programsAreChunks (true); + + activePlugins.add (this); + } + + ~JuceVSTWrapper() + { + JUCE_AUTORELEASEPOOL + { + { + #if JUCE_LINUX + MessageManagerLock mmLock; + #endif + stopTimer(); + deleteEditor (false); + + hasShutdown = true; + + delete filter; + filter = nullptr; + + jassert (editorComp == 0); + + channels.free(); + deleteTempChannels(); + + jassert (activePlugins.contains (this)); + activePlugins.removeFirstMatchingValue (this); + } + + if (activePlugins.size() == 0) + { + #if JUCE_LINUX + SharedMessageThread::deleteInstance(); + #endif + shutdownJuce_GUI(); + + #if JUCE_WINDOWS + messageThreadIsDefinitelyCorrect = false; + #endif + } + } + } + + void open() + { + // Note: most hosts call this on the UI thread, but wavelab doesn't, so be careful in here. + if (filter->hasEditor()) + cEffect.flags |= effFlagsHasEditor; + else + cEffect.flags &= ~effFlagsHasEditor; + } + + void close() + { + // Note: most hosts call this on the UI thread, but wavelab doesn't, so be careful in here. + stopTimer(); + + if (MessageManager::getInstance()->isThisTheMessageThread()) + deleteEditor (false); + } + + //============================================================================== + bool getEffectName (char* name) + { + String (JucePlugin_Name).copyToUTF8 (name, 64); + return true; + } + + bool getVendorString (char* text) + { + String (JucePlugin_Manufacturer).copyToUTF8 (text, 64); + return true; + } + + bool getProductString (char* text) { return getEffectName (text); } + VstInt32 getVendorVersion() { return convertHexVersionToDecimal (JucePlugin_VersionCode); } + VstPlugCategory getPlugCategory() { return JucePlugin_VSTCategory; } + bool keysRequired() { return (JucePlugin_EditorRequiresKeyboardFocus) != 0; } + + VstInt32 canDo (char* text) + { + VstInt32 result = 0; + + if (strcmp (text, "receiveVstEvents") == 0 + || strcmp (text, "receiveVstMidiEvent") == 0 + || strcmp (text, "receiveVstMidiEvents") == 0) + { + #if JucePlugin_WantsMidiInput + result = 1; + #else + result = -1; + #endif + } + else if (strcmp (text, "sendVstEvents") == 0 + || strcmp (text, "sendVstMidiEvent") == 0 + || strcmp (text, "sendVstMidiEvents") == 0) + { + #if JucePlugin_ProducesMidiOutput + result = 1; + #else + result = -1; + #endif + } + else if (strcmp (text, "receiveVstTimeInfo") == 0 + || strcmp (text, "conformsToWindowRules") == 0 + || strcmp (text, "bypass") == 0) + { + result = 1; + } + else if (strcmp (text, "openCloseAnyThread") == 0) + { + // This tells Wavelab to use the UI thread to invoke open/close, + // like all other hosts do. + result = -1; + } + + return result; + } + + bool getInputProperties (VstInt32 index, VstPinProperties* properties) + { + if (filter == nullptr || index >= JucePlugin_MaxNumInputChannels) + return false; + + setPinProperties (*properties, filter->getInputChannelName ((int) index), + speakerIn, filter->isInputChannelStereoPair ((int) index)); + return true; + } + + bool getOutputProperties (VstInt32 index, VstPinProperties* properties) + { + if (filter == nullptr || index >= JucePlugin_MaxNumOutputChannels) + return false; + + setPinProperties (*properties, filter->getOutputChannelName ((int) index), + speakerOut, filter->isOutputChannelStereoPair ((int) index)); + return true; + } + + static void setPinProperties (VstPinProperties& properties, const String& name, + VstSpeakerArrangementType type, const bool isPair) + { + name.copyToUTF8 (properties.label, (size_t) (kVstMaxLabelLen - 1)); + name.copyToUTF8 (properties.shortLabel, (size_t) (kVstMaxShortLabelLen - 1)); + + if (type != kSpeakerArrEmpty) + { + properties.flags = kVstPinUseSpeaker; + properties.arrangementType = type; + } + else + { + properties.flags = kVstPinIsActive; + properties.arrangementType = 0; + + if (isPair) + properties.flags |= kVstPinIsStereo; + } + } + + bool setBypass (bool b) + { + isBypassed = b; + return true; + } + + VstInt32 getGetTailSize() + { + if (filter != nullptr) + return (VstInt32) (filter->getTailLengthSeconds() * getSampleRate()); + + return 0; + } + + //============================================================================== + VstInt32 processEvents (VstEvents* events) + { + #if JucePlugin_WantsMidiInput + VSTMidiEventList::addEventsToMidiBuffer (events, midiEvents); + return 1; + #else + return 0; + #endif + } + + void process (float** inputs, float** outputs, VstInt32 numSamples) + { + const int numIn = numInChans; + const int numOut = numOutChans; + + AudioSampleBuffer temp (numIn, numSamples); + for (int i = numIn; --i >= 0;) + memcpy (temp.getSampleData (i), outputs[i], sizeof (float) * (size_t) numSamples); + + processReplacing (inputs, outputs, numSamples); + + AudioSampleBuffer dest (outputs, numOut, numSamples); + + for (int i = jmin (numIn, numOut); --i >= 0;) + dest.addFrom (i, 0, temp, i, 0, numSamples); + } + + void processReplacing (float** inputs, float** outputs, VstInt32 numSamples) + { + if (firstProcessCallback) + { + firstProcessCallback = false; + + // if this fails, the host hasn't called resume() before processing + jassert (isProcessing); + + // (tragically, some hosts actually need this, although it's stupid to have + // to do it here..) + if (! isProcessing) + resume(); + + filter->setNonRealtime (getCurrentProcessLevel() == 4 /* kVstProcessLevelOffline */); + + #if JUCE_WINDOWS + if (GetThreadPriority (GetCurrentThread()) <= THREAD_PRIORITY_NORMAL + && GetThreadPriority (GetCurrentThread()) >= THREAD_PRIORITY_LOWEST) + filter->setNonRealtime (true); + #endif + } + + #if JUCE_DEBUG && ! JucePlugin_ProducesMidiOutput + const int numMidiEventsComingIn = midiEvents.getNumEvents(); + #endif + + jassert (activePlugins.contains (this)); + + { + const ScopedLock sl (filter->getCallbackLock()); + + const int numIn = numInChans; + const int numOut = numOutChans; + + if (filter->isSuspended()) + { + for (int i = 0; i < numOut; ++i) + FloatVectorOperations::clear (outputs[i], numSamples); + } + else + { + int i; + for (i = 0; i < numOut; ++i) + { + float* chan = tempChannels.getUnchecked(i); + + if (chan == nullptr) + { + chan = outputs[i]; + + // if some output channels are disabled, some hosts supply the same buffer + // for multiple channels - this buggers up our method of copying the + // inputs over the outputs, so we need to create unique temp buffers in this case.. + for (int j = i; --j >= 0;) + { + if (outputs[j] == chan) + { + chan = new float [blockSize * 2]; + tempChannels.set (i, chan); + break; + } + } + } + + if (i < numIn && chan != inputs[i]) + memcpy (chan, inputs[i], sizeof (float) * (size_t) numSamples); + + channels[i] = chan; + } + + for (; i < numIn; ++i) + channels[i] = inputs[i]; + + { + AudioSampleBuffer chans (channels, jmax (numIn, numOut), numSamples); + + if (isBypassed) + filter->processBlockBypassed (chans, midiEvents); + else + filter->processBlock (chans, midiEvents); + } + + // copy back any temp channels that may have been used.. + for (i = 0; i < numOut; ++i) + if (const float* const chan = tempChannels.getUnchecked(i)) + memcpy (outputs[i], chan, sizeof (float) * (size_t) numSamples); + } + } + + if (! midiEvents.isEmpty()) + { + #if JucePlugin_ProducesMidiOutput + const int numEvents = midiEvents.getNumEvents(); + + outgoingEvents.ensureSize (numEvents); + outgoingEvents.clear(); + + const juce::uint8* midiEventData; + int midiEventSize, midiEventPosition; + MidiBuffer::Iterator i (midiEvents); + + while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition)) + { + jassert (midiEventPosition >= 0 && midiEventPosition < numSamples); + + outgoingEvents.addEvent (midiEventData, midiEventSize, midiEventPosition); + } + + sendVstEventsToHost (outgoingEvents.events); + #elif JUCE_DEBUG + /* This assertion is caused when you've added some events to the + midiMessages array in your processBlock() method, which usually means + that you're trying to send them somewhere. But in this case they're + getting thrown away. + + If your plugin does want to send midi messages, you'll need to set + the JucePlugin_ProducesMidiOutput macro to 1 in your + JucePluginCharacteristics.h file. + + If you don't want to produce any midi output, then you should clear the + midiMessages array at the end of your processBlock() method, to + indicate that you don't want any of the events to be passed through + to the output. + */ + jassert (midiEvents.getNumEvents() <= numMidiEventsComingIn); + #endif + + midiEvents.clear(); + } + } + + //============================================================================== + VstInt32 startProcess() { return 0; } + VstInt32 stopProcess() { return 0; } + + void resume() + { + if (filter != nullptr) + { + isProcessing = true; + channels.calloc ((size_t) (numInChans + numOutChans)); + + double rate = getSampleRate(); + jassert (rate > 0); + if (rate <= 0.0) + rate = 44100.0; + + const int blockSize = getBlockSize(); + jassert (blockSize > 0); + + firstProcessCallback = true; + + filter->setNonRealtime (getCurrentProcessLevel() == 4 /* kVstProcessLevelOffline */); + filter->setPlayConfigDetails (numInChans, numOutChans, rate, blockSize); + + deleteTempChannels(); + + filter->prepareToPlay (rate, blockSize); + + midiEvents.ensureSize (2048); + midiEvents.clear(); + + setInitialDelay (filter->getLatencySamples()); + + AudioEffectX::resume(); + + #if JucePlugin_ProducesMidiOutput + outgoingEvents.ensureSize (512); + #endif + } + } + + void suspend() + { + if (filter != nullptr) + { + AudioEffectX::suspend(); + + filter->releaseResources(); + outgoingEvents.freeEvents(); + + isProcessing = false; + channels.free(); + + deleteTempChannels(); + } + } + + bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info) + { + const VstTimeInfo* const ti = getTimeInfo (kVstPpqPosValid | kVstTempoValid | kVstBarsValid | kVstCyclePosValid + | kVstTimeSigValid | kVstSmpteValid | kVstClockValid); + + if (ti == nullptr || ti->sampleRate <= 0) + return false; + + info.bpm = (ti->flags & kVstTempoValid) != 0 ? ti->tempo : 0.0; + + if ((ti->flags & kVstTimeSigValid) != 0) + { + info.timeSigNumerator = ti->timeSigNumerator; + info.timeSigDenominator = ti->timeSigDenominator; + } + else + { + info.timeSigNumerator = 4; + info.timeSigDenominator = 4; + } + + info.timeInSamples = (int64) (ti->samplePos + 0.5); + info.timeInSeconds = ti->samplePos / ti->sampleRate; + info.ppqPosition = (ti->flags & kVstPpqPosValid) != 0 ? ti->ppqPos : 0.0; + info.ppqPositionOfLastBarStart = (ti->flags & kVstBarsValid) != 0 ? ti->barStartPos : 0.0; + + if ((ti->flags & kVstSmpteValid) != 0) + { + AudioPlayHead::FrameRateType rate = AudioPlayHead::fpsUnknown; + double fps = 1.0; + + switch (ti->smpteFrameRate) + { + case kVstSmpte24fps: rate = AudioPlayHead::fps24; fps = 24.0; break; + case kVstSmpte25fps: rate = AudioPlayHead::fps25; fps = 25.0; break; + case kVstSmpte2997fps: rate = AudioPlayHead::fps2997; fps = 29.97; break; + case kVstSmpte30fps: rate = AudioPlayHead::fps30; fps = 30.0; break; + case kVstSmpte2997dfps: rate = AudioPlayHead::fps2997drop; fps = 29.97; break; + case kVstSmpte30dfps: rate = AudioPlayHead::fps30drop; fps = 30.0; break; + + case kVstSmpteFilm16mm: + case kVstSmpteFilm35mm: fps = 24.0; break; + + case kVstSmpte239fps: fps = 23.976; break; + case kVstSmpte249fps: fps = 24.976; break; + case kVstSmpte599fps: fps = 59.94; break; + case kVstSmpte60fps: fps = 60; break; + + default: jassertfalse; // unknown frame-rate.. + } + + info.frameRate = rate; + info.editOriginTime = ti->smpteOffset / (80.0 * fps); + } + else + { + info.frameRate = AudioPlayHead::fpsUnknown; + info.editOriginTime = 0; + } + + info.isRecording = (ti->flags & kVstTransportRecording) != 0; + info.isPlaying = (ti->flags & (kVstTransportRecording | kVstTransportPlaying)) != 0; + info.isLooping = (ti->flags & kVstTransportCycleActive) != 0; + + if ((ti->flags & kVstCyclePosValid) != 0) + { + info.ppqLoopStart = ti->cycleStartPos; + info.ppqLoopEnd = ti->cycleEndPos; + } + else + { + info.ppqLoopStart = 0; + info.ppqLoopEnd = 0; + } + + return true; + } + + //============================================================================== + VstInt32 getProgram() + { + return filter != nullptr ? filter->getCurrentProgram() : 0; + } + + void setProgram (VstInt32 program) + { + if (filter != nullptr) + filter->setCurrentProgram (program); + } + + void setProgramName (char* name) + { + if (filter != nullptr) + filter->changeProgramName (filter->getCurrentProgram(), name); + } + + void getProgramName (char* name) + { + if (filter != nullptr) + filter->getProgramName (filter->getCurrentProgram()).copyToUTF8 (name, 24); + } + + bool getProgramNameIndexed (VstInt32 /*category*/, VstInt32 index, char* text) + { + if (filter != nullptr && isPositiveAndBelow (index, filter->getNumPrograms())) + { + filter->getProgramName (index).copyToUTF8 (text, 24); + return true; + } + + return false; + } + + //============================================================================== + float getParameter (VstInt32 index) + { + if (filter == nullptr) + return 0.0f; + + jassert (isPositiveAndBelow (index, filter->getNumParameters())); + return filter->getParameter (index); + } + + void setParameter (VstInt32 index, float value) + { + if (filter != nullptr) + { + jassert (isPositiveAndBelow (index, filter->getNumParameters())); + filter->setParameter (index, value); + } + } + + void getParameterDisplay (VstInt32 index, char* text) + { + if (filter != nullptr) + { + jassert (isPositiveAndBelow (index, filter->getNumParameters())); + filter->getParameterText (index).copyToUTF8 (text, 24); // length should technically be kVstMaxParamStrLen, which is 8, but hosts will normally allow a bit more. + } + } + + void getParameterName (VstInt32 index, char* text) + { + if (filter != nullptr) + { + jassert (isPositiveAndBelow (index, filter->getNumParameters())); + filter->getParameterName (index).copyToUTF8 (text, 16); // length should technically be kVstMaxParamStrLen, which is 8, but hosts will normally allow a bit more. + } + } + + void audioProcessorParameterChanged (AudioProcessor*, int index, float newValue) + { + if (audioMaster != nullptr) + audioMaster (&cEffect, audioMasterAutomate, index, 0, 0, newValue); + } + + void audioProcessorParameterChangeGestureBegin (AudioProcessor*, int index) { beginEdit (index); } + void audioProcessorParameterChangeGestureEnd (AudioProcessor*, int index) { endEdit (index); } + + void audioProcessorChanged (AudioProcessor*) + { + setInitialDelay (filter->getLatencySamples()); + ioChanged(); + updateDisplay(); + } + + bool canParameterBeAutomated (VstInt32 index) + { + return filter != nullptr && filter->isParameterAutomatable ((int) index); + } + + struct ChannelConfigComparator + { + static int compareElements (const short* const first, const short* const second) noexcept + { + if (first[0] < second[0]) return -1; + if (first[0] > second[0]) return 1; + if (first[1] < second[1]) return -1; + if (first[1] > second[1]) return 1; + return 0; + } + }; + + bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput, + VstSpeakerArrangement* pluginOutput) + { + short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations }; + + Array <short*> channelConfigsSorted; + ChannelConfigComparator comp; + + for (int i = 0; i < numElementsInArray (channelConfigs); ++i) + channelConfigsSorted.addSorted (comp, channelConfigs[i]); + + for (int i = channelConfigsSorted.size(); --i >= 0;) + { + const short* const config = channelConfigsSorted.getUnchecked(i); + bool inCountMatches = (config[0] == pluginInput->numChannels); + bool outCountMatches = (config[1] == pluginOutput->numChannels); + + if (inCountMatches && outCountMatches) + { + speakerIn = (VstSpeakerArrangementType) pluginInput->type; + speakerOut = (VstSpeakerArrangementType) pluginOutput->type; + numInChans = pluginInput->numChannels; + numOutChans = pluginOutput->numChannels; + + filter->setPlayConfigDetails (numInChans, numOutChans, + filter->getSampleRate(), + filter->getBlockSize()); + + filter->setSpeakerArrangement (getSpeakerArrangementString (speakerIn), + getSpeakerArrangementString (speakerOut)); + return true; + } + } + + filter->setSpeakerArrangement (String::empty, String::empty); + return false; + } + + static const char* getSpeakerArrangementString (VstSpeakerArrangementType type) noexcept + { + switch (type) + { + case kSpeakerArrMono: return "M"; + case kSpeakerArrStereo: return "L R"; + case kSpeakerArrStereoSurround: return "Ls Rs"; + case kSpeakerArrStereoCenter: return "Lc Rc"; + case kSpeakerArrStereoSide: return "Sl Sr"; + case kSpeakerArrStereoCLfe: return "C Lfe"; + case kSpeakerArr30Cine: return "L R C"; + case kSpeakerArr30Music: return "L R S"; + case kSpeakerArr31Cine: return "L R C Lfe"; + case kSpeakerArr31Music: return "L R Lfe S"; + case kSpeakerArr40Cine: return "L R C S"; + case kSpeakerArr40Music: return "L R Ls Rs"; + case kSpeakerArr41Cine: return "L R C Lfe S"; + case kSpeakerArr41Music: return "L R Lfe Ls Rs"; + case kSpeakerArr50: return "L R C Ls Rs" ; + case kSpeakerArr51: return "L R C Lfe Ls Rs"; + case kSpeakerArr60Cine: return "L R C Ls Rs Cs"; + case kSpeakerArr60Music: return "L R Ls Rs Sl Sr "; + case kSpeakerArr61Cine: return "L R C Lfe Ls Rs Cs"; + case kSpeakerArr61Music: return "L R Lfe Ls Rs Sl Sr"; + case kSpeakerArr70Cine: return "L R C Ls Rs Lc Rc "; + case kSpeakerArr70Music: return "L R C Ls Rs Sl Sr"; + case kSpeakerArr71Cine: return "L R C Lfe Ls Rs Lc Rc"; + case kSpeakerArr71Music: return "L R C Lfe Ls Rs Sl Sr"; + case kSpeakerArr80Cine: return "L R C Ls Rs Lc Rc Cs"; + case kSpeakerArr80Music: return "L R C Ls Rs Cs Sl Sr"; + case kSpeakerArr81Cine: return "L R C Lfe Ls Rs Lc Rc Cs"; + case kSpeakerArr81Music: return "L R C Lfe Ls Rs Cs Sl Sr" ; + case kSpeakerArr102: return "L R C Lfe Ls Rs Tfl Tfc Tfr Trl Trr Lfe2"; + default: break; + } + + return nullptr; + } + + //============================================================================== + VstInt32 getChunk (void** data, bool onlyStoreCurrentProgramData) + { + if (filter == nullptr) + return 0; + + chunkMemory.setSize (0); + if (onlyStoreCurrentProgramData) + filter->getCurrentProgramStateInformation (chunkMemory); + else + filter->getStateInformation (chunkMemory); + + *data = (void*) chunkMemory.getData(); + + // because the chunk is only needed temporarily by the host (or at least you'd + // hope so) we'll give it a while and then free it in the timer callback. + chunkMemoryTime = juce::Time::getApproximateMillisecondCounter(); + + return (VstInt32) chunkMemory.getSize(); + } + + VstInt32 setChunk (void* data, VstInt32 byteSize, bool onlyRestoreCurrentProgramData) + { + if (filter != nullptr) + { + chunkMemory.setSize (0); + chunkMemoryTime = 0; + + if (byteSize > 0 && data != nullptr) + { + if (onlyRestoreCurrentProgramData) + filter->setCurrentProgramStateInformation (data, byteSize); + else + filter->setStateInformation (data, byteSize); + } + } + + return 0; + } + + void timerCallback() + { + if (shouldDeleteEditor) + { + shouldDeleteEditor = false; + deleteEditor (true); + } + + if (chunkMemoryTime > 0 + && chunkMemoryTime < juce::Time::getApproximateMillisecondCounter() - 2000 + && ! recursionCheck) + { + chunkMemoryTime = 0; + chunkMemory.setSize (0); + } + + #if JUCE_MAC + if (hostWindow != 0) + checkWindowVisibility (hostWindow, editorComp); + #endif + + tryMasterIdle(); + } + + void tryMasterIdle() + { + if (Component::isMouseButtonDownAnywhere() && ! recursionCheck) + { + const juce::uint32 now = juce::Time::getMillisecondCounter(); + + if (now > lastMasterIdleCall + 20 && editorComp != nullptr) + { + lastMasterIdleCall = now; + + recursionCheck = true; + masterIdle(); + recursionCheck = false; + } + } + } + + void doIdleCallback() + { + // (wavelab calls this on a separate thread and causes a deadlock).. + if (MessageManager::getInstance()->isThisTheMessageThread() + && ! recursionCheck) + { + recursionCheck = true; + + JUCE_AUTORELEASEPOOL + { + Timer::callPendingTimersSynchronously(); + + for (int i = ComponentPeer::getNumPeers(); --i >= 0;) + ComponentPeer::getPeer (i)->performAnyPendingRepaintsNow(); + + recursionCheck = false; + } + } + } + + void createEditorComp() + { + if (hasShutdown || filter == nullptr) + return; + + if (editorComp == nullptr) + { + if (AudioProcessorEditor* const ed = filter->createEditorIfNeeded()) + { + cEffect.flags |= effFlagsHasEditor; + ed->setOpaque (true); + ed->setVisible (true); + + editorComp = new EditorCompWrapper (*this, ed); + } + else + { + cEffect.flags &= ~effFlagsHasEditor; + } + } + + shouldDeleteEditor = false; + } + + void deleteEditor (bool canDeleteLaterIfModal) + { + JUCE_AUTORELEASEPOOL + { + PopupMenu::dismissAllActiveMenus(); + + jassert (! recursionCheck); + recursionCheck = true; + + if (editorComp != nullptr) + { + if (Component* const modalComponent = Component::getCurrentlyModalComponent()) + { + modalComponent->exitModalState (0); + + if (canDeleteLaterIfModal) + { + shouldDeleteEditor = true; + recursionCheck = false; + return; + } + } + + #if JUCE_MAC + if (hostWindow != 0) + { + detachComponentFromWindowRef (editorComp, hostWindow); + hostWindow = 0; + } + #endif + + filter->editorBeingDeleted (editorComp->getEditorComp()); + + editorComp = nullptr; + + // there's some kind of component currently modal, but the host + // is trying to delete our plugin. You should try to avoid this happening.. + jassert (Component::getCurrentlyModalComponent() == nullptr); + } + + #if JUCE_LINUX + hostWindow = 0; + #endif + + recursionCheck = false; + } + } + + VstIntPtr dispatcher (VstInt32 opCode, VstInt32 index, VstIntPtr value, void* ptr, float opt) + { + if (hasShutdown) + return 0; + + if (opCode == effEditIdle) + { + doIdleCallback(); + return 0; + } + else if (opCode == effEditOpen) + { + checkWhetherMessageThreadIsCorrect(); + const MessageManagerLock mmLock; + jassert (! recursionCheck); + + startTimer (1000 / 4); // performs misc housekeeping chores + + deleteEditor (true); + createEditorComp(); + + if (editorComp != nullptr) + { + editorComp->setOpaque (true); + editorComp->setVisible (false); + + #if JUCE_WINDOWS + editorComp->addToDesktop (0, ptr); + hostWindow = (HWND) ptr; + #elif JUCE_LINUX + editorComp->addToDesktop (0); + hostWindow = (Window) ptr; + Window editorWnd = (Window) editorComp->getWindowHandle(); + XReparentWindow (display, editorWnd, hostWindow, 0, 0); + #else + hostWindow = attachComponentToWindowRef (editorComp, ptr); + #endif + editorComp->setVisible (true); + + return 1; + } + } + else if (opCode == effEditClose) + { + checkWhetherMessageThreadIsCorrect(); + const MessageManagerLock mmLock; + deleteEditor (true); + return 0; + } + else if (opCode == effEditGetRect) + { + checkWhetherMessageThreadIsCorrect(); + const MessageManagerLock mmLock; + createEditorComp(); + + if (editorComp != nullptr) + { + editorSize.left = 0; + editorSize.top = 0; + editorSize.right = (VstInt16) editorComp->getWidth(); + editorSize.bottom = (VstInt16) editorComp->getHeight(); + + *((ERect**) ptr) = &editorSize; + + return (VstIntPtr) (pointer_sized_int) &editorSize; + } + + return 0; + } + + return AudioEffectX::dispatcher (opCode, index, value, ptr, opt); + } + + void resizeHostWindow (int newWidth, int newHeight) + { + if (editorComp != nullptr) + { + if (! (canHostDo (const_cast <char*> ("sizeWindow")) && sizeWindow (newWidth, newHeight))) + { + // some hosts don't support the sizeWindow call, so do it manually.. + #if JUCE_MAC + setNativeHostWindowSize (hostWindow, editorComp, newWidth, newHeight, getHostType()); + + #elif JUCE_LINUX + // (Currently, all linux hosts support sizeWindow, so this should never need to happen) + editorComp->setSize (newWidth, newHeight); + + #else + int dw = 0; + int dh = 0; + const int frameThickness = GetSystemMetrics (SM_CYFIXEDFRAME); + + HWND w = (HWND) editorComp->getWindowHandle(); + + while (w != 0) + { + HWND parent = GetParent (w); + + if (parent == 0) + break; + + TCHAR windowType [32] = { 0 }; + GetClassName (parent, windowType, 31); + + if (String (windowType).equalsIgnoreCase ("MDIClient")) + break; + + RECT windowPos, parentPos; + GetWindowRect (w, &windowPos); + GetWindowRect (parent, &parentPos); + + SetWindowPos (w, 0, 0, 0, newWidth + dw, newHeight + dh, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER); + + dw = (parentPos.right - parentPos.left) - (windowPos.right - windowPos.left); + dh = (parentPos.bottom - parentPos.top) - (windowPos.bottom - windowPos.top); + + w = parent; + + if (dw == 2 * frameThickness) + break; + + if (dw > 100 || dh > 100) + w = 0; + } + + if (w != 0) + SetWindowPos (w, 0, 0, 0, newWidth + dw, newHeight + dh, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER); + #endif + } + + if (ComponentPeer* peer = editorComp->getPeer()) + peer->handleMovedOrResized(); + } + } + + static PluginHostType& getHostType() + { + static PluginHostType hostType; + return hostType; + } + + //============================================================================== + // A component to hold the AudioProcessorEditor, and cope with some housekeeping + // chores when it changes or repaints. + class EditorCompWrapper : public Component, + public AsyncUpdater + { + public: + EditorCompWrapper (JuceVSTWrapper& w, AudioProcessorEditor* editor) + : wrapper (w) + { + setOpaque (true); + editor->setOpaque (true); + + setBounds (editor->getBounds()); + editor->setTopLeftPosition (0, 0); + addAndMakeVisible (editor); + + #if JUCE_WINDOWS + if (! getHostType().isReceptor()) + addMouseListener (this, true); + + registerMouseWheelHook(); + + if (PluginHostType().isAbletonLive()) + registerKeyboardHook(); + #endif + } + + ~EditorCompWrapper() + { + #if JUCE_WINDOWS + unregisterMouseWheelHook(); + unregisterKeyboardHook(); + #endif + + deleteAllChildren(); // note that we can't use a ScopedPointer because the editor may + // have been transferred to another parent which takes over ownership. + } + + void paint (Graphics&) {} + + void paintOverChildren (Graphics&) + { + // this causes an async call to masterIdle() to help + // creaky old DAWs like Nuendo repaint themselves while we're + // repainting. Otherwise they just seem to give up and sit there + // waiting. + triggerAsyncUpdate(); + } + + #if JUCE_MAC + bool keyPressed (const KeyPress&) + { + // If we have an unused keypress, move the key-focus to a host window + // and re-inject the event.. + return forwardCurrentKeyEventToHost (this); + } + #endif + + AudioProcessorEditor* getEditorComp() const + { + return dynamic_cast <AudioProcessorEditor*> (getChildComponent (0)); + } + + void resized() + { + if (Component* const editor = getChildComponent(0)) + editor->setBounds (getLocalBounds()); + } + + void childBoundsChanged (Component* child) + { + child->setTopLeftPosition (0, 0); + + const int cw = child->getWidth(); + const int ch = child->getHeight(); + + #if JUCE_MAC && JUCE_64BIT + setTopLeftPosition (0, getHeight() - ch); + #endif + + wrapper.resizeHostWindow (cw, ch); + + #if ! JUCE_LINUX // setSize() on linux causes renoise and energyxt to fail. + setSize (cw, ch); + #else + XResizeWindow (display, (Window) getWindowHandle(), cw, ch); + #endif + + #if JUCE_MAC + wrapper.resizeHostWindow (cw, ch); // (doing this a second time seems to be necessary in tracktion) + #endif + } + + void handleAsyncUpdate() + { + wrapper.tryMasterIdle(); + } + + #if JUCE_WINDOWS + void mouseDown (const MouseEvent&) + { + broughtToFront(); + } + + void broughtToFront() + { + // for hosts like nuendo, need to also pop the MDI container to the + // front when our comp is clicked on. + HWND parent = findMDIParentOf ((HWND) getWindowHandle()); + + if (parent != 0) + SetWindowPos (parent, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } + #endif + + private: + //============================================================================== + JuceVSTWrapper& wrapper; + FakeMouseMoveGenerator fakeMouseGenerator; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EditorCompWrapper) + }; + + //============================================================================== +private: + AudioProcessor* filter; + juce::MemoryBlock chunkMemory; + juce::uint32 chunkMemoryTime; + ScopedPointer<EditorCompWrapper> editorComp; + ERect editorSize; + MidiBuffer midiEvents; + VSTMidiEventList outgoingEvents; + VstSpeakerArrangementType speakerIn, speakerOut; + int numInChans, numOutChans; + bool isProcessing, isBypassed, hasShutdown, firstProcessCallback, shouldDeleteEditor; + HeapBlock<float*> channels; + Array<float*> tempChannels; // see note in processReplacing() + + #if JUCE_MAC + void* hostWindow; + #elif JUCE_LINUX + Window hostWindow; + #else + HWND hostWindow; + #endif + + static inline VstInt32 convertHexVersionToDecimal (const unsigned int hexVersion) + { + #if JUCE_VST_RETURN_HEX_VERSION_NUMBER_DIRECTLY + return (VstInt32) hexVersion; + #else + return (VstInt32) (((hexVersion >> 24) & 0xff) * 1000 + + ((hexVersion >> 16) & 0xff) * 100 + + ((hexVersion >> 8) & 0xff) * 10 + + (hexVersion & 0xff)); + #endif + } + + //============================================================================== + #if JUCE_WINDOWS + // Workarounds for hosts which attempt to open editor windows on a non-GUI thread.. (Grrrr...) + static void checkWhetherMessageThreadIsCorrect() + { + const PluginHostType host (getHostType()); + + if (host.isWavelab() || host.isCubaseBridged() || host.isPremiere()) + { + if (! messageThreadIsDefinitelyCorrect) + { + MessageManager::getInstance()->setCurrentThreadAsMessageThread(); + + class MessageThreadCallback : public CallbackMessage + { + public: + MessageThreadCallback (bool& tr) : triggered (tr) {} + + void messageCallback() + { + triggered = true; + } + + private: + bool& triggered; + }; + + (new MessageThreadCallback (messageThreadIsDefinitelyCorrect))->post(); + } + } + } + #else + static void checkWhetherMessageThreadIsCorrect() {} + #endif + + //============================================================================== + void deleteTempChannels() + { + for (int i = tempChannels.size(); --i >= 0;) + delete[] (tempChannels.getUnchecked(i)); + + tempChannels.clear(); + + if (filter != nullptr) + tempChannels.insertMultiple (0, 0, filter->getNumInputChannels() + filter->getNumOutputChannels()); + } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceVSTWrapper) +}; + +//============================================================================== +namespace +{ + AEffect* pluginEntryPoint (audioMasterCallback audioMaster) + { + JUCE_AUTORELEASEPOOL + { + initialiseJuce_GUI(); + + try + { + if (audioMaster (0, audioMasterVersion, 0, 0, 0, 0) != 0) + { + #if JUCE_LINUX + MessageManagerLock mmLock; + #endif + + AudioProcessor* const filter = createPluginFilterOfType (AudioProcessor::wrapperType_VST); + JuceVSTWrapper* const wrapper = new JuceVSTWrapper (audioMaster, filter); + return wrapper->getAeffect(); + } + } + catch (...) + {} + } + + return nullptr; + } +} + +#if ! JUCE_WINDOWS + #define JUCE_EXPORTED_FUNCTION extern "C" __attribute__ ((visibility("default"))) +#endif + +//============================================================================== +// Mac startup code.. +#if JUCE_MAC + + JUCE_EXPORTED_FUNCTION AEffect* VSTPluginMain (audioMasterCallback audioMaster); + JUCE_EXPORTED_FUNCTION AEffect* VSTPluginMain (audioMasterCallback audioMaster) + { + initialiseMac(); + return pluginEntryPoint (audioMaster); + } + + JUCE_EXPORTED_FUNCTION AEffect* main_macho (audioMasterCallback audioMaster); + JUCE_EXPORTED_FUNCTION AEffect* main_macho (audioMasterCallback audioMaster) + { + initialiseMac(); + return pluginEntryPoint (audioMaster); + } + +//============================================================================== +// Linux startup code.. +#elif JUCE_LINUX + + JUCE_EXPORTED_FUNCTION AEffect* VSTPluginMain (audioMasterCallback audioMaster); + JUCE_EXPORTED_FUNCTION AEffect* VSTPluginMain (audioMasterCallback audioMaster) + { + SharedMessageThread::getInstance(); + return pluginEntryPoint (audioMaster); + } + + JUCE_EXPORTED_FUNCTION AEffect* main_plugin (audioMasterCallback audioMaster) asm ("main"); + JUCE_EXPORTED_FUNCTION AEffect* main_plugin (audioMasterCallback audioMaster) + { + return VSTPluginMain (audioMaster); + } + + // don't put initialiseJuce_GUI or shutdownJuce_GUI in these... it will crash! + __attribute__((constructor)) void myPluginInit() {} + __attribute__((destructor)) void myPluginFini() {} + +//============================================================================== +// Win32 startup code.. +#else + + extern "C" __declspec (dllexport) AEffect* VSTPluginMain (audioMasterCallback audioMaster) + { + return pluginEntryPoint (audioMaster); + } + + #ifndef JUCE_64BIT // (can't compile this on win64, but it's not needed anyway with VST2.4) + extern "C" __declspec (dllexport) int main (audioMasterCallback audioMaster) + { + return (int) pluginEntryPoint (audioMaster); + } + #endif +#endif + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm b/JuceLibraryCode/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm new file mode 100644 index 000000000..79e218207 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm @@ -0,0 +1,261 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" + +#if JucePlugin_Build_VST + +#define JUCE_MAC_WINDOW_VISIBITY_BODGE 1 + +#include "../utility/juce_IncludeSystemHeaders.h" +#include "../utility/juce_IncludeModuleHeaders.h" +#include "../utility/juce_FakeMouseMoveGenerator.h" +#include "../utility/juce_CarbonVisibility.h" +#include "../utility/juce_PluginHostType.h" + +//============================================================================== +namespace juce +{ + +#if ! JUCE_64BIT +static void updateComponentPos (Component* const comp) +{ + HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int) + comp->getProperties() ["dummyViewRef"].toString().getHexValue64(); + + HIRect r; + HIViewGetFrame (dummyView, &r); + HIViewRef root; + HIViewFindByID (HIViewGetRoot (HIViewGetWindow (dummyView)), kHIViewWindowContentID, &root); + HIViewConvertRect (&r, HIViewGetSuperview (dummyView), root); + + Rect windowPos; + GetWindowBounds (HIViewGetWindow (dummyView), kWindowContentRgn, &windowPos); + + comp->setTopLeftPosition ((int) (windowPos.left + r.origin.x), + (int) (windowPos.top + r.origin.y)); +} + +static pascal OSStatus viewBoundsChangedEvent (EventHandlerCallRef, EventRef, void* user) +{ + updateComponentPos ((Component*) user); + return noErr; +} +#endif + +//============================================================================== +void initialiseMac(); +void initialiseMac() +{ + #if ! JUCE_64BIT + NSApplicationLoad(); + #endif +} + +void* attachComponentToWindowRef (Component* comp, void* windowRef); +void* attachComponentToWindowRef (Component* comp, void* windowRef) +{ + JUCE_AUTORELEASEPOOL + { + #if JUCE_64BIT + NSView* parentView = (NSView*) windowRef; + + #if JucePlugin_EditorRequiresKeyboardFocus + comp->addToDesktop (0, parentView); + #else + comp->addToDesktop (ComponentPeer::windowIgnoresKeyPresses, parentView); + #endif + + // (this workaround is because Wavelab provides a zero-size parent view..) + if ([parentView frame].size.height == 0) + [((NSView*) comp->getWindowHandle()) setFrameOrigin: NSZeroPoint]; + + comp->setVisible (true); + comp->toFront (false); + + [[parentView window] setAcceptsMouseMovedEvents: YES]; + return parentView; + #else + NSWindow* hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef]; + [hostWindow retain]; + [hostWindow setCanHide: YES]; + [hostWindow setReleasedWhenClosed: YES]; + + HIViewRef parentView = 0; + + WindowAttributes attributes; + GetWindowAttributes ((WindowRef) windowRef, &attributes); + if ((attributes & kWindowCompositingAttribute) != 0) + { + HIViewRef root = HIViewGetRoot ((WindowRef) windowRef); + HIViewFindByID (root, kHIViewWindowContentID, &parentView); + + if (parentView == 0) + parentView = root; + } + else + { + GetRootControl ((WindowRef) windowRef, (ControlRef*) &parentView); + + if (parentView == 0) + CreateRootControl ((WindowRef) windowRef, (ControlRef*) &parentView); + } + + // It seems that the only way to successfully position our overlaid window is by putting a dummy + // HIView into the host's carbon window, and then catching events to see when it gets repositioned + HIViewRef dummyView = 0; + HIImageViewCreate (0, &dummyView); + HIRect r = { {0, 0}, { (float) comp->getWidth(), (float) comp->getHeight()} }; + HIViewSetFrame (dummyView, &r); + HIViewAddSubview (parentView, dummyView); + comp->getProperties().set ("dummyViewRef", String::toHexString ((pointer_sized_int) (void*) dummyView)); + + EventHandlerRef ref; + const EventTypeSpec kControlBoundsChangedEvent = { kEventClassControl, kEventControlBoundsChanged }; + InstallEventHandler (GetControlEventTarget (dummyView), NewEventHandlerUPP (viewBoundsChangedEvent), 1, &kControlBoundsChangedEvent, (void*) comp, &ref); + comp->getProperties().set ("boundsEventRef", String::toHexString ((pointer_sized_int) (void*) ref)); + + updateComponentPos (comp); + + #if ! JucePlugin_EditorRequiresKeyboardFocus + comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); + #else + comp->addToDesktop (ComponentPeer::windowIsTemporary); + #endif + + comp->setVisible (true); + comp->toFront (false); + + NSView* pluginView = (NSView*) comp->getWindowHandle(); + NSWindow* pluginWindow = [pluginView window]; + [pluginWindow setExcludedFromWindowsMenu: YES]; + [pluginWindow setCanHide: YES]; + + [hostWindow addChildWindow: pluginWindow + ordered: NSWindowAbove]; + [hostWindow orderFront: nil]; + [pluginWindow orderFront: nil]; + + attachWindowHidingHooks (comp, (WindowRef) windowRef, hostWindow); + + return hostWindow; + #endif + } +} + +void detachComponentFromWindowRef (Component* comp, void* nsWindow); +void detachComponentFromWindowRef (Component* comp, void* nsWindow) +{ + JUCE_AUTORELEASEPOOL + { + #if JUCE_64BIT + comp->removeFromDesktop(); + #else + EventHandlerRef ref = (EventHandlerRef) (void*) (pointer_sized_int) + comp->getProperties() ["boundsEventRef"].toString().getHexValue64(); + RemoveEventHandler (ref); + + removeWindowHidingHooks (comp); + + HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int) + comp->getProperties() ["dummyViewRef"].toString().getHexValue64(); + + if (HIViewIsValid (dummyView)) + CFRelease (dummyView); + + NSWindow* hostWindow = (NSWindow*) nsWindow; + NSView* pluginView = (NSView*) comp->getWindowHandle(); + NSWindow* pluginWindow = [pluginView window]; + + [hostWindow removeChildWindow: pluginWindow]; + comp->removeFromDesktop(); + + [hostWindow release]; + + // The event loop needs to be run between closing the window and deleting the plugin, + // presumably to let the cocoa objects get tidied up. Leaving out this line causes crashes + // in Live and Reaper when you delete the plugin with its window open. + // (Doing it this way rather than using a single longer timout means that we can guarantee + // how many messages will be dispatched, which seems to be vital in Reaper) + for (int i = 20; --i >= 0;) + MessageManager::getInstance()->runDispatchLoopUntil (1); + #endif + } +} + +void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight, const PluginHostType& host); +void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight, const PluginHostType& host) +{ + JUCE_AUTORELEASEPOOL + { + #if JUCE_64BIT + if (NSView* hostView = (NSView*) nsWindow) + { + // xxx is this necessary, or do the hosts detect a change in the child view and do this automatically? + [hostView setFrameSize: NSMakeSize ([hostView frame].size.width + (newWidth - component->getWidth()), + [hostView frame].size.height + (newHeight - component->getHeight()))]; + } + #else + + if (HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int) + component->getProperties() ["dummyViewRef"].toString().getHexValue64()) + { + HIRect frameRect; + HIViewGetFrame (dummyView, &frameRect); + frameRect.size.width = newWidth; + frameRect.size.height = newHeight; + HIViewSetFrame (dummyView, &frameRect); + } + #endif + } +} + +void checkWindowVisibility (void* nsWindow, Component* comp); +void checkWindowVisibility (void* nsWindow, Component* comp) +{ + #if ! JUCE_64BIT + comp->setVisible ([((NSWindow*) nsWindow) isVisible]); + #endif +} + +bool forwardCurrentKeyEventToHost (Component* comp); +bool forwardCurrentKeyEventToHost (Component* comp) +{ + #if JUCE_64BIT + return false; + #else + NSWindow* win = [(NSView*) comp->getWindowHandle() window]; + [[win parentWindow] makeKeyWindow]; + [NSApp postEvent: [NSApp currentEvent] atStart: YES]; + return true; + #endif +} + +} // (juce namespace) + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/juce_audio_plugin_client.h b/JuceLibraryCode/modules/juce_audio_plugin_client/juce_audio_plugin_client.h new file mode 100644 index 000000000..9c90f6fcf --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/juce_audio_plugin_client.h @@ -0,0 +1,33 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_AUDIO_PLUGIN_CLIENT_JUCEHEADER__ +#define __JUCE_AUDIO_PLUGIN_CLIENT_JUCEHEADER__ + +#include "../juce_gui_basics/juce_gui_basics.h" +#include "../juce_audio_basics/juce_audio_basics.h" +#include "../juce_audio_processors/juce_audio_processors.h" +#include "utility/juce_CheckSettingMacros.h" + +#endif // __JUCE_AUDIO_PLUGIN_CLIENT_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/juce_module_info b/JuceLibraryCode/modules/juce_audio_plugin_client/juce_module_info new file mode 100644 index 000000000..ad6543cb5 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/juce_module_info @@ -0,0 +1,42 @@ +{ + "id": "juce_audio_plugin_client", + "name": "JUCE audio plugin wrapper classes", + "version": "2.1.1", + "description": "Classes for building VST, RTAS and AU plugins.", + "website": "http://www.juce.com/juce", + "license": "GPL/Commercial", + + "dependencies": [ { "id": "juce_gui_basics", "version": "matching" }, + { "id": "juce_audio_basics", "version": "matching" }, + { "id": "juce_audio_processors", "version": "matching" } ], + + "include": "juce_audio_plugin_client.h", + + "compile": [ { "file": "VST/juce_VST_Wrapper.cpp" }, + { "file": "VST/juce_VST_Wrapper.mm", "target": "xcode" }, + { "file": "RTAS/juce_RTAS_DigiCode1.cpp", "warnings": "disabled", "stdcall": "1", "target": "xcode, msvc" }, + { "file": "RTAS/juce_RTAS_DigiCode2.cpp", "warnings": "disabled", "stdcall": "1", "target": "xcode, msvc" }, + { "file": "RTAS/juce_RTAS_DigiCode3.cpp", "warnings": "disabled", "stdcall": "1", "target": "xcode, msvc" }, + { "file": "RTAS/juce_RTAS_MacResources.r", "target": "xcode" }, + { "file": "RTAS/juce_RTAS_MacUtilities.mm", "target": "xcode" }, + { "file": "RTAS/juce_RTAS_WinResources.rsr", "target": "msvc" }, + { "file": "RTAS/juce_RTAS_WinUtilities.cpp", "target": "msvc", "warnings": "disabled", "stdcall": "1" }, + { "file": "RTAS/juce_RTAS_Wrapper.cpp", "warnings": "disabled", "stdcall": "1", "target": "xcode, msvc" }, + { "file": "AU/juce_AU_Resources.r", "target": "xcode" }, + { "file": "AU/juce_AU_Wrapper.mm", "target": "xcode" }, + { "file": "AAX/juce_AAX_Wrapper.cpp", "target": "xcode, msvc" }, + { "file": "AAX/juce_AAX_Wrapper.mm", "target": "xcode" }, + { "file": "utility/juce_PluginUtilities.cpp" } + ], + + "browse": [ "AU/*.cpp", + "AU/*.mm", + "AU/*.h", + "RTAS/*.cpp", + "RTAS/*.mm", + "RTAS/*.h", + "VST/*", + "AAX/*", + "utility/*" + ] +} diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h new file mode 100644 index 000000000..5bf37d538 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h @@ -0,0 +1,79 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_CARBONVISIBILITY_JUCEHEADER__ +#define __JUCE_CARBONVISIBILITY_JUCEHEADER__ + +//============================================================================== +#if JUCE_SUPPORT_CARBON && JUCE_MAC_WINDOW_VISIBITY_BODGE + +/* When you wrap a WindowRef as an NSWindow, it seems to bugger up the HideWindow + function, so when the host tries (and fails) to hide the window, this stuff catches + the event and forces it to update. +*/ +static pascal OSStatus windowVisibilityBodge (EventHandlerCallRef, EventRef e, void* user) +{ + NSWindow* hostWindow = (NSWindow*) user; + + switch (GetEventKind (e)) + { + case kEventWindowInit: [hostWindow display]; break; + case kEventWindowShown: [hostWindow orderFront: nil]; break; + case kEventWindowHidden: [hostWindow orderOut: nil]; break; + } + + return eventNotHandledErr; +} + +static void attachWindowHidingHooks (Component* comp, void* hostWindowRef, NSWindow* nsWindow) +{ + const EventTypeSpec eventsToCatch[] = + { + { kEventClassWindow, kEventWindowInit }, + { kEventClassWindow, kEventWindowShown }, + { kEventClassWindow, kEventWindowHidden } + }; + + EventHandlerRef ref; + InstallWindowEventHandler ((WindowRef) hostWindowRef, + NewEventHandlerUPP (windowVisibilityBodge), + GetEventTypeCount (eventsToCatch), eventsToCatch, + (void*) nsWindow, &ref); + + comp->getProperties().set ("carbonEventRef", String::toHexString ((pointer_sized_int) (void*) ref)); +} + +static void removeWindowHidingHooks (Component* comp) +{ + if (comp != nullptr) + RemoveEventHandler ((EventHandlerRef) (void*) (pointer_sized_int) + comp->getProperties() ["carbonEventRef"].toString().getHexValue64()); +} + +#elif JUCE_MAC + static void attachWindowHidingHooks (void*, void*, void*) {} + static void removeWindowHidingHooks (void*) {} +#endif + +#endif // __JUCE_CARBONVISIBILITY_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_CheckSettingMacros.h b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_CheckSettingMacros.h new file mode 100644 index 000000000..747465568 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_CheckSettingMacros.h @@ -0,0 +1,99 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +// The following checks should cause a compile error if you've forgotten to +// define all your plugin settings properly.. + +#if ! (JucePlugin_Build_VST || JucePlugin_Build_AU || JucePlugin_Build_RTAS || JucePlugin_Build_AAX \ + || JucePlugin_Build_Standalone || JucePlugin_Build_LV2) + #error "You need to enable at least one plugin format!" +#endif + +#ifndef JucePlugin_IsSynth + #error "You need to define the JucePlugin_IsSynth value!" +#endif + +#ifndef JucePlugin_ManufacturerCode + #error "You need to define the JucePlugin_ManufacturerCode value!" +#endif + +#ifndef JucePlugin_PluginCode + #error "You need to define the JucePlugin_PluginCode value!" +#endif + +#ifndef JucePlugin_ProducesMidiOutput + #error "You need to define the JucePlugin_ProducesMidiOutput value!" +#endif + +#ifndef JucePlugin_WantsMidiInput + #error "You need to define the JucePlugin_WantsMidiInput value!" +#endif + +#ifndef JucePlugin_MaxNumInputChannels + #error "You need to define the JucePlugin_MaxNumInputChannels value!" +#endif + +#ifndef JucePlugin_MaxNumOutputChannels + #error "You need to define the JucePlugin_MaxNumOutputChannels value!" +#endif + +#ifndef JucePlugin_PreferredChannelConfigurations + #error "You need to define the JucePlugin_PreferredChannelConfigurations value!" +#endif + +#ifdef JucePlugin_Latency + #error "JucePlugin_Latency is now deprecated - instead, call the AudioProcessor::setLatencySamples() method if your plugin has a non-zero delay" +#endif + +#ifndef JucePlugin_SilenceInProducesSilenceOut + #error "You need to define the JucePlugin_SilenceInProducesSilenceOut value!" +#endif + +#ifndef JucePlugin_EditorRequiresKeyboardFocus + #error "You need to define the JucePlugin_EditorRequiresKeyboardFocus value!" +#endif + +//============================================================================== +#if _WIN64 || (__LP64__ && (defined(__APPLE_CPP__) || defined(__APPLE_CC__))) + #undef JucePlugin_Build_RTAS + #define JucePlugin_Build_RTAS 0 +#endif + +//============================================================================== +#if JucePlugin_Build_RTAS && _MSC_VER && ! defined (JucePlugin_WinBag_path) + #error "You need to define the JucePlugin_WinBag_path value!" +#endif + +#if JucePlugin_Build_LV2 && ! defined (JucePlugin_LV2URI) + #error "You need to define the JucePlugin_LV2URI value!" +#endif + +#if JucePlugin_Build_AAX && ! defined (JucePlugin_AAXIdentifier) + #error "You need to define the JucePlugin_AAXIdentifier value!" +#endif + +#if defined (__ppc__) + #undef JucePlugin_Build_AAX + #define JucePlugin_Build_AAX 0 +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h new file mode 100644 index 000000000..9f5c45cd0 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h @@ -0,0 +1,66 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_FAKEMOUSEMOVEGENERATOR_JUCEHEADER__ +#define __JUCE_FAKEMOUSEMOVEGENERATOR_JUCEHEADER__ + +#if JUCE_MAC && JUCE_SUPPORT_CARBON + +//============================================================================== +// Helper class to workaround carbon windows not getting mouse-moves.. +class FakeMouseMoveGenerator : private Timer +{ +public: + FakeMouseMoveGenerator() + { + startTimer (1000 / 30); + } + + void timerCallback() + { + // workaround for carbon windows not getting mouse-moves.. + const Point<int> screenPos (Desktop::getInstance().getMainMouseSource().getScreenPosition()); + + if (screenPos != lastScreenPos) + { + lastScreenPos = screenPos; + const ModifierKeys mods (ModifierKeys::getCurrentModifiers()); + + if (! mods.isAnyMouseButtonDown()) + if (Component* const comp = Desktop::getInstance().findComponentAt (screenPos)) + if (ComponentPeer* const peer = comp->getPeer()) + if (! peer->isFocused()) + peer->handleMouseEvent (0, peer->globalToLocal (screenPos), mods, Time::currentTimeMillis()); + } + } + +private: + Point<int> lastScreenPos; +}; + +#else +struct FakeMouseMoveGenerator {}; +#endif + +#endif // __JUCE_FAKEMOUSEMOVEGENERATOR_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h new file mode 100644 index 000000000..69b15589a --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h @@ -0,0 +1,34 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#include "../juce_audio_plugin_client.h" + +using namespace juce; + +#if JUCE_MAC && ! DOXYGEN + #define Point juce::Point + #define Component juce::Component +#endif + +extern AudioProcessor* JUCE_CALLTYPE createPluginFilterOfType (AudioProcessor::WrapperType); diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_IncludeSystemHeaders.h b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_IncludeSystemHeaders.h new file mode 100644 index 000000000..8f76b1473 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_IncludeSystemHeaders.h @@ -0,0 +1,66 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#if JUCE_WINDOWS + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x500 + #undef STRICT + #define STRICT 1 + #include <windows.h> + #include <float.h> + #pragma warning (disable : 4312 4355) + #ifdef __INTEL_COMPILER + #pragma warning (disable : 1899) + #endif + +#elif JUCE_LINUX + #include <float.h> + #include <sys/time.h> + #include <X11/Xlib.h> + #include <X11/Xutil.h> + #include <X11/Xatom.h> + #undef Font + #undef KeyPress + #undef Drawable + #undef Time + +#else + #if ! (defined (JUCE_SUPPORT_CARBON) || defined (__LP64__)) + #define JUCE_SUPPORT_CARBON 1 + #endif + + #if JUCE_SUPPORT_CARBON + #define Point CarbonDummyPointName + #define Component CarbonDummyCompName + #include <Cocoa/Cocoa.h> + #include <Carbon/Carbon.h> + #undef Point + #undef Component + #else + #include <Cocoa/Cocoa.h> + #endif + #include <objc/runtime.h> + #include <objc/objc.h> + #include <objc/message.h> +#endif diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h new file mode 100644 index 000000000..a121dfbf7 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h @@ -0,0 +1,165 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +//============================================================================== +class PluginHostType +{ +public: + //============================================================================== + PluginHostType() : type (getHostType()) {} + PluginHostType (const PluginHostType& other) : type (other.type) {} + PluginHostType& operator= (const PluginHostType& other) { type = other.type; return *this; } + + //============================================================================== + enum HostType + { + UnknownHost, + AbletonLive6, + AbletonLive7, + AbletonLive8, + AbletonLiveGeneric, + AdobePremierePro, + AppleLogic, + CakewalkSonar8, + CakewalkSonarGeneric, + DigidesignProTools, + EmagicLogic, + Reaper, + MackieTracktion3, + MackieTracktionGeneric, + SteinbergCubase4, + SteinbergCubase5, + SteinbergCubase5Bridged, + SteinbergCubaseGeneric, + SteinbergCubase6, + SteinbergCubase7, + SteinbergWavelab5, + SteinbergWavelab6, + SteinbergWavelab7, + SteinbergWavelab8, + SteinbergNuendo, + SteinbergWavelabGeneric, + MuseReceptorGeneric, + MagixSamplitude, + FruityLoops, + WaveBurner, + DigitalPerformer, + StudioOne + }; + + HostType type; + + //============================================================================== + bool isAbletonLive() const noexcept { return type == AbletonLive6 || type == AbletonLive7 || type == AbletonLive8 || type == AbletonLiveGeneric; } + bool isCubase() const noexcept { return type == SteinbergCubase4 || type == SteinbergCubase5 || type == SteinbergCubase5Bridged || type == SteinbergCubase6 || type == SteinbergCubase7 || type == SteinbergCubaseGeneric; } + bool isCubaseBridged() const noexcept { return type == SteinbergCubase5Bridged; } + bool isNuendo() const noexcept { return type == SteinbergNuendo; } + bool isTracktion() const noexcept { return type == MackieTracktion3 || type == MackieTracktionGeneric; } + bool isSonar() const noexcept { return type == CakewalkSonar8 || type == CakewalkSonarGeneric; } + bool isWavelab() const noexcept { return isWavelabLegacy() || type == SteinbergWavelab7 || type == SteinbergWavelab8 || type == SteinbergWavelabGeneric; } + bool isWavelabLegacy() const noexcept { return type == SteinbergWavelab5 || type == SteinbergWavelab6; } + bool isPremiere() const noexcept { return type == AdobePremierePro; } + bool isLogic() const noexcept { return type == AppleLogic || type == EmagicLogic; } + bool isReceptor() const noexcept { return type == MuseReceptorGeneric; } + bool isSamplitude() const noexcept { return type == MagixSamplitude; } + bool isFruityLoops() const noexcept { return type == FruityLoops; } + bool isWaveBurner() const noexcept { return type == WaveBurner; } + bool isDigitalPerformer() const noexcept { return type == DigitalPerformer; } + bool isReaper() const noexcept { return type == Reaper; } + bool isStudioOne() const noexcept { return type == StudioOne; } + + //============================================================================== + static String getHostPath() + { + return File::getSpecialLocation (File::hostApplicationPath).getFullPathName(); + } + + //============================================================================== +private: + static HostType getHostType() + { + const String hostPath (getHostPath()); + const String hostFilename (File (hostPath).getFileName()); + + #if JUCE_MAC + if (hostPath.containsIgnoreCase ("Live 6.")) return AbletonLive6; + if (hostPath.containsIgnoreCase ("Live 7.")) return AbletonLive7; + if (hostPath.containsIgnoreCase ("Live 8.")) return AbletonLive8; + if (hostFilename.containsIgnoreCase ("Live")) return AbletonLiveGeneric; + if (hostFilename.containsIgnoreCase ("Adobe Premiere")) return AdobePremierePro; + if (hostFilename.contains ("Logic")) return AppleLogic; + if (hostFilename.containsIgnoreCase ("Pro Tools")) return DigidesignProTools; + if (hostFilename.containsIgnoreCase ("Cubase 4")) return SteinbergCubase4; + if (hostFilename.containsIgnoreCase ("Cubase 5")) return SteinbergCubase5; + if (hostFilename.containsIgnoreCase ("Cubase 6")) return SteinbergCubase6; + if (hostFilename.containsIgnoreCase ("Cubase 7")) return SteinbergCubase7; + if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; + if (hostPath.containsIgnoreCase ("Wavelab 7")) return SteinbergWavelab7; + if (hostPath.containsIgnoreCase ("Wavelab 8")) return SteinbergWavelab8; + if (hostPath.containsIgnoreCase ("Nuendo")) return SteinbergNuendo; + if (hostFilename.containsIgnoreCase ("Wavelab")) return SteinbergWavelabGeneric; + if (hostFilename.containsIgnoreCase ("WaveBurner")) return WaveBurner; + if (hostFilename.contains ("Digital Performer")) return DigitalPerformer; + if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; + if (hostPath.containsIgnoreCase ("Studio One")) return StudioOne; + + #elif JUCE_WINDOWS + if (hostFilename.containsIgnoreCase ("Live 6.")) return AbletonLive6; + if (hostFilename.containsIgnoreCase ("Live 7.")) return AbletonLive7; + if (hostFilename.containsIgnoreCase ("Live 8.")) return AbletonLive8; + if (hostFilename.containsIgnoreCase ("Live ")) return AbletonLiveGeneric; + if (hostFilename.containsIgnoreCase ("Adobe Premiere")) return AdobePremierePro; + if (hostFilename.containsIgnoreCase ("ProTools")) return DigidesignProTools; + if (hostPath.containsIgnoreCase ("SONAR 8")) return CakewalkSonar8; + if (hostFilename.containsIgnoreCase ("SONAR")) return CakewalkSonarGeneric; + if (hostFilename.containsIgnoreCase ("Logic")) return EmagicLogic; + if (hostPath.containsIgnoreCase ("Tracktion 3")) return MackieTracktion3; + if (hostFilename.containsIgnoreCase ("Tracktion")) return MackieTracktionGeneric; + if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; + if (hostFilename.containsIgnoreCase ("Cubase4")) return SteinbergCubase4; + if (hostFilename.containsIgnoreCase ("Cubase5")) return SteinbergCubase5; + if (hostFilename.containsIgnoreCase ("Cubase6")) return SteinbergCubase6; + if (hostFilename.containsIgnoreCase ("Cubase7")) return SteinbergCubase7; + if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; + if (hostFilename.containsIgnoreCase ("VSTBridgeApp")) return SteinbergCubase5Bridged; + if (hostPath.containsIgnoreCase ("Wavelab 5")) return SteinbergWavelab5; + if (hostPath.containsIgnoreCase ("Wavelab 6")) return SteinbergWavelab6; + if (hostPath.containsIgnoreCase ("Wavelab 7")) return SteinbergWavelab7; + if (hostPath.containsIgnoreCase ("Wavelab 8")) return SteinbergWavelab8; + if (hostPath.containsIgnoreCase ("Nuendo")) return SteinbergNuendo; + if (hostFilename.containsIgnoreCase ("Wavelab")) return SteinbergWavelabGeneric; + if (hostFilename.containsIgnoreCase ("rm-host")) return MuseReceptorGeneric; + if (hostFilename.startsWithIgnoreCase ("Sam")) return MagixSamplitude; + if (hostFilename.startsWith ("FL")) return FruityLoops; + if (hostPath.containsIgnoreCase ("Studio One")) return StudioOne; + if (hostPath.containsIgnoreCase ("Digital Performer")) return DigitalPerformer; + + #elif JUCE_LINUX + jassertfalse // not yet done! + #else + #error + #endif + return UnknownHost; + } +}; diff --git a/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp new file mode 100644 index 000000000..e4684d66b --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp @@ -0,0 +1,79 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#if _MSC_VER + #include <windows.h> +#endif + +// Your project must contain an AppConfig.h file with your project-specific settings in it, +// and your header search path must make it accessible to the module's files. +#include "AppConfig.h" + +#include "../utility/juce_CheckSettingMacros.h" +#include "juce_IncludeModuleHeaders.h" + +#if _MSC_VER + +#if JucePlugin_Build_RTAS + extern "C" BOOL WINAPI DllMainRTAS (HINSTANCE, DWORD, LPVOID); +#endif + +extern "C" BOOL WINAPI DllMain (HINSTANCE instance, DWORD reason, LPVOID reserved) +{ + if (reason == DLL_PROCESS_ATTACH) + Process::setCurrentModuleInstanceHandle (instance); + + #if JucePlugin_Build_RTAS + if (GetModuleHandleA ("DAE.DLL") != 0) + { + #if JucePlugin_Build_AAX + if (! File::getSpecialLocation (File::currentExecutableFile).hasFileExtension ("aaxplugin")) + #endif + return DllMainRTAS (instance, reason, reserved); + } + #endif + + (void) reserved; + return TRUE; +} + +#endif + +//============================================================================== +/** Somewhere in the codebase of your plugin, you need to implement this function + and make it return a new instance of the filter subclass that you're building. +*/ +extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); + +AudioProcessor* JUCE_CALLTYPE createPluginFilterOfType (AudioProcessor::WrapperType type) +{ + AudioProcessor::setTypeOfNextNewPlugin (type); + AudioProcessor* const pluginInstance = createPluginFilter(); + AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::wrapperType_Undefined); + + // your createPluginFilter() method must return an object! + jassert (pluginInstance != nullptr && pluginInstance->wrapperType == type); + + return pluginInstance; +} diff --git a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp index 32f992a54..cbd25424a 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.h b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.h index befb802ca..2b14d3614 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -77,6 +76,9 @@ public: /** Returns a readable version of the name of the plugin that this identifier refers to. */ virtual String getNameOfPluginFromIdentifier (const String& fileOrIdentifier) = 0; + /** Returns true if this plugin's version or date has changed and it should be re-checked. */ + virtual bool pluginNeedsRescanning (const PluginDescription&) = 0; + /** Checks whether this plugin could possibly be loaded. It doesn't actually need to load it, just to check whether the file or component still exists. diff --git a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp index c802da1be..7535a721d 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -41,10 +40,6 @@ void AudioPluginFormatManager::addDefaultFormats() jassert (dynamic_cast <AudioUnitPluginFormat*> (formats[i]) == nullptr); #endif - #if JUCE_PLUGINHOST_DX && JUCE_WINDOWS - jassert (dynamic_cast <DirectXPluginFormat*> (formats[i]) == nullptr); - #endif - #if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX jassert (dynamic_cast <LADSPAPluginFormat*> (formats[i]) == nullptr); #endif @@ -59,10 +54,6 @@ void AudioPluginFormatManager::addDefaultFormats() formats.add (new VSTPluginFormat()); #endif - #if JUCE_PLUGINHOST_DX && JUCE_WINDOWS - formats.add (new DirectXPluginFormat()); - #endif - #if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX formats.add (new LADSPAPluginFormat()); #endif diff --git a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h index 674319239..d500133d5 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h index c9201335e..5cbd2c603 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -47,6 +46,7 @@ public: AudioPluginInstance* createInstanceFromDescription (const PluginDescription& desc); bool fileMightContainThisPluginType (const String& fileOrIdentifier); String getNameOfPluginFromIdentifier (const String& fileOrIdentifier); + bool pluginNeedsRescanning (const PluginDescription&); StringArray searchPathsForPlugins (const FileSearchPath&, bool recursive); bool doesPluginStillExist (const PluginDescription&); FileSearchPath getDefaultLocationsToSearch(); diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index ef5cb5f5d..40a40ede7 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -52,9 +51,9 @@ namespace juce #endif #if AU_LOGGING - #define log(a) Logger::writeToLog(a); + #define JUCE_AU_LOG(a) Logger::writeToLog(a); #else - #define log(a) + #define JUCE_AU_LOG(a) #endif namespace AudioUnitFormatHelpers @@ -85,7 +84,7 @@ namespace AudioUnitFormatHelpers static const char* auIdentifierPrefix = "AudioUnit:"; - String createAUPluginIdentifier (const ComponentDescription& desc) + String createPluginIdentifier (const AudioComponentDescription& desc) { jassert (osTypeToString ('abcd') == "abcd"); // agh, must have got the endianness wrong.. jassert (stringToOSType ("abcd") == (OSType) 'abcd'); // ditto @@ -109,48 +108,30 @@ namespace AudioUnitFormatHelpers return s; } - void getAUDetails (ComponentRecord* comp, String& name, String& manufacturer) + void getNameAndManufacturer (AudioComponent comp, String& name, String& manufacturer) { - Handle componentNameHandle = NewHandle (sizeof (void*)); - Handle componentInfoHandle = NewHandle (sizeof (void*)); - - if (componentNameHandle != 0 && componentInfoHandle != 0) + CFStringRef cfName; + if (AudioComponentCopyName (comp, &cfName) == noErr) { - ComponentDescription desc; - - if (GetComponentInfo (comp, &desc, componentNameHandle, componentInfoHandle, 0) == noErr) - { - ConstStr255Param nameString = (ConstStr255Param) (*componentNameHandle); - ConstStr255Param infoString = (ConstStr255Param) (*componentInfoHandle); - - if (nameString != 0 && nameString[0] != 0) - { - const String all ((const char*) nameString + 1, nameString[0]); - DBG ("name: " + all); - - manufacturer = all.upToFirstOccurrenceOf (":", false, false).trim(); - name = all.fromFirstOccurrenceOf (":", false, false).trim(); - } + name = String::fromCFString (cfName); + CFRelease (cfName); - if (infoString != 0 && infoString[0] != 0) - { - DBG ("info: " + String ((const char*) infoString + 1, infoString[0])); - } - - if (name.isEmpty()) - name = "<Unknown>"; - } + DBG ("AU name: " + name); + } - DisposeHandle (componentNameHandle); - DisposeHandle (componentInfoHandle); + if (name.containsChar (':')) + { + manufacturer = name.upToFirstOccurrenceOf (":", false, false).trim(); + name = name.fromFirstOccurrenceOf (":", false, false).trim(); } + + if (name.isEmpty()) + name = "<Unknown>"; } - bool getComponentDescFromIdentifier (const String& fileOrIdentifier, ComponentDescription& desc, + bool getComponentDescFromIdentifier (const String& fileOrIdentifier, AudioComponentDescription& desc, String& name, String& version, String& manufacturer) { - zerostruct (desc); - if (fileOrIdentifier.startsWithIgnoreCase (auIdentifierPrefix)) { String s (fileOrIdentifier.substring (jmax (fileOrIdentifier.lastIndexOfChar (':'), @@ -162,13 +143,30 @@ namespace AudioUnitFormatHelpers if (tokens.size() == 3) { + zerostruct (desc); desc.componentType = stringToOSType (tokens[0]); desc.componentSubType = stringToOSType (tokens[1]); desc.componentManufacturer = stringToOSType (tokens[2]); - if (ComponentRecord* comp = FindNextComponent (0, &desc)) + if (AudioComponent comp = AudioComponentFindNext (0, &desc)) { - getAUDetails (comp, name, manufacturer); + getNameAndManufacturer (comp, name, manufacturer); + + if (manufacturer.isEmpty()) + manufacturer = tokens[2]; + + if (version.isEmpty()) + { + UInt32 versionNum; + + if (AudioComponentGetVersion (comp, &versionNum) == noErr) + { + version << (int) (versionNum >> 16) << "." + << (int) ((versionNum >> 8) & 0xff) << "." + << (int) (versionNum & 0xff); + } + } + return true; } } @@ -177,14 +175,11 @@ namespace AudioUnitFormatHelpers return false; } - bool getComponentDescFromFile (const String& fileOrIdentifier, ComponentDescription& desc, + bool getComponentDescFromFile (const String& fileOrIdentifier, AudioComponentDescription& desc, String& name, String& version, String& manufacturer) { zerostruct (desc); - if (getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer)) - return true; - const File file (fileOrIdentifier); if (! file.hasFileExtension (".component")) return false; @@ -236,6 +231,10 @@ namespace AudioUnitFormatHelpers desc.componentType = types[0]; desc.componentSubType = types[1]; desc.componentManufacturer = types[2]; + + if (AudioComponent comp = AudioComponentFindNext (0, &desc)) + getNameAndManufacturer (comp, name, manufacturer); + break; } @@ -287,35 +286,29 @@ public: numOutputBusChannels (0), numInputBusses (0), numOutputBusses (0), - audioUnit (0), + audioUnit (nullptr), parameterListenerRef (0), midiConcatenator (2048) { using namespace AudioUnitFormatHelpers; - try - { - ++insideCallback; + ++insideCallback; - log ("Opening AU: " + fileOrIdentifier); + JUCE_AU_LOG ("Opening AU: " + fileOrIdentifier); - if (getComponentDescFromFile (fileOrIdentifier, componentDesc, pluginName, version, manufacturer)) + if (getComponentDescFromIdentifier (fileOrIdentifier, componentDesc, pluginName, version, manufacturer) + || getComponentDescFromFile (fileOrIdentifier, componentDesc, pluginName, version, manufacturer)) + { + if (AudioComponent comp = AudioComponentFindNext (0, &componentDesc)) { - if (ComponentRecord* const comp = FindNextComponent (0, &componentDesc)) - { - audioUnit = (AudioUnit) OpenComponent (comp); + AudioComponentInstanceNew (comp, &audioUnit); - wantsMidiMessages = componentDesc.componentType == kAudioUnitType_MusicDevice - || componentDesc.componentType == kAudioUnitType_MusicEffect; - } + wantsMidiMessages = componentDesc.componentType == kAudioUnitType_MusicDevice + || componentDesc.componentType == kAudioUnitType_MusicEffect; } - - --insideCallback; - } - catch (...) - { - --insideCallback; } + + --insideCallback; } ~AudioUnitPluginInstance() @@ -330,13 +323,13 @@ public: parameterListenerRef = 0; } - if (audioUnit != 0) + if (audioUnit != nullptr) { if (prepared) releaseResources(); - CloseComponent (audioUnit); - audioUnit = 0; + AudioComponentInstanceDispose (audioUnit); + audioUnit = nullptr; } } @@ -358,7 +351,7 @@ public: { desc.name = pluginName; desc.descriptiveName = pluginName; - desc.fileOrIdentifier = AudioUnitFormatHelpers::createAUPluginIdentifier (componentDesc); + desc.fileOrIdentifier = AudioUnitFormatHelpers::createPluginIdentifier (componentDesc); desc.uid = ((int) componentDesc.componentType) ^ ((int) componentDesc.componentSubType) ^ ((int) componentDesc.componentManufacturer); @@ -385,7 +378,7 @@ public: Float64 tail = 0; UInt32 tailSize = sizeof (tail); - if (audioUnit != 0) + if (audioUnit != nullptr) AudioUnitGetProperty (audioUnit, kAudioUnitProperty_TailTime, kAudioUnitScope_Global, 0, &tail, &tailSize); @@ -398,16 +391,16 @@ public: //============================================================================== // AudioProcessor methods: - void prepareToPlay (double sampleRate_, int estimatedSamplesPerBlock) + void prepareToPlay (double newSampleRate, int estimatedSamplesPerBlock) { - if (audioUnit != 0) + if (audioUnit != nullptr) { releaseResources(); updateNumChannels(); Float64 sampleRateIn = 0, sampleRateOut = 0; UInt32 sampleRateSize = sizeof (sampleRateIn); - const Float64 sr = sampleRate_; + const Float64 sr = newSampleRate; for (int i = 0; i < numInputBusses; ++i) { @@ -431,24 +424,19 @@ public: setPlayConfigDetails (numInputBusChannels * numInputBusses, numOutputBusChannels * numOutputBusses, - sampleRate_, estimatedSamplesPerBlock); + newSampleRate, estimatedSamplesPerBlock); Float64 latencySecs = 0.0; UInt32 latencySize = sizeof (latencySecs); AudioUnitGetProperty (audioUnit, kAudioUnitProperty_Latency, kAudioUnitScope_Global, 0, &latencySecs, &latencySize); - setLatencySamples (roundToInt (latencySecs * sampleRate_)); - - for (int i = 0; i < numInputBusses; ++i) AudioUnitReset (audioUnit, kAudioUnitScope_Input, i); - for (int i = 0; i < numOutputBusses; ++i) AudioUnitReset (audioUnit, kAudioUnitScope_Output, i); - - AudioUnitReset (audioUnit, kAudioUnitScope_Global, 0); + setLatencySamples (roundToInt (latencySecs * newSampleRate)); { AudioStreamBasicDescription stream; zerostruct (stream); // (can't use "= { 0 }" on this object because it's typedef'ed as a C struct) - stream.mSampleRate = sampleRate_; + stream.mSampleRate = sr; stream.mFormatID = kAudioFormatLinearPCM; stream.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kAudioFormatFlagIsNonInterleaved | kAudioFormatFlagsNativeEndian; stream.mFramesPerPacket = 1; @@ -479,6 +467,8 @@ public: currentBuffer = nullptr; wasPlaying = false; + resetBusses(); + prepared = (AudioUnitInitialize (audioUnit) == noErr); jassert (prepared); } @@ -489,10 +479,7 @@ public: if (prepared) { AudioUnitUninitialize (audioUnit); - - for (int i = 0; i < numInputBusses; ++i) AudioUnitReset (audioUnit, kAudioUnitScope_Input, i); - for (int i = 0; i < numOutputBusses; ++i) AudioUnitReset (audioUnit, kAudioUnitScope_Output, i); - + resetBusses(); AudioUnitReset (audioUnit, kAudioUnitScope_Global, 0); outputBufferList.free(); @@ -503,6 +490,12 @@ public: incomingMidi.clear(); } + void resetBusses() + { + for (int i = 0; i < numInputBusses; ++i) AudioUnitReset (audioUnit, kAudioUnitScope_Input, i); + for (int i = 0; i < numOutputBusses; ++i) AudioUnitReset (audioUnit, kAudioUnitScope_Output, i); + } + void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) { const int numSamples = buffer.getNumSamples(); @@ -530,9 +523,8 @@ public: { const uint8* midiEventData; int midiEventSize, midiEventPosition; - MidiBuffer::Iterator i (midiMessages); - while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition)) + for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (midiEventData, midiEventSize, midiEventPosition);) { if (midiEventSize <= 3) MusicDeviceMIDIEvent (audioUnit, @@ -545,10 +537,12 @@ public: midiMessages.clear(); } - AudioUnitRenderActionFlags flags = 0; for (int i = 0; i < numOutputBusses; ++i) + { + AudioUnitRenderActionFlags flags = 0; AudioUnitRender (audioUnit, &flags, &timeStamp, i, numSamples, getAudioBufferListForBus (i)); + } timeStamp.mSampleTime += numSamples; } @@ -600,7 +594,7 @@ public: AudioUnitParameterValue value = 0; - if (audioUnit != 0) + if (audioUnit != nullptr) { if (const ParamInfo* p = parameters[index]) { @@ -620,7 +614,7 @@ public: { const ScopedLock sl (lock); - if (audioUnit != 0) + if (audioUnit != nullptr) { if (const ParamInfo* p = parameters[index]) { @@ -634,7 +628,7 @@ public: void sendParameterChangeEvent (int index) { - jassert (audioUnit != 0); + jassert (audioUnit != nullptr); const ParamInfo& p = *parameters.getUnchecked (index); @@ -815,7 +809,7 @@ public: { parameters.clear(); - if (audioUnit != 0) + if (audioUnit != nullptr) { UInt32 paramListSize = 0; AudioUnitGetProperty (audioUnit, kAudioUnitProperty_ParameterList, kAudioUnitScope_Global, @@ -879,7 +873,7 @@ private: friend class AudioUnitPluginWindowCocoa; friend class AudioUnitPluginFormat; - ComponentDescription componentDesc; + AudioComponentDescription componentDesc; String pluginName, manufacturer, version; String fileOrIdentifier; CriticalSection lock; @@ -909,7 +903,7 @@ private: void setPluginCallbacks() { - if (audioUnit != 0) + if (audioUnit != nullptr) { { AURenderCallbackStruct info; @@ -1365,7 +1359,7 @@ private: { { // This forces CoreAudio.component to be loaded, otherwise the AUGenericView will assert - ComponentDescription desc; + AudioComponentDescription desc; String name, version, manufacturer; AudioUnitFormatHelpers::getComponentDescFromIdentifier ("AudioUnit:Output/auou,genr,appl", desc, name, version, manufacturer); @@ -1395,8 +1389,8 @@ public: AudioUnitPluginWindowCarbon (AudioUnitPluginInstance& plugin_) : AudioProcessorEditor (&plugin_), plugin (plugin_), - componentRecord (nullptr), - viewComponent (0) + audioComponent (nullptr), + viewComponent (nullptr) { addAndMakeVisible (innerWrapper = new InnerWrapperComponent (*this)); @@ -1409,12 +1403,12 @@ public: kAudioUnitScope_Global, 0, &propertySize, NULL) == noErr && propertySize > 0) { - HeapBlock<ComponentDescription> views (propertySize / sizeof (ComponentDescription)); + HeapBlock<AudioComponentDescription> views (propertySize / sizeof (AudioComponentDescription)); if (AudioUnitGetProperty (plugin.audioUnit, kAudioUnitProperty_GetUIComponentList, kAudioUnitScope_Global, 0, &views[0], &propertySize) == noErr) { - componentRecord = FindNextComponent (0, &views[0]); + audioComponent = AudioComponentFindNext (nullptr, &views[0]); } } } @@ -1427,7 +1421,7 @@ public: plugin.editorBeingDeleted (this); } - bool isValid() const noexcept { return componentRecord != nullptr; } + bool isValid() const noexcept { return audioComponent != nullptr; } //============================================================================== void paint (Graphics& g) @@ -1450,27 +1444,27 @@ public: AudioUnitCarbonView getViewComponent() { - if (viewComponent == 0 && componentRecord != nullptr) - viewComponent = (AudioUnitCarbonView) OpenComponent (componentRecord); + if (viewComponent == nullptr && audioComponent != nullptr) + AudioComponentInstanceNew (audioComponent, &viewComponent); return viewComponent; } void closeViewComponent() { - if (viewComponent != 0) + if (viewComponent != nullptr) { - log ("Closing AU GUI: " + plugin.getName()); + JUCE_AU_LOG ("Closing AU GUI: " + plugin.getName()); - CloseComponent (viewComponent); - viewComponent = 0; + AudioComponentInstanceDispose (viewComponent); + viewComponent = nullptr; } } private: //============================================================================== AudioUnitPluginInstance& plugin; - ComponentRecord* componentRecord; + AudioComponent audioComponent; AudioUnitCarbonView viewComponent; //============================================================================== @@ -1489,7 +1483,7 @@ private: HIViewRef attachView (WindowRef windowRef, HIViewRef rootView) { - log ("Opening AU GUI: " + owner.plugin.getName()); + JUCE_AU_LOG ("Opening AU GUI: " + owner.plugin.getName()); AudioUnitCarbonView carbonView = owner.getViewComponent(); @@ -1598,7 +1592,7 @@ AudioPluginInstance* AudioUnitPluginFormat::createInstanceFromDescription (const { ScopedPointer <AudioUnitPluginInstance> result (new AudioUnitPluginInstance (desc.fileOrIdentifier)); - if (result->audioUnit != 0) + if (result->audioUnit != nullptr) { result->initialise(); return result.release(); @@ -1612,19 +1606,19 @@ StringArray AudioUnitPluginFormat::searchPathsForPlugins (const FileSearchPath& const bool /*recursive*/) { StringArray result; - ComponentRecord* comp = nullptr; + AudioComponent comp = nullptr; for (;;) { - ComponentDescription desc; + AudioComponentDescription desc; zerostruct (desc); - comp = FindNextComponent (comp, &desc); + comp = AudioComponentFindNext (comp, &desc); - if (comp == 0) + if (comp == nullptr) break; - GetComponentInfo (comp, &desc, 0, 0, 0); + AudioComponentGetDescription (comp, &desc); if (desc.componentType == kAudioUnitType_MusicDevice || desc.componentType == kAudioUnitType_MusicEffect @@ -1632,7 +1626,7 @@ StringArray AudioUnitPluginFormat::searchPathsForPlugins (const FileSearchPath& || desc.componentType == kAudioUnitType_Generator || desc.componentType == kAudioUnitType_Panner) { - const String s (AudioUnitFormatHelpers::createAUPluginIdentifier (desc)); + const String s (AudioUnitFormatHelpers::createPluginIdentifier (desc)); DBG (s); result.add (s); } @@ -1643,11 +1637,11 @@ StringArray AudioUnitPluginFormat::searchPathsForPlugins (const FileSearchPath& bool AudioUnitPluginFormat::fileMightContainThisPluginType (const String& fileOrIdentifier) { - ComponentDescription desc; + AudioComponentDescription desc; String name, version, manufacturer; if (AudioUnitFormatHelpers::getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer)) - return FindNextComponent (0, &desc) != 0; + return AudioComponentFindNext (nullptr, &desc) != nullptr; const File f (File::createFileWithoutCheckingPath (fileOrIdentifier)); @@ -1657,7 +1651,7 @@ bool AudioUnitPluginFormat::fileMightContainThisPluginType (const String& fileOr String AudioUnitPluginFormat::getNameOfPluginFromIdentifier (const String& fileOrIdentifier) { - ComponentDescription desc; + AudioComponentDescription desc; String name, version, manufacturer; AudioUnitFormatHelpers::getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer); @@ -1667,6 +1661,16 @@ String AudioUnitPluginFormat::getNameOfPluginFromIdentifier (const String& fileO return name; } +bool AudioUnitPluginFormat::pluginNeedsRescanning (const PluginDescription& desc) +{ + AudioComponentDescription newDesc; + String name, version, manufacturer; + + return ! (AudioUnitFormatHelpers::getComponentDescFromIdentifier (desc.fileOrIdentifier, newDesc, + name, version, manufacturer) + && version == desc.version); +} + bool AudioUnitPluginFormat::doesPluginStillExist (const PluginDescription& desc) { if (desc.fileOrIdentifier.startsWithIgnoreCase (AudioUnitFormatHelpers::auIdentifierPrefix)) @@ -1680,6 +1684,6 @@ FileSearchPath AudioUnitPluginFormat::getDefaultLocationsToSearch() return FileSearchPath(); } -#undef log +#undef JUCE_AU_LOG #endif diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_DirectXPluginFormat.h b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_DirectXPluginFormat.h deleted file mode 100644 index 6e794f7e4..000000000 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_DirectXPluginFormat.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. - - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - ------------------------------------------------------------------------------ - - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. - - ============================================================================== -*/ - -#ifndef __JUCE_DIRECTXPLUGINFORMAT_JUCEHEADER__ -#define __JUCE_DIRECTXPLUGINFORMAT_JUCEHEADER__ - -#include "../format/juce_AudioPluginFormat.h" - -#if JUCE_PLUGINHOST_DX && JUCE_WINDOWS - - -// Sorry, this file is just a placeholder at the moment!... - - -//============================================================================== -/** - Implements a plugin format manager for DirectX plugins. -*/ -class JUCE_API DirectXPluginFormat : public AudioPluginFormat -{ -public: - //============================================================================== - DirectXPluginFormat(); - ~DirectXPluginFormat(); - - //============================================================================== - String getName() const { return "DirectX"; } - void findAllTypesForFile (OwnedArray <PluginDescription>&, const String& fileOrIdentifier); - AudioPluginInstance* createInstanceFromDescription (const PluginDescription&); - bool fileMightContainThisPluginType (const String& fileOrIdentifier); - String getNameOfPluginFromIdentifier (const String& fileOrIdentifier) { return fileOrIdentifier; } - FileSearchPath getDefaultLocationsToSearch(); - bool canScanForPlugins() const { return true; } - -private: - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectXPluginFormat) -}; - -#endif - -#endif // __JUCE_DIRECTXPLUGINFORMAT_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp new file mode 100644 index 000000000..9a8aee290 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp @@ -0,0 +1,705 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +#if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX + +} // (juce namespace) + +#include <ladspa.h> + +namespace juce +{ + +static int shellLADSPAUIDToCreate = 0; +static int insideLADSPACallback = 0; + +#define JUCE_LADSPA_LOGGING 1 + +#if JUCE_LADSPA_LOGGING + #define JUCE_LADSPA_LOG(x) Logger::writeToLog (x); +#else + #define JUCE_LADSPA_LOG(x) +#endif + +//============================================================================== +class LADSPAModuleHandle : public ReferenceCountedObject +{ +public: + LADSPAModuleHandle (const File& f) + : file (f), moduleMain (nullptr) + { + getActiveModules().add (this); + } + + ~LADSPAModuleHandle() + { + getActiveModules().removeFirstMatchingValue (this); + close(); + } + + typedef ReferenceCountedObjectPtr<LADSPAModuleHandle> Ptr; + + static Array <LADSPAModuleHandle*>& getActiveModules() + { + static Array <LADSPAModuleHandle*> activeModules; + return activeModules; + } + + static LADSPAModuleHandle* findOrCreateModule (const File& file) + { + for (int i = getActiveModules().size(); --i >= 0;) + { + LADSPAModuleHandle* const module = getActiveModules().getUnchecked(i); + + if (module->file == file) + return module; + } + + ++insideLADSPACallback; + shellLADSPAUIDToCreate = 0; + + JUCE_LADSPA_LOG ("Loading LADSPA module: " + file.getFullPathName()); + + ScopedPointer<LADSPAModuleHandle> m (new LADSPAModuleHandle (file)); + + if (! m->open()) + m = nullptr; + + --insideLADSPACallback; + + return m.release(); + } + + File file; + LADSPA_Descriptor_Function moduleMain; + +private: + DynamicLibrary module; + + bool open() + { + module.open (file.getFullPathName()); + moduleMain = (LADSPA_Descriptor_Function) module.getFunction ("ladspa_descriptor"); + return moduleMain != nullptr; + } + + void close() + { + module.close(); + } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LADSPAModuleHandle) +}; + + +//============================================================================== +class LADSPAPluginInstance : public AudioPluginInstance +{ +public: + LADSPAPluginInstance (const LADSPAModuleHandle::Ptr& m) + : plugin (nullptr), handle (nullptr), initialised (false), + tempBuffer (1, 1), module (m) + { + ++insideLADSPACallback; + + name = module->file.getFileNameWithoutExtension(); + + JUCE_LADSPA_LOG ("Creating LADSPA instance: " + name); + + if (module->moduleMain != nullptr) + { + plugin = module->moduleMain (shellLADSPAUIDToCreate); + + if (plugin == nullptr) + { + JUCE_LADSPA_LOG ("Cannot find any valid descriptor in shared library"); + --insideLADSPACallback; + return; + } + } + else + { + JUCE_LADSPA_LOG ("Cannot find any valid plugin in shared library"); + --insideLADSPACallback; + return; + } + + const double sampleRate = getSampleRate() > 0 ? getSampleRate() : 44100.0; + + handle = plugin->instantiate (plugin, (uint32) sampleRate); + + --insideLADSPACallback; + } + + ~LADSPAPluginInstance() + { + const ScopedLock sl (lock); + + jassert (insideLADSPACallback == 0); + + if (handle != nullptr && plugin != nullptr && plugin->cleanup != nullptr) + plugin->cleanup (handle); + + initialised = false; + module = nullptr; + plugin = nullptr; + handle = nullptr; + } + + void initialise() + { + if (initialised || plugin == nullptr || handle == nullptr) + return; + + JUCE_LADSPA_LOG ("Initialising LADSPA: " + name); + + initialised = true; + + inputs.clear(); + outputs.clear(); + parameters.clear(); + + for (unsigned int i = 0; i < plugin->PortCount; ++i) + { + const LADSPA_PortDescriptor portDesc = plugin->PortDescriptors[i]; + + if ((portDesc & LADSPA_PORT_CONTROL) != 0) + parameters.add (i); + + if ((portDesc & LADSPA_PORT_AUDIO) != 0) + { + if ((portDesc & LADSPA_PORT_INPUT) != 0) inputs.add (i); + if ((portDesc & LADSPA_PORT_OUTPUT) != 0) outputs.add (i); + } + } + + parameterValues.calloc (parameters.size()); + + for (int i = 0; i < parameters.size(); ++i) + plugin->connect_port (handle, parameters[i], &(parameterValues[i].scaled)); + + setPlayConfigDetails (inputs.size(), outputs.size(), + getSampleRate() > 0 ? getSampleRate() : 44100.0f, + getBlockSize() > 0 ? getBlockSize() : 512); + + setCurrentProgram (0); + setLatencySamples (0); + + // Some plugins crash if this doesn't happen: + if (plugin->activate != nullptr) plugin->activate (handle); + if (plugin->deactivate != nullptr) plugin->deactivate (handle); + } + + //============================================================================== + // AudioPluginInstance methods: + + void fillInPluginDescription (PluginDescription& desc) const + { + desc.name = getName(); + desc.fileOrIdentifier = module->file.getFullPathName(); + desc.uid = getUID(); + desc.lastFileModTime = module->file.getLastModificationTime(); + desc.pluginFormatName = "LADSPA"; + desc.category = getCategory(); + desc.manufacturerName = plugin != nullptr ? String (plugin->Maker) : String::empty; + desc.version = getVersion(); + desc.numInputChannels = getNumInputChannels(); + desc.numOutputChannels = getNumOutputChannels(); + desc.isInstrument = false; + } + + const String getName() const + { + if (plugin != nullptr && plugin->Label != nullptr) + return plugin->Label; + + return name; + } + + int getUID() const + { + if (plugin != nullptr && plugin->UniqueID != 0) + return (int) plugin->UniqueID; + + return module->file.hashCode(); + } + + String getVersion() const { return LADSPA_VERSION; } + String getCategory() const { return "Effect"; } + + bool acceptsMidi() const { return false; } + bool producesMidi() const { return false; } + + bool silenceInProducesSilenceOut() const { return plugin == nullptr; } // ..any way to get a proper answer for these? + double getTailLengthSeconds() const { return 0.0; } + + //============================================================================== + void prepareToPlay (double newSampleRate, int samplesPerBlockExpected) + { + setPlayConfigDetails (inputs.size(), outputs.size(), + newSampleRate, samplesPerBlockExpected); + + setLatencySamples (0); + + initialise(); + + if (initialised) + { + tempBuffer.setSize (jmax (1, outputs.size()), samplesPerBlockExpected); + + // dodgy hack to force some plugins to initialise the sample rate.. + if (getNumParameters() > 0) + { + const float old = getParameter (0); + setParameter (0, (old < 0.5f) ? 1.0f : 0.0f); + setParameter (0, old); + } + + if (plugin->activate != nullptr) + plugin->activate (handle); + } + } + + void releaseResources() + { + if (handle != nullptr && plugin->deactivate != nullptr) + plugin->deactivate (handle); + + tempBuffer.setSize (1, 1); + } + + void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) + { + const int numSamples = buffer.getNumSamples(); + + if (initialised && plugin != nullptr && handle != nullptr) + { + for (int i = 0; i < inputs.size(); ++i) + plugin->connect_port (handle, inputs[i], + i < buffer.getNumChannels() ? buffer.getSampleData (i) : nullptr); + + if (plugin->run != nullptr) + { + for (int i = 0; i < outputs.size(); ++i) + plugin->connect_port (handle, outputs.getUnchecked(i), + i < buffer.getNumChannels() ? buffer.getSampleData (i) : nullptr); + + plugin->run (handle, numSamples); + return; + } + + if (plugin->run_adding != nullptr) + { + tempBuffer.setSize (outputs.size(), numSamples); + tempBuffer.clear(); + + for (int i = 0; i < outputs.size(); ++i) + plugin->connect_port (handle, outputs.getUnchecked(i), tempBuffer.getSampleData (i)); + + plugin->run_adding (handle, numSamples); + + for (int i = 0; i < outputs.size(); ++i) + if (i < buffer.getNumChannels()) + buffer.copyFrom (i, 0, tempBuffer, i, 0, numSamples); + + return; + } + + jassertfalse; // no callback to use? + } + + for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i) + buffer.clear (i, 0, numSamples); + } + + bool isInputChannelStereoPair (int index) const { return isPositiveAndBelow (index, getNumInputChannels()); } + bool isOutputChannelStereoPair (int index) const { return isPositiveAndBelow (index, getNumInputChannels()); } + + const String getInputChannelName (const int index) const + { + if (isPositiveAndBelow (index, getNumInputChannels())) + return String (plugin->PortNames [inputs [index]]).trim(); + + return String::empty; + } + + const String getOutputChannelName (const int index) const + { + if (isPositiveAndBelow (index, getNumInputChannels())) + return String (plugin->PortNames [outputs [index]]).trim(); + + return String::empty; + } + + //============================================================================== + int getNumParameters() { return handle != nullptr ? parameters.size() : 0; } + + bool isParameterAutomatable (int index) const + { + return plugin != nullptr + && (plugin->PortDescriptors [parameters[index]] & LADSPA_PORT_INPUT) != 0; + } + + float getParameter (int index) + { + if (plugin != nullptr && isPositiveAndBelow (index, parameters.size())) + { + const ScopedLock sl (lock); + return parameterValues[index].unscaled; + } + + return 0.0f; + } + + void setParameter (int index, float newValue) + { + if (plugin != nullptr && isPositiveAndBelow (index, parameters.size())) + { + const ScopedLock sl (lock); + + ParameterValue& p = parameterValues[index]; + + if (p.unscaled != newValue) + p = ParameterValue (getNewParamScaled (plugin->PortRangeHints [parameters[index]], newValue), newValue); + } + } + + const String getParameterName (int index) + { + if (plugin != nullptr) + { + jassert (isPositiveAndBelow (index, parameters.size())); + return String (plugin->PortNames [parameters [index]]).trim(); + } + + return String::empty; + } + + const String getParameterText (int index) + { + if (plugin != nullptr) + { + jassert (index >= 0 && index < parameters.size()); + + const LADSPA_PortRangeHint& hint = plugin->PortRangeHints [parameters [index]]; + + if (LADSPA_IS_HINT_INTEGER (hint.HintDescriptor)) + return String ((int) parameterValues[index].scaled); + + return String (parameterValues[index].scaled, 4); + } + + return String::empty; + } + + //============================================================================== + int getNumPrograms() { return 0; } + int getCurrentProgram() { return 0; } + + void setCurrentProgram (int newIndex) + { + if (plugin != nullptr) + for (int i = 0; i < parameters.size(); ++i) + parameterValues[i] = getParamValue (plugin->PortRangeHints [parameters[i]]); + } + + const String getProgramName (int index) + { + // XXX + return String::empty; + } + + void changeProgramName (int index, const String& newName) + { + // XXX + } + + //============================================================================== + void getStateInformation (MemoryBlock& destData) + { + destData.setSize (sizeof (float) * getNumParameters()); + destData.fillWith (0); + + float* const p = (float*) ((char*) destData.getData()); + for (int i = 0; i < getNumParameters(); ++i) + p[i] = getParameter(i); + } + + void getCurrentProgramStateInformation (MemoryBlock& destData) + { + getStateInformation (destData); + } + + void setStateInformation (const void* data, int sizeInBytes) + { + const float* p = static_cast <const float*> (data); + + for (int i = 0; i < getNumParameters(); ++i) + setParameter (i, p[i]); + } + + void setCurrentProgramStateInformation (const void* data, int sizeInBytes) + { + setStateInformation (data, sizeInBytes); + } + + bool hasEditor() const + { + return false; + } + + AudioProcessorEditor* createEditor() + { + return nullptr; + } + + bool isValid() const + { + return handle != nullptr; + } + + LADSPAModuleHandle::Ptr module; + const LADSPA_Descriptor* plugin; + +private: + LADSPA_Handle handle; + String name; + CriticalSection lock; + bool initialised; + AudioSampleBuffer tempBuffer; + Array<int> inputs, outputs, parameters; + + struct ParameterValue + { + inline ParameterValue() noexcept : scaled (0), unscaled (0) {} + inline ParameterValue (float s, float u) noexcept : scaled (s), unscaled (u) {} + + float scaled, unscaled; + }; + + HeapBlock<ParameterValue> parameterValues; + + //============================================================================== + static float scaledValue (float low, float high, float alpha, bool useLog) noexcept + { + if (useLog && low > 0 && high > 0) + return expf (logf (low) * (1.0f - alpha) + logf (high) * alpha); + + return low + (high - low) * alpha; + } + + static float toIntIfNecessary (const LADSPA_PortRangeHintDescriptor& desc, float value) + { + return LADSPA_IS_HINT_INTEGER (desc) ? ((float) (int) value) : value; + } + + float getNewParamScaled (const LADSPA_PortRangeHint& hint, float newValue) const + { + const LADSPA_PortRangeHintDescriptor& desc = hint.HintDescriptor; + + if (LADSPA_IS_HINT_TOGGLED (desc)) + return (newValue < 0.5f) ? 0.0f : 1.0f; + + const float scale = LADSPA_IS_HINT_SAMPLE_RATE (desc) ? (float) getSampleRate() : 1.0f; + const float lower = hint.LowerBound * scale; + const float upper = hint.UpperBound * scale; + + if (LADSPA_IS_HINT_BOUNDED_BELOW (desc) && LADSPA_IS_HINT_BOUNDED_ABOVE (desc)) + return toIntIfNecessary (desc, scaledValue (lower, upper, newValue, LADSPA_IS_HINT_LOGARITHMIC (desc))); + + if (LADSPA_IS_HINT_BOUNDED_BELOW (desc)) return toIntIfNecessary (desc, newValue); + if (LADSPA_IS_HINT_BOUNDED_ABOVE (desc)) return toIntIfNecessary (desc, newValue * upper); + + return 0.0f; + } + + ParameterValue getParamValue (const LADSPA_PortRangeHint& hint) const + { + const LADSPA_PortRangeHintDescriptor& desc = hint.HintDescriptor; + + if (LADSPA_IS_HINT_HAS_DEFAULT (desc)) + { + if (LADSPA_IS_HINT_DEFAULT_0 (desc)) return ParameterValue(); + if (LADSPA_IS_HINT_DEFAULT_1 (desc)) return ParameterValue (1.0f, 1.0f); + if (LADSPA_IS_HINT_DEFAULT_100 (desc)) return ParameterValue (100.0f, 0.5f); + if (LADSPA_IS_HINT_DEFAULT_440 (desc)) return ParameterValue (440.0f, 0.5f); + + const float scale = LADSPA_IS_HINT_SAMPLE_RATE (desc) ? (float) getSampleRate() : 1.0f; + const float lower = hint.LowerBound * scale; + const float upper = hint.UpperBound * scale; + + if (LADSPA_IS_HINT_BOUNDED_BELOW (desc) && LADSPA_IS_HINT_DEFAULT_MINIMUM (desc)) return ParameterValue (lower, 0.0f); + if (LADSPA_IS_HINT_BOUNDED_ABOVE (desc) && LADSPA_IS_HINT_DEFAULT_MAXIMUM (desc)) return ParameterValue (upper, 1.0f); + + if (LADSPA_IS_HINT_BOUNDED_BELOW (desc)) + { + const bool useLog = LADSPA_IS_HINT_LOGARITHMIC (desc); + + if (LADSPA_IS_HINT_DEFAULT_LOW (desc)) return ParameterValue (scaledValue (lower, upper, 0.25f, useLog), 0.25f); + if (LADSPA_IS_HINT_DEFAULT_MIDDLE (desc)) return ParameterValue (scaledValue (lower, upper, 0.50f, useLog), 0.50f); + if (LADSPA_IS_HINT_DEFAULT_HIGH (desc)) return ParameterValue (scaledValue (lower, upper, 0.75f, useLog), 0.75f); + } + } + + return ParameterValue(); + } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LADSPAPluginInstance) +}; + + +//============================================================================== +//============================================================================== +LADSPAPluginFormat::LADSPAPluginFormat() {} +LADSPAPluginFormat::~LADSPAPluginFormat() {} + +void LADSPAPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& results, + const String& fileOrIdentifier) +{ + if (! fileMightContainThisPluginType (fileOrIdentifier)) + return; + + PluginDescription desc; + desc.fileOrIdentifier = fileOrIdentifier; + desc.uid = 0; + + ScopedPointer<LADSPAPluginInstance> instance (dynamic_cast <LADSPAPluginInstance*> (createInstanceFromDescription (desc))); + + if (instance == nullptr || ! instance->isValid()) + return; + + instance->initialise(); + + instance->fillInPluginDescription (desc); + + if (instance->module->moduleMain != nullptr) + { + for (int uid = 0;; ++uid) + { + if (const LADSPA_Descriptor* plugin = instance->module->moduleMain (uid)) + { + desc.uid = uid; + desc.name = plugin->Name != nullptr ? plugin->Name : "Unknown"; + + if (! arrayContainsPlugin (results, desc)) + results.add (new PluginDescription (desc)); + } + else + { + break; + } + } + } +} + +AudioPluginInstance* LADSPAPluginFormat::createInstanceFromDescription (const PluginDescription& desc) +{ + LADSPAPluginInstance* result = nullptr; + + if (fileMightContainThisPluginType (desc.fileOrIdentifier)) + { + File file (desc.fileOrIdentifier); + + const File previousWorkingDirectory (File::getCurrentWorkingDirectory()); + file.getParentDirectory().setAsCurrentWorkingDirectory(); + + const LADSPAModuleHandle::Ptr module (LADSPAModuleHandle::findOrCreateModule (file)); + + if (module != nullptr) + { + shellLADSPAUIDToCreate = desc.uid; + + result = new LADSPAPluginInstance (module); + + if (result->plugin != nullptr && result->isValid()) + result->initialise(); + else + deleteAndZero (result); + } + + previousWorkingDirectory.setAsCurrentWorkingDirectory(); + } + + return result; +} + +bool LADSPAPluginFormat::fileMightContainThisPluginType (const String& fileOrIdentifier) +{ + const File f (File::createFileWithoutCheckingPath (fileOrIdentifier)); + return f.existsAsFile() && f.hasFileExtension (".so"); +} + +String LADSPAPluginFormat::getNameOfPluginFromIdentifier (const String& fileOrIdentifier) +{ + return fileOrIdentifier; +} + +bool LADSPAPluginFormat::pluginNeedsRescanning (const PluginDescription& desc) +{ + return File (desc.fileOrIdentifier).getLastModificationTime() != desc.lastFileModTime; +} + +bool LADSPAPluginFormat::doesPluginStillExist (const PluginDescription& desc) +{ + return File::createFileWithoutCheckingPath (desc.fileOrIdentifier).exists(); +} + +StringArray LADSPAPluginFormat::searchPathsForPlugins (const FileSearchPath& directoriesToSearch, const bool recursive) +{ + StringArray results; + + for (int j = 0; j < directoriesToSearch.getNumPaths(); ++j) + recursiveFileSearch (results, directoriesToSearch[j], recursive); + + return results; +} + +void LADSPAPluginFormat::recursiveFileSearch (StringArray& results, const File& dir, const bool recursive) +{ + DirectoryIterator iter (dir, false, "*", File::findFilesAndDirectories); + + while (iter.next()) + { + const File f (iter.getFile()); + bool isPlugin = false; + + if (fileMightContainThisPluginType (f.getFullPathName())) + { + isPlugin = true; + results.add (f.getFullPathName()); + } + + if (recursive && (! isPlugin) && f.isDirectory()) + recursiveFileSearch (results, f, true); + } +} + +FileSearchPath LADSPAPluginFormat::getDefaultLocationsToSearch() +{ + return FileSearchPath (SystemStats::getEnvironmentVariable ("LADSPA_PATH", + "/usr/lib/ladspa;/usr/local/lib/ladspa;~/.ladspa") + .replace (":", ";")); +} + +#endif diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h index 598b5e9da..9da1450cd 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -28,15 +27,11 @@ #include "../format/juce_AudioPluginFormat.h" -#if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX - - -// Sorry, this file is just a placeholder at the moment!... - +#if (JUCE_PLUGINHOST_LADSPA && JUCE_LINUX) || DOXYGEN //============================================================================== /** - Implements a plugin format manager for DirectX plugins. + Implements a plugin format manager for LADSPA plugins. */ class JUCE_API LADSPAPluginFormat : public AudioPluginFormat { @@ -47,17 +42,23 @@ public: //============================================================================== String getName() const { return "LADSPA"; } - void findAllTypesForFile (OwnedArray <PluginDescription>& results, const String& fileOrIdentifier); - AudioPluginInstance* createInstanceFromDescription (const PluginDescription&); + void findAllTypesForFile (OwnedArray <PluginDescription>&, const String& fileOrIdentifier); + AudioPluginInstance* createInstanceFromDescription (const PluginDescription& desc); bool fileMightContainThisPluginType (const String& fileOrIdentifier); - String getNameOfPluginFromIdentifier (const String& fileOrIdentifier) { return fileOrIdentifier; } + String getNameOfPluginFromIdentifier (const String& fileOrIdentifier); + bool pluginNeedsRescanning (const PluginDescription&); + StringArray searchPathsForPlugins (const FileSearchPath&, bool recursive); + bool doesPluginStillExist (const PluginDescription&); FileSearchPath getDefaultLocationsToSearch(); bool canScanForPlugins() const { return true; } private: + void recursiveFileSearch (StringArray&, const File&, bool recursive); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LADSPAPluginFormat) }; + #endif #endif // __JUCE_LADSPAPLUGINFORMAT_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h index 60da48d2c..219764b2c 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 5647851f6..65afa0a18 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -33,7 +32,7 @@ #if JUCE_MAC static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) { - return FSPathMakeRef (reinterpret_cast <const UInt8*> (path.toUTF8().getAddress()), destFSRef, 0) == noErr; + return FSPathMakeRef (reinterpret_cast <const UInt8*> (path.toRawUTF8()), destFSRef, 0) == noErr; } #endif @@ -65,6 +64,10 @@ #include "juce_VSTMidiEventList.h" #if JUCE_MINGW + #ifndef WM_APPCOMMAND + #define WM_APPCOMMAND 0x0319 + #endif + extern "C" void _fpreset(); extern "C" void _clearfp(); #elif ! JUCE_WINDOWS @@ -85,64 +88,64 @@ const int fxbVersionNum = 1; struct fxProgram { - long chunkMagic; // 'CcnK' - long byteSize; // of this chunk, excl. magic + byteSize - long fxMagic; // 'FxCk' - long version; - long fxID; // fx unique id - long fxVersion; - long numParams; + VstInt32 chunkMagic; // 'CcnK' + VstInt32 byteSize; // of this chunk, excl. magic + byteSize + VstInt32 fxMagic; // 'FxCk' + VstInt32 version; + VstInt32 fxID; // fx unique id + VstInt32 fxVersion; + VstInt32 numParams; char prgName[28]; float params[1]; // variable no. of parameters }; struct fxSet { - long chunkMagic; // 'CcnK' - long byteSize; // of this chunk, excl. magic + byteSize - long fxMagic; // 'FxBk' - long version; - long fxID; // fx unique id - long fxVersion; - long numPrograms; + VstInt32 chunkMagic; // 'CcnK' + VstInt32 byteSize; // of this chunk, excl. magic + byteSize + VstInt32 fxMagic; // 'FxBk' + VstInt32 version; + VstInt32 fxID; // fx unique id + VstInt32 fxVersion; + VstInt32 numPrograms; char future[128]; fxProgram programs[1]; // variable no. of programs }; struct fxChunkSet { - long chunkMagic; // 'CcnK' - long byteSize; // of this chunk, excl. magic + byteSize - long fxMagic; // 'FxCh', 'FPCh', or 'FBCh' - long version; - long fxID; // fx unique id - long fxVersion; - long numPrograms; + VstInt32 chunkMagic; // 'CcnK' + VstInt32 byteSize; // of this chunk, excl. magic + byteSize + VstInt32 fxMagic; // 'FxCh', 'FPCh', or 'FBCh' + VstInt32 version; + VstInt32 fxID; // fx unique id + VstInt32 fxVersion; + VstInt32 numPrograms; char future[128]; - long chunkSize; + VstInt32 chunkSize; char chunk[8]; // variable }; struct fxProgramSet { - long chunkMagic; // 'CcnK' - long byteSize; // of this chunk, excl. magic + byteSize - long fxMagic; // 'FxCh', 'FPCh', or 'FBCh' - long version; - long fxID; // fx unique id - long fxVersion; - long numPrograms; + VstInt32 chunkMagic; // 'CcnK' + VstInt32 byteSize; // of this chunk, excl. magic + byteSize + VstInt32 fxMagic; // 'FxCh', 'FPCh', or 'FBCh' + VstInt32 version; + VstInt32 fxID; // fx unique id + VstInt32 fxVersion; + VstInt32 numPrograms; char name[28]; - long chunkSize; + VstInt32 chunkSize; char chunk[8]; // variable }; namespace { - long vst_swap (const long x) noexcept + VstInt32 vst_swap (const VstInt32 x) noexcept { #ifdef JUCE_LITTLE_ENDIAN - return (long) ByteOrder::swap ((uint32) x); + return (VstInt32) ByteOrder::swap ((uint32) x); #else return x; #endif @@ -493,7 +496,7 @@ public: if (file.hasFileExtension (".vst")) { - const char* const utf8 = file.getFullPathName().toUTF8().getAddress(); + const char* const utf8 = file.getFullPathName().toRawUTF8(); if (CFURLRef url = CFURLCreateFromFileSystemRepresentation (0, (const UInt8*) utf8, strlen (utf8), file.isDirectory())) @@ -556,7 +559,7 @@ public: { FSRef fn; - if (FSPathMakeRef ((UInt8*) file.getFullPathName().toUTF8().getAddress(), &fn, 0) == noErr) + if (FSPathMakeRef ((UInt8*) file.getFullPathName().toRawUTF8(), &fn, 0) == noErr) { resFileId = FSOpenResFile (&fn, fsRdPerm); @@ -578,7 +581,7 @@ public: DetachResource (resHandle); HLock (resHandle); - Ptr ptr; + ::Ptr ptr; Str255 errorText; OSErr err = GetMemFragment (*resHandle, GetHandleSize (resHandle), @@ -776,22 +779,17 @@ public: if (effect != nullptr && effect->magic == kEffectMagic) { - try - { - #if JUCE_MAC - if (module->resFileId != 0) - UseResFile (module->resFileId); - #endif + #if JUCE_MAC + if (module->resFileId != 0) + UseResFile (module->resFileId); + #endif - // Must delete any editors before deleting the plugin instance! - jassert (getActiveEditor() == 0); + // Must delete any editors before deleting the plugin instance! + jassert (getActiveEditor() == 0); - _fpreset(); // some dodgy plugs fuck around with this + _fpreset(); // some dodgy plugs fuck around with this - module->closeEffect (effect); - } - catch (...) - {} + module->closeEffect (effect); } module = nullptr; @@ -1048,36 +1046,21 @@ public: jlimit (0, numSamples - 1, samplePosition)); } - try - { - effect->dispatcher (effect, effProcessEvents, 0, 0, midiEventsToSend.events, 0); - } - catch (...) - {} + effect->dispatcher (effect, effProcessEvents, 0, 0, midiEventsToSend.events, 0); } _clearfp(); if ((effect->flags & effFlagsCanReplacing) != 0) { - try - { - effect->processReplacing (effect, buffer.getArrayOfChannels(), buffer.getArrayOfChannels(), numSamples); - } - catch (...) - {} + effect->processReplacing (effect, buffer.getArrayOfChannels(), buffer.getArrayOfChannels(), numSamples); } else { tempBuffer.setSize (effect->numOutputs, numSamples); tempBuffer.clear(); - try - { - effect->process (effect, buffer.getArrayOfChannels(), tempBuffer.getArrayOfChannels(), numSamples); - } - catch (...) - {} + effect->process (effect, buffer.getArrayOfChannels(), tempBuffer.getArrayOfChannels(), numSamples); for (int i = effect->numOutputs; --i >= 0;) buffer.copyFrom (i, 0, tempBuffer.getSampleData (i), numSamples); @@ -1165,14 +1148,8 @@ public: { if (effect != nullptr && isPositiveAndBelow (index, (int) effect->numParams)) { - try - { - const ScopedLock sl (lock); - return effect->getParameter (effect, index); - } - catch (...) - { - } + const ScopedLock sl (lock); + return effect->getParameter (effect, index); } return 0.0f; @@ -1182,16 +1159,10 @@ public: { if (effect != nullptr && isPositiveAndBelow (index, (int) effect->numParams)) { - try - { - const ScopedLock sl (lock); + const ScopedLock sl (lock); - if (effect->getParameter (effect, index) != newValue) - effect->setParameter (effect, index, newValue); - } - catch (...) - { - } + if (effect->getParameter (effect, index) != newValue) + effect->setParameter (effect, index, newValue); } } @@ -1245,7 +1216,7 @@ public: if (index == getCurrentProgram()) { if (getNumPrograms() > 0 && newName != getCurrentProgramName()) - dispatch (effSetProgramName, 0, 0, (void*) newName.substring (0, 24).toUTF8().getAddress(), 0.0f); + dispatch (effSetProgramName, 0, 0, (void*) newName.substring (0, 24).toRawUTF8(), 0.0f); } else { @@ -1573,7 +1544,7 @@ public: set->fxID = vst_swap (getUID()); set->fxVersion = vst_swap (getVersionNumber()); set->numPrograms = vst_swap (numPrograms); - set->chunkSize = vst_swap ((long) chunk.getSize()); + set->chunkSize = vst_swap ((VstInt32) chunk.getSize()); chunk.copyTo (set->chunk, 0, chunk.getSize()); } @@ -1590,7 +1561,7 @@ public: set->fxID = vst_swap (getUID()); set->fxVersion = vst_swap (getVersionNumber()); set->numPrograms = vst_swap (numPrograms); - set->chunkSize = vst_swap ((long) chunk.getSize()); + set->chunkSize = vst_swap ((VstInt32) chunk.getSize()); getCurrentProgramName().copyToUTF8 (set->name, sizeof (set->name) - 1); chunk.copyTo (set->chunk, 0, chunk.getSize()); @@ -1834,7 +1805,7 @@ private: #if JUCE_MAC return (VstIntPtr) (void*) &module->parentDirFSSpec; #else - return (VstIntPtr) (pointer_sized_uint) module->fullParentDirectoryPathName.toUTF8().getAddress(); + return (VstIntPtr) (pointer_sized_uint) module->fullParentDirectoryPathName.toRawUTF8(); #endif } @@ -1918,12 +1889,12 @@ class VSTPluginWindow : public AudioProcessorEditor, { public: //============================================================================== - VSTPluginWindow (VSTPluginInstance& plugin_) - : AudioProcessorEditor (&plugin_), + VSTPluginWindow (VSTPluginInstance& plug) + : AudioProcessorEditor (&plug), #if ! JUCE_MAC ComponentMovementWatcher (this), #endif - plugin (plugin_), + plugin (plug), isOpen (false), recursiveResize (false), pluginWantsKeys (false), @@ -1999,7 +1970,7 @@ public: { if (isShowing()) openPluginWindow(); - else + else if (! shouldAvoidDeletingWindow()) closePluginWindow(); componentMovedOrResized (true, true); @@ -2046,7 +2017,7 @@ public: { if (ComponentPeer* const peer = getPeer()) { - peer->addMaskedRegion (getScreenBounds() - peer->getScreenPosition()); + peer->addMaskedRegion (peer->globalToLocal (getScreenBounds())); #if JUCE_LINUX if (pluginWindow != 0) @@ -2077,17 +2048,16 @@ public: //============================================================================== void timerCallback() { - #if JUCE_WINDOWS - if (--sizeCheckCount <= 0) + if (isShowing()) { - sizeCheckCount = 10; - - checkPluginWindowSize(); - } - #endif + #if JUCE_WINDOWS + if (--sizeCheckCount <= 0) + { + sizeCheckCount = 10; + checkPluginWindowSize(); + } + #endif - try - { static bool reentrant = false; if (! reentrant) @@ -2097,13 +2067,13 @@ public: reentrant = false; } } - catch (...) - {} } //============================================================================== void mouseDown (const MouseEvent& e) { + (void) e; + #if JUCE_LINUX if (pluginWindow == 0) return; @@ -2126,8 +2096,6 @@ public: sendEventToChild (&ev); #elif JUCE_WINDOWS - (void) e; - toFront (true); #endif } @@ -2157,6 +2125,16 @@ private: EventProcPtr pluginProc; #endif + // This is a workaround for old Mackie plugins that crash if their + // window is deleted more than once. + bool shouldAvoidDeletingWindow() const + { + PluginDescription desc; + plugin.fillInPluginDescription (desc); + + return desc.manufacturerName.containsIgnoreCase ("Loud Technologies"); + } + //============================================================================== #if JUCE_MAC #if JUCE_SUPPORT_CARBON @@ -2394,11 +2372,9 @@ private: message, wParam, lParam); } - return CallWindowProc ((WNDPROC) (w->originalWndProc), + return CallWindowProc ((WNDPROC) w->originalWndProc, (HWND) w->pluginHWND, - message, - wParam, - lParam); + message, wParam, lParam); } } @@ -2565,9 +2541,10 @@ private: class InnerWrapperComponent : public CarbonViewWrapperComponent { public: - InnerWrapperComponent (VSTPluginWindow& owner_) - : owner (owner_), alreadyInside (false) + InnerWrapperComponent (VSTPluginWindow& w) + : owner (w), alreadyInside (false) { + keepPluginWindowWhenHidden = w.shouldAvoidDeletingWindow(); } ~InnerWrapperComponent() @@ -2619,7 +2596,7 @@ private: { if (ComponentPeer* const peer = getPeer()) { - const Point<int> pos (getScreenPosition() - peer->getScreenPosition()); + const Point<int> pos (peer->globalToLocal (getScreenPosition())); ERect r; r.left = (VstInt16) pos.getX(); r.top = (VstInt16) pos.getY(); @@ -2665,24 +2642,34 @@ AudioProcessorEditor* VSTPluginInstance::createEditor() // entry point for all callbacks from the plugin static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt) { - try - { - if (effect != nullptr) - if (VSTPluginInstance* instance = (VSTPluginInstance*) (effect->resvd2)) - return instance->handleCallback (opcode, index, value, ptr, opt); + if (effect != nullptr) + if (VSTPluginInstance* instance = (VSTPluginInstance*) (effect->resvd2)) + return instance->handleCallback (opcode, index, value, ptr, opt); - return VSTPluginInstance::handleGeneralCallback (opcode, index, value, ptr, opt); - } - catch (...) - { - return 0; - } + return VSTPluginInstance::handleGeneralCallback (opcode, index, value, ptr, opt); } //============================================================================== VSTPluginFormat::VSTPluginFormat() {} VSTPluginFormat::~VSTPluginFormat() {} +static VSTPluginInstance* createAndUpdateDesc (VSTPluginFormat& format, PluginDescription& desc) +{ + if (VSTPluginInstance* instance = dynamic_cast <VSTPluginInstance*> (format.createInstanceFromDescription (desc))) + { + #if JUCE_MAC + if (instance->module->resFileId != 0) + UseResFile (instance->module->resFileId); + #endif + + instance->fillInPluginDescription (desc); + + return instance; + } + + return nullptr; +} + void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& results, const String& fileOrIdentifier) { @@ -2693,66 +2680,45 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& resul desc.fileOrIdentifier = fileOrIdentifier; desc.uid = 0; - ScopedPointer <VSTPluginInstance> instance (dynamic_cast <VSTPluginInstance*> (createInstanceFromDescription (desc))); + ScopedPointer<VSTPluginInstance> instance (createAndUpdateDesc (*this, desc)); if (instance == nullptr) return; - try - { - #if JUCE_MAC - if (instance->module->resFileId != 0) - UseResFile (instance->module->resFileId); - #endif - - instance->fillInPluginDescription (desc); + VstPlugCategory category = (VstPlugCategory) instance->dispatch (effGetPlugCategory, 0, 0, 0, 0); - VstPlugCategory category = (VstPlugCategory) instance->dispatch (effGetPlugCategory, 0, 0, 0, 0); - - if (category != kPlugCategShell) - { - // Normal plugin... - results.add (new PluginDescription (desc)); + if (category != kPlugCategShell) + { + // Normal plugin... + results.add (new PluginDescription (desc)); - instance->dispatch (effOpen, 0, 0, 0, 0); - } - else + instance->dispatch (effOpen, 0, 0, 0, 0); + } + else + { + // It's a shell plugin, so iterate all the subtypes... + for (;;) { - // It's a shell plugin, so iterate all the subtypes... - for (;;) - { - char shellEffectName [64] = { 0 }; - const int uid = (int) instance->dispatch (effShellGetNextPlugin, 0, 0, shellEffectName, 0); - - if (uid == 0) - break; + char shellEffectName [256] = { 0 }; + const int uid = (int) instance->dispatch (effShellGetNextPlugin, 0, 0, shellEffectName, 0); - desc.uid = uid; - desc.name = shellEffectName; - desc.descriptiveName = shellEffectName; + if (uid == 0) + break; - bool alreadyThere = false; + desc.uid = uid; - for (int i = results.size(); --i >= 0;) - { - PluginDescription* const d = results.getUnchecked(i); + ScopedPointer<VSTPluginInstance> shellInstance (createAndUpdateDesc (*this, desc)); - if (d->isDuplicateOf (desc)) - { - alreadyThere = true; - break; - } - } + if (shellInstance != nullptr) + { + jassert (desc.uid == uid); + desc.name = shellEffectName; - if (! alreadyThere) + if (! arrayContainsPlugin (results, desc)) results.add (new PluginDescription (desc)); } } } - catch (...) - { - // crashed while loading... - } } AudioPluginInstance* VSTPluginFormat::createInstanceFromDescription (const PluginDescription& desc) @@ -2829,6 +2795,11 @@ String VSTPluginFormat::getNameOfPluginFromIdentifier (const String& fileOrIdent return fileOrIdentifier; } +bool VSTPluginFormat::pluginNeedsRescanning (const PluginDescription& desc) +{ + return File (desc.fileOrIdentifier).getLastModificationTime() != desc.lastFileModTime; +} + bool VSTPluginFormat::doesPluginStillExist (const PluginDescription& desc) { return File (desc.fileOrIdentifier).exists(); @@ -2871,7 +2842,9 @@ FileSearchPath VSTPluginFormat::getDefaultLocationsToSearch() #if JUCE_MAC return FileSearchPath ("~/Library/Audio/Plug-Ins/VST;/Library/Audio/Plug-Ins/VST"); #elif JUCE_LINUX - return FileSearchPath ("/usr/lib/vst"); + return FileSearchPath (SystemStats::getEnvironmentVariable ("VST_PATH", + "/usr/lib/vst;/usr/local/lib/vst;~/.vst") + .replace (":", ";")); #elif JUCE_WINDOWS const String programFiles (File::getSpecialLocation (File::globalApplicationsDirectory).getFullPathName()); diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h index c77e4c325..70011e810 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -86,6 +85,7 @@ public: AudioPluginInstance* createInstanceFromDescription (const PluginDescription&); bool fileMightContainThisPluginType (const String& fileOrIdentifier); String getNameOfPluginFromIdentifier (const String& fileOrIdentifier); + bool pluginNeedsRescanning (const PluginDescription&); StringArray searchPathsForPlugins (const FileSearchPath&, bool recursive); bool doesPluginStillExist (const PluginDescription&); FileSearchPath getDefaultLocationsToSearch(); diff --git a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.cpp b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.cpp index a4dc54ba0..ad9b0639c 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -62,6 +61,16 @@ namespace juce { +static inline bool arrayContainsPlugin (const OwnedArray<PluginDescription>& list, + const PluginDescription& desc) +{ + for (int i = list.size(); --i >= 0;) + if (list.getUnchecked(i)->isDuplicateOf (desc)) + return true; + + return false; +} + // START_AUTOINCLUDE format/*.cpp, processors/*.cpp, format_types/*.cpp, // format_types/*.mm, scanning/*.cpp #include "format/juce_AudioPluginFormat.cpp" @@ -71,6 +80,7 @@ namespace juce #include "processors/juce_AudioProcessorGraph.cpp" #include "processors/juce_GenericAudioProcessorEditor.cpp" #include "processors/juce_PluginDescription.cpp" +#include "format_types/juce_LADSPAPluginFormat.cpp" #include "format_types/juce_VSTPluginFormat.cpp" #include "format_types/juce_AudioUnitPluginFormat.mm" #include "scanning/juce_KnownPluginList.cpp" diff --git a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h index f21cda161..ed68be7f6 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h +++ b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -99,9 +98,6 @@ namespace juce #ifndef __JUCE_AUDIOUNITPLUGINFORMAT_JUCEHEADER__ #include "format_types/juce_AudioUnitPluginFormat.h" #endif -#ifndef __JUCE_DIRECTXPLUGINFORMAT_JUCEHEADER__ - #include "format_types/juce_DirectXPluginFormat.h" -#endif #ifndef __JUCE_LADSPAPLUGINFORMAT_JUCEHEADER__ #include "format_types/juce_LADSPAPluginFormat.h" #endif diff --git a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.mm b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.mm index 7c9c33f8d..918e84810 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.mm +++ b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/juce_module_info b/JuceLibraryCode/modules/juce_audio_processors/juce_module_info index 3429273c7..0e04efa28 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/juce_module_info +++ b/JuceLibraryCode/modules/juce_audio_processors/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_audio_processors", "name": "JUCE audio plugin hosting classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for loading and playing VST, AU, or internally-generated audio processors.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPlayHead.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPlayHead.h index 9d38984fe..17af3cf0d 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPlayHead.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPlayHead.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -80,16 +79,13 @@ public: /** For timecode, the position of the start of the edit, in seconds from 00:00:00:00. */ double editOriginTime; - /** The current play position in pulses-per-quarter-note. - - This is the number of quarter notes since the edit start. - */ + /** The current play position, in pulses-per-quarter-note. */ double ppqPosition; /** The position of the start of the last bar, in pulses-per-quarter-note. - This is the number of quarter notes from the start of the edit to the - start of the current bar. + This is the time from the start of the edit to the start of the current + bar, in ppq units. Note - this value may be unavailable on some hosts, e.g. Pro-Tools. If it's not available, the value will be 0. diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h index 8c8ed9879..67d64731d 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index 23ad5f4ec..0105d8a12 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.h index e919bcf29..ede308f4e 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -555,10 +554,10 @@ public: //============================================================================== /** Adds a listener that will be called when an aspect of this processor changes. */ - void addListener (AudioProcessorListener* newListener); + virtual void addListener (AudioProcessorListener* newListener); /** Removes a previously added listener. */ - void removeListener (AudioProcessorListener* listenerToRemove); + virtual void removeListener (AudioProcessorListener* listenerToRemove); //============================================================================== /** Tells the processor to use this playhead object. diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index 7af959033..a4c9d296b 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp @@ -1,30 +1,29 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ -AudioProcessorEditor::AudioProcessorEditor (AudioProcessor* const owner_) - : owner (owner_) +AudioProcessorEditor::AudioProcessorEditor (AudioProcessor* const p) + : owner (p) { // the filter must be valid.. jassert (owner != nullptr); diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h index f7efd3df3..d021fc52b 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 9f624c280..a36386d19 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -925,7 +924,9 @@ void AudioProcessorGraph::Node::setParentGraph (AudioProcessorGraph* const graph AudioProcessorGraph::AudioProcessorGraph() : lastNodeId (0), renderingBuffers (1, 1), - currentAudioOutputBuffer (1, 1) + currentAudioInputBuffer (nullptr), + currentAudioOutputBuffer (1, 1), + currentMidiInputBuffer (nullptr) { } @@ -959,12 +960,21 @@ AudioProcessorGraph::Node* AudioProcessorGraph::getNodeForId (const uint32 nodeI AudioProcessorGraph::Node* AudioProcessorGraph::addNode (AudioProcessor* const newProcessor, uint32 nodeId) { - if (newProcessor == nullptr) + if (newProcessor == nullptr || newProcessor == this) { jassertfalse; return nullptr; } + for (int i = nodes.size(); --i >= 0;) + { + if (nodes.getUnchecked(i)->getProcessor() == newProcessor) + { + jassertfalse; // Cannot add the same object to the graph twice! + return nullptr; + } + } + if (nodeId == 0) { nodeId = ++lastNodeId; diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h index d27355453..3481b19c4 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h index 55a39ff10..d24c2819b 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp index 65fe98930..1512f4aa0 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -28,16 +27,16 @@ class ProcessorParameterPropertyComp : public PropertyComponent, private Timer { public: - ProcessorParameterPropertyComp (const String& name, AudioProcessor& owner_, const int index_) + ProcessorParameterPropertyComp (const String& name, AudioProcessor& p, const int index_) : PropertyComponent (name), - owner (owner_), + owner (p), index (index_), paramHasChanged (false), - slider (owner_, index_) + slider (p, index_) { startTimer (100); addAndMakeVisible (&slider); - owner_.addListener (this); + owner.addListener (this); } ~ProcessorParameterPropertyComp() @@ -77,8 +76,8 @@ private: class ParamSlider : public Slider { public: - ParamSlider (AudioProcessor& owner_, const int index_) - : owner (owner_), + ParamSlider (AudioProcessor& p, const int index_) + : owner (p), index (index_) { setRange (0.0, 1.0, 0.0); @@ -118,26 +117,26 @@ private: //============================================================================== -GenericAudioProcessorEditor::GenericAudioProcessorEditor (AudioProcessor* const owner_) - : AudioProcessorEditor (owner_) +GenericAudioProcessorEditor::GenericAudioProcessorEditor (AudioProcessor* const p) + : AudioProcessorEditor (p) { - jassert (owner_ != nullptr); + jassert (p != nullptr); setOpaque (true); addAndMakeVisible (&panel); Array <PropertyComponent*> params; - const int numParams = owner_->getNumParameters(); + const int numParams = p->getNumParameters(); int totalHeight = 0; for (int i = 0; i < numParams; ++i) { - String name (owner_->getParameterName (i)); + String name (p->getParameterName (i)); if (name.trim().isEmpty()) name = "Unnamed"; - ProcessorParameterPropertyComp* const pc = new ProcessorParameterPropertyComp (name, *owner_, i); + ProcessorParameterPropertyComp* const pc = new ProcessorParameterPropertyComp (name, *p, i); params.add (pc); totalHeight += pc->getPreferredHeight(); } diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h index 21338840a..792b2a796 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_PluginDescription.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_PluginDescription.cpp index a21b316bb..7562d29ac 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_PluginDescription.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_PluginDescription.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_PluginDescription.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_PluginDescription.h index 7cbd0edaf..257bbd79e 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_PluginDescription.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_PluginDescription.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp index 3b02cb39c..84f463319 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -79,25 +78,8 @@ void KnownPluginList::removeType (const int index) sendChangeMessage(); } -namespace -{ - Time getPluginFileModTime (const String& fileOrIdentifier) - { - if (fileOrIdentifier.startsWithChar ('/') || fileOrIdentifier[1] == ':') - return File (fileOrIdentifier).getLastModificationTime(); - - return Time(); - } - - bool timesAreDifferent (const Time& t1, const Time& t2) noexcept - { - return t1 != t2 || t1 == Time(); - } - - enum { menuIdBase = 0x324503f4 }; -} - -bool KnownPluginList::isListingUpToDate (const String& fileOrIdentifier) const +bool KnownPluginList::isListingUpToDate (const String& fileOrIdentifier, + AudioPluginFormat& formatToUse) const { if (getTypeForFile (fileOrIdentifier) == nullptr) return false; @@ -107,10 +89,8 @@ bool KnownPluginList::isListingUpToDate (const String& fileOrIdentifier) const const PluginDescription* const d = types.getUnchecked(i); if (d->fileOrIdentifier == fileOrIdentifier - && timesAreDifferent (d->lastFileModTime, getPluginFileModTime (fileOrIdentifier))) - { + && formatToUse.pluginNeedsRescanning (*d)) return false; - } } return true; @@ -126,6 +106,8 @@ bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier, OwnedArray <PluginDescription>& typesFound, AudioPluginFormat& format) { + const ScopedLock sl (scanLock); + if (dontRescanIfAlreadyInList && getTypeForFile (fileOrIdentifier) != nullptr) { @@ -137,7 +119,7 @@ bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier, if (d->fileOrIdentifier == fileOrIdentifier && d->pluginFormatName == format.getName()) { - if (timesAreDifferent (d->lastFileModTime, getPluginFileModTime (fileOrIdentifier))) + if (format.pluginNeedsRescanning (*d)) needsRescanning = true; else typesFound.add (new PluginDescription (*d)); @@ -153,14 +135,17 @@ bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier, OwnedArray <PluginDescription> found; - if (scanner != nullptr) - { - if (! scanner->findPluginTypesFor (format, found, fileOrIdentifier)) - addToBlacklist (fileOrIdentifier); - } - else { - format.findAllTypesForFile (found, fileOrIdentifier); + const ScopedUnlock sl (scanLock); + if (scanner != nullptr) + { + if (! scanner->findPluginTypesFor (format, found, fileOrIdentifier)) + addToBlacklist (fileOrIdentifier); + } + else + { + format.findAllTypesForFile (found, fileOrIdentifier); + } } for (int i = 0; i < found.size(); ++i) @@ -332,6 +317,8 @@ void KnownPluginList::recreateFromXml (const XmlElement& xml) //============================================================================== struct PluginTreeUtils { + enum { menuIdBase = 0x324503f4 }; + static void buildTreeByFolder (KnownPluginList::PluginTree& tree, const Array <PluginDescription*>& allPlugins) { for (int i = 0; i < allPlugins.size(); ++i) @@ -506,7 +493,7 @@ void KnownPluginList::addToMenu (PopupMenu& menu, const SortMethod sortMethod) c int KnownPluginList::getIndexChosenByMenu (const int menuResultCode) const { - const int i = menuResultCode - menuIdBase; + const int i = menuResultCode - PluginTreeUtils::menuIdBase; return isPositiveAndBelow (i, types.size()) ? i : -1; } diff --git a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.h b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.h index c861b9721..5ea4d2587 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.h +++ b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -104,7 +103,8 @@ public: /** Returns true if the specified file is already known about and if it hasn't been modified since our entry was created. */ - bool isListingUpToDate (const String& possiblePluginFileOrIdentifier) const; + bool isListingUpToDate (const String& possiblePluginFileOrIdentifier, + AudioPluginFormat& formatToUse) const; /** Scans and adds a bunch of files that might have been dragged-and-dropped. If any types are found in the files, their descriptions are returned in the array. @@ -201,6 +201,7 @@ private: OwnedArray <PluginDescription> types; StringArray blacklist; ScopedPointer<CustomScanner> scanner; + CriticalSection scanLock; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KnownPluginList) }; diff --git a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp index 02036ba05..3c8a54289 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -39,7 +38,6 @@ PluginDirectoryScanner::PluginDirectoryScanner (KnownPluginList& listToAddTo, : list (listToAddTo), format (formatToLookFor), deadMansPedalFile (deadMansPedal), - nextIndex (0), progress (0) { directoriesToSearch.removeRedundantPaths(); @@ -60,6 +58,7 @@ PluginDirectoryScanner::PluginDirectoryScanner (KnownPluginList& listToAddTo, } applyBlacklistingsFromDeadMansPedal (listToAddTo, deadMansPedalFile); + nextIndex.set (filesOrIdentifiersToScan.size()); } PluginDirectoryScanner::~PluginDirectoryScanner() @@ -69,43 +68,51 @@ PluginDirectoryScanner::~PluginDirectoryScanner() //============================================================================== String PluginDirectoryScanner::getNextPluginFileThatWillBeScanned() const { - return format.getNameOfPluginFromIdentifier (filesOrIdentifiersToScan [nextIndex]); + return format.getNameOfPluginFromIdentifier (filesOrIdentifiersToScan [nextIndex.get() - 1]); +} + +void PluginDirectoryScanner::updateProgress() +{ + progress = (1.0f - nextIndex.get() / (float) filesOrIdentifiersToScan.size()); } bool PluginDirectoryScanner::scanNextFile (const bool dontRescanIfAlreadyInList) { - String file (filesOrIdentifiersToScan [nextIndex]); + const int index = --nextIndex; - if (file.isNotEmpty() && ! list.isListingUpToDate (file)) + if (index >= 0) { - OwnedArray <PluginDescription> typesFound; + String file (filesOrIdentifiersToScan [index]); - // Add this plugin to the end of the dead-man's pedal list in case it crashes... - StringArray crashedPlugins (readDeadMansPedalFile (deadMansPedalFile)); - crashedPlugins.removeString (file); - crashedPlugins.add (file); - setDeadMansPedalFile (crashedPlugins); + if (file.isNotEmpty() && ! list.isListingUpToDate (file, format)) + { + OwnedArray <PluginDescription> typesFound; - list.scanAndAddFile (file, dontRescanIfAlreadyInList, typesFound, format); + // Add this plugin to the end of the dead-man's pedal list in case it crashes... + StringArray crashedPlugins (readDeadMansPedalFile (deadMansPedalFile)); + crashedPlugins.removeString (file); + crashedPlugins.add (file); + setDeadMansPedalFile (crashedPlugins); - // Managed to load without crashing, so remove it from the dead-man's-pedal.. - crashedPlugins.removeString (file); - setDeadMansPedalFile (crashedPlugins); + list.scanAndAddFile (file, dontRescanIfAlreadyInList, typesFound, format); - if (typesFound.size() == 0 && ! list.getBlacklistedFiles().contains (file)) - failedFiles.add (file); + // Managed to load without crashing, so remove it from the dead-man's-pedal.. + crashedPlugins.removeString (file); + setDeadMansPedalFile (crashedPlugins); + + if (typesFound.size() == 0 && ! list.getBlacklistedFiles().contains (file)) + failedFiles.add (file); + } } - return skipNextFile(); + updateProgress(); + return index > 0; } bool PluginDirectoryScanner::skipNextFile() { - if (nextIndex >= filesOrIdentifiersToScan.size()) - return false; - - progress = ++nextIndex / (float) filesOrIdentifiersToScan.size(); - return nextIndex < filesOrIdentifiersToScan.size(); + updateProgress(); + return --nextIndex > 0; } void PluginDirectoryScanner::setDeadMansPedalFile (const StringArray& newContents) diff --git a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h index 1f6651e5c..bedb9d078 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h +++ b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -115,9 +114,10 @@ private: StringArray filesOrIdentifiersToScan; File deadMansPedalFile; StringArray failedFiles; - int nextIndex; + Atomic<int> nextIndex; float progress; + void updateProgress(); void setDeadMansPedalFile (const StringArray& newContents); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginDirectoryScanner) diff --git a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index c27e3ae7f..cc612ecbb 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -32,7 +31,7 @@ PluginListComponent::PluginListComponent (AudioPluginFormatManager& manager, deadMansPedalFile (deadMansPedal), optionsButton ("Options..."), propertiesToUse (properties), - scanOnBackgroundThread (false) + numThreads (0) { listBox.setModel (this); addAndMakeVisible (&listBox); @@ -60,9 +59,9 @@ void PluginListComponent::setOptionsButtonText (const String& newText) resized(); } -void PluginListComponent::setScansOnMessageThread (bool useMessageThread) noexcept +void PluginListComponent::setNumberOfThreadsForScanning (int num) { - scanOnBackgroundThread = ! useMessageThread; + numThreads = num; } void PluginListComponent::resized() @@ -200,7 +199,11 @@ void PluginListComponent::optionsMenuCallback (int result) case 6: showSelectedFolder(); break; case 7: removeMissingPlugins(); break; - default: scanFor (formatManager.getFormat (result - 10)); break; + default: + if (AudioPluginFormat* format = formatManager.getFormat (result - 10)) + scanFor (*format); + + break; } } @@ -243,28 +246,38 @@ void PluginListComponent::filesDropped (const StringArray& files, int, int) list.scanAndAddDragAndDroppedFiles (formatManager, files, typesFound); } +FileSearchPath PluginListComponent::getLastSearchPath (PropertiesFile& properties, AudioPluginFormat& format) +{ + return properties.getValue ("lastPluginScanPath_" + format.getName(), + format.getDefaultLocationsToSearch().toString()); +} + +void PluginListComponent::setLastSearchPath (PropertiesFile& properties, AudioPluginFormat& format, + const FileSearchPath& newPath) +{ + properties.setValue ("lastPluginScanPath_" + format.getName(), newPath.toString()); +} + //============================================================================== -class PluginListComponent::Scanner : private Timer, - private Thread +class PluginListComponent::Scanner : private Timer { public: Scanner (PluginListComponent& plc, AudioPluginFormat& format, PropertiesFile* properties, - bool useThread) - : Thread ("plugin_scan"), - owner (plc), formatToScan (format), propertiesToUse (properties), + int threads) + : owner (plc), formatToScan (format), propertiesToUse (properties), pathChooserWindow (TRANS("Select folders to scan..."), String::empty, AlertWindow::NoIcon), progressWindow (TRANS("Scanning for plug-ins..."), TRANS("Searching for all possible plug-in files..."), AlertWindow::NoIcon), - progress (0.0), shouldUseThread (useThread), finished (false) + progress (0.0), numThreads (threads), finished (false) { FileSearchPath path (formatToScan.getDefaultLocationsToSearch()); if (path.getNumPaths() > 0) // if the path is empty, then paths aren't used for this format. { if (propertiesToUse != nullptr) - path = propertiesToUse->getValue ("lastPluginScanPath_" + formatToScan.getName(), path.toString()); + path = getLastSearchPath (*propertiesToUse, formatToScan); pathList.setSize (500, 300); pathList.setPath (path); @@ -285,7 +298,11 @@ public: ~Scanner() { - stopThread (10000); + if (pool != nullptr) + { + pool->removeAllJobs (true, 60000); + pool = nullptr; + } } private: @@ -309,7 +326,7 @@ private: if (propertiesToUse != nullptr) { - propertiesToUse->setValue ("lastPluginScanPath_" + formatToScan.getName(), pathList.getPath().toString()); + setLastSearchPath (*propertiesToUse, formatToScan, pathList.getPath()); propertiesToUse->saveIfNeeded(); } @@ -317,8 +334,13 @@ private: progressWindow.addProgressBarComponent (progress); progressWindow.enterModalState(); - if (shouldUseThread) - startThread(); + if (numThreads > 0) + { + pool = new ThreadPool (numThreads); + + for (int i = numThreads; --i >= 0;) + pool->addJob (new ScanJob (*this), true); + } startTimer (20); } @@ -331,7 +353,7 @@ private: void timerCallback() { - if (! isThreadRunning()) + if (pool == nullptr) { if (doNextScan()) startTimer (20); @@ -346,15 +368,9 @@ private: progressWindow.setMessage (progressMessage); } - void run() - { - while (doNextScan() && ! threadShouldExit()) - {} - } - bool doNextScan() { - progressMessage = TRANS("Testing:\n\n") + scanner->getNextPluginFileThatWillBeScanned(); + progressMessage = TRANS("Testing") + ":\n\n" + scanner->getNextPluginFileThatWillBeScanned(); if (scanner->scanNextFile (true)) { @@ -374,15 +390,35 @@ private: FileSearchPathListComponent pathList; String progressMessage; double progress; - bool shouldUseThread, finished; + int numThreads; + bool finished; + + ScopedPointer<ThreadPool> pool; + + struct ScanJob : public ThreadPoolJob + { + ScanJob (Scanner& s) : ThreadPoolJob ("pluginscan"), scanner (s) {} + + JobStatus runJob() + { + while (scanner.doNextScan() && ! shouldExit()) + {} + + return jobHasFinished; + } + + Scanner& scanner; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ScanJob) + }; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Scanner) + }; -void PluginListComponent::scanFor (AudioPluginFormat* format) +void PluginListComponent::scanFor (AudioPluginFormat& format) { - if (format != nullptr) - currentScanner = new Scanner (*this, *format, propertiesToUse, scanOnBackgroundThread); + currentScanner = new Scanner (*this, format, propertiesToUse, numThreads); } void PluginListComponent::scanFinished (const StringArray& failedFiles) @@ -397,6 +433,7 @@ void PluginListComponent::scanFinished (const StringArray& failedFiles) if (shortNames.size() > 0) AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, TRANS("Scan complete"), - TRANS("Note that the following files appeared to be plugin files, but failed to load correctly:\n\n") + TRANS("Note that the following files appeared to be plugin files, but failed to load correctly") + + ":\n\n" + shortNames.joinIntoString (", ")); } diff --git a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.h b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.h index 524693f90..1d52c9236 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.h +++ b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -61,8 +60,20 @@ public: /** Changes the text in the panel's button. */ void setOptionsButtonText (const String& newText); - /** Chooses whether to use the message thread or a background thread for scanning. */ - void setScansOnMessageThread (bool useMessageThread) noexcept; + /** Sets how many threads to simultaneously scan for plugins. + If this is 0, then all scanning happens on the message thread (this is the default) + */ + void setNumberOfThreadsForScanning (int numThreads); + + /** Returns the last search path stored in a given properties file for the specified format. */ + static FileSearchPath getLastSearchPath (PropertiesFile& properties, AudioPluginFormat& format); + + /** Stores a search path in a properties file for the given format. */ + static void setLastSearchPath (PropertiesFile& properties, AudioPluginFormat& format, + const FileSearchPath& newPath); + + /** Triggers a scan for the given format. */ + void scanFor (AudioPluginFormat& format); //============================================================================== /** @internal */ @@ -86,14 +97,13 @@ private: ListBox listBox; TextButton optionsButton; PropertiesFile* propertiesToUse; - bool scanOnBackgroundThread; + int numThreads; class Scanner; friend class Scanner; friend class ScopedPointer<Scanner>; ScopedPointer<Scanner> currentScanner; - void scanFor (AudioPluginFormat*); void scanFinished (const StringArray&); static void optionsMenuStaticCallback (int, PluginListComponent*); diff --git a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index 99d59ee56..99af694e2 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -70,7 +69,6 @@ class AudioDeviceSelectorComponent::MidiInputSelectorComponentListBox : public private ListBoxModel { public: - //============================================================================== MidiInputSelectorComponentListBox (AudioDeviceManager& deviceManager_, const String& noItemsMessage_, const int minNumber_, @@ -193,6 +191,7 @@ struct AudioDeviceSetupDetails bool useStereoPairs; }; +static String getNoDeviceString() { return "<< " + TRANS("none") + " >>"; } //============================================================================== class AudioDeviceSettingsPanel : public Component, @@ -515,7 +514,7 @@ private: for (int i = 0; i < devs.size(); ++i) combo.addItem (devs[i], i + 1); - combo.addItem (TRANS("<< none >>"), -1); + combo.addItem (getNoDeviceString(), -1); combo.setSelectedId (-1, true); } @@ -959,7 +958,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager& { addAndMakeVisible (midiInputsList = new MidiInputSelectorComponentListBox (deviceManager, - TRANS("(No MIDI inputs available)"), + "(" + TRANS("No MIDI inputs available") + ")", 0, 0)); midiInputsLabel = new Label (String::empty, TRANS ("Active MIDI inputs:")); @@ -1102,7 +1101,7 @@ void AudioDeviceSelectorComponent::updateAllControls() const StringArray midiOuts (MidiOutput::getDevices()); - midiOutputSelector->addItem (TRANS("<< none >>"), -1); + midiOutputSelector->addItem (getNoDeviceString(), -1); midiOutputSelector->addSeparator(); for (int i = 0; i < midiOuts.size(); ++i) diff --git a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h index 4c609cba8..12e1ca8f9 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h +++ b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp index 88cb8d841..66b20e274 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp +++ b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -78,13 +77,13 @@ class AudioThumbnail::LevelDataSource : public TimeSliceClient public: 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) : lengthInSamples (0), numSamplesFinished (0), sampleRate (0), numChannels (0), - hashCode (src->hashCode()), owner (thumb), source (src) + hashCode (src->hashCode()), owner (thumb), source (src), lastReaderUseTime (0) { } @@ -526,6 +525,7 @@ AudioThumbnail::AudioThumbnail (const int originalSamplesPerThumbnailSample, window (new CachedWindow()), samplesPerThumbSample (originalSamplesPerThumbnailSample), totalSamples (0), + numSamplesFinished (0), numChannels (0), sampleRate (0) { diff --git a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnail.h b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnail.h index 1f95f63e1..63aa8103a 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnail.h +++ b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnail.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h index fa4931c86..4fe5db4ad 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h +++ b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp index 7c9c2c781..a60ad061b 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp +++ b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h index 10cd9f8ca..3d51d30bc 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h +++ b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index d09207983..e583c76ad 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -266,7 +265,7 @@ int MidiKeyboardComponent::getKeyStartPosition (const int midiNoteNumber) const const uint8 MidiKeyboardComponent::whiteNotes[] = { 0, 2, 4, 5, 7, 9, 11 }; const uint8 MidiKeyboardComponent::blackNotes[] = { 1, 3, 6, 8, 10 }; -int MidiKeyboardComponent::xyToNote (const Point<int>& pos, float& mousePositionVelocity) +int MidiKeyboardComponent::xyToNote (Point<int> pos, float& mousePositionVelocity) { if (! reallyContains (pos, false)) return -1; @@ -286,7 +285,7 @@ int MidiKeyboardComponent::xyToNote (const Point<int>& pos, float& mousePosition return remappedXYToNote (p + Point<int> (xOffset, 0), mousePositionVelocity); } -int MidiKeyboardComponent::remappedXYToNote (const Point<int>& pos, float& mousePositionVelocity) const +int MidiKeyboardComponent::remappedXYToNote (Point<int> pos, float& mousePositionVelocity) const { if (pos.getY() < blackNoteLength) { @@ -692,7 +691,7 @@ void MidiKeyboardComponent::updateNoteUnderMouse (const MouseEvent& e, bool isDo updateNoteUnderMouse (e.getPosition(), isDown, e.source.getIndex()); } -void MidiKeyboardComponent::updateNoteUnderMouse (const Point<int>& pos, bool isDown, int fingerNum) +void MidiKeyboardComponent::updateNoteUnderMouse (Point<int> pos, bool isDown, int fingerNum) { float mousePositionVelocity = 0.0f; const int newNote = xyToNote (pos, mousePositionVelocity); diff --git a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h index 271170997..c1f27219a 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h +++ b/JuceLibraryCode/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -398,10 +397,10 @@ private: static const uint8 blackNotes[]; void getKeyPos (int midiNoteNumber, int& x, int& w) const; - int xyToNote (const Point<int>&, float& mousePositionVelocity); - int remappedXYToNote (const Point<int>&, float& mousePositionVelocity) const; + int xyToNote (Point<int>, float& mousePositionVelocity); + int remappedXYToNote (Point<int>, float& mousePositionVelocity) const; void resetAnyKeysInUse(); - void updateNoteUnderMouse (const Point<int>&, bool isDown, int fingerNum); + void updateNoteUnderMouse (Point<int>, bool isDown, int fingerNum); void updateNoteUnderMouse (const MouseEvent&, bool isDown); void repaintNote (const int midiNoteNumber); void setLowestVisibleKeyFloat (float noteNumber); diff --git a/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.cpp b/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.cpp index 218789fac..b5f8f7024 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.cpp +++ b/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.h b/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.h index 51ef2e03a..8b481b71d 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.h +++ b/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.mm b/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.mm index b0fdd6670..b5b749711 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.mm +++ b/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_utils/juce_module_info b/JuceLibraryCode/modules/juce_audio_utils/juce_module_info index 10a0442c4..2e9f7bdbd 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/juce_module_info +++ b/JuceLibraryCode/modules/juce_audio_utils/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_audio_utils", "name": "JUCE extra audio utility classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for audio-related GUI and miscellaneous tasks.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp b/JuceLibraryCode/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp index ccf452f84..c5ebcf005 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp +++ b/JuceLibraryCode/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h b/JuceLibraryCode/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h index 6dd853d92..76e37ec42 100644 --- a/JuceLibraryCode/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h +++ b/JuceLibraryCode/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.cpp index 239b6c552..666cc50d0 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.h b/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.h index 44eb8cdc3..6e74fc802 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_Array.h b/JuceLibraryCode/modules/juce_core/containers/juce_Array.h index a6f4f60f1..206dff0cc 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_Array.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_Array.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_ArrayAllocationBase.h b/JuceLibraryCode/modules/juce_core/containers/juce_ArrayAllocationBase.h index 7f27294ed..d19887f61 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_ArrayAllocationBase.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_ArrayAllocationBase.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.cpp index c0afb5578..69e587feb 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.h b/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.h index f68e78008..f2cfefa1a 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_ElementComparator.h b/JuceLibraryCode/modules/juce_core/containers/juce_ElementComparator.h index f976c40c7..dc7b81c0e 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_ElementComparator.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_ElementComparator.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_HashMap.h b/JuceLibraryCode/modules/juce_core/containers/juce_HashMap.h index 64f569440..86d6691ca 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_HashMap.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_HashMap.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_LinkedListPointer.h b/JuceLibraryCode/modules/juce_core/containers/juce_LinkedListPointer.h index 37f01e5ec..705d0cbe2 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_LinkedListPointer.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_LinkedListPointer.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.cpp index 91567f607..5ea71a533 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -27,8 +30,8 @@ NamedValueSet::NamedValue::NamedValue() noexcept { } -inline NamedValueSet::NamedValue::NamedValue (const Identifier& name_, const var& value_) - : name (name_), value (value_) +inline NamedValueSet::NamedValue::NamedValue (const Identifier n, const var& v) + : name (n), value (v) { } @@ -52,8 +55,8 @@ NamedValueSet::NamedValue::NamedValue (NamedValue&& other) noexcept { } -inline NamedValueSet::NamedValue::NamedValue (const Identifier& name_, var&& value_) - : name (name_), value (static_cast <var&&> (value_)) +inline NamedValueSet::NamedValue::NamedValue (const Identifier n, var&& v) + : name (n), value (static_cast <var&&> (v)) { } @@ -138,7 +141,7 @@ int NamedValueSet::size() const noexcept return values.size(); } -const var& NamedValueSet::operator[] (const Identifier& name) const +const var& NamedValueSet::operator[] (const Identifier name) const { for (NamedValue* i = values; i != nullptr; i = i->nextListItem) if (i->name == name) @@ -147,7 +150,7 @@ const var& NamedValueSet::operator[] (const Identifier& name) const return var::null; } -var NamedValueSet::getWithDefault (const Identifier& name, const var& defaultReturnValue) const +var NamedValueSet::getWithDefault (const Identifier name, const var& defaultReturnValue) const { if (const var* const v = getVarPointer (name)) return *v; @@ -155,7 +158,7 @@ var NamedValueSet::getWithDefault (const Identifier& name, const var& defaultRet return defaultReturnValue; } -var* NamedValueSet::getVarPointer (const Identifier& name) const noexcept +var* NamedValueSet::getVarPointer (const Identifier name) const noexcept { for (NamedValue* i = values; i != nullptr; i = i->nextListItem) if (i->name == name) @@ -165,7 +168,7 @@ var* NamedValueSet::getVarPointer (const Identifier& name) const noexcept } #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS -bool NamedValueSet::set (const Identifier& name, var&& newValue) +bool NamedValueSet::set (const Identifier name, var&& newValue) { LinkedListPointer<NamedValue>* i = &values; @@ -190,7 +193,7 @@ bool NamedValueSet::set (const Identifier& name, var&& newValue) } #endif -bool NamedValueSet::set (const Identifier& name, const var& newValue) +bool NamedValueSet::set (const Identifier name, const var& newValue) { LinkedListPointer<NamedValue>* i = &values; @@ -214,12 +217,12 @@ bool NamedValueSet::set (const Identifier& name, const var& newValue) return true; } -bool NamedValueSet::contains (const Identifier& name) const +bool NamedValueSet::contains (const Identifier name) const { return getVarPointer (name) != nullptr; } -bool NamedValueSet::remove (const Identifier& name) +bool NamedValueSet::remove (const Identifier name) { LinkedListPointer<NamedValue>* i = &values; @@ -264,16 +267,43 @@ void NamedValueSet::setFromXmlAttributes (const XmlElement& xml) const int numAtts = xml.getNumAttributes(); // xxx inefficient - should write an att iterator.. for (int i = 0; i < numAtts; ++i) - appender.append (new NamedValue (xml.getAttributeName (i), var (xml.getAttributeValue (i)))); + { + const String& name = xml.getAttributeName (i); + const String& value = xml.getAttributeValue (i); + + if (name.startsWith ("base64:")) + { + MemoryBlock mb; + + if (mb.fromBase64Encoding (value)) + { + appender.append (new NamedValue (name.substring (7), var (mb))); + continue; + } + } + + appender.append (new NamedValue (name, var (value))); + } } void NamedValueSet::copyToXmlAttributes (XmlElement& xml) const { for (NamedValue* i = values; i != nullptr; i = i->nextListItem) { - jassert (! i->value.isObject()); // DynamicObjects can't be stored as XML! + if (const MemoryBlock* mb = i->value.getBinaryData()) + { + xml.setAttribute ("base64:" + i->name.toString(), + mb->toBase64Encoding()); + } + else + { + // These types can't be stored as XML! + jassert (! i->value.isObject()); + jassert (! i->value.isMethod()); + jassert (! i->value.isArray()); - xml.setAttribute (i->name.toString(), - i->value.toString()); + xml.setAttribute (i->name.toString(), + i->value.toString()); + } } } diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.h b/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.h index 6c07f976f..745fdf140 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -71,35 +74,35 @@ public: If the name isn't found, this will return a void variant. @see getProperty */ - const var& operator[] (const Identifier& name) const; + const var& operator[] (const Identifier name) const; /** Tries to return the named value, but if no such value is found, this will instead return the supplied default value. */ - var getWithDefault (const Identifier& name, const var& defaultReturnValue) const; + var getWithDefault (const Identifier name, const var& defaultReturnValue) const; /** Changes or adds a named value. @returns true if a value was changed or added; false if the value was already set the the value passed-in. */ - bool set (const Identifier& name, const var& newValue); + bool set (const Identifier name, const var& newValue); #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS /** Changes or adds a named value. @returns true if a value was changed or added; false if the value was already set the the value passed-in. */ - bool set (const Identifier& name, var&& newValue); + bool set (const Identifier name, var&& newValue); #endif /** Returns true if the set contains an item with the specified name. */ - bool contains (const Identifier& name) const; + bool contains (const Identifier name) const; /** Removes a value from the set. @returns true if a value was removed; false if there was no value with the name that was given. */ - bool remove (const Identifier& name); + bool remove (const Identifier name); /** Returns the name of the value at a given index. The index must be between 0 and size() - 1. @@ -121,7 +124,7 @@ public: Do not use this method unless you really need access to the internal var object for some reason - for normal reading and writing always prefer operator[]() and set(). */ - var* getVarPointer (const Identifier& name) const noexcept; + var* getVarPointer (const Identifier name) const noexcept; //============================================================================== /** Sets properties to the values of all of an XML element's attributes. */ @@ -139,11 +142,11 @@ private: public: NamedValue() noexcept; NamedValue (const NamedValue&); - NamedValue (const Identifier& name, const var& value); + NamedValue (const Identifier name, const var& value); NamedValue& operator= (const NamedValue&); #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS NamedValue (NamedValue&&) noexcept; - NamedValue (const Identifier& name, var&& value); + NamedValue (const Identifier name, var&& value); NamedValue& operator= (NamedValue&&) noexcept; #endif bool operator== (const NamedValue& other) const noexcept; diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_OwnedArray.h b/JuceLibraryCode/modules/juce_core/containers/juce_OwnedArray.h index 5e0328f64..f3cdbea1d 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_OwnedArray.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_OwnedArray.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_PropertySet.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_PropertySet.cpp index 8464c5ba8..ba23e7ada 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_PropertySet.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_PropertySet.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_PropertySet.h b/JuceLibraryCode/modules/juce_core/containers/juce_PropertySet.h index 3d455660e..2333c244c 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_PropertySet.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_PropertySet.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_ReferenceCountedArray.h b/JuceLibraryCode/modules/juce_core/containers/juce_ReferenceCountedArray.h index 209851156..96583114d 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_ReferenceCountedArray.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_ScopedValueSetter.h b/JuceLibraryCode/modules/juce_core/containers/juce_ScopedValueSetter.h index 7599019c8..45836a5d2 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_ScopedValueSetter.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_ScopedValueSetter.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -61,7 +64,7 @@ public: given new value, and will then reset it to its original value when this object is deleted. */ ScopedValueSetter (ValueType& valueToSet, - const ValueType& newValue) + ValueType newValue) : value (valueToSet), originalValue (valueToSet) { @@ -72,8 +75,8 @@ public: given new value, and will then reset it to be valueWhenDeleted when this object is deleted. */ ScopedValueSetter (ValueType& valueToSet, - const ValueType& newValue, - const ValueType& valueWhenDeleted) + ValueType newValue, + ValueType valueWhenDeleted) : value (valueToSet), originalValue (valueWhenDeleted) { diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_SortedSet.h b/JuceLibraryCode/modules/juce_core/containers/juce_SortedSet.h index f18b53378..d51fd472e 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_SortedSet.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_SortedSet.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.h b/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.h index 70586f459..366084e7c 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -34,7 +37,7 @@ /** Holds a set of primitive values, storing them as a set of ranges. - This container acts like an array, but can efficiently hold large continguous + This container acts like an array, but can efficiently hold large contiguous ranges of values. It's quite a specialised class, mostly useful for things like keeping the set of selected rows in a listbox. @@ -162,7 +165,7 @@ public: /** Adds a range of contiguous values to the set. e.g. addRange (Range \<int\> (10, 14)) will add (10, 11, 12, 13) to the set. */ - void addRange (const Range<Type>& range) + void addRange (const Range<Type> range) { jassert (range.getLength() >= 0); if (range.getLength() > 0) @@ -179,7 +182,7 @@ public: /** Removes a range of values from the set. e.g. removeRange (Range\<int\> (10, 14)) will remove (10, 11, 12, 13) from the set. */ - void removeRange (const Range<Type>& rangeToRemove) + void removeRange (const Range<Type> rangeToRemove) { jassert (rangeToRemove.getLength() >= 0); @@ -216,7 +219,7 @@ public: } /** Does an XOR of the values in a given range. */ - void invertRange (const Range<Type>& range) + void invertRange (const Range<Type> range) { SparseSet newItems; newItems.addRange (range); @@ -231,7 +234,7 @@ public: } /** Checks whether any part of a given range overlaps any part of this set. */ - bool overlapsRange (const Range<Type>& range) + bool overlapsRange (const Range<Type> range) { if (range.getLength() > 0) { @@ -249,7 +252,7 @@ public: } /** Checks whether the whole of a given range is contained within this one. */ - bool containsRange (const Range<Type>& range) + bool containsRange (const Range<Type> range) { if (range.getLength() > 0) { diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_Variant.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_Variant.cpp index 23d016aef..a302d363d 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_Variant.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_Variant.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -31,7 +34,8 @@ enum VariantStreamMarkers varMarker_Double = 4, varMarker_String = 5, varMarker_Int64 = 6, - varMarker_Array = 7 + varMarker_Array = 7, + varMarker_Binary = 8 }; //============================================================================== @@ -47,7 +51,8 @@ public: virtual String toString (const ValueUnion&) const { return String::empty; } virtual bool toBool (const ValueUnion&) const noexcept { return false; } virtual ReferenceCountedObject* toObject (const ValueUnion&) const noexcept { return nullptr; } - virtual Array<var>* toArray (const ValueUnion&) const noexcept { return 0; } + virtual Array<var>* toArray (const ValueUnion&) const noexcept { return nullptr; } + virtual MemoryBlock* toBinary (const ValueUnion&) const noexcept { return nullptr; } virtual bool isVoid() const noexcept { return false; } virtual bool isInt() const noexcept { return false; } @@ -57,6 +62,7 @@ public: virtual bool isString() const noexcept { return false; } virtual bool isObject() const noexcept { return false; } virtual bool isArray() const noexcept { return false; } + virtual bool isBinary() const noexcept { return false; } virtual bool isMethod() const noexcept { return false; } virtual void cleanUp (ValueUnion&) const noexcept {} @@ -292,6 +298,35 @@ public: } }; +//============================================================================== +class var::VariantType_Binary : public var::VariantType +{ +public: + VariantType_Binary() noexcept {} + + static const VariantType_Binary instance; + + void cleanUp (ValueUnion& data) const noexcept { delete data.binaryValue; } + void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest.binaryValue = new MemoryBlock (*source.binaryValue); } + + String toString (const ValueUnion& data) const { return data.binaryValue->toBase64Encoding(); } + bool isBinary() const noexcept { return true; } + MemoryBlock* toBinary (const ValueUnion& data) const noexcept { return data.binaryValue; } + + bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept + { + const MemoryBlock* const otherBlock = otherType.toBinary (otherData); + return otherBlock != nullptr && *otherBlock == *data.binaryValue; + } + + void writeToStream (const ValueUnion& data, OutputStream& output) const + { + output.writeCompressedInt (1 + (int) data.binaryValue->getSize()); + output.writeByte (varMarker_Binary); + output << *data.binaryValue; + } +}; + //============================================================================== class var::VariantType_Method : public var::VariantType { @@ -300,7 +335,7 @@ public: static const VariantType_Method instance; String toString (const ValueUnion&) const { return "Method"; } - bool toBool (const ValueUnion& data) const noexcept { return data.methodValue != 0; } + bool toBool (const ValueUnion& data) const noexcept { return data.methodValue != nullptr; } bool isMethod() const noexcept { return true; } bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept @@ -324,6 +359,7 @@ const var::VariantType_Double var::VariantType_Double::instance; const var::VariantType_String var::VariantType_String::instance; const var::VariantType_Object var::VariantType_Object::instance; const var::VariantType_Array var::VariantType_Array::instance; +const var::VariantType_Binary var::VariantType_Binary::instance; const var::VariantType_Method var::VariantType_Method::instance; @@ -354,6 +390,8 @@ var::var (const Array<var>& v) : type (&VariantType_Array::instance) { v var::var (const String& v) : type (&VariantType_String::instance) { new (value.stringValue) String (v); } var::var (const char* const v) : type (&VariantType_String::instance) { new (value.stringValue) String (v); } var::var (const wchar_t* const v) : type (&VariantType_String::instance) { new (value.stringValue) String (v); } +var::var (const void* v, size_t sz) : type (&VariantType_Binary::instance) { value.binaryValue = new MemoryBlock (v, sz); } +var::var (const MemoryBlock& v) : type (&VariantType_Binary::instance) { value.binaryValue = new MemoryBlock (v); } var::var (ReferenceCountedObject* const object) : type (&VariantType_Object::instance) { @@ -363,16 +401,18 @@ var::var (ReferenceCountedObject* const object) : type (&VariantType_Object::in object->incReferenceCount(); } + //============================================================================== -bool var::isVoid() const noexcept { return type->isVoid(); } -bool var::isInt() const noexcept { return type->isInt(); } -bool var::isInt64() const noexcept { return type->isInt64(); } -bool var::isBool() const noexcept { return type->isBool(); } -bool var::isDouble() const noexcept { return type->isDouble(); } -bool var::isString() const noexcept { return type->isString(); } -bool var::isObject() const noexcept { return type->isObject(); } -bool var::isArray() const noexcept { return type->isArray(); } -bool var::isMethod() const noexcept { return type->isMethod(); } +bool var::isVoid() const noexcept { return type->isVoid(); } +bool var::isInt() const noexcept { return type->isInt(); } +bool var::isInt64() const noexcept { return type->isInt64(); } +bool var::isBool() const noexcept { return type->isBool(); } +bool var::isDouble() const noexcept { return type->isDouble(); } +bool var::isString() const noexcept { return type->isString(); } +bool var::isObject() const noexcept { return type->isObject(); } +bool var::isArray() const noexcept { return type->isArray(); } +bool var::isBinaryData() const noexcept { return type->isBinary(); } +bool var::isMethod() const noexcept { return type->isMethod(); } var::operator int() const noexcept { return type->toInt (value); } var::operator int64() const noexcept { return type->toInt64 (value); } @@ -383,6 +423,7 @@ String var::toString() const { return type->toString var::operator String() const { return type->toString (value); } ReferenceCountedObject* var::getObject() const noexcept { return type->toObject (value); } Array<var>* var::getArray() const noexcept { return type->toArray (value); } +MemoryBlock* var::getBinaryData() const noexcept { return type->toBinary (value); } DynamicObject* var::getDynamicObject() const noexcept { return dynamic_cast <DynamicObject*> (getObject()); } //============================================================================== @@ -423,6 +464,11 @@ var::var (String&& v) : type (&VariantType_String::instance) new (value.stringValue) String (static_cast<String&&> (v)); } +var::var (MemoryBlock&& v) : type (&VariantType_Binary::instance) +{ + value.binaryValue = new MemoryBlock (static_cast<MemoryBlock&&> (v)); +} + var& var::operator= (String&& v) { type->cleanUp (value); @@ -452,7 +498,7 @@ bool operator!= (const var& v1, const char* const v2) { return v1.toString //============================================================================== -var var::operator[] (const Identifier& propertyName) const +var var::operator[] (const Identifier propertyName) const { if (DynamicObject* const o = getDynamicObject()) return o->getProperty (propertyName); @@ -465,7 +511,7 @@ var var::operator[] (const char* const propertyName) const return operator[] (Identifier (propertyName)); } -var var::getProperty (const Identifier& propertyName, const var& defaultReturnValue) const +var var::getProperty (const Identifier propertyName, const var& defaultReturnValue) const { if (DynamicObject* const o = getDynamicObject()) return o->getProperties().getWithDefault (propertyName, defaultReturnValue); @@ -473,7 +519,7 @@ var var::getProperty (const Identifier& propertyName, const var& defaultReturnVa return defaultReturnValue; } -var var::invoke (const Identifier& method, const var* arguments, int numArguments) const +var var::invoke (const Identifier method, const var* arguments, int numArguments) const { if (DynamicObject* const o = getDynamicObject()) return o->invokeMethod (method, arguments, numArguments); @@ -491,35 +537,35 @@ var var::invokeMethod (DynamicObject* const target, const var* const arguments, return var::null; } -var var::call (const Identifier& method) const +var var::call (const Identifier method) const { return invoke (method, nullptr, 0); } -var var::call (const Identifier& method, const var& arg1) const +var var::call (const Identifier method, const var& arg1) const { return invoke (method, &arg1, 1); } -var var::call (const Identifier& method, const var& arg1, const var& arg2) const +var var::call (const Identifier method, const var& arg1, const var& arg2) const { var args[] = { arg1, arg2 }; return invoke (method, args, 2); } -var var::call (const Identifier& method, const var& arg1, const var& arg2, const var& arg3) +var var::call (const Identifier method, const var& arg1, const var& arg2, const var& arg3) { var args[] = { arg1, arg2, arg3 }; return invoke (method, args, 3); } -var var::call (const Identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4) const +var var::call (const Identifier method, const var& arg1, const var& arg2, const var& arg3, const var& arg4) const { var args[] = { arg1, arg2, arg3, arg4 }; return invoke (method, args, 4); } -var var::call (const Identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const +var var::call (const Identifier method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const { var args[] = { arg1, arg2, arg3, arg4, arg5 }; return invoke (method, args, 5); @@ -630,6 +676,19 @@ var var::readFromStream (InputStream& input) return var (mo.toUTF8()); } + case varMarker_Binary: + { + MemoryBlock mb (numBytes - 1); + + if (numBytes > 1) + { + const int numRead = input.read (mb.getData(), numBytes - 1); + mb.setSize (numRead); + } + + return var (mb); + } + case varMarker_Array: { var v; diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_Variant.h b/JuceLibraryCode/modules/juce_core/containers/juce_Variant.h index 107bc111f..f11bf608c 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_Variant.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_Variant.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -77,6 +80,8 @@ public: var (const Array<var>& value); var (ReferenceCountedObject* object); var (MethodFunction method) noexcept; + var (const void* binaryData, size_t dataSize); + var (const MemoryBlock& binaryData); var& operator= (const var& valueToCopy); var& operator= (int value); @@ -93,12 +98,14 @@ public: #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS var (var&& other) noexcept; var (String&& value); + var (MemoryBlock&& binaryData); var& operator= (var&& other) noexcept; var& operator= (String&& value); #endif void swapWith (var& other) noexcept; + //============================================================================== operator int() const noexcept; operator int64() const noexcept; operator bool() const noexcept; @@ -106,10 +113,27 @@ public: operator double() const noexcept; operator String() const; String toString() const; + + /** If this variant holds an array, this provides access to it. + NOTE: Beware when you use this - the array pointer is only valid for the lifetime + of the variant that returned it, so be very careful not to call this method on temporary + var objects that are the return-value of a function, and which may go out of scope before + you use the array! + */ Array<var>* getArray() const noexcept; + + /** If this variant holds a memory block, this provides access to it. + NOTE: Beware when you use this - the MemoryBlock pointer is only valid for the lifetime + of the variant that returned it, so be very careful not to call this method on temporary + var objects that are the return-value of a function, and which may go out of scope before + you use the MemoryBlock! + */ + MemoryBlock* getBinaryData() const noexcept; + ReferenceCountedObject* getObject() const noexcept; DynamicObject* getDynamicObject() const noexcept; + //============================================================================== bool isVoid() const noexcept; bool isInt() const noexcept; bool isInt64() const noexcept; @@ -118,6 +142,7 @@ public: bool isString() const noexcept; bool isObject() const noexcept; bool isArray() const noexcept; + bool isBinaryData() const noexcept; bool isMethod() const noexcept; /** Returns true if this var has the same value as the one supplied. @@ -198,27 +223,27 @@ public: //============================================================================== /** If this variant is an object, this returns one of its properties. */ - var operator[] (const Identifier& propertyName) const; + var operator[] (const Identifier propertyName) const; /** If this variant is an object, this returns one of its properties. */ var operator[] (const char* propertyName) const; /** If this variant is an object, this returns one of its properties, or a default fallback value if the property is not set. */ - var getProperty (const Identifier& propertyName, const var& defaultReturnValue) const; + var getProperty (const Identifier propertyName, const var& defaultReturnValue) const; /** If this variant is an object, this invokes one of its methods with no arguments. */ - var call (const Identifier& method) const; + var call (const Identifier method) const; /** If this variant is an object, this invokes one of its methods with one argument. */ - var call (const Identifier& method, const var& arg1) const; + var call (const Identifier method, const var& arg1) const; /** If this variant is an object, this invokes one of its methods with 2 arguments. */ - var call (const Identifier& method, const var& arg1, const var& arg2) const; + var call (const Identifier method, const var& arg1, const var& arg2) const; /** If this variant is an object, this invokes one of its methods with 3 arguments. */ - var call (const Identifier& method, const var& arg1, const var& arg2, const var& arg3); + var call (const Identifier method, const var& arg1, const var& arg2, const var& arg3); /** If this variant is an object, this invokes one of its methods with 4 arguments. */ - var call (const Identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4) const; + var call (const Identifier method, const var& arg1, const var& arg2, const var& arg3, const var& arg4) const; /** If this variant is an object, this invokes one of its methods with 5 arguments. */ - var call (const Identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const; + var call (const Identifier method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const; /** If this variant is an object, this invokes one of its methods with a list of arguments. */ - var invoke (const Identifier& method, const var* arguments, int numArguments) const; + var invoke (const Identifier method, const var* arguments, int numArguments) const; //============================================================================== /** Writes a binary representation of this value to a stream. @@ -245,6 +270,7 @@ private: class VariantType_String; friend class VariantType_String; class VariantType_Object; friend class VariantType_Object; class VariantType_Array; friend class VariantType_Array; + class VariantType_Binary; friend class VariantType_Binary; class VariantType_Method; friend class VariantType_Method; union ValueUnion @@ -256,6 +282,7 @@ private: char stringValue [sizeof (String)]; ReferenceCountedObject* objectValue; Array<var>* arrayValue; + MemoryBlock* binaryValue; MethodFunction methodValue; }; diff --git a/JuceLibraryCode/modules/juce_core/files/juce_DirectoryIterator.cpp b/JuceLibraryCode/modules/juce_core/files/juce_DirectoryIterator.cpp index 0553b8a9b..7da018e1a 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_DirectoryIterator.cpp +++ b/JuceLibraryCode/modules/juce_core/files/juce_DirectoryIterator.cpp @@ -1,50 +1,70 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ -DirectoryIterator::DirectoryIterator (const File& directory, - bool isRecursive_, - const String& wildCard_, - const int whatToLookFor_) - : fileFinder (directory, isRecursive_ ? "*" : wildCard_), - wildCard (wildCard_), +DirectoryIterator::DirectoryIterator (const File& directory, bool recursive, + const String& pattern, const int type) + : wildCards (parseWildcards (pattern)), + fileFinder (directory, (recursive || wildCards.size() > 1) ? "*" : pattern), + wildCard (pattern), path (File::addTrailingSeparator (directory.getFullPathName())), index (-1), totalNumFiles (-1), - whatToLookFor (whatToLookFor_), - isRecursive (isRecursive_), + whatToLookFor (type), + isRecursive (recursive), hasBeenAdvanced (false) { // you have to specify the type of files you're looking for! - jassert ((whatToLookFor_ & (File::findFiles | File::findDirectories)) != 0); - jassert (whatToLookFor_ > 0 && whatToLookFor_ <= 7); + jassert ((type & (File::findFiles | File::findDirectories)) != 0); + jassert (type > 0 && type <= 7); } DirectoryIterator::~DirectoryIterator() { } +StringArray DirectoryIterator::parseWildcards (const String& pattern) +{ + StringArray s; + s.addTokens (pattern, ";,", "\"'"); + s.trim(); + s.removeEmptyStrings(); + return s; +} + +bool DirectoryIterator::fileMatches (const StringArray& wildCards, const String& filename) +{ + for (int i = 0; i < wildCards.size(); ++i) + if (filename.matchesWildcard (wildCards[i], ! File::areFileNamesCaseSensitive())) + return true; + + return false; +} + bool DirectoryIterator::next() { return next (nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); @@ -91,7 +111,7 @@ bool DirectoryIterator::next (bool* const isDirResult, bool* const isHiddenResul // if recursive, we're not relying on the OS iterator to do the wildcard match, so do it now.. if (matches && isRecursive) - matches = filename.matchesWildcard (wildCard, ! File::areFileNamesCaseSensitive()); + matches = fileMatches (wildCards, filename); if (matches && (whatToLookFor & File::ignoreHiddenFiles) != 0) matches = ! isHidden; diff --git a/JuceLibraryCode/modules/juce_core/files/juce_DirectoryIterator.h b/JuceLibraryCode/modules/juce_core/files/juce_DirectoryIterator.h index 0ad3b269a..6dad1be46 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_DirectoryIterator.h +++ b/JuceLibraryCode/modules/juce_core/files/juce_DirectoryIterator.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -64,7 +67,8 @@ public: @param directory the directory to search in @param isRecursive whether all the subdirectories should also be searched - @param wildCard the file pattern to match + @param wildCard the file pattern to match. This may contain multiple patterns + separated by a semi-colon or comma, e.g. "*.jpg;*.png" @param whatToLookFor a value from the File::TypesOfFileToFind enum, specifying whether to look for files, directories, or both. */ @@ -138,6 +142,7 @@ private: }; friend class ScopedPointer<NativeIterator::Pimpl>; + StringArray wildCards; NativeIterator fileFinder; String wildCard, path; int index; @@ -148,6 +153,9 @@ private: ScopedPointer <DirectoryIterator> subIterator; File currentFile; + static StringArray parseWildcards (const String& pattern); + static bool fileMatches (const StringArray& wildCards, const String& filename); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryIterator) }; diff --git a/JuceLibraryCode/modules/juce_core/files/juce_File.cpp b/JuceLibraryCode/modules/juce_core/files/juce_File.cpp index 567810efb..5c8a8352f 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_File.cpp +++ b/JuceLibraryCode/modules/juce_core/files/juce_File.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -457,13 +460,13 @@ Result File::createDirectory() const } //============================================================================== -Time File::getLastModificationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (m); } -Time File::getLastAccessTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (a); } -Time File::getCreationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (c); } +Time File::getLastModificationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (m); } +Time File::getLastAccessTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (a); } +Time File::getCreationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (c); } -bool File::setLastModificationTime (const Time& t) const { return setFileTimesInternal (t.toMilliseconds(), 0, 0); } -bool File::setLastAccessTime (const Time& t) const { return setFileTimesInternal (0, t.toMilliseconds(), 0); } -bool File::setCreationTime (const Time& t) const { return setFileTimesInternal (0, 0, t.toMilliseconds()); } +bool File::setLastModificationTime (Time t) const { return setFileTimesInternal (t.toMilliseconds(), 0, 0); } +bool File::setLastAccessTime (Time t) const { return setFileTimesInternal (0, t.toMilliseconds(), 0); } +bool File::setCreationTime (Time t) const { return setFileTimesInternal (0, 0, t.toMilliseconds()); } //============================================================================== bool File::loadFileAsData (MemoryBlock& destBlock) const diff --git a/JuceLibraryCode/modules/juce_core/files/juce_File.h b/JuceLibraryCode/modules/juce_core/files/juce_File.h index 25bd0f101..701649418 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_File.h +++ b/JuceLibraryCode/modules/juce_core/files/juce_File.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -392,7 +395,7 @@ public: @returns true if it manages to change the file's time. @see getLastModificationTime, setLastAccessTime, setCreationTime */ - bool setLastModificationTime (const Time& newTime) const; + bool setLastModificationTime (Time newTime) const; /** Changes the last-access time for this file. @@ -400,7 +403,7 @@ public: @returns true if it manages to change the file's time. @see getLastAccessTime, setLastModificationTime, setCreationTime */ - bool setLastAccessTime (const Time& newTime) const; + bool setLastAccessTime (Time newTime) const; /** Changes the creation date for this file. @@ -408,7 +411,7 @@ public: @returns true if it manages to change the file's time. @see getCreationTime, setLastModificationTime, setLastAccessTime */ - bool setCreationTime (const Time& newTime) const; + bool setCreationTime (Time newTime) const; /** If possible, this will try to create a version string for the given file. diff --git a/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.cpp b/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.cpp index 2d8a64fb3..426f3adc7 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.h b/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.h index 9a89ea4e7..589c9e601 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.h +++ b/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/files/juce_FileOutputStream.cpp b/JuceLibraryCode/modules/juce_core/files/juce_FileOutputStream.cpp index b8f1be5e4..54487093d 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_FileOutputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/files/juce_FileOutputStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/files/juce_FileOutputStream.h b/JuceLibraryCode/modules/juce_core/files/juce_FileOutputStream.h index d6188c797..b3aae8105 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_FileOutputStream.h +++ b/JuceLibraryCode/modules/juce_core/files/juce_FileOutputStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.cpp b/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.cpp index d5d0b1d8b..053e92a1a 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.cpp +++ b/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.h b/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.h index adc018ae6..c1f9a5af0 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.h +++ b/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/files/juce_MemoryMappedFile.h b/JuceLibraryCode/modules/juce_core/files/juce_MemoryMappedFile.h index 62ddfd54d..f1aaa56ae 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_MemoryMappedFile.h +++ b/JuceLibraryCode/modules/juce_core/files/juce_MemoryMappedFile.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/files/juce_TemporaryFile.cpp b/JuceLibraryCode/modules/juce_core/files/juce_TemporaryFile.cpp index 51885490b..d5789b65e 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_TemporaryFile.cpp +++ b/JuceLibraryCode/modules/juce_core/files/juce_TemporaryFile.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/files/juce_TemporaryFile.h b/JuceLibraryCode/modules/juce_core/files/juce_TemporaryFile.h index 0cc5bcb4f..477ff161a 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_TemporaryFile.h +++ b/JuceLibraryCode/modules/juce_core/files/juce_TemporaryFile.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/json/juce_JSON.cpp b/JuceLibraryCode/modules/juce_core/json/juce_JSON.cpp index e03df74d1..b49a39ceb 100644 --- a/JuceLibraryCode/modules/juce_core/json/juce_JSON.cpp +++ b/JuceLibraryCode/modules/juce_core/json/juce_JSON.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -26,6 +29,21 @@ class JSONParser { public: + static Result parseObjectOrArray (String::CharPointerType t, var& result) + { + t = t.findEndOfWhitespace(); + + switch (t.getAndAdvance()) + { + case 0: result = var::null; return Result::ok(); + case '{': return parseObject (t, result); + case '[': return parseArray (t, result); + } + + return createFail ("Expected '{' or '['", &t); + } + +private: static Result parseAny (String::CharPointerType& t, var& result) { t = t.findEndOfWhitespace(); @@ -34,7 +52,7 @@ public: switch (t2.getAndAdvance()) { case '{': t = t2; return parseObject (t, result); - case '[': t = t2; return parseArray (t, result); + case '[': t = t2; return parseArray (t, result); case '"': t = t2; return parseString (t, result); case '-': @@ -84,7 +102,6 @@ public: return createFail ("Syntax error", &t); } -private: static Result createFail (const char* const message, const String::CharPointerType* location = nullptr) { String m (message); @@ -194,7 +211,8 @@ private: if (nextChar == ',') continue; - else if (nextChar == '}') + + if (nextChar == '}') break; } } @@ -237,7 +255,8 @@ private: if (nextChar == ',') continue; - else if (nextChar == ']') + + if (nextChar == ']') break; return createFail ("Expected object array item, but found", &oldT); @@ -248,8 +267,7 @@ private: static Result parseString (String::CharPointerType& t, var& result) { - Array<juce_wchar> buffer; - buffer.ensureStorageAllocated (256); + MemoryOutputStream buffer (256); for (;;) { @@ -295,11 +313,10 @@ private: if (c == 0) return createFail ("Unexpected end-of-input in string constant"); - buffer.add (c); + buffer.appendUTF8Char (c); } - buffer.add (0); - result = String (CharPointer_UTF32 (buffer.getRawDataPointer())); + result = buffer.toString(); return Result::ok(); } }; @@ -336,7 +353,8 @@ public: } else { - jassert (! v.isMethod()); // Can't convert an object with methods to JSON! + // Can't convert these other types of object to JSON! + jassert (! (v.isMethod() || v.isBinaryData())); out << v.toString(); } @@ -482,8 +500,8 @@ private: var JSON::parse (const String& text) { var result; - String::CharPointerType t (text.getCharPointer()); - if (! JSONParser::parseAny (t, result)) + + if (! JSONParser::parseObjectOrArray (text.getCharPointer(), result)) result = var::null; return result; @@ -501,8 +519,7 @@ var JSON::parse (const File& file) Result JSON::parse (const String& text, var& result) { - String::CharPointerType t (text.getCharPointer()); - return JSONParser::parseAny (t, result); + return JSONParser::parseObjectOrArray (text.getCharPointer(), result); } String JSON::toString (const var& data, const bool allOnOneLine) @@ -605,12 +622,12 @@ public: expect (JSON::parse (String::empty) == var::null); expect (JSON::parse ("{}").isObject()); expect (JSON::parse ("[]").isArray()); - expect (JSON::parse ("1234").isInt()); - expect (JSON::parse ("12345678901234").isInt64()); - expect (JSON::parse ("1.123e3").isDouble()); - expect (JSON::parse ("-1234").isInt()); - expect (JSON::parse ("-12345678901234").isInt64()); - expect (JSON::parse ("-1.123e3").isDouble()); + expect (JSON::parse ("[ 1234 ]")[0].isInt()); + expect (JSON::parse ("[ 12345678901234 ]")[0].isInt64()); + expect (JSON::parse ("[ 1.123e3 ]")[0].isDouble()); + expect (JSON::parse ("[ -1234]")[0].isInt()); + expect (JSON::parse ("[-12345678901234]")[0].isInt64()); + expect (JSON::parse ("[-1.123e3]")[0].isDouble()); for (int i = 100; --i >= 0;) { @@ -621,7 +638,7 @@ public: const bool oneLine = r.nextBool(); String asString (JSON::toString (v, oneLine)); - var parsed = JSON::parse (asString); + var parsed = JSON::parse ("[" + asString + "]")[0]; String parsedString (JSON::toString (parsed, oneLine)); expect (asString.isNotEmpty() && parsedString == asString); } diff --git a/JuceLibraryCode/modules/juce_core/json/juce_JSON.h b/JuceLibraryCode/modules/juce_core/json/juce_JSON.h index da09a86ca..dc5b8366d 100644 --- a/JuceLibraryCode/modules/juce_core/json/juce_JSON.h +++ b/JuceLibraryCode/modules/juce_core/json/juce_JSON.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/juce_core.cpp b/JuceLibraryCode/modules/juce_core/juce_core.cpp index ea54142c1..a5d522761 100644 --- a/JuceLibraryCode/modules/juce_core/juce_core.cpp +++ b/JuceLibraryCode/modules/juce_core/juce_core.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -52,10 +55,13 @@ #include <ctime> #include <winsock2.h> #include <ws2tcpip.h> - #include <Dbghelp.h> - #if ! JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES - #pragma comment (lib, "DbgHelp.lib") + #if ! JUCE_MINGW + #include <Dbghelp.h> + + #if ! JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES + #pragma comment (lib, "DbgHelp.lib") + #endif #endif #if JUCE_MINGW @@ -81,6 +87,8 @@ #include <arpa/inet.h> #include <netinet/tcp.h> #include <sys/time.h> + #include <net/if.h> + #include <sys/ioctl.h> #if ! JUCE_ANDROID #include <execinfo.h> @@ -125,6 +133,7 @@ namespace juce #include "network/juce_NamedPipe.cpp" #include "network/juce_Socket.cpp" #include "network/juce_URL.cpp" +#include "network/juce_IPAddress.cpp" #include "streams/juce_BufferedInputStream.cpp" #include "streams/juce_FileInputSource.cpp" #include "streams/juce_InputStream.cpp" diff --git a/JuceLibraryCode/modules/juce_core/juce_core.h b/JuceLibraryCode/modules/juce_core/juce_core.h index 469b0fd62..4425f95a9 100644 --- a/JuceLibraryCode/modules/juce_core/juce_core.h +++ b/JuceLibraryCode/modules/juce_core/juce_core.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -26,14 +29,6 @@ #ifndef __JUCE_CORE_JUCEHEADER__ #define __JUCE_CORE_JUCEHEADER__ -/* This line is here as a sanity-check to catch syntax errors caused by mistakes in 3rd-party - header files that have been included prior to this one. If you hit an error at this line, - there's probably some kind of syntax problem in whatever code immediately precedes this header. - - It also causes an error if you attempt to build using a C or obj-C compiler rather than a C++ one. -*/ -namespace DummyNamespaceStatementToCatchSyntaxErrors {} - #ifndef JUCE_MODULE_AVAILABLE_juce_core /* If you fail to make sure that all your compile units are building JUCE with the same set of option flags, then there's a risk that different compile units will treat the classes as having @@ -280,6 +275,9 @@ namespace juce #ifndef __JUCE_WINDOWSREGISTRY_JUCEHEADER__ #include "misc/juce_WindowsRegistry.h" #endif +#ifndef __JUCE_IPADDRESS_JUCEHEADER__ + #include "network/juce_IPAddress.h" +#endif #ifndef __JUCE_MACADDRESS_JUCEHEADER__ #include "network/juce_MACAddress.h" #endif diff --git a/JuceLibraryCode/modules/juce_core/juce_core.mm b/JuceLibraryCode/modules/juce_core/juce_core.mm index 6814ebd32..90a2f7cdb 100644 --- a/JuceLibraryCode/modules/juce_core/juce_core.mm +++ b/JuceLibraryCode/modules/juce_core/juce_core.mm @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/juce_module_info b/JuceLibraryCode/modules/juce_core/juce_module_info index 99ebd2b31..8a5fde872 100644 --- a/JuceLibraryCode/modules/juce_core/juce_module_info +++ b/JuceLibraryCode/modules/juce_core/juce_module_info @@ -1,10 +1,10 @@ { "id": "juce_core", "name": "JUCE core classes", - "version": "2.0.38", + "version": "2.1.1", "description": "The essential set of basic JUCE classes, as required by all the other JUCE modules. Includes text, container, memory, threading and i/o functionality.", "website": "http://www.juce.com/juce", - "license": "GPL/Commercial", + "license": "ISC Permissive", "dependencies": [], @@ -33,5 +33,6 @@ "OSXFrameworks": "Cocoa IOKit", "iOSFrameworks": "Foundation", - "LinuxLibs": "rt dl pthread" + "LinuxLibs": "rt dl pthread", + "mingwLibs": "uuid wsock32 wininet version ole32 ws2_32 oleaut32 imm32 comdlg32 shlwapi rpcrt4 winmm" } diff --git a/JuceLibraryCode/modules/juce_core/logging/juce_FileLogger.cpp b/JuceLibraryCode/modules/juce_core/logging/juce_FileLogger.cpp index c21785770..8cadfda8b 100644 --- a/JuceLibraryCode/modules/juce_core/logging/juce_FileLogger.cpp +++ b/JuceLibraryCode/modules/juce_core/logging/juce_FileLogger.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/logging/juce_FileLogger.h b/JuceLibraryCode/modules/juce_core/logging/juce_FileLogger.h index bf040d20d..4436cbf08 100644 --- a/JuceLibraryCode/modules/juce_core/logging/juce_FileLogger.h +++ b/JuceLibraryCode/modules/juce_core/logging/juce_FileLogger.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -33,7 +36,7 @@ //============================================================================== /** - A simple implemenation of a Logger that writes to a file. + A simple implementation of a Logger that writes to a file. @see Logger */ diff --git a/JuceLibraryCode/modules/juce_core/logging/juce_Logger.cpp b/JuceLibraryCode/modules/juce_core/logging/juce_Logger.cpp index 6e2c940a3..0b1c8d6be 100644 --- a/JuceLibraryCode/modules/juce_core/logging/juce_Logger.cpp +++ b/JuceLibraryCode/modules/juce_core/logging/juce_Logger.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -45,12 +48,16 @@ void Logger::writeToLog (const String& message) outputDebugString (message); } -#if JUCE_LOG_ASSERTIONS -void JUCE_API logAssertion (const char* const filename, const int lineNum) noexcept +#if JUCE_LOG_ASSERTIONS || JUCE_DEBUG +void JUCE_API JUCE_CALLTYPE logAssertion (const char* const filename, const int lineNum) noexcept { String m ("JUCE Assertion failure in "); m << File::createFileWithoutCheckingPath (filename).getFileName() << ':' << lineNum; + #if JUCE_LOG_ASSERTIONS Logger::writeToLog (m); + #else + DBG (m); + #endif } #endif diff --git a/JuceLibraryCode/modules/juce_core/logging/juce_Logger.h b/JuceLibraryCode/modules/juce_core/logging/juce_Logger.h index 6282c0c0c..c9f2f3d84 100644 --- a/JuceLibraryCode/modules/juce_core/logging/juce_Logger.h +++ b/JuceLibraryCode/modules/juce_core/logging/juce_Logger.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.cpp b/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.cpp index 0db4198e8..398fbc354 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.cpp +++ b/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.h b/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.h index 34e3d77f2..94c5a34bb 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.h +++ b/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_Expression.cpp b/JuceLibraryCode/modules/juce_core/maths/juce_Expression.cpp index 69f920c37..41b144a8c 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_Expression.cpp +++ b/JuceLibraryCode/modules/juce_core/maths/juce_Expression.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_Expression.h b/JuceLibraryCode/modules/juce_core/maths/juce_Expression.h index da2c5e51d..d7c1ff346 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_Expression.h +++ b/JuceLibraryCode/modules/juce_core/maths/juce_Expression.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions.h b/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions.h index f5c064763..d365f55e3 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions.h +++ b/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -300,13 +303,11 @@ inline int64 abs64 (const int64 n) noexcept //============================================================================== /** A predefined value for Pi, at double-precision. - @see float_Pi */ const double double_Pi = 3.1415926535897932384626433832795; -/** A predefined value for Pi, at sngle-precision. - +/** A predefined value for Pi, at single-precision. @see double_Pi */ const float float_Pi = 3.14159265358979323846f; diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_Random.cpp b/JuceLibraryCode/modules/juce_core/maths/juce_Random.cpp index ef6447ab9..a884f6704 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_Random.cpp +++ b/JuceLibraryCode/modules/juce_core/maths/juce_Random.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_Random.h b/JuceLibraryCode/modules/juce_core/maths/juce_Random.h index af279e5a1..d9296987b 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_Random.h +++ b/JuceLibraryCode/modules/juce_core/maths/juce_Random.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_Range.h b/JuceLibraryCode/modules/juce_core/maths/juce_Range.h index 95a675d7a..1e05624b3 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_Range.h +++ b/JuceLibraryCode/modules/juce_core/maths/juce_Range.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -40,8 +43,7 @@ class Range public: //============================================================================== /** Constructs an empty range. */ - Range() noexcept - : start (ValueType()), end (ValueType()) + Range() noexcept : start(), end() { } @@ -58,23 +60,18 @@ public: } /** Copies another range object. */ - Range& operator= (const Range& other) noexcept + Range& operator= (Range other) noexcept { start = other.start; end = other.end; return *this; } - /** Destructor. */ - ~Range() noexcept - { - } - /** Returns the range that lies between two positions (in either order). */ static Range between (const ValueType position1, const ValueType position2) noexcept { - return (position1 < position2) ? Range (position1, position2) - : Range (position2, position1); + return position1 < position2 ? Range (position1, position2) + : Range (position2, position1); } /** Returns a range with the specified start position and a length of zero. */ @@ -167,7 +164,7 @@ public: //============================================================================== /** Adds an amount to the start and end of the range. */ - inline const Range& operator+= (const ValueType amountToAdd) noexcept + inline Range operator+= (const ValueType amountToAdd) noexcept { start += amountToAdd; end += amountToAdd; @@ -175,7 +172,7 @@ public: } /** Subtracts an amount from the start and end of the range. */ - inline const Range& operator-= (const ValueType amountToSubtract) noexcept + inline Range operator-= (const ValueType amountToSubtract) noexcept { start -= amountToSubtract; end -= amountToSubtract; @@ -197,8 +194,8 @@ public: return Range (start - amountToSubtract, end - amountToSubtract); } - bool operator== (const Range& other) const noexcept { return start == other.start && end == other.end; } - bool operator!= (const Range& other) const noexcept { return start != other.start || end != other.end; } + bool operator== (Range other) const noexcept { return start == other.start && end == other.end; } + bool operator!= (Range other) const noexcept { return start != other.start || end != other.end; } //============================================================================== /** Returns true if the given position lies inside this range. */ @@ -214,27 +211,27 @@ public: } /** Returns true if the given range lies entirely inside this range. */ - bool contains (const Range& other) const noexcept + bool contains (Range other) const noexcept { return start <= other.start && end >= other.end; } /** Returns true if the given range intersects this one. */ - bool intersects (const Range& other) const noexcept + bool intersects (Range other) const noexcept { return other.start < end && start < other.end; } /** Returns the range that is the intersection of the two ranges, or an empty range with an undefined start position if they don't overlap. */ - Range getIntersectionWith (const Range& other) const noexcept + Range getIntersectionWith (Range other) const noexcept { return Range (jmax (start, other.start), jmin (end, other.end)); } /** Returns the smallest range that contains both this one and the other one. */ - Range getUnionWith (const Range& other) const noexcept + Range getUnionWith (Range other) const noexcept { return Range (jmin (start, other.start), jmax (end, other.end)); @@ -250,7 +247,7 @@ public: will be the new range, shifted forwards or backwards so that it doesn't extend beyond this one, but keeping its original length. */ - Range constrainRange (const Range& rangeToConstrain) const noexcept + Range constrainRange (Range rangeToConstrain) const noexcept { const ValueType otherLen = rangeToConstrain.getLength(); return getLength() <= otherLen diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_Atomic.h b/JuceLibraryCode/modules/juce_core/memory/juce_Atomic.h index e31d23eba..1c846f055 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_Atomic.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_Atomic.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -45,7 +48,7 @@ public: } /** Creates a new value, with a given initial value. */ - inline Atomic (const Type initialValue) noexcept + inline explicit Atomic (const Type initialValue) noexcept : value (initialValue) { } diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_ByteOrder.h b/JuceLibraryCode/modules/juce_core/memory/juce_ByteOrder.h index bd9bc4c1f..1c8827dd8 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_ByteOrder.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_ByteOrder.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_HeapBlock.h b/JuceLibraryCode/modules/juce_core/memory/juce_HeapBlock.h index 8986a8fe8..5f8dfc7b7 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_HeapBlock.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_HeapBlock.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_LeakedObjectDetector.h b/JuceLibraryCode/modules/juce_core/memory/juce_LeakedObjectDetector.h index 4d8618768..7c0eb57af 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_LeakedObjectDetector.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_LeakedObjectDetector.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_Memory.h b/JuceLibraryCode/modules/juce_core/memory/juce_Memory.h index 7defad5b6..d13774de3 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_Memory.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_Memory.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -79,8 +82,16 @@ inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != n JUCE_DECLARE_NON_COPYABLE (ScopedAutoReleasePool) }; - /** A macro that can be used to easily declare a local ScopedAutoReleasePool object for RAII-based obj-C autoreleasing. */ + /** A macro that can be used to easily declare a local ScopedAutoReleasePool + object for RAII-based obj-C autoreleasing. + Because this may use the \@autoreleasepool syntax, you must follow the macro with + a set of braces to mark the scope of the pool. + */ +#if (JUCE_COMPILER_SUPPORTS_ARC && defined (__OBJC__)) || DOXYGEN + #define JUCE_AUTORELEASEPOOL @autoreleasepool +#else #define JUCE_AUTORELEASEPOOL const juce::ScopedAutoReleasePool JUCE_JOIN_MACRO (autoReleasePool_, __LINE__); +#endif #else #define JUCE_AUTORELEASEPOOL @@ -92,7 +103,7 @@ inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != n avoiding problems when an object is created in one module and passed across to another where it is deleted. By piggy-backing on the JUCE_LEAK_DETECTOR macro, these allocators can be injected into most juce classes. */ -#if JUCE_MSVC && (defined (JUCE_DLL) || defined (JUCE_DLL_BUILD)) && ! DOXYGEN +#if JUCE_MSVC && (defined (JUCE_DLL) || defined (JUCE_DLL_BUILD)) && ! (JUCE_DISABLE_DLL_ALLOCATORS || DOXYGEN) extern JUCE_API void* juceDLL_malloc (size_t); extern JUCE_API void juceDLL_free (void*); diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.cpp b/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.cpp index e6ff0f2f1..29f930798 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.cpp +++ b/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.h b/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.h index e84cf2a2b..74d10b48a 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_OptionalScopedPointer.h b/JuceLibraryCode/modules/juce_core/memory/juce_OptionalScopedPointer.h index 55d23470c..37110134a 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_OptionalScopedPointer.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_OptionalScopedPointer.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_ReferenceCountedObject.h b/JuceLibraryCode/modules/juce_core/memory/juce_ReferenceCountedObject.h index b1d1a8629..34d8a0d30 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_ReferenceCountedObject.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_ReferenceCountedObject.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -125,7 +128,7 @@ private: /** Adds reference-counting to an object. - This is efectively a version of the ReferenceCountedObject class, but which + This is effectively a version of the ReferenceCountedObject class, but which uses a non-atomic counter, and so is not thread-safe (but which will be more efficient). For more details on how to use it, see the ReferenceCountedObject class notes. diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_ScopedPointer.h b/JuceLibraryCode/modules/juce_core/memory/juce_ScopedPointer.h index 0676fdcfc..7fe216141 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_ScopedPointer.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_ScopedPointer.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -141,6 +144,21 @@ public: return *this; } + #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS + ScopedPointer (ScopedPointer&& other) noexcept + : object (other.object) + { + other.object = nullptr; + } + + ScopedPointer& operator= (ScopedPointer&& other) noexcept + { + object = other.object; + other.object = nullptr; + return *this; + } + #endif + //============================================================================== /** Returns the object that this ScopedPointer refers to. */ inline operator ObjectType*() const noexcept { return object; } @@ -186,11 +204,11 @@ private: const ScopedPointer* getAddress() const noexcept { return this; } #if ! JUCE_MSVC // (MSVC can't deal with multiple copy constructors) - /* These are private to stop people accidentally copying a const ScopedPointer (the compiler - would let you do so by implicitly casting the source to its raw object pointer). + /* The copy constructors are private to stop people accidentally copying a const ScopedPointer + (the compiler would let you do so by implicitly casting the source to its raw object pointer). - A side effect of this is that you may hit a puzzling compiler error when you write something - like this: + A side effect of this is that in a compiler that doesn't support C++11, you may hit an + error when you write something like this: ScopedPointer<MyClass> m = new MyClass(); // Compile error: copy constructor is private. @@ -199,12 +217,10 @@ private: ScopedPointer<MyClass> m (new MyClass()); // Compiles OK - It's good practice to always use the latter form when writing your object declarations anyway, - rather than writing them as assignments and assuming (or hoping) that the compiler will be - smart enough to replace your construction + assignment with a single constructor. + It's probably best to use the latter form when writing your object declarations anyway, as + this is a better representation of the code that you actually want the compiler to produce. */ - ScopedPointer (const ScopedPointer&); - ScopedPointer& operator= (const ScopedPointer&); + JUCE_DECLARE_NON_COPYABLE (ScopedPointer) #endif }; diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_Singleton.h b/JuceLibraryCode/modules/juce_core/memory/juce_Singleton.h index b9b6e82d1..0935b742e 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_Singleton.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_Singleton.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_WeakReference.h b/JuceLibraryCode/modules/juce_core/memory/juce_WeakReference.h index 9ba7e9ef9..7d3ccc6cd 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_WeakReference.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_WeakReference.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_Result.cpp b/JuceLibraryCode/modules/juce_core/misc/juce_Result.cpp index d25dba9c6..f4d19852b 100644 --- a/JuceLibraryCode/modules/juce_core/misc/juce_Result.cpp +++ b/JuceLibraryCode/modules/juce_core/misc/juce_Result.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_Result.h b/JuceLibraryCode/modules/juce_core/misc/juce_Result.h index 03225c8e7..701059556 100644 --- a/JuceLibraryCode/modules/juce_core/misc/juce_Result.h +++ b/JuceLibraryCode/modules/juce_core/misc/juce_Result.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_Uuid.cpp b/JuceLibraryCode/modules/juce_core/misc/juce_Uuid.cpp index ecd8c443a..9df787f4a 100644 --- a/JuceLibraryCode/modules/juce_core/misc/juce_Uuid.cpp +++ b/JuceLibraryCode/modules/juce_core/misc/juce_Uuid.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_Uuid.h b/JuceLibraryCode/modules/juce_core/misc/juce_Uuid.h index 0b45f7865..878804f71 100644 --- a/JuceLibraryCode/modules/juce_core/misc/juce_Uuid.h +++ b/JuceLibraryCode/modules/juce_core/misc/juce_Uuid.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_WindowsRegistry.h b/JuceLibraryCode/modules/juce_core/misc/juce_WindowsRegistry.h index 8f1d658d3..e542d5fb4 100644 --- a/JuceLibraryCode/modules/juce_core/misc/juce_WindowsRegistry.h +++ b/JuceLibraryCode/modules/juce_core/misc/juce_WindowsRegistry.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/java/JuceAppActivity.java b/JuceLibraryCode/modules/juce_core/native/java/JuceAppActivity.java index 057994e67..458e75714 100644 --- a/JuceLibraryCode/modules/juce_core/native/java/JuceAppActivity.java +++ b/JuceLibraryCode/modules/juce_core/native/java/JuceAppActivity.java @@ -69,6 +69,8 @@ public final class JuceAppActivity extends Activity viewHolder = new ViewHolder (this); setContentView (viewHolder); + + setVolumeControlStream (AudioManager.STREAM_MUSIC); } @Override diff --git a/JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h b/JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h index 970448990..a76b0ac49 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h +++ b/JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_android_Files.cpp b/JuceLibraryCode/modules/juce_core/native/juce_android_Files.cpp index e6e1ee4e3..15f90886d 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_android_Files.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_android_Files.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_android_JNIHelpers.h b/JuceLibraryCode/modules/juce_core/native/juce_android_JNIHelpers.h index 8ab63ffb4..1ad45c81f 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_android_JNIHelpers.h +++ b/JuceLibraryCode/modules/juce_core/native/juce_android_JNIHelpers.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_android_Misc.cpp b/JuceLibraryCode/modules/juce_core/native/juce_android_Misc.cpp index 36c1685ba..b9d5f733c 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_android_Misc.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_android_Misc.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_android_Network.cpp b/JuceLibraryCode/modules/juce_core/native/juce_android_Network.cpp index 0c8508231..fe5f45057 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_android_Network.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_android_Network.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_android_SystemStats.cpp b/JuceLibraryCode/modules/juce_core/native/juce_android_SystemStats.cpp index 0ce161cbe..56c6cd9bf 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_android_SystemStats.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_android_SystemStats.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_android_Threads.cpp b/JuceLibraryCode/modules/juce_core/native/juce_android_Threads.cpp index f8d9e74c0..b1b1bd0ae 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_android_Threads.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_android_Threads.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_linux_Files.cpp b/JuceLibraryCode/modules/juce_core/native/juce_linux_Files.cpp index f0b1586a2..a953cba2b 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_linux_Files.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_linux_Files.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_linux_Network.cpp b/JuceLibraryCode/modules/juce_core/native/juce_linux_Network.cpp index 0dd84e881..84805d9ae 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_linux_Network.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_linux_Network.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -258,8 +261,7 @@ private: if (responseHeader.isNotEmpty()) { - headerLines.clear(); - headerLines.addLines (responseHeader); + headerLines = StringArray::fromLines (responseHeader); const int statusCode = responseHeader.fromFirstOccurrenceOf (" ", false, false) .substring (0, 3).getIntValue(); diff --git a/JuceLibraryCode/modules/juce_core/native/juce_linux_SystemStats.cpp b/JuceLibraryCode/modules/juce_core/native/juce_linux_SystemStats.cpp index 767a8cd27..ccbb307c9 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_linux_SystemStats.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_linux_SystemStats.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_linux_Threads.cpp b/JuceLibraryCode/modules/juce_core/native/juce_linux_Threads.cpp index 6e999b278..36bbf0aaa 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_linux_Threads.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_linux_Threads.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -77,22 +80,11 @@ JUCE_API bool JUCE_CALLTYPE Process::isRunningUnderDebugger() return juce_isRunningUnderDebugger(); } -void Process::raisePrivilege() +static void swapUserAndEffectiveUser() { - // If running suid root, change effective user to root - if (geteuid() != 0 && getuid() == 0) - { - setreuid (geteuid(), getuid()); - setregid (getegid(), getgid()); - } + (void) setreuid (geteuid(), getuid()); + (void) setregid (getegid(), getgid()); } -void Process::lowerPrivilege() -{ - // If runing suid root, change effective user back to real user - if (geteuid() == 0 && getuid() != 0) - { - setreuid (geteuid(), getuid()); - setregid (getegid(), getgid()); - } -} +void Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); } +void Process::lowerPrivilege() { if (geteuid() == 0 && getuid() != 0) swapUserAndEffectiveUser(); } diff --git a/JuceLibraryCode/modules/juce_core/native/juce_mac_Files.mm b/JuceLibraryCode/modules/juce_core/native/juce_mac_Files.mm index 6548a4ed3..ccd30df2d 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_mac_Files.mm +++ b/JuceLibraryCode/modules/juce_core/native/juce_mac_Files.mm @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -32,18 +35,20 @@ bool File::copyInternal (const File& dest) const { JUCE_AUTORELEASEPOOL - NSFileManager* fm = [NSFileManager defaultManager]; - - return [fm fileExistsAtPath: juceStringToNS (fullPath)] - #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 - && [fm copyItemAtPath: juceStringToNS (fullPath) - toPath: juceStringToNS (dest.getFullPathName()) - error: nil]; - #else - && [fm copyPath: juceStringToNS (fullPath) - toPath: juceStringToNS (dest.getFullPathName()) - handler: nil]; - #endif + { + NSFileManager* fm = [NSFileManager defaultManager]; + + return [fm fileExistsAtPath: juceStringToNS (fullPath)] + #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + && [fm copyItemAtPath: juceStringToNS (fullPath) + toPath: juceStringToNS (dest.getFullPathName()) + error: nil]; + #else + && [fm copyPath: juceStringToNS (fullPath) + toPath: juceStringToNS (dest.getFullPathName()) + handler: nil]; + #endif + } } void File::findFileSystemRoots (Array<File>& destArray) @@ -75,19 +80,21 @@ namespace FileHelpers { #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 JUCE_AUTORELEASEPOOL - NSNumber* hidden = nil; - NSError* err = nil; + { + NSNumber* hidden = nil; + NSError* err = nil; - return [[NSURL fileURLWithPath: juceStringToNS (path)] - getResourceValue: &hidden forKey: NSURLIsHiddenKey error: &err] - && [hidden boolValue]; + return [[NSURL fileURLWithPath: juceStringToNS (path)] + getResourceValue: &hidden forKey: NSURLIsHiddenKey error: &err] + && [hidden boolValue]; + } #elif JUCE_IOS return File (path).getFileName().startsWithChar ('.'); #else FSRef ref; LSItemInfoRecord info; - return FSPathMakeRefWithOptions ((const UInt8*) path.toUTF8().getAddress(), kFSPathMakeRefDoNotFollowLeafSymlink, &ref, 0) == noErr + return FSPathMakeRefWithOptions ((const UInt8*) path.toRawUTF8(), kFSPathMakeRefDoNotFollowLeafSymlink, &ref, 0) == noErr && LSCopyItemInfoForRef (&ref, kLSRequestBasicFlagsOnly, &info) == noErr && (info.flags & kLSItemInfoIsInvisible) != 0; #endif @@ -143,17 +150,19 @@ bool File::isOnRemovableDrive() const return false; // xxx is this possible? #else JUCE_AUTORELEASEPOOL - BOOL removable = false; + { + BOOL removable = false; - [[NSWorkspace sharedWorkspace] - getFileSystemInfoForPath: juceStringToNS (getFullPathName()) - isRemovable: &removable - isWritable: nil - isUnmountable: nil - description: nil - type: nil]; + [[NSWorkspace sharedWorkspace] + getFileSystemInfoForPath: juceStringToNS (getFullPathName()) + isRemovable: &removable + isWritable: nil + isUnmountable: nil + description: nil + type: nil]; - return removable; + return removable; + } #endif } @@ -169,82 +178,84 @@ int juce_argc = 0; File File::getSpecialLocation (const SpecialLocationType type) { JUCE_AUTORELEASEPOOL - String resultPath; - - switch (type) { - case userHomeDirectory: resultPath = nsStringToJuce (NSHomeDirectory()); break; - - #if JUCE_IOS - case userDocumentsDirectory: resultPath = FileHelpers::getIOSSystemLocation (NSDocumentDirectory); break; - case userDesktopDirectory: resultPath = FileHelpers::getIOSSystemLocation (NSDesktopDirectory); break; + String resultPath; - case tempDirectory: + switch (type) { - File tmp (FileHelpers::getIOSSystemLocation (NSCachesDirectory)); - tmp = tmp.getChildFile (juce_getExecutableFile().getFileNameWithoutExtension()); - tmp.createDirectory(); - return tmp.getFullPathName(); - } + case userHomeDirectory: resultPath = nsStringToJuce (NSHomeDirectory()); break; - #else - case userDocumentsDirectory: resultPath = "~/Documents"; break; - case userDesktopDirectory: resultPath = "~/Desktop"; break; + #if JUCE_IOS + case userDocumentsDirectory: resultPath = FileHelpers::getIOSSystemLocation (NSDocumentDirectory); break; + case userDesktopDirectory: resultPath = FileHelpers::getIOSSystemLocation (NSDesktopDirectory); break; - case tempDirectory: - { - File tmp ("~/Library/Caches/" + juce_getExecutableFile().getFileNameWithoutExtension()); - tmp.createDirectory(); - return tmp.getFullPathName(); - } - #endif - case userMusicDirectory: resultPath = "~/Music"; break; - case userMoviesDirectory: resultPath = "~/Movies"; break; - case userPicturesDirectory: resultPath = "~/Pictures"; break; - case userApplicationDataDirectory: resultPath = "~/Library"; break; - case commonApplicationDataDirectory: resultPath = "/Library"; break; - case globalApplicationsDirectory: resultPath = "/Applications"; break; - - case invokedExecutableFile: - if (juce_argv != nullptr && juce_argc > 0) - return File (CharPointer_UTF8 (juce_argv[0])); - // deliberate fall-through... - - case currentExecutableFile: - return juce_getExecutableFile(); - - case currentApplicationFile: - { - const File exe (juce_getExecutableFile()); - const File parent (exe.getParentDirectory()); + case tempDirectory: + { + File tmp (FileHelpers::getIOSSystemLocation (NSCachesDirectory)); + tmp = tmp.getChildFile (juce_getExecutableFile().getFileNameWithoutExtension()); + tmp.createDirectory(); + return tmp.getFullPathName(); + } - #if JUCE_IOS - return parent; #else - return parent.getFullPathName().endsWithIgnoreCase ("Contents/MacOS") - ? parent.getParentDirectory().getParentDirectory() - : exe; + case userDocumentsDirectory: resultPath = "~/Documents"; break; + case userDesktopDirectory: resultPath = "~/Desktop"; break; + + case tempDirectory: + { + File tmp ("~/Library/Caches/" + juce_getExecutableFile().getFileNameWithoutExtension()); + tmp.createDirectory(); + return tmp.getFullPathName(); + } #endif + case userMusicDirectory: resultPath = "~/Music"; break; + case userMoviesDirectory: resultPath = "~/Movies"; break; + case userPicturesDirectory: resultPath = "~/Pictures"; break; + case userApplicationDataDirectory: resultPath = "~/Library"; break; + case commonApplicationDataDirectory: resultPath = "/Library"; break; + case globalApplicationsDirectory: resultPath = "/Applications"; break; + + case invokedExecutableFile: + if (juce_argv != nullptr && juce_argc > 0) + return File (CharPointer_UTF8 (juce_argv[0])); + // deliberate fall-through... + + case currentExecutableFile: + return juce_getExecutableFile(); + + case currentApplicationFile: + { + const File exe (juce_getExecutableFile()); + const File parent (exe.getParentDirectory()); + + #if JUCE_IOS + return parent; + #else + return parent.getFullPathName().endsWithIgnoreCase ("Contents/MacOS") + ? parent.getParentDirectory().getParentDirectory() + : exe; + #endif + } + + case hostApplicationPath: + { + unsigned int size = 8192; + HeapBlock<char> buffer; + buffer.calloc (size + 8); + + _NSGetExecutablePath (buffer.getData(), &size); + return String::fromUTF8 (buffer, (int) size); + } + + default: + jassertfalse; // unknown type? + break; } - case hostApplicationPath: - { - unsigned int size = 8192; - HeapBlock<char> buffer; - buffer.calloc (size + 8); - - _NSGetExecutablePath (buffer.getData(), &size); - return String::fromUTF8 (buffer, (int) size); - } - - default: - jassertfalse; // unknown type? - break; + if (resultPath.isNotEmpty()) + return File (resultPath.convertToPrecomposedUnicode()); } - if (resultPath.isNotEmpty()) - return File (resultPath.convertToPrecomposedUnicode()); - return File::nonexistent; } @@ -252,24 +263,14 @@ File File::getSpecialLocation (const SpecialLocationType type) String File::getVersion() const { JUCE_AUTORELEASEPOOL - String result; - - NSBundle* bundle = [NSBundle bundleWithPath: juceStringToNS (getFullPathName())]; - - if (bundle != nil) { - NSDictionary* info = [bundle infoDictionary]; - - if (info != nil) - { - NSString* name = [info valueForKey: nsStringLiteral ("CFBundleShortVersionString")]; - - if (name != nil) - result = nsStringToJuce (name); - } + if (NSBundle* bundle = [NSBundle bundleWithPath: juceStringToNS (getFullPathName())]) + if (NSDictionary* info = [bundle infoDictionary]) + if (NSString* name = [info valueForKey: nsStringLiteral ("CFBundleShortVersionString")]) + return nsStringToJuce (name); } - return result; + return String::empty; } //============================================================================== @@ -298,15 +299,16 @@ bool File::moveToTrash() const return deleteFile(); //xxx is there a trashcan on the iOS? #else JUCE_AUTORELEASEPOOL - - NSString* p = juceStringToNS (getFullPathName()); - - return [[NSWorkspace sharedWorkspace] - performFileOperation: NSWorkspaceRecycleOperation - source: [p stringByDeletingLastPathComponent] - destination: nsEmptyString() - files: [NSArray arrayWithObject: [p lastPathComponent]] - tag: nil ]; + { + NSString* p = juceStringToNS (getFullPathName()); + + return [[NSWorkspace sharedWorkspace] + performFileOperation: NSWorkspaceRecycleOperation + source: [p stringByDeletingLastPathComponent] + destination: nsEmptyString() + files: [NSArray arrayWithObject: [p lastPathComponent]] + tag: nil ]; + } #endif } @@ -320,8 +322,9 @@ public: enumerator (nil) { JUCE_AUTORELEASEPOOL - - enumerator = [[[NSFileManager defaultManager] enumeratorAtPath: juceStringToNS (directory.getFullPathName())] retain]; + { + enumerator = [[[NSFileManager defaultManager] enumeratorAtPath: juceStringToNS (directory.getFullPathName())] retain]; + } } ~Pimpl() @@ -334,30 +337,32 @@ public: Time* const modTime, Time* const creationTime, bool* const isReadOnly) { JUCE_AUTORELEASEPOOL - const char* wildcardUTF8 = nullptr; - - for (;;) { - NSString* file; - if (enumerator == nil || (file = [enumerator nextObject]) == nil) - return false; + const char* wildcardUTF8 = nullptr; - [enumerator skipDescendents]; - filenameFound = nsStringToJuce (file); + for (;;) + { + NSString* file; + if (enumerator == nil || (file = [enumerator nextObject]) == nil) + return false; - if (wildcardUTF8 == nullptr) - wildcardUTF8 = wildCard.toUTF8(); + [enumerator skipDescendents]; + filenameFound = nsStringToJuce (file); - if (fnmatch (wildcardUTF8, filenameFound.toUTF8(), FNM_CASEFOLD) != 0) - continue; + if (wildcardUTF8 == nullptr) + wildcardUTF8 = wildCard.toUTF8(); - const String fullPath (parentDir + filenameFound); - updateStatInfoForFile (fullPath, isDir, fileSize, modTime, creationTime, isReadOnly); + if (fnmatch (wildcardUTF8, filenameFound.toUTF8(), FNM_CASEFOLD) != 0) + continue; - if (isHidden != nullptr) - *isHidden = FileHelpers::isHiddenFile (fullPath); + const String fullPath (parentDir + filenameFound); + updateStatInfoForFile (fullPath, isDir, fileSize, modTime, creationTime, isReadOnly); - return true; + if (isHidden != nullptr) + *isHidden = FileHelpers::isHiddenFile (fullPath); + + return true; + } } } @@ -392,37 +397,38 @@ bool Process::openDocument (const String& fileName, const String& parameters) return [[UIApplication sharedApplication] openURL: [NSURL URLWithString: juceStringToNS (fileName)]]; #else JUCE_AUTORELEASEPOOL - - if (parameters.isEmpty()) { - return [[NSWorkspace sharedWorkspace] openFile: juceStringToNS (fileName)] - || [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: juceStringToNS (fileName)]]; - } + if (parameters.isEmpty()) + { + return [[NSWorkspace sharedWorkspace] openFile: juceStringToNS (fileName)] + || [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: juceStringToNS (fileName)]]; + } - bool ok = false; - const File file (fileName); + bool ok = false; + const File file (fileName); - if (file.isBundle()) - { - NSMutableArray* urls = [NSMutableArray array]; - - StringArray docs; - docs.addTokens (parameters, true); - for (int i = 0; i < docs.size(); ++i) - [urls addObject: juceStringToNS (docs[i])]; - - ok = [[NSWorkspace sharedWorkspace] openURLs: urls - withAppBundleIdentifier: [[NSBundle bundleWithPath: juceStringToNS (fileName)] bundleIdentifier] - options: 0 - additionalEventParamDescriptor: nil - launchIdentifiers: nil]; - } - else if (file.exists()) - { - ok = FileHelpers::launchExecutable ("\"" + fileName + "\" " + parameters); - } + if (file.isBundle()) + { + NSMutableArray* urls = [NSMutableArray array]; + + StringArray docs; + docs.addTokens (parameters, true); + for (int i = 0; i < docs.size(); ++i) + [urls addObject: juceStringToNS (docs[i])]; + + ok = [[NSWorkspace sharedWorkspace] openURLs: urls + withAppBundleIdentifier: [[NSBundle bundleWithPath: juceStringToNS (fileName)] bundleIdentifier] + options: 0 + additionalEventParamDescriptor: nil + launchIdentifiers: nil]; + } + else if (file.exists()) + { + ok = FileHelpers::launchExecutable ("\"" + fileName + "\" " + parameters); + } - return ok; + return ok; + } #endif } @@ -440,15 +446,16 @@ void File::revealToUser() const OSType File::getMacOSType() const { JUCE_AUTORELEASEPOOL + { + #if JUCE_IOS || (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) + NSDictionary* fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath: juceStringToNS (getFullPathName()) error: nil]; + #else + // (the cast here avoids a deprecation warning) + NSDictionary* fileDict = [((id) [NSFileManager defaultManager]) fileAttributesAtPath: juceStringToNS (getFullPathName()) traverseLink: NO]; + #endif - #if JUCE_IOS || (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) - NSDictionary* fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath: juceStringToNS (getFullPathName()) error: nil]; - #else - // (the cast here avoids a deprecation warning) - NSDictionary* fileDict = [((id) [NSFileManager defaultManager]) fileAttributesAtPath: juceStringToNS (getFullPathName()) traverseLink: NO]; - #endif - - return [fileDict fileHFSTypeCode]; + return [fileDict fileHFSTypeCode]; + } } bool File::isBundle() const @@ -457,7 +464,9 @@ bool File::isBundle() const return false; // xxx can't find a sensible way to do this without trying to open the bundle.. #else JUCE_AUTORELEASEPOOL - return [[NSWorkspace sharedWorkspace] isFilePackageAtPath: juceStringToNS (getFullPathName())]; + { + return [[NSWorkspace sharedWorkspace] isFilePackageAtPath: juceStringToNS (getFullPathName())]; + } #endif } diff --git a/JuceLibraryCode/modules/juce_core/native/juce_mac_Network.mm b/JuceLibraryCode/modules/juce_core/native/juce_mac_Network.mm index 762d14afe..c178db6a9 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_mac_Network.mm +++ b/JuceLibraryCode/modules/juce_core/native/juce_mac_Network.mm @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -61,39 +64,40 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, return false; #else JUCE_AUTORELEASEPOOL - - String script; - script << "tell application \"Mail\"\r\n" - "set newMessage to make new outgoing message with properties {subject:\"" - << emailSubject.replace ("\"", "\\\"") - << "\", content:\"" - << bodyText.replace ("\"", "\\\"") - << "\" & return & return}\r\n" - "tell newMessage\r\n" - "set visible to true\r\n" - "set sender to \"sdfsdfsdfewf\"\r\n" - "make new to recipient at end of to recipients with properties {address:\"" - << targetEmailAddress - << "\"}\r\n"; - - for (int i = 0; i < filesToAttach.size(); ++i) { - script << "tell content\r\n" - "make new attachment with properties {file name:\"" - << filesToAttach[i].replace ("\"", "\\\"") - << "\"} at after the last paragraph\r\n" - "end tell\r\n"; - } + String script; + script << "tell application \"Mail\"\r\n" + "set newMessage to make new outgoing message with properties {subject:\"" + << emailSubject.replace ("\"", "\\\"") + << "\", content:\"" + << bodyText.replace ("\"", "\\\"") + << "\" & return & return}\r\n" + "tell newMessage\r\n" + "set visible to true\r\n" + "set sender to \"sdfsdfsdfewf\"\r\n" + "make new to recipient at end of to recipients with properties {address:\"" + << targetEmailAddress + << "\"}\r\n"; + + for (int i = 0; i < filesToAttach.size(); ++i) + { + script << "tell content\r\n" + "make new attachment with properties {file name:\"" + << filesToAttach[i].replace ("\"", "\\\"") + << "\"} at after the last paragraph\r\n" + "end tell\r\n"; + } - script << "end tell\r\n" - "end tell\r\n"; + script << "end tell\r\n" + "end tell\r\n"; - NSAppleScript* s = [[NSAppleScript alloc] initWithSource: juceStringToNS (script)]; - NSDictionary* error = nil; - const bool ok = [s executeAndReturnError: &error] != nil; - [s release]; + NSAppleScript* s = [[NSAppleScript alloc] initWithSource: juceStringToNS (script)]; + NSDictionary* error = nil; + const bool ok = [s executeAndReturnError: &error] != nil; + [s release]; - return ok; + return ok; + } #endif } @@ -229,7 +233,9 @@ public: while (! threadShouldExit()) { JUCE_AUTORELEASEPOOL - [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.01]]; + { + [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.01]]; + } } } @@ -305,16 +311,18 @@ public: finished (false), isPost (isPost_), timeOutMs (timeOutMs_) { JUCE_AUTORELEASEPOOL - createConnection (progressCallback, progressCallbackContext); - - if (responseHeaders != nullptr && connection != nullptr && connection->headers != nil) { - NSEnumerator* enumerator = [connection->headers keyEnumerator]; - NSString* key; + createConnection (progressCallback, progressCallbackContext); + + if (responseHeaders != nullptr && connection != nullptr && connection->headers != nil) + { + NSEnumerator* enumerator = [connection->headers keyEnumerator]; + NSString* key; - while ((key = [enumerator nextObject]) != nil) - responseHeaders->set (nsStringToJuce (key), - nsStringToJuce ((NSString*) [connection->headers objectForKey: key])); + while ((key = [enumerator nextObject]) != nil) + responseHeaders->set (nsStringToJuce (key), + nsStringToJuce ((NSString*) [connection->headers objectForKey: key])); + } } } @@ -332,14 +340,15 @@ public: return 0; JUCE_AUTORELEASEPOOL + { + const int bytesRead = connection->read (static_cast <char*> (buffer), bytesToRead); + position += bytesRead; - const int bytesRead = connection->read (static_cast <char*> (buffer), bytesToRead); - position += bytesRead; - - if (bytesRead == 0) - finished = true; + if (bytesRead == 0) + finished = true; - return bytesRead; + return bytesRead; + } } bool setPosition (int64 wantedPos) diff --git a/JuceLibraryCode/modules/juce_core/native/juce_mac_Strings.mm b/JuceLibraryCode/modules/juce_core/native/juce_mac_Strings.mm index 61b849bf8..ac8190052 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_mac_Strings.mm +++ b/JuceLibraryCode/modules/juce_core/native/juce_mac_Strings.mm @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -46,7 +49,9 @@ String String::convertToPrecomposedUnicode() const { #if JUCE_IOS JUCE_AUTORELEASEPOOL - return nsStringToJuce ([juceStringToNS (*this) precomposedStringWithCanonicalMapping]); + { + return nsStringToJuce ([juceStringToNS (*this) precomposedStringWithCanonicalMapping]); + } #else UnicodeMapping map; diff --git a/JuceLibraryCode/modules/juce_core/native/juce_mac_SystemStats.mm b/JuceLibraryCode/modules/juce_core/native/juce_mac_SystemStats.mm index c485e4bf9..b3d82cabb 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_mac_SystemStats.mm +++ b/JuceLibraryCode/modules/juce_core/native/juce_mac_SystemStats.mm @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -36,7 +39,11 @@ ScopedAutoReleasePool::~ScopedAutoReleasePool() //============================================================================== void Logger::outputDebugString (const String& text) { - std::cerr << text << std::endl; + // Would prefer to use std::cerr here, but avoiding it for + // the moment, due to clang JIT linkage problems. + fputs (text.toRawUTF8(), stderr); + fputs ("\n", stderr); + fflush (stderr); } //============================================================================== @@ -106,10 +113,12 @@ static RLimitInitialiser rLimitInitialiser; static String getOSXVersion() { JUCE_AUTORELEASEPOOL - NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile: - nsStringLiteral ("/System/Library/CoreServices/SystemVersion.plist")]; + { + NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile: + nsStringLiteral ("/System/Library/CoreServices/SystemVersion.plist")]; - return nsStringToJuce ([dict objectForKey: nsStringLiteral ("ProductVersion")]); + return nsStringToJuce ([dict objectForKey: nsStringLiteral ("ProductVersion")]); + } } #endif diff --git a/JuceLibraryCode/modules/juce_core/native/juce_mac_Threads.mm b/JuceLibraryCode/modules/juce_core/native/juce_mac_Threads.mm index e4be4d511..84139e465 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_mac_Threads.mm +++ b/JuceLibraryCode/modules/juce_core/native/juce_mac_Threads.mm @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_osx_ObjCHelpers.h b/JuceLibraryCode/modules/juce_core/native/juce_osx_ObjCHelpers.h index f17353422..590a84d9f 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_osx_ObjCHelpers.h +++ b/JuceLibraryCode/modules/juce_core/native/juce_osx_ObjCHelpers.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_posix_NamedPipe.cpp b/JuceLibraryCode/modules/juce_core/native/juce_posix_NamedPipe.cpp index 8636ce478..c951974cf 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_posix_NamedPipe.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_posix_NamedPipe.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_posix_SharedCode.h b/JuceLibraryCode/modules/juce_core/native/juce_posix_SharedCode.h index 7ef4733e7..6d649af37 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_posix_SharedCode.h +++ b/JuceLibraryCode/modules/juce_core/native/juce_posix_SharedCode.h @@ -1,36 +1,31 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ -/* - This file contains posix routines that are common to both the Linux and Mac builds. - - It gets included directly in the cpp files for these platforms. -*/ - - -//============================================================================== CriticalSection::CriticalSection() noexcept { pthread_mutexattr_t atts; @@ -543,7 +538,7 @@ void MemoryMappedFile::openInternal (const File& file, AccessMode mode) MemoryMappedFile::~MemoryMappedFile() { if (address != nullptr) - munmap (address, range.getLength()); + munmap (address, (size_t) range.getLength()); if (fileHandle != 0) close (fileHandle); @@ -824,18 +819,20 @@ extern "C" void* threadEntryProc (void*); extern "C" void* threadEntryProc (void* userData) { JUCE_AUTORELEASEPOOL - - #if JUCE_ANDROID - struct AndroidThreadScope { - AndroidThreadScope() { threadLocalJNIEnvHolder.attach(); } - ~AndroidThreadScope() { threadLocalJNIEnvHolder.detach(); } - }; + #if JUCE_ANDROID + struct AndroidThreadScope + { + AndroidThreadScope() { threadLocalJNIEnvHolder.attach(); } + ~AndroidThreadScope() { threadLocalJNIEnvHolder.detach(); } + }; - const AndroidThreadScope androidEnv; - #endif + const AndroidThreadScope androidEnv; + #endif + + juce_threadEntryPoint (userData); + } - juce_threadEntryPoint (userData); return nullptr; } @@ -874,9 +871,11 @@ void Thread::setCurrentThreadName (const String& name) { #if JUCE_IOS || (JUCE_MAC && defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) JUCE_AUTORELEASEPOOL - [[NSThread currentThread] setName: juceStringToNS (name)]; + { + [[NSThread currentThread] setName: juceStringToNS (name)]; + } #elif JUCE_LINUX - prctl (PR_SET_NAME, name.toUTF8().getAddress(), 0, 0, 0); + pthread_setname_np (pthread_self(), name.toRawUTF8()); #endif } @@ -953,8 +952,8 @@ void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) bool DynamicLibrary::open (const String& name) { close(); - handle = dlopen (name.toUTF8(), RTLD_LOCAL | RTLD_NOW); - return handle != 0; + handle = dlopen (name.isEmpty() ? nullptr : name.toUTF8().getAddress(), RTLD_LOCAL | RTLD_NOW); + return handle != nullptr; } void DynamicLibrary::close() @@ -1073,9 +1072,7 @@ private: bool ChildProcess::start (const String& command) { - StringArray tokens; - tokens.addTokens (command, true); - return start (tokens); + return start (StringArray::fromTokens (command, true)); } bool ChildProcess::start (const StringArray& args) diff --git a/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h b/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h index cde5bad86..f361c2dae 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h +++ b/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -26,6 +29,28 @@ #ifndef __JUCE_WIN32_COMSMARTPTR_JUCEHEADER__ #define __JUCE_WIN32_COMSMARTPTR_JUCEHEADER__ +#ifndef _MSC_VER +template<typename Type> struct UUIDGetter { static CLSID get() { jassertfalse; return CLSID(); } }; +#define __uuidof(x) UUIDGetter<x>::get() +#endif + +inline GUID uuidFromString (const char* const s) noexcept +{ + unsigned long p0; + unsigned int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10; + + #ifndef _MSC_VER + sscanf + #else + sscanf_s + #endif + (s, "%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", + &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10); + + GUID g = { p0, (uint16) p1, (uint16) p2, { (uint8) p3, (uint8) p4, (uint8) p5, (uint8) p6, + (uint8) p7, (uint8) p8, (uint8) p9, (uint8) p10 }}; + return g; +} //============================================================================== /** A simple COM smart pointer. diff --git a/JuceLibraryCode/modules/juce_core/native/juce_win32_Files.cpp b/JuceLibraryCode/modules/juce_core/native/juce_win32_Files.cpp index 1df1a9862..dbc8d46f3 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_win32_Files.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_win32_Files.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_win32_Network.cpp b/JuceLibraryCode/modules/juce_core/native/juce_win32_Network.cpp index 599adbef1..11b305750 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_win32_Network.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_win32_Network.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -315,27 +318,39 @@ InputStream* URL::createNativeStream (const String& address, bool isPost, const //============================================================================== -namespace MACAddressHelpers +struct GetAdaptersInfoHelper { - void getViaGetAdaptersInfo (Array<MACAddress>& result) + bool callGetAdaptersInfo() { DynamicLibrary dll ("iphlpapi.dll"); JUCE_LOAD_WINAPI_FUNCTION (dll, GetAdaptersInfo, getAdaptersInfo, DWORD, (PIP_ADAPTER_INFO, PULONG)) - if (getAdaptersInfo != nullptr) - { - ULONG len = sizeof (IP_ADAPTER_INFO); - HeapBlock<IP_ADAPTER_INFO> adapterInfo (1); + if (getAdaptersInfo == nullptr) + return false; - if (getAdaptersInfo (adapterInfo, &len) == ERROR_BUFFER_OVERFLOW) - adapterInfo.malloc (len, 1); + adapterInfo.malloc (1); + ULONG len = sizeof (IP_ADAPTER_INFO); - if (getAdaptersInfo (adapterInfo, &len) == NO_ERROR) - { - for (PIP_ADAPTER_INFO adapter = adapterInfo; adapter != nullptr; adapter = adapter->Next) - if (adapter->AddressLength >= 6) - result.addIfNotAlreadyThere (MACAddress (adapter->Address)); - } + if (getAdaptersInfo (adapterInfo, &len) == ERROR_BUFFER_OVERFLOW) + adapterInfo.malloc (len, 1); + + return getAdaptersInfo (adapterInfo, &len) == NO_ERROR; + } + + HeapBlock<IP_ADAPTER_INFO> adapterInfo; +}; + +namespace MACAddressHelpers +{ + void getViaGetAdaptersInfo (Array<MACAddress>& result) + { + GetAdaptersInfoHelper gah; + + if (gah.callGetAdaptersInfo()) + { + for (PIP_ADAPTER_INFO adapter = gah.adapterInfo; adapter != nullptr; adapter = adapter->Next) + if (adapter->AddressLength >= 6) + result.addIfNotAlreadyThere (MACAddress (adapter->Address)); } } @@ -375,7 +390,8 @@ namespace MACAddressHelpers NAME_BUFFER NameBuff [30]; }; - ASTAT astat = { 0 }; + ASTAT astat; + zerostruct (astat); ncb.ncb_buffer = (unsigned char*) &astat; ncb.ncb_length = sizeof (ASTAT); @@ -393,6 +409,24 @@ void MACAddress::findAllAddresses (Array<MACAddress>& result) MACAddressHelpers::getViaNetBios (result); } +void IPAddress::findAllAddresses (Array<IPAddress>& result) +{ + result.addIfNotAlreadyThere (IPAddress::local()); + + GetAdaptersInfoHelper gah; + + if (gah.callGetAdaptersInfo()) + { + for (PIP_ADAPTER_INFO adapter = gah.adapterInfo; adapter != nullptr; adapter = adapter->Next) + { + IPAddress ip (adapter->IpAddressList.IpAddress.String); + + if (ip != IPAddress::any()) + result.addIfNotAlreadyThere (ip); + } + } +} + //============================================================================== bool Process::openEmailWithAttachments (const String& targetEmailAddress, const String& emailSubject, @@ -407,15 +441,15 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, return false; MapiMessage message = { 0 }; - message.lpszSubject = (LPSTR) emailSubject.toUTF8().getAddress(); - message.lpszNoteText = (LPSTR) bodyText.toUTF8().getAddress(); + message.lpszSubject = (LPSTR) emailSubject.toRawUTF8(); + message.lpszNoteText = (LPSTR) bodyText.toRawUTF8(); MapiRecipDesc recip = { 0 }; recip.ulRecipClass = MAPI_TO; String targetEmailAddress_ (targetEmailAddress); if (targetEmailAddress_.isEmpty()) targetEmailAddress_ = " "; // (Windows Mail can't deal with a blank address) - recip.lpszName = (LPSTR) targetEmailAddress_.toUTF8().getAddress(); + recip.lpszName = (LPSTR) targetEmailAddress_.toRawUTF8(); message.nRecipCount = 1; message.lpRecips = &recip; @@ -428,7 +462,7 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, for (int i = 0; i < filesToAttach.size(); ++i) { files[i].nPosition = (ULONG) -1; - files[i].lpszPathName = (LPSTR) filesToAttach[i].toUTF8().getAddress(); + files[i].lpszPathName = (LPSTR) filesToAttach[i].toRawUTF8(); } return mapiSendMail (0, 0, &message, MAPI_DIALOG | MAPI_LOGON_UI, 0) == SUCCESS_SUCCESS; diff --git a/JuceLibraryCode/modules/juce_core/native/juce_win32_Registry.cpp b/JuceLibraryCode/modules/juce_core/native/juce_win32_Registry.cpp index 94a35eb02..fb9cba03f 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_win32_Registry.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_win32_Registry.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_win32_SystemStats.cpp b/JuceLibraryCode/modules/juce_core/native/juce_win32_SystemStats.cpp index 25f4a442f..816d26afc 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_win32_SystemStats.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/native/juce_win32_Threads.cpp b/JuceLibraryCode/modules/juce_core/native/juce_win32_Threads.cpp index 421349a59..1bfd0f49b 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_win32_Threads.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_win32_Threads.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -247,7 +250,7 @@ void Thread::yield() //============================================================================== static int lastProcessPriority = -1; -// called by WindowDriver because Windows does wierd things to process priority +// called by WindowDriver because Windows does weird things to process priority // when you swap apps, and this forces an update when the app is brought to the front. void juce_repeatLastProcessPriority() { @@ -608,7 +611,7 @@ struct HighResolutionTimer::Pimpl const int actualPeriod = jlimit ((int) tc.wPeriodMin, (int) tc.wPeriodMax, newPeriod); timerID = timeSetEvent (actualPeriod, tc.wPeriodMin, callbackFunction, (DWORD_PTR) this, - TIME_PERIODIC | TIME_CALLBACK_FUNCTION | TIME_KILL_SYNCHRONOUS); + TIME_PERIODIC | TIME_CALLBACK_FUNCTION | 0x100 /*TIME_KILL_SYNCHRONOUS*/); } } } diff --git a/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.cpp b/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.cpp new file mode 100644 index 000000000..0a7bd41f7 --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.cpp @@ -0,0 +1,149 @@ +/* + ============================================================================== + + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ------------------------------------------------------------------------------ + + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. + + For more details, visit www.juce.com + + ============================================================================== +*/ + +IPAddress::IPAddress() noexcept +{ + address[0] = 0; address[1] = 0; + address[2] = 0; address[3] = 0; +} + +IPAddress::IPAddress (const uint8 bytes[4]) noexcept +{ + address[0] = bytes[0]; address[1] = bytes[1]; + address[2] = bytes[2]; address[3] = bytes[3]; +} + +IPAddress::IPAddress (uint8 a0, uint8 a1, uint8 a2, uint8 a3) noexcept +{ + address[0] = a0; address[1] = a1; + address[2] = a2; address[3] = a3; +} + +IPAddress::IPAddress (uint32 n) noexcept +{ + address[0] = (n >> 24); + address[1] = (n >> 16) & 255; + address[2] = (n >> 8) & 255; + address[3] = (n & 255); +} + +IPAddress::IPAddress (const String& adr) +{ + StringArray tokens; + tokens.addTokens (adr, ".", String::empty); + + for (int i = 0; i < 4; ++i) + address[i] = (uint8) tokens[i].getIntValue(); +} + +String IPAddress::toString() const +{ + String s ((int) address[0]); + + for (int i = 1; i < 4; ++i) + s << '.' << (int) address[i]; + + return s; +} + +IPAddress IPAddress::any() noexcept { return IPAddress(); } +IPAddress IPAddress::broadcast() noexcept { return IPAddress (255, 255, 255, 255); } +IPAddress IPAddress::local() noexcept { return IPAddress (127, 0, 0, 1); } + +bool IPAddress::operator== (const IPAddress& other) const noexcept +{ + return address[0] == other.address[0] + && address[1] == other.address[1] + && address[2] == other.address[2] + && address[3] == other.address[3]; +} + +bool IPAddress::operator!= (const IPAddress& other) const noexcept +{ + return ! operator== (other); +} + +#if ! JUCE_WINDOWS +static void addAddress (const sockaddr_in* addr_in, Array<IPAddress>& result) +{ + in_addr_t addr = addr_in->sin_addr.s_addr; + + if (addr != INADDR_NONE) + result.addIfNotAlreadyThere (IPAddress (ntohl (addr))); +} + +static void findIPAddresses (int sock, Array<IPAddress>& result) +{ + ifconf cfg; + HeapBlock<char> buffer; + size_t bufferSize = 1024; + + do + { + bufferSize *= 2; + buffer.calloc (bufferSize); + + cfg.ifc_len = bufferSize; + cfg.ifc_buf = buffer; + + if (ioctl (sock, SIOCGIFCONF, &cfg) < 0 && errno != EINVAL) + return; + + } while (bufferSize < cfg.ifc_len + 2 * (IFNAMSIZ + sizeof (struct sockaddr_in6))); + + #if JUCE_MAC || JUCE_IOS + while (cfg.ifc_len >= (int) (IFNAMSIZ + sizeof (struct sockaddr_in))) + { + if (cfg.ifc_req->ifr_addr.sa_family == AF_INET) // Skip non-internet addresses + addAddress ((const sockaddr_in*) &cfg.ifc_req->ifr_addr, result); + + cfg.ifc_len -= IFNAMSIZ + cfg.ifc_req->ifr_addr.sa_len; + cfg.ifc_buf += IFNAMSIZ + cfg.ifc_req->ifr_addr.sa_len; + } + #else + for (int i = 0; i < cfg.ifc_len / sizeof (struct ifreq); ++i) + { + const ifreq& item = cfg.ifc_req[i]; + + if (item.ifr_addr.sa_family == AF_INET) + addAddress ((const sockaddr_in*) &item.ifr_addr, result); + } + #endif +} + +void IPAddress::findAllAddresses (Array<IPAddress>& result) +{ + const int sock = socket (AF_INET, SOCK_DGRAM, 0); // a dummy socket to execute the IO control + + if (sock >= 0) + { + findIPAddresses (sock, result); + ::close (sock); + } +} +#endif diff --git a/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.h b/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.h new file mode 100644 index 000000000..92f8819fc --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.h @@ -0,0 +1,82 @@ +/* + ============================================================================== + + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ------------------------------------------------------------------------------ + + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. + + For more details, visit www.juce.com + + ============================================================================== +*/ + +#ifndef __JUCE_IPADDRESS_JUCEHEADER__ +#define __JUCE_IPADDRESS_JUCEHEADER__ + + +//============================================================================== +/** + An IPV4 address. +*/ +class JUCE_API IPAddress +{ +public: + //============================================================================== + /** Populates a list of all the IP addresses that this machine is using. */ + static void findAllAddresses (Array<IPAddress>& results); + + //============================================================================== + /** Creates a null address (0.0.0.0). */ + IPAddress() noexcept; + + /** Creates an address from 4 bytes. */ + explicit IPAddress (const uint8 bytes[4]) noexcept; + + /** Creates an address from 4 bytes. */ + IPAddress (uint8 address1, uint8 address2, uint8 address3, uint8 address4) noexcept; + + /** Creates an address from a packed 32-bit integer, where the MSB is + the first number in the address, and the LSB is the last. + */ + explicit IPAddress (uint32 asNativeEndian32Bit) noexcept; + + /** Parses a string IP address of the form "a.b.c.d". */ + explicit IPAddress (const String& address); + + /** Returns a dot-separated string in the form "1.2.3.4" */ + String toString() const; + + /** Returns an address meaning "any" (0.0.0.0) */ + static IPAddress any() noexcept; + + /** Returns an address meaning "broadcast" (255.255.255.255) */ + static IPAddress broadcast() noexcept; + + /** Returns an address meaning "localhost" (127.0.0.1) */ + static IPAddress local() noexcept; + + bool operator== (const IPAddress& other) const noexcept; + bool operator!= (const IPAddress& other) const noexcept; + + /** The elements of the IP address. */ + uint8 address[4]; +}; + + +#endif // __JUCE_IPADDRESS_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_core/network/juce_MACAddress.cpp b/JuceLibraryCode/modules/juce_core/network/juce_MACAddress.cpp index 03eb7348f..b7cb3c115 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_MACAddress.cpp +++ b/JuceLibraryCode/modules/juce_core/network/juce_MACAddress.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/network/juce_MACAddress.h b/JuceLibraryCode/modules/juce_core/network/juce_MACAddress.h index 126785e66..4f09c1be5 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_MACAddress.h +++ b/JuceLibraryCode/modules/juce_core/network/juce_MACAddress.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.cpp b/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.cpp index 902a2df26..488e63f41 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.cpp +++ b/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.h b/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.h index f4fb42aed..7bc848998 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.h +++ b/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp b/JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp index 52a6c258c..3bb59187b 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp +++ b/JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -34,8 +37,10 @@ #if JUCE_WINDOWS typedef int juce_socklen_t; + typedef SOCKET SocketHandle; #else typedef socklen_t juce_socklen_t; + typedef int SocketHandle; #endif //============================================================================== @@ -57,7 +62,7 @@ namespace SocketHelpers #endif } - static bool resetSocketOptions (const int handle, const bool isDatagram, const bool allowBroadcast) noexcept + static bool resetSocketOptions (const SocketHandle handle, const bool isDatagram, const bool allowBroadcast) noexcept { const int sndBufSize = 65536; const int rcvBufSize = 65536; @@ -70,7 +75,7 @@ namespace SocketHelpers : (setsockopt (handle, IPPROTO_TCP, TCP_NODELAY, (const char*) &one, sizeof (one)) == 0)); } - static bool bindSocketToPort (const int handle, const int port) noexcept + static bool bindSocketToPort (const SocketHandle handle, const int port) noexcept { if (handle <= 0 || port <= 0) return false; @@ -84,7 +89,7 @@ namespace SocketHelpers return bind (handle, (struct sockaddr*) &servTmpAddr, sizeof (struct sockaddr_in)) >= 0; } - static int readSocket (const int handle, + static int readSocket (const SocketHandle handle, void* const destBuffer, const int maxBytesToRead, bool volatile& connected, const bool blockUntilSpecifiedAmountHasArrived) noexcept @@ -122,7 +127,7 @@ namespace SocketHelpers return bytesRead; } - static int waitForReadiness (const int handle, const bool forReading, const int timeoutMsecs) noexcept + static int waitForReadiness (const SocketHandle handle, const bool forReading, const int timeoutMsecs) noexcept { struct timeval timeout; struct timeval* timeoutp; @@ -148,7 +153,7 @@ namespace SocketHelpers fd_set* const pwset = forReading ? nullptr : &wset; #if JUCE_WINDOWS - if (select (handle + 1, prset, pwset, 0, timeoutp) < 0) + if (select ((int) handle + 1, prset, pwset, 0, timeoutp) < 0) return -1; #else { @@ -175,7 +180,7 @@ namespace SocketHelpers return FD_ISSET (handle, forReading ? &rset : &wset) ? 1 : 0; } - static bool setSocketBlockingState (const int handle, const bool shouldBlock) noexcept + static bool setSocketBlockingState (const SocketHandle handle, const bool shouldBlock) noexcept { #if JUCE_WINDOWS u_long nonBlocking = shouldBlock ? 0 : (u_long) 1; diff --git a/JuceLibraryCode/modules/juce_core/network/juce_Socket.h b/JuceLibraryCode/modules/juce_core/network/juce_Socket.h index c3044fec1..6fb708de2 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_Socket.h +++ b/JuceLibraryCode/modules/juce_core/network/juce_Socket.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -91,6 +94,9 @@ public: /** True if the socket is connected to this machine rather than over the network. */ bool isLocal() const noexcept; + /** Returns the OS's socket handle that's currently open. */ + int getRawSocketHandle() const noexcept { return handle; } + //============================================================================== /** Waits until the socket is ready for reading or writing. @@ -155,7 +161,6 @@ public: */ StreamingSocket* waitForNextConnection() const; - private: //============================================================================== String hostName; @@ -237,6 +242,9 @@ public: /** True if the socket is connected to this machine rather than over the network. */ bool isLocal() const noexcept; + /** Returns the OS's socket handle that's currently open. */ + int getRawSocketHandle() const noexcept { return handle; } + //============================================================================== /** Waits until the socket is ready for reading or writing. @@ -283,7 +291,6 @@ public: */ DatagramSocket* waitForNextConnection() const; - private: //============================================================================== String hostName; diff --git a/JuceLibraryCode/modules/juce_core/network/juce_URL.cpp b/JuceLibraryCode/modules/juce_core/network/juce_URL.cpp index 1efeefac6..fc46865c5 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_URL.cpp +++ b/JuceLibraryCode/modules/juce_core/network/juce_URL.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -415,7 +418,7 @@ String URL::removeEscapeChars (const String& s) // We need to operate on the string as raw UTF8 chars, and then recombine them into unicode // after all the replacements have been made, so that multi-byte chars are handled. - Array<char> utf8 (result.toUTF8().getAddress(), (int) result.getNumBytesAsUTF8()); + Array<char> utf8 (result.toRawUTF8(), (int) result.getNumBytesAsUTF8()); for (int i = 0; i < utf8.size(); ++i) { @@ -440,7 +443,7 @@ String URL::addEscapeChars (const String& s, const bool isParameter) const CharPointer_UTF8 legalChars (isParameter ? "_-.*!'()" : ",$_-.*!'()"); - Array<char> utf8 (s.toUTF8().getAddress(), (int) s.getNumBytesAsUTF8()); + Array<char> utf8 (s.toRawUTF8(), (int) s.getNumBytesAsUTF8()); for (int i = 0; i < utf8.size(); ++i) { diff --git a/JuceLibraryCode/modules/juce_core/network/juce_URL.h b/JuceLibraryCode/modules/juce_core/network/juce_URL.h index e9150969d..c4fec726b 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_URL.h +++ b/JuceLibraryCode/modules/juce_core/network/juce_URL.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -150,7 +153,7 @@ public: /** Returns an array of the names of all the URL's parameters. E.g. for the url "www.fish.com?type=haddock&amount=some+fish", this array would - contain two items: "type" and "haddock". + contain two items: "type" and "amount". You can call getParameterValues() to get the corresponding value of each parameter. Note that the list can contain multiple parameters with the same name. diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.cpp index 5af0ce442..ec01f8e1b 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.h b/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.h index e61dc99fb..b9fd2bcbf 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.h +++ b/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_FileInputSource.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_FileInputSource.cpp index cd7ad6619..51b9db906 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_FileInputSource.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_FileInputSource.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_FileInputSource.h b/JuceLibraryCode/modules/juce_core/streams/juce_FileInputSource.h index 05181a82d..a32dcf415 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_FileInputSource.h +++ b/JuceLibraryCode/modules/juce_core/streams/juce_FileInputSource.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_InputSource.h b/JuceLibraryCode/modules/juce_core/streams/juce_InputSource.h index ea852842f..bd68df3f2 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_InputSource.h +++ b/JuceLibraryCode/modules/juce_core/streams/juce_InputSource.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_InputStream.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_InputStream.cpp index f5afaf30a..08ff61ccd 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_InputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_InputStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_InputStream.h b/JuceLibraryCode/modules/juce_core/streams/juce_InputStream.h index 9a1c0fbea..fb0f43e74 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_InputStream.h +++ b/JuceLibraryCode/modules/juce_core/streams/juce_InputStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.cpp index 026973767..de64475c0 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.h b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.h index ec9fda941..dc7e1a21a 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.h +++ b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -32,7 +35,7 @@ //============================================================================== /** - Allows a block of data and to be accessed as a stream. + Allows a block of data to be accessed as a stream. This can either be used to refer to a shared block of memory, or can make its own internal copy of the data when the MemoryInputStream is created. diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryOutputStream.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryOutputStream.cpp index 79d51d41f..53844f465 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryOutputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryOutputStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -68,13 +71,18 @@ void MemoryOutputStream::reset() noexcept size = 0; } -void MemoryOutputStream::prepareToWrite (size_t numBytes) +char* MemoryOutputStream::prepareToWrite (size_t numBytes) { jassert ((ssize_t) numBytes >= 0); size_t storageNeeded = position + numBytes; if (storageNeeded >= data.getSize()) data.ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~31u); + + char* const writePointer = static_cast <char*> (data.getData()) + position; + position += numBytes; + size = jmax (size, position); + return writePointer; } bool MemoryOutputStream::write (const void* const buffer, size_t howMany) @@ -82,12 +90,7 @@ bool MemoryOutputStream::write (const void* const buffer, size_t howMany) jassert (buffer != nullptr && ((ssize_t) howMany) >= 0); if (howMany > 0) - { - prepareToWrite (howMany); - memcpy (static_cast<char*> (data.getData()) + position, buffer, howMany); - position += howMany; - size = jmax (size, position); - } + memcpy (prepareToWrite (howMany), buffer, howMany); return true; } @@ -95,12 +98,12 @@ bool MemoryOutputStream::write (const void* const buffer, size_t howMany) void MemoryOutputStream::writeRepeatedByte (uint8 byte, size_t howMany) { if (howMany > 0) - { - prepareToWrite (howMany); - memset (static_cast<char*> (data.getData()) + position, byte, howMany); - position += howMany; - size = jmax (size, position); - } + memset (prepareToWrite (howMany), byte, howMany); +} + +void MemoryOutputStream::appendUTF8Char (juce_wchar c) +{ + CharPointer_UTF8 (prepareToWrite (CharPointer_UTF8::getBytesRequiredFor (c))).write (c); } MemoryBlock MemoryOutputStream::getMemoryBlock() const diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryOutputStream.h b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryOutputStream.h index da8422a7f..07e5ea42b 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryOutputStream.h +++ b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryOutputStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -42,7 +45,7 @@ class JUCE_API MemoryOutputStream : public OutputStream { public: //============================================================================== - /** Creates an empty memory stream ready for writing into. + /** Creates an empty memory stream, ready to be written into. @param initialSize the intial amount of capacity to allocate for writing into */ @@ -70,13 +73,11 @@ public: //============================================================================== /** Returns a pointer to the data that has been written to the stream. - @see getDataSize */ const void* getData() const noexcept; /** Returns the number of bytes of data that have been written to the stream. - @see getData */ size_t getDataSize() const noexcept { return size; } @@ -89,6 +90,9 @@ public: */ void preallocate (size_t bytesToPreallocate); + /** Appends the utf-8 bytes for a unicode character */ + void appendUTF8Char (juce_wchar character); + /** Returns a String created from the (UTF8) data that has been written to the stream. */ String toUTF8() const; @@ -120,7 +124,7 @@ private: size_t position, size; void trimExternalBlockSize(); - void prepareToWrite (size_t); + char* prepareToWrite (size_t); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryOutputStream) }; diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_OutputStream.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_OutputStream.cpp index 5b9444b15..33b5f3145 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_OutputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_OutputStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_OutputStream.h b/JuceLibraryCode/modules/juce_core/streams/juce_OutputStream.h index 009bd4974..a9ba2fa0a 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_OutputStream.h +++ b/JuceLibraryCode/modules/juce_core/streams/juce_OutputStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.cpp index e505aab6d..c998c7984 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.h b/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.h index 2d8569740..58f586dcd 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.h +++ b/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/system/juce_PlatformDefs.h b/JuceLibraryCode/modules/juce_core/system/juce_PlatformDefs.h index 288595eed..12f5b1de6 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_PlatformDefs.h +++ b/JuceLibraryCode/modules/juce_core/system/juce_PlatformDefs.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -51,10 +54,8 @@ //============================================================================== // Debugging and assertion macros -#if JUCE_LOG_ASSERTIONS +#if JUCE_LOG_ASSERTIONS || JUCE_DEBUG #define juce_LogCurrentAssertion juce::logAssertion (__FILE__, __LINE__); -#elif JUCE_DEBUG - #define juce_LogCurrentAssertion std::cerr << "JUCE Assertion failure in " << __FILE__ << ", line " << __LINE__ << std::endl; #else #define juce_LogCurrentAssertion #endif @@ -288,10 +289,14 @@ namespace juce //============================================================================== // Here, we'll check for C++11 compiler support, and if it's not available, define // a few workarounds, so that we can still use some of the newer language features. -#if defined (__GXX_EXPERIMENTAL_CXX0X__) && defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) +#if defined (__GXX_EXPERIMENTAL_CXX0X__) && defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 #define JUCE_COMPILER_SUPPORTS_NULLPTR 1 #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 + + #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL) + #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 + #endif #endif #if JUCE_CLANG && defined (__has_feature) @@ -306,6 +311,14 @@ namespace juce #if __has_feature (cxx_rvalue_references) #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 #endif + + #ifndef JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL + #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 + #endif + + #ifndef JUCE_COMPILER_SUPPORTS_ARC + #define JUCE_COMPILER_SUPPORTS_ARC 1 + #endif #endif #if defined (_MSC_VER) && _MSC_VER >= 1600 @@ -313,6 +326,10 @@ namespace juce #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 #endif +#if defined (_MSC_VER) && _MSC_VER >= 1700 + #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 +#endif + //============================================================================== // Declare some fake versions of nullptr and noexcept, for older compilers: #if ! (DOXYGEN || JUCE_COMPILER_SUPPORTS_NOEXCEPT) @@ -332,4 +349,9 @@ namespace juce #define nullptr (0) #endif +#if ! (DOXYGEN || JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL) + #undef override + #define override +#endif + #endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_core/system/juce_StandardHeader.h b/JuceLibraryCode/modules/juce_core/system/juce_StandardHeader.h index 70ae55ba2..5fa3c0750 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_StandardHeader.h +++ b/JuceLibraryCode/modules/juce_core/system/juce_StandardHeader.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -32,8 +35,8 @@ See also SystemStats::getJUCEVersion() for a string version. */ #define JUCE_MAJOR_VERSION 2 -#define JUCE_MINOR_VERSION 0 -#define JUCE_BUILDNUMBER 38 +#define JUCE_MINOR_VERSION 1 +#define JUCE_BUILDNUMBER 1 /** Current Juce version number. @@ -156,10 +159,7 @@ namespace juce { extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger(); - - #if JUCE_LOG_ASSERTIONS - extern JUCE_API void logAssertion (const char* file, int line) noexcept; - #endif + extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noexcept; #include "../memory/juce_Memory.h" #include "../maths/juce_MathsFunctions.h" diff --git a/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.cpp b/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.cpp index 3ca36d625..c8313d0d6 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.cpp +++ b/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -70,7 +73,7 @@ String SystemStats::getStackBacktrace() { String result; - #if JUCE_ANDROID + #if JUCE_ANDROID || JUCE_MINGW jassertfalse; // sorry, not implemented yet! #elif JUCE_WINDOWS diff --git a/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.h b/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.h index 333071fae..60c7788f0 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.h +++ b/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/system/juce_TargetPlatform.h b/JuceLibraryCode/modules/juce_core/system/juce_TargetPlatform.h index 2cb4e3d72..3d0b62468 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_TargetPlatform.h +++ b/JuceLibraryCode/modules/juce_core/system/juce_TargetPlatform.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_ASCII.h b/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_ASCII.h index d029a0a77..ed9fd0360 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_ASCII.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_ASCII.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -51,25 +54,25 @@ public: { } - inline CharPointer_ASCII& operator= (const CharPointer_ASCII& other) noexcept + inline CharPointer_ASCII operator= (const CharPointer_ASCII other) noexcept { data = other.data; return *this; } - inline CharPointer_ASCII& operator= (const CharType* text) noexcept + inline CharPointer_ASCII operator= (const CharType* text) noexcept { data = const_cast <CharType*> (text); return *this; } /** This is a pointer comparison, it doesn't compare the actual text. */ - inline bool operator== (const CharPointer_ASCII& other) const noexcept { return data == other.data; } - inline bool operator!= (const CharPointer_ASCII& other) const noexcept { return data != other.data; } - inline bool operator<= (const CharPointer_ASCII& other) const noexcept { return data <= other.data; } - inline bool operator< (const CharPointer_ASCII& other) const noexcept { return data < other.data; } - inline bool operator>= (const CharPointer_ASCII& other) const noexcept { return data >= other.data; } - inline bool operator> (const CharPointer_ASCII& other) const noexcept { return data > other.data; } + inline bool operator== (CharPointer_ASCII other) const noexcept { return data == other.data; } + inline bool operator!= (CharPointer_ASCII other) const noexcept { return data != other.data; } + inline bool operator<= (CharPointer_ASCII other) const noexcept { return data <= other.data; } + inline bool operator< (CharPointer_ASCII other) const noexcept { return data < other.data; } + inline bool operator>= (CharPointer_ASCII other) const noexcept { return data >= other.data; } + inline bool operator> (CharPointer_ASCII other) const noexcept { return data > other.data; } /** Returns the address that this pointer is pointing to. */ inline CharType* getAddress() const noexcept { return data; } @@ -84,14 +87,14 @@ public: inline juce_wchar operator*() const noexcept { return (juce_wchar) (uint8) *data; } /** Moves this pointer along to the next character in the string. */ - inline CharPointer_ASCII& operator++() noexcept + inline CharPointer_ASCII operator++() noexcept { ++data; return *this; } /** Moves this pointer to the previous character in the string. */ - inline CharPointer_ASCII& operator--() noexcept + inline CharPointer_ASCII operator--() noexcept { --data; return *this; @@ -168,7 +171,7 @@ public: } /** Returns the number of characters in this string, or up to the given end pointer, whichever is lower. */ - size_t lengthUpTo (const CharPointer_ASCII& end) const noexcept + size_t lengthUpTo (const CharPointer_ASCII end) const noexcept { return CharacterFunctions::lengthUpTo (*this, end); } @@ -194,7 +197,7 @@ public: The value returned does NOT include the terminating null character. */ template <class CharPointer> - static size_t getBytesRequiredFor (const CharPointer& text) noexcept + static size_t getBytesRequiredFor (const CharPointer text) noexcept { return text.length(); } @@ -207,13 +210,13 @@ public: /** Copies a source string to this pointer, advancing this pointer as it goes. */ template <typename CharPointer> - void writeAll (const CharPointer& src) noexcept + void writeAll (const CharPointer src) noexcept { CharacterFunctions::copyAll (*this, src); } /** Copies a source string to this pointer, advancing this pointer as it goes. */ - void writeAll (const CharPointer_ASCII& src) noexcept + void writeAll (const CharPointer_ASCII src) noexcept { strcpy (data, src.data); } @@ -223,7 +226,7 @@ public: to the destination buffer before stopping. */ template <typename CharPointer> - size_t writeWithDestByteLimit (const CharPointer& src, const size_t maxDestBytes) noexcept + size_t writeWithDestByteLimit (const CharPointer src, const size_t maxDestBytes) noexcept { return CharacterFunctions::copyWithDestByteLimit (*this, src, maxDestBytes); } @@ -233,45 +236,45 @@ public: written to the destination buffer before stopping (including the terminating null). */ template <typename CharPointer> - void writeWithCharLimit (const CharPointer& src, const int maxChars) noexcept + void writeWithCharLimit (const CharPointer src, const int maxChars) noexcept { CharacterFunctions::copyWithCharLimit (*this, src, maxChars); } /** Compares this string with another one. */ template <typename CharPointer> - int compare (const CharPointer& other) const noexcept + int compare (const CharPointer other) const noexcept { return CharacterFunctions::compare (*this, other); } /** Compares this string with another one. */ - int compare (const CharPointer_ASCII& other) const noexcept + int compare (const CharPointer_ASCII other) const noexcept { return strcmp (data, other.data); } /** Compares this string with another one, up to a specified number of characters. */ template <typename CharPointer> - int compareUpTo (const CharPointer& other, const int maxChars) const noexcept + int compareUpTo (const CharPointer other, const int maxChars) const noexcept { return CharacterFunctions::compareUpTo (*this, other, maxChars); } /** Compares this string with another one, up to a specified number of characters. */ - int compareUpTo (const CharPointer_ASCII& other, const int maxChars) const noexcept + int compareUpTo (const CharPointer_ASCII other, const int maxChars) const noexcept { return strncmp (data, other.data, (size_t) maxChars); } /** Compares this string with another one. */ template <typename CharPointer> - int compareIgnoreCase (const CharPointer& other) const + int compareIgnoreCase (const CharPointer other) const { return CharacterFunctions::compareIgnoreCase (*this, other); } - int compareIgnoreCase (const CharPointer_ASCII& other) const + int compareIgnoreCase (const CharPointer_ASCII other) const { #if JUCE_WINDOWS return stricmp (data, other.data); @@ -282,14 +285,14 @@ public: /** Compares this string with another one, up to a specified number of characters. */ template <typename CharPointer> - int compareIgnoreCaseUpTo (const CharPointer& other, const int maxChars) const noexcept + int compareIgnoreCaseUpTo (const CharPointer other, const int maxChars) const noexcept { return CharacterFunctions::compareIgnoreCaseUpTo (*this, other, maxChars); } /** Returns the character index of a substring, or -1 if it isn't found. */ template <typename CharPointer> - int indexOf (const CharPointer& stringToFind) const noexcept + int indexOf (const CharPointer stringToFind) const noexcept { return CharacterFunctions::indexOf (*this, stringToFind); } diff --git a/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF16.h b/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF16.h index 89aadca6c..eacbb9932 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF16.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF16.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -52,25 +55,25 @@ public: { } - inline CharPointer_UTF16& operator= (const CharPointer_UTF16& other) noexcept + inline CharPointer_UTF16 operator= (CharPointer_UTF16 other) noexcept { data = other.data; return *this; } - inline CharPointer_UTF16& operator= (const CharType* text) noexcept + inline CharPointer_UTF16 operator= (const CharType* text) noexcept { data = const_cast <CharType*> (text); return *this; } /** This is a pointer comparison, it doesn't compare the actual text. */ - inline bool operator== (const CharPointer_UTF16& other) const noexcept { return data == other.data; } - inline bool operator!= (const CharPointer_UTF16& other) const noexcept { return data != other.data; } - inline bool operator<= (const CharPointer_UTF16& other) const noexcept { return data <= other.data; } - inline bool operator< (const CharPointer_UTF16& other) const noexcept { return data < other.data; } - inline bool operator>= (const CharPointer_UTF16& other) const noexcept { return data >= other.data; } - inline bool operator> (const CharPointer_UTF16& other) const noexcept { return data > other.data; } + inline bool operator== (CharPointer_UTF16 other) const noexcept { return data == other.data; } + inline bool operator!= (CharPointer_UTF16 other) const noexcept { return data != other.data; } + inline bool operator<= (CharPointer_UTF16 other) const noexcept { return data <= other.data; } + inline bool operator< (CharPointer_UTF16 other) const noexcept { return data < other.data; } + inline bool operator>= (CharPointer_UTF16 other) const noexcept { return data >= other.data; } + inline bool operator> (CharPointer_UTF16 other) const noexcept { return data > other.data; } /** Returns the address that this pointer is pointing to. */ inline CharType* getAddress() const noexcept { return data; } @@ -93,7 +96,7 @@ public: } /** Moves this pointer along to the next character in the string. */ - CharPointer_UTF16& operator++() noexcept + CharPointer_UTF16 operator++() noexcept { const juce_wchar n = *data++; @@ -104,7 +107,7 @@ public: } /** Moves this pointer back to the previous character in the string. */ - CharPointer_UTF16& operator--() noexcept + CharPointer_UTF16 operator--() noexcept { const juce_wchar n = *--data; @@ -231,7 +234,7 @@ public: } /** Returns the number of characters in this string, or up to the given end pointer, whichever is lower. */ - size_t lengthUpTo (const CharPointer_UTF16& end) const noexcept + size_t lengthUpTo (const CharPointer_UTF16 end) const noexcept { return CharacterFunctions::lengthUpTo (*this, end); } @@ -281,13 +284,13 @@ public: /** Copies a source string to this pointer, advancing this pointer as it goes. */ template <typename CharPointer> - void writeAll (const CharPointer& src) noexcept + void writeAll (const CharPointer src) noexcept { CharacterFunctions::copyAll (*this, src); } /** Copies a source string to this pointer, advancing this pointer as it goes. */ - void writeAll (const CharPointer_UTF16& src) noexcept + void writeAll (const CharPointer_UTF16 src) noexcept { const CharType* s = src.data; @@ -303,7 +306,7 @@ public: to the destination buffer before stopping. */ template <typename CharPointer> - size_t writeWithDestByteLimit (const CharPointer& src, const size_t maxDestBytes) noexcept + size_t writeWithDestByteLimit (const CharPointer src, const size_t maxDestBytes) noexcept { return CharacterFunctions::copyWithDestByteLimit (*this, src, maxDestBytes); } @@ -313,51 +316,51 @@ public: written to the destination buffer before stopping (including the terminating null). */ template <typename CharPointer> - void writeWithCharLimit (const CharPointer& src, const int maxChars) noexcept + void writeWithCharLimit (const CharPointer src, const int maxChars) noexcept { CharacterFunctions::copyWithCharLimit (*this, src, maxChars); } /** Compares this string with another one. */ template <typename CharPointer> - int compare (const CharPointer& other) const noexcept + int compare (const CharPointer other) const noexcept { return CharacterFunctions::compare (*this, other); } /** Compares this string with another one, up to a specified number of characters. */ template <typename CharPointer> - int compareUpTo (const CharPointer& other, const int maxChars) const noexcept + int compareUpTo (const CharPointer other, const int maxChars) const noexcept { return CharacterFunctions::compareUpTo (*this, other, maxChars); } /** Compares this string with another one. */ template <typename CharPointer> - int compareIgnoreCase (const CharPointer& other) const noexcept + int compareIgnoreCase (const CharPointer other) const noexcept { return CharacterFunctions::compareIgnoreCase (*this, other); } /** Compares this string with another one, up to a specified number of characters. */ template <typename CharPointer> - int compareIgnoreCaseUpTo (const CharPointer& other, const int maxChars) const noexcept + int compareIgnoreCaseUpTo (const CharPointer other, const int maxChars) const noexcept { return CharacterFunctions::compareIgnoreCaseUpTo (*this, other, maxChars); } #if JUCE_WINDOWS && ! DOXYGEN - int compareIgnoreCase (const CharPointer_UTF16& other) const noexcept + int compareIgnoreCase (const CharPointer_UTF16 other) const noexcept { return _wcsicmp (data, other.data); } - int compareIgnoreCaseUpTo (const CharPointer_UTF16& other, int maxChars) const noexcept + int compareIgnoreCaseUpTo (const CharPointer_UTF16 other, int maxChars) const noexcept { return _wcsnicmp (data, other.data, (size_t) maxChars); } - int indexOf (const CharPointer_UTF16& stringToFind) const noexcept + int indexOf (const CharPointer_UTF16 stringToFind) const noexcept { const CharType* const t = wcsstr (data, stringToFind.getAddress()); return t == nullptr ? -1 : (int) (t - data); @@ -366,7 +369,7 @@ public: /** Returns the character index of a substring, or -1 if it isn't found. */ template <typename CharPointer> - int indexOf (const CharPointer& stringToFind) const noexcept + int indexOf (const CharPointer stringToFind) const noexcept { return CharacterFunctions::indexOf (*this, stringToFind); } @@ -466,7 +469,7 @@ public: } /** Atomically swaps this pointer for a new value, returning the previous value. */ - CharPointer_UTF16 atomicSwap (const CharPointer_UTF16& newValue) + CharPointer_UTF16 atomicSwap (const CharPointer_UTF16 newValue) { return CharPointer_UTF16 (reinterpret_cast <Atomic<CharType*>&> (data).exchange (newValue.data)); } diff --git a/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF32.h b/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF32.h index f7aa6df79..daed787f1 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF32.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF32.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -48,25 +51,25 @@ public: { } - inline CharPointer_UTF32& operator= (const CharPointer_UTF32& other) noexcept + inline CharPointer_UTF32 operator= (CharPointer_UTF32 other) noexcept { data = other.data; return *this; } - inline CharPointer_UTF32& operator= (const CharType* text) noexcept + inline CharPointer_UTF32 operator= (const CharType* text) noexcept { data = const_cast <CharType*> (text); return *this; } /** This is a pointer comparison, it doesn't compare the actual text. */ - inline bool operator== (const CharPointer_UTF32& other) const noexcept { return data == other.data; } - inline bool operator!= (const CharPointer_UTF32& other) const noexcept { return data != other.data; } - inline bool operator<= (const CharPointer_UTF32& other) const noexcept { return data <= other.data; } - inline bool operator< (const CharPointer_UTF32& other) const noexcept { return data < other.data; } - inline bool operator>= (const CharPointer_UTF32& other) const noexcept { return data >= other.data; } - inline bool operator> (const CharPointer_UTF32& other) const noexcept { return data > other.data; } + inline bool operator== (CharPointer_UTF32 other) const noexcept { return data == other.data; } + inline bool operator!= (CharPointer_UTF32 other) const noexcept { return data != other.data; } + inline bool operator<= (CharPointer_UTF32 other) const noexcept { return data <= other.data; } + inline bool operator< (CharPointer_UTF32 other) const noexcept { return data < other.data; } + inline bool operator>= (CharPointer_UTF32 other) const noexcept { return data >= other.data; } + inline bool operator> (CharPointer_UTF32 other) const noexcept { return data > other.data; } /** Returns the address that this pointer is pointing to. */ inline CharType* getAddress() const noexcept { return data; } @@ -81,14 +84,14 @@ public: inline juce_wchar operator*() const noexcept { return *data; } /** Moves this pointer along to the next character in the string. */ - inline CharPointer_UTF32& operator++() noexcept + inline CharPointer_UTF32 operator++() noexcept { ++data; return *this; } /** Moves this pointer to the previous character in the string. */ - inline CharPointer_UTF32& operator--() noexcept + inline CharPointer_UTF32 operator--() noexcept { --data; return *this; @@ -172,7 +175,7 @@ public: } /** Returns the number of characters in this string, or up to the given end pointer, whichever is lower. */ - size_t lengthUpTo (const CharPointer_UTF32& end) const noexcept + size_t lengthUpTo (const CharPointer_UTF32 end) const noexcept { return CharacterFunctions::lengthUpTo (*this, end); } @@ -198,7 +201,7 @@ public: The value returned does NOT include the terminating null character. */ template <class CharPointer> - static size_t getBytesRequiredFor (const CharPointer& text) noexcept + static size_t getBytesRequiredFor (const CharPointer text) noexcept { return sizeof (CharType) * text.length(); } @@ -211,13 +214,13 @@ public: /** Copies a source string to this pointer, advancing this pointer as it goes. */ template <typename CharPointer> - void writeAll (const CharPointer& src) noexcept + void writeAll (const CharPointer src) noexcept { CharacterFunctions::copyAll (*this, src); } /** Copies a source string to this pointer, advancing this pointer as it goes. */ - void writeAll (const CharPointer_UTF32& src) noexcept + void writeAll (const CharPointer_UTF32 src) noexcept { const CharType* s = src.data; @@ -233,7 +236,7 @@ public: to the destination buffer before stopping. */ template <typename CharPointer> - size_t writeWithDestByteLimit (const CharPointer& src, const size_t maxDestBytes) noexcept + size_t writeWithDestByteLimit (const CharPointer src, const size_t maxDestBytes) noexcept { return CharacterFunctions::copyWithDestByteLimit (*this, src, maxDestBytes); } @@ -243,21 +246,21 @@ public: written to the destination buffer before stopping (including the terminating null). */ template <typename CharPointer> - void writeWithCharLimit (const CharPointer& src, const int maxChars) noexcept + void writeWithCharLimit (const CharPointer src, const int maxChars) noexcept { CharacterFunctions::copyWithCharLimit (*this, src, maxChars); } /** Compares this string with another one. */ template <typename CharPointer> - int compare (const CharPointer& other) const noexcept + int compare (const CharPointer other) const noexcept { return CharacterFunctions::compare (*this, other); } #if JUCE_NATIVE_WCHAR_IS_UTF32 && ! JUCE_ANDROID /** Compares this string with another one. */ - int compare (const CharPointer_UTF32& other) const noexcept + int compare (const CharPointer_UTF32 other) const noexcept { return wcscmp (data, other.data); } @@ -265,28 +268,28 @@ public: /** Compares this string with another one, up to a specified number of characters. */ template <typename CharPointer> - int compareUpTo (const CharPointer& other, const int maxChars) const noexcept + int compareUpTo (const CharPointer other, const int maxChars) const noexcept { return CharacterFunctions::compareUpTo (*this, other, maxChars); } /** Compares this string with another one. */ template <typename CharPointer> - int compareIgnoreCase (const CharPointer& other) const + int compareIgnoreCase (const CharPointer other) const { return CharacterFunctions::compareIgnoreCase (*this, other); } /** Compares this string with another one, up to a specified number of characters. */ template <typename CharPointer> - int compareIgnoreCaseUpTo (const CharPointer& other, const int maxChars) const noexcept + int compareIgnoreCaseUpTo (const CharPointer other, const int maxChars) const noexcept { return CharacterFunctions::compareIgnoreCaseUpTo (*this, other, maxChars); } /** Returns the character index of a substring, or -1 if it isn't found. */ template <typename CharPointer> - int indexOf (const CharPointer& stringToFind) const noexcept + int indexOf (const CharPointer stringToFind) const noexcept { return CharacterFunctions::indexOf (*this, stringToFind); } @@ -362,7 +365,7 @@ public: } /** Atomically swaps this pointer for a new value, returning the previous value. */ - CharPointer_UTF32 atomicSwap (const CharPointer_UTF32& newValue) + CharPointer_UTF32 atomicSwap (const CharPointer_UTF32 newValue) { return CharPointer_UTF32 (reinterpret_cast <Atomic<CharType*>&> (data).exchange (newValue.data)); } diff --git a/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF8.h b/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF8.h index 92f018d30..3113b3654 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF8.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_CharPointer_UTF8.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -47,25 +50,25 @@ public: { } - inline CharPointer_UTF8& operator= (const CharPointer_UTF8& other) noexcept + inline CharPointer_UTF8 operator= (CharPointer_UTF8 other) noexcept { data = other.data; return *this; } - inline CharPointer_UTF8& operator= (const CharType* text) noexcept + inline CharPointer_UTF8 operator= (const CharType* text) noexcept { data = const_cast <CharType*> (text); return *this; } /** This is a pointer comparison, it doesn't compare the actual text. */ - inline bool operator== (const CharPointer_UTF8& other) const noexcept { return data == other.data; } - inline bool operator!= (const CharPointer_UTF8& other) const noexcept { return data != other.data; } - inline bool operator<= (const CharPointer_UTF8& other) const noexcept { return data <= other.data; } - inline bool operator< (const CharPointer_UTF8& other) const noexcept { return data < other.data; } - inline bool operator>= (const CharPointer_UTF8& other) const noexcept { return data >= other.data; } - inline bool operator> (const CharPointer_UTF8& other) const noexcept { return data > other.data; } + inline bool operator== (CharPointer_UTF8 other) const noexcept { return data == other.data; } + inline bool operator!= (CharPointer_UTF8 other) const noexcept { return data != other.data; } + inline bool operator<= (CharPointer_UTF8 other) const noexcept { return data <= other.data; } + inline bool operator< (CharPointer_UTF8 other) const noexcept { return data < other.data; } + inline bool operator>= (CharPointer_UTF8 other) const noexcept { return data >= other.data; } + inline bool operator> (CharPointer_UTF8 other) const noexcept { return data > other.data; } /** Returns the address that this pointer is pointing to. */ inline CharType* getAddress() const noexcept { return data; } @@ -132,7 +135,7 @@ public: } /** Moves this pointer back to the previous character in the string. */ - CharPointer_UTF8& operator--() noexcept + CharPointer_UTF8 operator--() noexcept { int count = 0; @@ -271,7 +274,7 @@ public: } /** Returns the number of characters in this string, or up to the given end pointer, whichever is lower. */ - size_t lengthUpTo (const CharPointer_UTF8& end) const noexcept + size_t lengthUpTo (const CharPointer_UTF8 end) const noexcept { return CharacterFunctions::lengthUpTo (*this, end); } @@ -363,13 +366,13 @@ public: /** Copies a source string to this pointer, advancing this pointer as it goes. */ template <typename CharPointer> - void writeAll (const CharPointer& src) noexcept + void writeAll (const CharPointer src) noexcept { CharacterFunctions::copyAll (*this, src); } /** Copies a source string to this pointer, advancing this pointer as it goes. */ - void writeAll (const CharPointer_UTF8& src) noexcept + void writeAll (const CharPointer_UTF8 src) noexcept { const CharType* s = src.data; @@ -385,7 +388,7 @@ public: to the destination buffer before stopping. */ template <typename CharPointer> - size_t writeWithDestByteLimit (const CharPointer& src, const size_t maxDestBytes) noexcept + size_t writeWithDestByteLimit (const CharPointer src, const size_t maxDestBytes) noexcept { return CharacterFunctions::copyWithDestByteLimit (*this, src, maxDestBytes); } @@ -395,34 +398,34 @@ public: written to the destination buffer before stopping (including the terminating null). */ template <typename CharPointer> - void writeWithCharLimit (const CharPointer& src, const int maxChars) noexcept + void writeWithCharLimit (const CharPointer src, const int maxChars) noexcept { CharacterFunctions::copyWithCharLimit (*this, src, maxChars); } /** Compares this string with another one. */ template <typename CharPointer> - int compare (const CharPointer& other) const noexcept + int compare (const CharPointer other) const noexcept { return CharacterFunctions::compare (*this, other); } /** Compares this string with another one, up to a specified number of characters. */ template <typename CharPointer> - int compareUpTo (const CharPointer& other, const int maxChars) const noexcept + int compareUpTo (const CharPointer other, const int maxChars) const noexcept { return CharacterFunctions::compareUpTo (*this, other, maxChars); } /** Compares this string with another one. */ template <typename CharPointer> - int compareIgnoreCase (const CharPointer& other) const noexcept + int compareIgnoreCase (const CharPointer other) const noexcept { return CharacterFunctions::compareIgnoreCase (*this, other); } /** Compares this string with another one. */ - int compareIgnoreCase (const CharPointer_UTF8& other) const noexcept + int compareIgnoreCase (const CharPointer_UTF8 other) const noexcept { #if JUCE_WINDOWS return stricmp (data, other.data); @@ -433,14 +436,14 @@ public: /** Compares this string with another one, up to a specified number of characters. */ template <typename CharPointer> - int compareIgnoreCaseUpTo (const CharPointer& other, const int maxChars) const noexcept + int compareIgnoreCaseUpTo (const CharPointer other, const int maxChars) const noexcept { return CharacterFunctions::compareIgnoreCaseUpTo (*this, other, maxChars); } /** Returns the character index of a substring, or -1 if it isn't found. */ template <typename CharPointer> - int indexOf (const CharPointer& stringToFind) const noexcept + int indexOf (const CharPointer stringToFind) const noexcept { return CharacterFunctions::indexOf (*this, stringToFind); } @@ -542,7 +545,7 @@ public: } /** Atomically swaps this pointer for a new value, returning the previous value. */ - CharPointer_UTF8 atomicSwap (const CharPointer_UTF8& newValue) + CharPointer_UTF8 atomicSwap (const CharPointer_UTF8 newValue) { return CharPointer_UTF8 (reinterpret_cast <Atomic<CharType*>&> (data).exchange (newValue.data)); } diff --git a/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.cpp b/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.cpp index e74154c3e..11eaa188b 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.h b/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.h index 5b7e0ddb0..0a2530c0a 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -255,7 +258,7 @@ public: //============================================================================== /** Parses a character string, to read an integer value. */ template <typename IntType, typename CharPointerType> - static IntType getIntValue (const CharPointerType& text) noexcept + static IntType getIntValue (const CharPointerType text) noexcept { IntType v = 0; CharPointerType s (text.findEndOfWhitespace()); @@ -294,7 +297,7 @@ public: /** Counts the number of characters in a given string, stopping if the count exceeds a specified end-pointer. */ template <typename CharPointerType> - static size_t lengthUpTo (CharPointerType start, const CharPointerType& end) noexcept + static size_t lengthUpTo (CharPointerType start, const CharPointerType end) noexcept { size_t len = 0; @@ -373,12 +376,10 @@ public: { const int c1 = (int) s1.getAndAdvance(); const int c2 = (int) s2.getAndAdvance(); - const int diff = c1 - c2; - if (diff != 0) - return diff < 0 ? -1 : 1; - else if (c1 == 0) - break; + + if (diff != 0) return diff < 0 ? -1 : 1; + if (c1 == 0) break; } return 0; @@ -392,12 +393,10 @@ public: { const int c1 = (int) s1.getAndAdvance(); const int c2 = (int) s2.getAndAdvance(); - const int diff = c1 - c2; - if (diff != 0) - return diff < 0 ? -1 : 1; - else if (c1 == 0) - break; + + if (diff != 0) return diff < 0 ? -1 : 1; + if (c1 == 0) break; } return 0; @@ -409,16 +408,12 @@ public: { for (;;) { - int c1 = (int) s1.toUpperCase(); - int c2 = (int) s2.toUpperCase(); - ++s1; - ++s2; - + const int c1 = (int) s1.toUpperCase(); ++s1; + const int c2 = (int) s2.toUpperCase(); ++s2; const int diff = c1 - c2; - if (diff != 0) - return diff < 0 ? -1 : 1; - else if (c1 == 0) - break; + + if (diff != 0) return diff < 0 ? -1 : 1; + if (c1 == 0) break; } return 0; @@ -430,16 +425,12 @@ public: { while (--maxChars >= 0) { - int c1 = s1.toUpperCase(); - int c2 = s2.toUpperCase(); - ++s1; - ++s2; - + const int c1 = (int) s1.toUpperCase(); ++s1; + const int c2 = (int) s2.toUpperCase(); ++s2; const int diff = c1 - c2; - if (diff != 0) - return diff < 0 ? -1 : 1; - else if (c1 == 0) - break; + + if (diff != 0) return diff < 0 ? -1 : 1; + if (c1 == 0) break; } return 0; @@ -449,7 +440,7 @@ public: Returns -1 if the substring is not found. */ template <typename CharPointerType1, typename CharPointerType2> - static int indexOf (CharPointerType1 textToSearch, const CharPointerType2& substringToLookFor) noexcept + static int indexOf (CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept { int index = 0; const int substringLength = (int) substringToLookFor.length(); @@ -471,7 +462,7 @@ public: null terminator. */ template <typename CharPointerType1, typename CharPointerType2> - static CharPointerType1 find (CharPointerType1 textToSearch, const CharPointerType2& substringToLookFor) noexcept + static CharPointerType1 find (CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept { const int substringLength = (int) substringToLookFor.length(); @@ -487,7 +478,7 @@ public: Returns -1 if the substring is not found. */ template <typename CharPointerType1, typename CharPointerType2> - static int indexOfIgnoreCase (CharPointerType1 haystack, const CharPointerType2& needle) noexcept + static int indexOfIgnoreCase (CharPointerType1 haystack, const CharPointerType2 needle) noexcept { int index = 0; const int needleLength = (int) needle.length(); diff --git a/JuceLibraryCode/modules/juce_core/text/juce_Identifier.cpp b/JuceLibraryCode/modules/juce_core/text/juce_Identifier.cpp index 6950a7cd0..c52ad5f24 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_Identifier.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_Identifier.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -39,7 +42,7 @@ Identifier::Identifier (const Identifier& other) noexcept { } -Identifier& Identifier::operator= (const Identifier& other) noexcept +Identifier& Identifier::operator= (const Identifier other) noexcept { name = other.name; return *this; @@ -48,9 +51,6 @@ Identifier& Identifier::operator= (const Identifier& other) noexcept Identifier::Identifier (const String& nm) : name (Identifier::getPool().getPooledString (nm)) { - /* An Identifier string must be suitable for use as a script variable or XML - attribute, so it can only contain this limited set of characters.. */ - jassert (isValidIdentifier (nm)); } Identifier::Identifier (const char* const nm) diff --git a/JuceLibraryCode/modules/juce_core/text/juce_Identifier.h b/JuceLibraryCode/modules/juce_core/text/juce_Identifier.h index 7decd5291..943261b54 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_Identifier.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_Identifier.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -61,16 +64,16 @@ public: Identifier (const Identifier& other) noexcept; /** Creates a copy of another identifier. */ - Identifier& operator= (const Identifier& other) noexcept; + Identifier& operator= (const Identifier other) noexcept; /** Destructor */ ~Identifier(); /** Compares two identifiers. This is a very fast operation. */ - inline bool operator== (const Identifier& other) const noexcept { return name == other.name; } + inline bool operator== (const Identifier other) const noexcept { return name == other.name; } /** Compares two identifiers. This is a very fast operation. */ - inline bool operator!= (const Identifier& other) const noexcept { return name != other.name; } + inline bool operator!= (const Identifier other) const noexcept { return name != other.name; } /** Returns this identifier as a string. */ String toString() const { return name; } diff --git a/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.cpp b/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.cpp index a42b1da46..553474245 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.cpp @@ -1,36 +1,39 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ -LocalisedStrings::LocalisedStrings (const String& fileContents) +LocalisedStrings::LocalisedStrings (const String& fileContents, bool ignoreCase) { - loadFromText (fileContents); + loadFromText (fileContents, ignoreCase); } -LocalisedStrings::LocalisedStrings (const File& fileToLoad) +LocalisedStrings::LocalisedStrings (const File& fileToLoad, bool ignoreCase) { - loadFromText (fileToLoad.loadFileAsString()); + loadFromText (fileToLoad.loadFileAsString(), ignoreCase); } LocalisedStrings::~LocalisedStrings() @@ -60,7 +63,7 @@ namespace { LeakAvoidanceTrick() { - const ScopedPointer<LocalisedStrings> dummy (new LocalisedStrings (String())); + const ScopedPointer<LocalisedStrings> dummy (new LocalisedStrings (String(), false)); } }; @@ -99,8 +102,10 @@ namespace } } -void LocalisedStrings::loadFromText (const String& fileContents) +void LocalisedStrings::loadFromText (const String& fileContents, bool ignoreCase) { + translations.setIgnoresCase (ignoreCase); + StringArray lines; lines.addLines (fileContents); @@ -138,11 +143,6 @@ void LocalisedStrings::loadFromText (const String& fileContents) } } -void LocalisedStrings::setIgnoresCase (const bool shouldIgnoreCase) -{ - translations.setIgnoresCase (shouldIgnoreCase); -} - //============================================================================== void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) { diff --git a/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.h b/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.h index 5a4dfa9dc..e063be632 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -81,14 +84,16 @@ public: When you create one of these, you can call setCurrentMappings() to make it the set of mappings that the system's using. */ - LocalisedStrings (const String& fileContents); + LocalisedStrings (const String& fileContents, + bool ignoreCaseOfKeys); /** Creates a set of translations from a file. When you create one of these, you can call setCurrentMappings() to make it the set of mappings that the system's using. */ - LocalisedStrings (const File& fileToLoad); + LocalisedStrings (const File& fileToLoad, + bool ignoreCaseOfKeys); /** Destructor. */ ~LocalisedStrings(); @@ -109,7 +114,7 @@ public: /** Returns the currently selected set of mappings. This is the object that was last passed to setCurrentMappings(). It may - be 0 if none has been created. + be nullptr if none has been created. */ static LocalisedStrings* getCurrentMappings(); @@ -166,12 +171,8 @@ public: */ const StringArray& getCountryCodes() const { return countryCodes; } - - //============================================================================== - /** Indicates whether to use a case-insensitive search when looking up a string. - This defaults to true. - */ - void setIgnoresCase (bool shouldIgnoreCase); + /** Provides access to the actual list of mappings. */ + const StringPairArray& getMappings() const { return translations; } private: //============================================================================== @@ -179,7 +180,7 @@ private: StringArray countryCodes; StringPairArray translations; - void loadFromText (const String& fileContents); + void loadFromText (const String&, bool ignoreCase); JUCE_LEAK_DETECTOR (LocalisedStrings) }; @@ -195,6 +196,15 @@ private: #define TRANS(stringLiteral) juce::translate (stringLiteral) #endif +/** A dummy version of the TRANS macro, used to indicate a string literal that should be + added to the translation file by source-code scanner tools. + + Wrapping a string literal in this macro has no effect, but by using it around strings + that your app needs to translate at a later stage, it lets automatic code-scanning tools + find this string and add it to the list of strings that need translation. +*/ +#define NEEDS_TRANS(stringLiteral) (stringLiteral) + /** Uses the LocalisedStrings class to translate the given string literal. @see LocalisedStrings */ diff --git a/JuceLibraryCode/modules/juce_core/text/juce_NewLine.h b/JuceLibraryCode/modules/juce_core/text/juce_NewLine.h index c8dda4727..878b1a3d6 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_NewLine.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_NewLine.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/text/juce_String.cpp b/JuceLibraryCode/modules/juce_core/text/juce_String.cpp index 146b89a89..56c7c62ae 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_String.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_String.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -70,7 +73,7 @@ public: } template <class CharPointer> - static CharPointerType createFromCharPointer (const CharPointer& text) + static CharPointerType createFromCharPointer (const CharPointer text) { if (text.getAddress() == nullptr || text.isEmpty()) return getEmpty(); @@ -87,7 +90,7 @@ public: } template <class CharPointer> - static CharPointerType createFromCharPointer (const CharPointer& text, size_t maxChars) + static CharPointerType createFromCharPointer (const CharPointer text, size_t maxChars) { if (text.getAddress() == nullptr || text.isEmpty() || maxChars == 0) return getEmpty(); @@ -108,7 +111,7 @@ public: } template <class CharPointer> - static CharPointerType createFromCharPointer (const CharPointer& start, const CharPointer& end) + static CharPointerType createFromCharPointer (const CharPointer start, const CharPointer end) { if (start.getAddress() == nullptr || start.isEmpty()) return getEmpty(); @@ -128,7 +131,7 @@ public: return dest; } - static CharPointerType createFromCharPointer (const CharPointerType& start, const CharPointerType& end) + static CharPointerType createFromCharPointer (const CharPointerType start, const CharPointerType end) { if (start.getAddress() == nullptr || start.isEmpty()) return getEmpty(); @@ -153,7 +156,7 @@ public: } //============================================================================== - static void retain (const CharPointerType& text) noexcept + static void retain (const CharPointerType text) noexcept { ++(bufferFromText (text)->refCount); } @@ -164,13 +167,13 @@ public: delete[] reinterpret_cast <char*> (b); } - static void release (const CharPointerType& text) noexcept + static void release (const CharPointerType text) noexcept { release (bufferFromText (text)); } //============================================================================== - static CharPointerType makeUnique (const CharPointerType& text) + static CharPointerType makeUnique (const CharPointerType text) { StringHolder* const b = bufferFromText (text); @@ -184,7 +187,7 @@ public: return newText; } - static CharPointerType makeUniqueWithByteSize (const CharPointerType& text, size_t numBytes) + static CharPointerType makeUniqueWithByteSize (const CharPointerType text, size_t numBytes) { StringHolder* const b = bufferFromText (text); @@ -198,7 +201,7 @@ public: return newText; } - static size_t getAllocatedNumBytes (const CharPointerType& text) noexcept + static size_t getAllocatedNumBytes (const CharPointerType text) noexcept { return bufferFromText (text)->allocatedNumBytes; } @@ -211,7 +214,7 @@ public: static StringHolder empty; private: - static inline StringHolder* bufferFromText (const CharPointerType& text) noexcept + static inline StringHolder* bufferFromText (const CharPointerType text) noexcept { // (Can't use offsetof() here because of warnings about this not being a POD) return reinterpret_cast <StringHolder*> (reinterpret_cast <char*> (text.getAddress()) @@ -243,8 +246,7 @@ void String::preallocateBytes (const size_t numBytesNeeded) } //============================================================================== -String::String() noexcept - : text (StringHolder::getEmpty()) +String::String() noexcept : text (StringHolder::getEmpty()) { } @@ -332,19 +334,21 @@ String::String (const char* const t, const size_t maxChars) } String::String (const wchar_t* const t) : text (StringHolder::createFromCharPointer (castToCharPointer_wchar_t (t))) {} -String::String (const CharPointer_UTF8& t) : text (StringHolder::createFromCharPointer (t)) {} -String::String (const CharPointer_UTF16& t) : text (StringHolder::createFromCharPointer (t)) {} -String::String (const CharPointer_UTF32& t) : text (StringHolder::createFromCharPointer (t)) {} -String::String (const CharPointer_ASCII& t) : text (StringHolder::createFromCharPointer (t)) {} - -String::String (const CharPointer_UTF8& t, const size_t maxChars) : text (StringHolder::createFromCharPointer (t, maxChars)) {} -String::String (const CharPointer_UTF16& t, const size_t maxChars) : text (StringHolder::createFromCharPointer (t, maxChars)) {} -String::String (const CharPointer_UTF32& t, const size_t maxChars) : text (StringHolder::createFromCharPointer (t, maxChars)) {} +String::String (const CharPointer_UTF8 t) : text (StringHolder::createFromCharPointer (t)) {} +String::String (const CharPointer_UTF16 t) : text (StringHolder::createFromCharPointer (t)) {} +String::String (const CharPointer_UTF32 t) : text (StringHolder::createFromCharPointer (t)) {} +String::String (const CharPointer_ASCII t) : text (StringHolder::createFromCharPointer (t)) {} + +String::String (const CharPointer_UTF8 t, const size_t maxChars) : text (StringHolder::createFromCharPointer (t, maxChars)) {} +String::String (const CharPointer_UTF16 t, const size_t maxChars) : text (StringHolder::createFromCharPointer (t, maxChars)) {} +String::String (const CharPointer_UTF32 t, const size_t maxChars) : text (StringHolder::createFromCharPointer (t, maxChars)) {} String::String (const wchar_t* const t, size_t maxChars) : text (StringHolder::createFromCharPointer (castToCharPointer_wchar_t (t), maxChars)) {} -String::String (const CharPointer_UTF8& start, const CharPointer_UTF8& end) : text (StringHolder::createFromCharPointer (start, end)) {} -String::String (const CharPointer_UTF16& start, const CharPointer_UTF16& end) : text (StringHolder::createFromCharPointer (start, end)) {} -String::String (const CharPointer_UTF32& start, const CharPointer_UTF32& end) : text (StringHolder::createFromCharPointer (start, end)) {} +String::String (const CharPointer_UTF8 start, const CharPointer_UTF8 end) : text (StringHolder::createFromCharPointer (start, end)) {} +String::String (const CharPointer_UTF16 start, const CharPointer_UTF16 end) : text (StringHolder::createFromCharPointer (start, end)) {} +String::String (const CharPointer_UTF32 start, const CharPointer_UTF32 end) : text (StringHolder::createFromCharPointer (start, end)) {} + +String::String (const std::string& s) : text (StringHolder::createFromFixedLength (s.data(), s.size())) {} String String::charToString (const juce_wchar character) { @@ -471,7 +475,7 @@ namespace NumberToStringConverters } template <typename IntegerType> - String::CharPointerType createFromInteger (const IntegerType number) + static String::CharPointerType createFromInteger (const IntegerType number) { char buffer [32]; char* const end = buffer + numElementsInArray (buffer); @@ -545,15 +549,15 @@ int64 String::hashCode64() const noexcept JUCE_API bool JUCE_CALLTYPE operator== (const String& s1, const String& s2) noexcept { return s1.compare (s2) == 0; } JUCE_API bool JUCE_CALLTYPE operator== (const String& s1, const char* const s2) noexcept { return s1.compare (s2) == 0; } JUCE_API bool JUCE_CALLTYPE operator== (const String& s1, const wchar_t* const s2) noexcept { return s1.compare (s2) == 0; } -JUCE_API bool JUCE_CALLTYPE operator== (const String& s1, const CharPointer_UTF8& s2) noexcept { return s1.getCharPointer().compare (s2) == 0; } -JUCE_API bool JUCE_CALLTYPE operator== (const String& s1, const CharPointer_UTF16& s2) noexcept { return s1.getCharPointer().compare (s2) == 0; } -JUCE_API bool JUCE_CALLTYPE operator== (const String& s1, const CharPointer_UTF32& s2) noexcept { return s1.getCharPointer().compare (s2) == 0; } +JUCE_API bool JUCE_CALLTYPE operator== (const String& s1, const CharPointer_UTF8 s2) noexcept { return s1.getCharPointer().compare (s2) == 0; } +JUCE_API bool JUCE_CALLTYPE operator== (const String& s1, const CharPointer_UTF16 s2) noexcept { return s1.getCharPointer().compare (s2) == 0; } +JUCE_API bool JUCE_CALLTYPE operator== (const String& s1, const CharPointer_UTF32 s2) noexcept { return s1.getCharPointer().compare (s2) == 0; } JUCE_API bool JUCE_CALLTYPE operator!= (const String& s1, const String& s2) noexcept { return s1.compare (s2) != 0; } JUCE_API bool JUCE_CALLTYPE operator!= (const String& s1, const char* const s2) noexcept { return s1.compare (s2) != 0; } JUCE_API bool JUCE_CALLTYPE operator!= (const String& s1, const wchar_t* const s2) noexcept { return s1.compare (s2) != 0; } -JUCE_API bool JUCE_CALLTYPE operator!= (const String& s1, const CharPointer_UTF8& s2) noexcept { return s1.getCharPointer().compare (s2) != 0; } -JUCE_API bool JUCE_CALLTYPE operator!= (const String& s1, const CharPointer_UTF16& s2) noexcept { return s1.getCharPointer().compare (s2) != 0; } -JUCE_API bool JUCE_CALLTYPE operator!= (const String& s1, const CharPointer_UTF32& s2) noexcept { return s1.getCharPointer().compare (s2) != 0; } +JUCE_API bool JUCE_CALLTYPE operator!= (const String& s1, const CharPointer_UTF8 s2) noexcept { return s1.getCharPointer().compare (s2) != 0; } +JUCE_API bool JUCE_CALLTYPE operator!= (const String& s1, const CharPointer_UTF16 s2) noexcept { return s1.getCharPointer().compare (s2) != 0; } +JUCE_API bool JUCE_CALLTYPE operator!= (const String& s1, const CharPointer_UTF32 s2) noexcept { return s1.getCharPointer().compare (s2) != 0; } JUCE_API bool JUCE_CALLTYPE operator> (const String& s1, const String& s2) noexcept { return s1.compare (s2) > 0; } JUCE_API bool JUCE_CALLTYPE operator< (const String& s1, const String& s2) noexcept { return s1.compare (s2) < 0; } JUCE_API bool JUCE_CALLTYPE operator>= (const String& s1, const String& s2) noexcept { return s1.compare (s2) >= 0; } @@ -1019,7 +1023,7 @@ struct WildCardMatcher || (ignoreCase && CharacterFunctions::toLowerCase (wc) == CharacterFunctions::toLowerCase (tc)); } - static bool matchesAnywhere (const CharPointer& wildcard, CharPointer test, const bool ignoreCase) noexcept + static bool matchesAnywhere (const CharPointer wildcard, CharPointer test, const bool ignoreCase) noexcept { for (; ! test.isEmpty(); ++test) if (matches (wildcard, test, ignoreCase)) @@ -1895,15 +1899,8 @@ String String::toHexString (const void* const d, const int size, const int group return s; } -int String::getHexValue32() const noexcept -{ - return HexConverter<int>::stringToHex (text); -} - -int64 String::getHexValue64() const noexcept -{ - return HexConverter<int64>::stringToHex (text); -} +int String::getHexValue32() const noexcept { return HexConverter<int> ::stringToHex (text); } +int64 String::getHexValue64() const noexcept { return HexConverter<int64>::stringToHex (text); } //============================================================================== String String::createStringFromData (const void* const data_, const int size) @@ -2011,16 +2008,26 @@ CharPointer_UTF8 String::toUTF8() const { return StringEncodingConverter <Char CharPointer_UTF16 String::toUTF16() const { return StringEncodingConverter <CharPointerType, CharPointer_UTF16>::convert (*this); } CharPointer_UTF32 String::toUTF32() const { return StringEncodingConverter <CharPointerType, CharPointer_UTF32>::convert (*this); } +const char* String::toRawUTF8() const +{ + return toUTF8().getAddress(); +} + const wchar_t* String::toWideCharPointer() const { return StringEncodingConverter <CharPointerType, CharPointer_wchar_t>::convert (*this).getAddress(); } +std::string String::toStdString() const +{ + return std::string (toRawUTF8()); +} + //============================================================================== template <class CharPointerType_Src, class CharPointerType_Dest> struct StringCopier { - static size_t copyToBuffer (const CharPointerType_Src& source, typename CharPointerType_Dest::CharType* const buffer, const size_t maxBufferSizeBytes) + static size_t copyToBuffer (const CharPointerType_Src source, typename CharPointerType_Dest::CharType* const buffer, const size_t maxBufferSizeBytes) { jassert (((ssize_t) maxBufferSizeBytes) >= 0); // keep this value positive! @@ -2251,6 +2258,7 @@ public: expect (s3.indexOf (L"HIJK") == -1); expect (s3.indexOfIgnoreCase ("hij") == 7); expect (s3.indexOfIgnoreCase (L"hijk") == -1); + expect (s3.toStdString() == s3.toRawUTF8()); String s4 (s3); s4.append (String ("xyz123"), 3); diff --git a/JuceLibraryCode/modules/juce_core/text/juce_String.h b/JuceLibraryCode/modules/juce_core/text/juce_String.h index 74fad7412..ca1501718 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_String.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_String.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -120,37 +123,40 @@ public: //============================================================================== /** Creates a string from a UTF-8 character string */ - String (const CharPointer_UTF8& text); + String (const CharPointer_UTF8 text); /** Creates a string from a UTF-8 character string */ - String (const CharPointer_UTF8& text, size_t maxChars); + String (const CharPointer_UTF8 text, size_t maxChars); /** Creates a string from a UTF-8 character string */ - String (const CharPointer_UTF8& start, const CharPointer_UTF8& end); + String (const CharPointer_UTF8 start, const CharPointer_UTF8 end); //============================================================================== /** Creates a string from a UTF-16 character string */ - String (const CharPointer_UTF16& text); + String (const CharPointer_UTF16 text); /** Creates a string from a UTF-16 character string */ - String (const CharPointer_UTF16& text, size_t maxChars); + String (const CharPointer_UTF16 text, size_t maxChars); /** Creates a string from a UTF-16 character string */ - String (const CharPointer_UTF16& start, const CharPointer_UTF16& end); + String (const CharPointer_UTF16 start, const CharPointer_UTF16 end); //============================================================================== /** Creates a string from a UTF-32 character string */ - String (const CharPointer_UTF32& text); + String (const CharPointer_UTF32 text); /** Creates a string from a UTF-32 character string */ - String (const CharPointer_UTF32& text, size_t maxChars); + String (const CharPointer_UTF32 text, size_t maxChars); /** Creates a string from a UTF-32 character string */ - String (const CharPointer_UTF32& start, const CharPointer_UTF32& end); + String (const CharPointer_UTF32 start, const CharPointer_UTF32 end); //============================================================================== /** Creates a string from an ASCII character string */ - String (const CharPointer_ASCII& text); + String (const CharPointer_ASCII text); + + /** Creates a string from a UTF-8 encoded std::string. */ + String (const std::string&); //============================================================================== /** Creates a string from a single character. */ @@ -239,7 +245,7 @@ public: @param maxCharsToTake the maximum number of characters to take from the string passed in */ template <class CharPointer> - void appendCharPointer (const CharPointer& textToAppend, size_t maxCharsToTake) + void appendCharPointer (const CharPointer textToAppend, size_t maxCharsToTake) { if (textToAppend.getAddress() != nullptr) { @@ -264,7 +270,7 @@ public: /** Appends a string to the end of this one. */ template <class CharPointer> - void appendCharPointer (const CharPointer& textToAppend) + void appendCharPointer (const CharPointer textToAppend) { if (textToAppend.getAddress() != nullptr) { @@ -1034,7 +1040,7 @@ public: that is returned must not be stored anywhere, as it can be deleted whenever the string changes. */ - inline const CharPointerType& getCharPointer() const noexcept { return text; } + inline CharPointerType getCharPointer() const noexcept { return text; } /** Returns a pointer to a UTF-8 version of this string. @@ -1045,10 +1051,23 @@ public: To find out how many bytes you need to store this string as UTF-8, you can call CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer()) - @see getCharPointer, toUTF16, toUTF32 + @see toRawUTF8, getCharPointer, toUTF16, toUTF32 */ CharPointer_UTF8 toUTF8() const; + /** Returns a pointer to a UTF-8 version of this string. + + Because it returns a reference to the string's internal data, the pointer + that is returned must not be stored anywhere, as it can be deleted whenever the + string changes. + + To find out how many bytes you need to store this string as UTF-8, you can call + CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer()) + + @see getCharPointer, toUTF8, toUTF16, toUTF32 + */ + const char* toRawUTF8() const; + /** Returns a pointer to a UTF-16 version of this string. Because it returns a reference to the string's internal data, the pointer @@ -1086,6 +1105,9 @@ public: */ const wchar_t* toWideCharPointer() const; + /** */ + std::string toStdString() const; + //============================================================================== /** Creates a String from a UTF-8 encoded buffer. If the size is < 0, it'll keep reading until it hits a zero. @@ -1277,11 +1299,11 @@ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const char* strin /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const wchar_t* string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF8& string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF8 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF16& string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF16 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF32& string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF32 string2) noexcept; /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const String& string2) noexcept; /** Case-sensitive comparison of two strings. */ @@ -1289,11 +1311,11 @@ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const char* strin /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const wchar_t* string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF8& string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF8 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF16& string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF16 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF32& string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF32 string2) noexcept; /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator> (const String& string1, const String& string2) noexcept; /** Case-sensitive comparison of two strings. */ @@ -1310,7 +1332,7 @@ JUCE_API bool JUCE_CALLTYPE operator<= (const String& string1, const String& str template <class traits> std::basic_ostream <char, traits>& JUCE_CALLTYPE operator<< (std::basic_ostream <char, traits>& stream, const String& stringToWrite) { - return stream << stringToWrite.toUTF8().getAddress(); + return stream << stringToWrite.toRawUTF8(); } /** This operator allows you to write a juce String directly to std output streams. diff --git a/JuceLibraryCode/modules/juce_core/text/juce_StringArray.cpp b/JuceLibraryCode/modules/juce_core/text/juce_StringArray.cpp index 351c0a21f..cbbaca52d 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_StringArray.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_StringArray.cpp @@ -1,29 +1,31 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ -//============================================================================== StringArray::StringArray() noexcept { } @@ -55,14 +57,19 @@ namespace StringArrayHelpers dest.add (*strings++); } - template <typename CharType> - void addArray (Array<String>& dest, const CharType* const* const strings, const int numberOfStrings) + template <typename Type> + void addArray (Array<String>& dest, const Type* const strings, const int numberOfStrings) { for (int i = 0; i < numberOfStrings; ++i) dest.add (strings [i]); } } +StringArray::StringArray (const String* initialStrings, int numberOfStrings) +{ + StringArrayHelpers::addArray (strings, initialStrings, numberOfStrings); +} + StringArray::StringArray (const char* const* const initialStrings) { StringArrayHelpers::addArray (strings, initialStrings); @@ -413,6 +420,30 @@ int StringArray::addLines (const String& sourceText) return numLines; } +StringArray StringArray::fromTokens (const String& stringToTokenise, + bool preserveQuotedStrings) +{ + StringArray s; + s.addTokens (stringToTokenise, preserveQuotedStrings); + return s; +} + +StringArray StringArray::fromTokens (const String& stringToTokenise, + const String& breakCharacters, + const String& quoteCharacters) +{ + StringArray s; + s.addTokens (stringToTokenise, breakCharacters, quoteCharacters); + return s; +} + +StringArray StringArray::fromLines (const String& stringToBreakUp) +{ + StringArray s; + s.addLines (stringToBreakUp); + return s; +} + //============================================================================== void StringArray::removeDuplicates (const bool ignoreCase) { diff --git a/JuceLibraryCode/modules/juce_core/text/juce_StringArray.h b/JuceLibraryCode/modules/juce_core/text/juce_StringArray.h index 127d4e43d..7dd9ef1a2 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_StringArray.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_StringArray.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -53,6 +56,12 @@ public: /** Creates an array containing a single string. */ explicit StringArray (const String& firstValue); + /** Creates an array from a raw array of strings. + @param strings an array of strings to add + @param numberOfStrings how many items there are in the array + */ + StringArray (const String* strings, int numberOfStrings); + /** Creates a copy of an array of string literals. @param strings an array of strings to add. Null pointers in the array will be treated as empty strings @@ -205,8 +214,8 @@ public: This will tokenise the given string using whitespace characters as the token delimiters, and will add these tokens to the end of the array. - @returns the number of tokens added + @see fromTokens */ int addTokens (const String& stringToTokenise, bool preserveQuotedStrings); @@ -223,6 +232,7 @@ public: which are treated as quotes. Any text occurring between quotes is not broken up into tokens. @returns the number of tokens added + @see fromTokens */ int addTokens (const String& stringToTokenise, const String& breakCharacters, @@ -236,6 +246,40 @@ public: */ int addLines (const String& stringToBreakUp); + /** Returns an array containing the tokens in a given string. + + This will tokenise the given string using whitespace characters as the + token delimiters, and return these tokens as an array. + @see addTokens + */ + static StringArray fromTokens (const String& stringToTokenise, + bool preserveQuotedStrings); + + /** Returns an array containing the tokens in a given string. + + This will tokenise the given string using whitespace characters as the + token delimiters, and return these tokens as an array. + + @param stringToTokenise the string to tokenise + @param breakCharacters a string of characters, any of which will be considered + to be a token delimiter. + @param quoteCharacters if this string isn't empty, it defines a set of characters + which are treated as quotes. Any text occurring + between quotes is not broken up into tokens. + @see addTokens + */ + static StringArray fromTokens (const String& stringToTokenise, + const String& breakCharacters, + const String& quoteCharacters); + + /** Returns an array containing the lines in a given string. + + This breaks a string down into lines separated by \\n or \\r\\n, and returns an + array containing these lines. Line-break characters are omitted from the strings that + are added to the array. + */ + static StringArray fromLines (const String& stringToBreakUp); + //============================================================================== /** Removes all elements from the array. */ void clear(); diff --git a/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.cpp b/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.cpp index 2a8f520be..f9cb60fe6 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.h b/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.h index 77ef182e7..360a018fa 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/text/juce_StringPool.cpp b/JuceLibraryCode/modules/juce_core/text/juce_StringPool.cpp index d8571cac0..672b3025a 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_StringPool.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_StringPool.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/text/juce_StringPool.h b/JuceLibraryCode/modules/juce_core/text/juce_StringPool.h index 9e3aa80f6..dfc77441e 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_StringPool.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_StringPool.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.cpp b/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.cpp index a303436ec..a5a7d7d05 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -82,10 +85,6 @@ struct TextDiffHelpers if (len >= minLengthToMatch) { - jassert (indexA >= 0 && indexA <= a.length); - jassert (indexB >= 0 && indexB <= b.length); - jassert (String (a.text + indexA, (size_t) len) == String (b.text + indexB, (size_t) len)); - if (indexA > 0 && indexB > 0) diffSkippingCommonStart (td, StringRegion (a.text, a.start, indexA), StringRegion (b.text, b.start, indexB)); diff --git a/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.h b/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.h index 7492e2a81..deee9b142 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.cpp index 2fb747269..7edab2a5f 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.h b/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.h index 80d50cf51..4f1442f72 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_CriticalSection.h b/JuceLibraryCode/modules/juce_core/threads/juce_CriticalSection.h index 9322d8350..38afac068 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_CriticalSection.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_CriticalSection.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_DynamicLibrary.h b/JuceLibraryCode/modules/juce_core/threads/juce_DynamicLibrary.h index 57c8decae..84d93e270 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_DynamicLibrary.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_DynamicLibrary.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.cpp index 16c27e168..3475b74d1 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.h b/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.h index 4fd59d510..f102ffa10 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_InterProcessLock.h b/JuceLibraryCode/modules/juce_core/threads/juce_InterProcessLock.h index a8c17945f..2384bbdce 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_InterProcessLock.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_InterProcessLock.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_Process.h b/JuceLibraryCode/modules/juce_core/threads/juce_Process.h index 2aeeee9ae..3eb787ab7 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_Process.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_Process.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ReadWriteLock.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_ReadWriteLock.cpp index 6aecf1868..7db6e921d 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ReadWriteLock.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ReadWriteLock.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ReadWriteLock.h b/JuceLibraryCode/modules/juce_core/threads/juce_ReadWriteLock.h index 1723933d0..d5c104167 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ReadWriteLock.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ReadWriteLock.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ScopedLock.h b/JuceLibraryCode/modules/juce_core/threads/juce_ScopedLock.h index 74c8f3f81..889e7f661 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ScopedLock.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ScopedLock.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ScopedReadLock.h b/JuceLibraryCode/modules/juce_core/threads/juce_ScopedReadLock.h index 84623c4bf..084775c10 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ScopedReadLock.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ScopedReadLock.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ScopedWriteLock.h b/JuceLibraryCode/modules/juce_core/threads/juce_ScopedWriteLock.h index eeadc1cd2..332314a44 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ScopedWriteLock.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ScopedWriteLock.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_SpinLock.h b/JuceLibraryCode/modules/juce_core/threads/juce_SpinLock.h index bf3c8f32f..910bded8e 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_SpinLock.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_SpinLock.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp index c0dce8541..0f0504a59 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_Thread.h b/JuceLibraryCode/modules/juce_core/threads/juce_Thread.h index 734062a9e..c2d240dbd 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_Thread.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_Thread.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ThreadLocalValue.h b/JuceLibraryCode/modules/juce_core/threads/juce_ThreadLocalValue.h index 5546284ad..22525c075 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ThreadLocalValue.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ThreadLocalValue.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -175,7 +178,7 @@ private: struct ObjectHolder { ObjectHolder (const Thread::ThreadID& tid) - : threadId (tid), object() + : threadId (tid), next (nullptr), object() {} Thread::ThreadID threadId; diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.cpp index e6a03131f..c5ee71bea 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.h b/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.h index ef7b28beb..4a0c20844 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_TimeSliceThread.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_TimeSliceThread.cpp index 5410635ea..f055a15e2 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_TimeSliceThread.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_TimeSliceThread.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -153,7 +156,7 @@ void TimeSliceThread::run() const ScopedLock sl2 (listLock); if (msUntilNextCall >= 0) - clientBeingCalled->nextCallTime += RelativeTime::milliseconds (msUntilNextCall); + clientBeingCalled->nextCallTime = now + RelativeTime::milliseconds (msUntilNextCall); else clients.removeFirstMatchingValue (clientBeingCalled); diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_TimeSliceThread.h b/JuceLibraryCode/modules/juce_core/threads/juce_TimeSliceThread.h index aa6193d3a..d59fbb7d1 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_TimeSliceThread.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_TimeSliceThread.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_WaitableEvent.h b/JuceLibraryCode/modules/juce_core/threads/juce_WaitableEvent.h index 108b9eb51..72ed1b562 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_WaitableEvent.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_WaitableEvent.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/time/juce_PerformanceCounter.cpp b/JuceLibraryCode/modules/juce_core/time/juce_PerformanceCounter.cpp index 80ac6589a..64da598ae 100644 --- a/JuceLibraryCode/modules/juce_core/time/juce_PerformanceCounter.cpp +++ b/JuceLibraryCode/modules/juce_core/time/juce_PerformanceCounter.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -30,6 +33,7 @@ PerformanceCounter::PerformanceCounter (const String& name_, numRuns (0), runsPerPrint (runsPerPrintout), totalTime (0), + started (0), outputFile (loggingFile) { if (outputFile != File::nonexistent) diff --git a/JuceLibraryCode/modules/juce_core/time/juce_PerformanceCounter.h b/JuceLibraryCode/modules/juce_core/time/juce_PerformanceCounter.h index 3e0222992..ff2822afe 100644 --- a/JuceLibraryCode/modules/juce_core/time/juce_PerformanceCounter.h +++ b/JuceLibraryCode/modules/juce_core/time/juce_PerformanceCounter.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.cpp b/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.cpp index 9b0384116..8d4804911 100644 --- a/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.cpp +++ b/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -28,12 +31,12 @@ RelativeTime::RelativeTime (const RelativeTime& other) noexcept : seconds (oth RelativeTime::~RelativeTime() noexcept {} //============================================================================== -const RelativeTime RelativeTime::milliseconds (const int milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); } -const RelativeTime RelativeTime::milliseconds (const int64 milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); } -const RelativeTime RelativeTime::minutes (const double numberOfMinutes) noexcept { return RelativeTime (numberOfMinutes * 60.0); } -const RelativeTime RelativeTime::hours (const double numberOfHours) noexcept { return RelativeTime (numberOfHours * (60.0 * 60.0)); } -const RelativeTime RelativeTime::days (const double numberOfDays) noexcept { return RelativeTime (numberOfDays * (60.0 * 60.0 * 24.0)); } -const RelativeTime RelativeTime::weeks (const double numberOfWeeks) noexcept { return RelativeTime (numberOfWeeks * (60.0 * 60.0 * 24.0 * 7.0)); } +RelativeTime RelativeTime::milliseconds (const int milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); } +RelativeTime RelativeTime::milliseconds (const int64 milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); } +RelativeTime RelativeTime::minutes (const double numberOfMinutes) noexcept { return RelativeTime (numberOfMinutes * 60.0); } +RelativeTime RelativeTime::hours (const double numberOfHours) noexcept { return RelativeTime (numberOfHours * (60.0 * 60.0)); } +RelativeTime RelativeTime::days (const double numberOfDays) noexcept { return RelativeTime (numberOfDays * (60.0 * 60.0 * 24.0)); } +RelativeTime RelativeTime::weeks (const double numberOfWeeks) noexcept { return RelativeTime (numberOfWeeks * (60.0 * 60.0 * 24.0 * 7.0)); } //============================================================================== int64 RelativeTime::inMilliseconds() const noexcept { return (int64) (seconds * 1000.0); } @@ -45,22 +48,29 @@ double RelativeTime::inWeeks() const noexcept { return seconds / (60.0 * 6 //============================================================================== RelativeTime& RelativeTime::operator= (const RelativeTime& other) noexcept { seconds = other.seconds; return *this; } -const RelativeTime& RelativeTime::operator+= (const RelativeTime& t) noexcept { seconds += t.seconds; return *this; } -const RelativeTime& RelativeTime::operator-= (const RelativeTime& t) noexcept { seconds -= t.seconds; return *this; } -const RelativeTime& RelativeTime::operator+= (const double secs) noexcept { seconds += secs; return *this; } -const RelativeTime& RelativeTime::operator-= (const double secs) noexcept { seconds -= secs; return *this; } +RelativeTime RelativeTime::operator+= (RelativeTime t) noexcept { seconds += t.seconds; return *this; } +RelativeTime RelativeTime::operator-= (RelativeTime t) noexcept { seconds -= t.seconds; return *this; } +RelativeTime RelativeTime::operator+= (const double secs) noexcept { seconds += secs; return *this; } +RelativeTime RelativeTime::operator-= (const double secs) noexcept { seconds -= secs; return *this; } -RelativeTime operator+ (const RelativeTime& t1, const RelativeTime& t2) noexcept { RelativeTime t (t1); return t += t2; } -RelativeTime operator- (const RelativeTime& t1, const RelativeTime& t2) noexcept { RelativeTime t (t1); return t -= t2; } +RelativeTime operator+ (RelativeTime t1, RelativeTime t2) noexcept { return t1 += t2; } +RelativeTime operator- (RelativeTime t1, RelativeTime t2) noexcept { return t1 -= t2; } -bool operator== (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() == t2.inSeconds(); } -bool operator!= (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() != t2.inSeconds(); } -bool operator> (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() > t2.inSeconds(); } -bool operator< (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() < t2.inSeconds(); } -bool operator>= (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() >= t2.inSeconds(); } -bool operator<= (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() <= t2.inSeconds(); } +bool operator== (RelativeTime t1, RelativeTime t2) noexcept { return t1.inSeconds() == t2.inSeconds(); } +bool operator!= (RelativeTime t1, RelativeTime t2) noexcept { return t1.inSeconds() != t2.inSeconds(); } +bool operator> (RelativeTime t1, RelativeTime t2) noexcept { return t1.inSeconds() > t2.inSeconds(); } +bool operator< (RelativeTime t1, RelativeTime t2) noexcept { return t1.inSeconds() < t2.inSeconds(); } +bool operator>= (RelativeTime t1, RelativeTime t2) noexcept { return t1.inSeconds() >= t2.inSeconds(); } +bool operator<= (RelativeTime t1, RelativeTime t2) noexcept { return t1.inSeconds() <= t2.inSeconds(); } //============================================================================== +static void translateTimeField (String& result, int n, const char* singular, const char* plural) +{ + result << TRANS (n == 1 ? singular : plural) + .replace (n == 1 ? "1" : "2", String (n)) + << ' '; +} + String RelativeTime::getDescription (const String& returnValueForZeroTime) const { if (seconds < 0.001 && seconds > -0.001) @@ -76,16 +86,14 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const int n = std::abs ((int) inWeeks()); if (n > 0) { - result << n << TRANS (n == 1 ? " week " - : " weeks "); + translateTimeField (result, n, NEEDS_TRANS("1 week"), NEEDS_TRANS("2 weeks")); ++fieldsShown; } n = std::abs ((int) inDays()) % 7; if (n > 0) { - result << n << TRANS (n == 1 ? " day " - : " days "); + translateTimeField (result, n, NEEDS_TRANS("1 day"), NEEDS_TRANS("2 days")); ++fieldsShown; } @@ -94,8 +102,7 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const n = std::abs ((int) inHours()) % 24; if (n > 0) { - result << n << TRANS (n == 1 ? " hr " - : " hrs "); + translateTimeField (result, n, NEEDS_TRANS("1 hr"), NEEDS_TRANS("2 hrs")); ++fieldsShown; } @@ -104,8 +111,7 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const n = std::abs ((int) inMinutes()) % 60; if (n > 0) { - result << n << TRANS (n == 1 ? " min " - : " mins "); + translateTimeField (result, n, NEEDS_TRANS("1 min"), NEEDS_TRANS("2 mins")); ++fieldsShown; } @@ -114,8 +120,7 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const n = std::abs ((int) inSeconds()) % 60; if (n > 0) { - result << n << TRANS (n == 1 ? " sec " - : " secs "); + translateTimeField (result, n, NEEDS_TRANS("1 sec"), NEEDS_TRANS("2 secs")); ++fieldsShown; } @@ -123,7 +128,7 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const { n = std::abs ((int) inMilliseconds()) % 1000; if (n > 0) - result << n << TRANS (" ms"); + result << n << ' ' << TRANS ("ms"); } } } diff --git a/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.h b/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.h index 21d86bf9c..7e3c8090f 100644 --- a/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.h +++ b/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -61,32 +64,32 @@ public: /** Creates a new RelativeTime object representing a number of milliseconds. @see minutes, hours, days, weeks */ - static const RelativeTime milliseconds (int milliseconds) noexcept; + static RelativeTime milliseconds (int milliseconds) noexcept; /** Creates a new RelativeTime object representing a number of milliseconds. @see minutes, hours, days, weeks */ - static const RelativeTime milliseconds (int64 milliseconds) noexcept; + static RelativeTime milliseconds (int64 milliseconds) noexcept; /** Creates a new RelativeTime object representing a number of minutes. @see milliseconds, hours, days, weeks */ - static const RelativeTime minutes (double numberOfMinutes) noexcept; + static RelativeTime minutes (double numberOfMinutes) noexcept; /** Creates a new RelativeTime object representing a number of hours. @see milliseconds, minutes, days, weeks */ - static const RelativeTime hours (double numberOfHours) noexcept; + static RelativeTime hours (double numberOfHours) noexcept; /** Creates a new RelativeTime object representing a number of days. @see milliseconds, minutes, hours, weeks */ - static const RelativeTime days (double numberOfDays) noexcept; + static RelativeTime days (double numberOfDays) noexcept; /** Creates a new RelativeTime object representing a number of weeks. @see milliseconds, minutes, hours, days */ - static const RelativeTime weeks (double numberOfWeeks) noexcept; + static RelativeTime weeks (double numberOfWeeks) noexcept; //============================================================================== /** Returns the number of milliseconds this time represents. @@ -139,14 +142,14 @@ public: //============================================================================== /** Adds another RelativeTime to this one. */ - const RelativeTime& operator+= (const RelativeTime& timeToAdd) noexcept; + RelativeTime operator+= (RelativeTime timeToAdd) noexcept; /** Subtracts another RelativeTime from this one. */ - const RelativeTime& operator-= (const RelativeTime& timeToSubtract) noexcept; + RelativeTime operator-= (RelativeTime timeToSubtract) noexcept; /** Adds a number of seconds to this time. */ - const RelativeTime& operator+= (double secondsToAdd) noexcept; + RelativeTime operator+= (double secondsToAdd) noexcept; /** Subtracts a number of seconds from this time. */ - const RelativeTime& operator-= (double secondsToSubtract) noexcept; + RelativeTime operator-= (double secondsToSubtract) noexcept; private: //============================================================================== @@ -155,23 +158,23 @@ private: //============================================================================== /** Compares two RelativeTimes. */ -bool operator== (const RelativeTime& t1, const RelativeTime& t2) noexcept; +bool operator== (RelativeTime t1, RelativeTime t2) noexcept; /** Compares two RelativeTimes. */ -bool operator!= (const RelativeTime& t1, const RelativeTime& t2) noexcept; +bool operator!= (RelativeTime t1, RelativeTime t2) noexcept; /** Compares two RelativeTimes. */ -bool operator> (const RelativeTime& t1, const RelativeTime& t2) noexcept; +bool operator> (RelativeTime t1, RelativeTime t2) noexcept; /** Compares two RelativeTimes. */ -bool operator< (const RelativeTime& t1, const RelativeTime& t2) noexcept; +bool operator< (RelativeTime t1, RelativeTime t2) noexcept; /** Compares two RelativeTimes. */ -bool operator>= (const RelativeTime& t1, const RelativeTime& t2) noexcept; +bool operator>= (RelativeTime t1, RelativeTime t2) noexcept; /** Compares two RelativeTimes. */ -bool operator<= (const RelativeTime& t1, const RelativeTime& t2) noexcept; +bool operator<= (RelativeTime t1, RelativeTime t2) noexcept; //============================================================================== /** Adds two RelativeTimes together. */ -RelativeTime operator+ (const RelativeTime& t1, const RelativeTime& t2) noexcept; +RelativeTime operator+ (RelativeTime t1, RelativeTime t2) noexcept; /** Subtracts two RelativeTimes. */ -RelativeTime operator- (const RelativeTime& t1, const RelativeTime& t2) noexcept; +RelativeTime operator- (RelativeTime t1, RelativeTime t2) noexcept; diff --git a/JuceLibraryCode/modules/juce_core/time/juce_Time.cpp b/JuceLibraryCode/modules/juce_core/time/juce_Time.cpp index 420e1d13b..634417000 100644 --- a/JuceLibraryCode/modules/juce_core/time/juce_Time.cpp +++ b/JuceLibraryCode/modules/juce_core/time/juce_Time.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -427,17 +430,17 @@ String Time::getWeekdayName (int day, const bool threeLetterVersion) } //============================================================================== -Time& Time::operator+= (const RelativeTime& delta) { millisSinceEpoch += delta.inMilliseconds(); return *this; } -Time& Time::operator-= (const RelativeTime& delta) { millisSinceEpoch -= delta.inMilliseconds(); return *this; } - -Time operator+ (const Time& time, const RelativeTime& delta) { Time t (time); return t += delta; } -Time operator- (const Time& time, const RelativeTime& delta) { Time t (time); return t -= delta; } -Time operator+ (const RelativeTime& delta, const Time& time) { Time t (time); return t += delta; } -const RelativeTime operator- (const Time& time1, const Time& time2) { return RelativeTime::milliseconds (time1.toMilliseconds() - time2.toMilliseconds()); } - -bool operator== (const Time& time1, const Time& time2) { return time1.toMilliseconds() == time2.toMilliseconds(); } -bool operator!= (const Time& time1, const Time& time2) { return time1.toMilliseconds() != time2.toMilliseconds(); } -bool operator< (const Time& time1, const Time& time2) { return time1.toMilliseconds() < time2.toMilliseconds(); } -bool operator> (const Time& time1, const Time& time2) { return time1.toMilliseconds() > time2.toMilliseconds(); } -bool operator<= (const Time& time1, const Time& time2) { return time1.toMilliseconds() <= time2.toMilliseconds(); } -bool operator>= (const Time& time1, const Time& time2) { return time1.toMilliseconds() >= time2.toMilliseconds(); } +Time& Time::operator+= (RelativeTime delta) { millisSinceEpoch += delta.inMilliseconds(); return *this; } +Time& Time::operator-= (RelativeTime delta) { millisSinceEpoch -= delta.inMilliseconds(); return *this; } + +Time operator+ (Time time, RelativeTime delta) { Time t (time); return t += delta; } +Time operator- (Time time, RelativeTime delta) { Time t (time); return t -= delta; } +Time operator+ (RelativeTime delta, Time time) { Time t (time); return t += delta; } +const RelativeTime operator- (Time time1, Time time2) { return RelativeTime::milliseconds (time1.toMilliseconds() - time2.toMilliseconds()); } + +bool operator== (Time time1, Time time2) { return time1.toMilliseconds() == time2.toMilliseconds(); } +bool operator!= (Time time1, Time time2) { return time1.toMilliseconds() != time2.toMilliseconds(); } +bool operator< (Time time1, Time time2) { return time1.toMilliseconds() < time2.toMilliseconds(); } +bool operator> (Time time1, Time time2) { return time1.toMilliseconds() > time2.toMilliseconds(); } +bool operator<= (Time time1, Time time2) { return time1.toMilliseconds() <= time2.toMilliseconds(); } +bool operator>= (Time time1, Time time2) { return time1.toMilliseconds() >= time2.toMilliseconds(); } diff --git a/JuceLibraryCode/modules/juce_core/time/juce_Time.h b/JuceLibraryCode/modules/juce_core/time/juce_Time.h index a56c421b0..2971aafe6 100644 --- a/JuceLibraryCode/modules/juce_core/time/juce_Time.h +++ b/JuceLibraryCode/modules/juce_core/time/juce_Time.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -252,9 +255,9 @@ public: //============================================================================== /** Adds a RelativeTime to this time. */ - Time& operator+= (const RelativeTime& delta); + Time& operator+= (RelativeTime delta); /** Subtracts a RelativeTime from this time. */ - Time& operator-= (const RelativeTime& delta); + Time& operator-= (RelativeTime delta); //============================================================================== /** Tries to set the computer's clock. @@ -377,27 +380,27 @@ private: //============================================================================== /** Adds a RelativeTime to a Time. */ -JUCE_API Time operator+ (const Time& time, const RelativeTime& delta); +JUCE_API Time operator+ (Time time, RelativeTime delta); /** Adds a RelativeTime to a Time. */ -JUCE_API Time operator+ (const RelativeTime& delta, const Time& time); +JUCE_API Time operator+ (RelativeTime delta, Time time); /** Subtracts a RelativeTime from a Time. */ -JUCE_API Time operator- (const Time& time, const RelativeTime& delta); +JUCE_API Time operator- (Time time, RelativeTime delta); /** Returns the relative time difference between two times. */ -JUCE_API const RelativeTime operator- (const Time& time1, const Time& time2); +JUCE_API const RelativeTime operator- (Time time1, Time time2); /** Compares two Time objects. */ -JUCE_API bool operator== (const Time& time1, const Time& time2); +JUCE_API bool operator== (Time time1, Time time2); /** Compares two Time objects. */ -JUCE_API bool operator!= (const Time& time1, const Time& time2); +JUCE_API bool operator!= (Time time1, Time time2); /** Compares two Time objects. */ -JUCE_API bool operator< (const Time& time1, const Time& time2); +JUCE_API bool operator< (Time time1, Time time2); /** Compares two Time objects. */ -JUCE_API bool operator<= (const Time& time1, const Time& time2); +JUCE_API bool operator<= (Time time1, Time time2); /** Compares two Time objects. */ -JUCE_API bool operator> (const Time& time1, const Time& time2); +JUCE_API bool operator> (Time time1, Time time2); /** Compares two Time objects. */ -JUCE_API bool operator>= (const Time& time1, const Time& time2); +JUCE_API bool operator>= (Time time1, Time time2); #endif // __JUCE_TIME_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTest.cpp b/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTest.cpp index c637e9498..9fd6a8e38 100644 --- a/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTest.cpp +++ b/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTest.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -230,5 +233,5 @@ void UnitTestRunner::addFail (const String& failureMessage) resultsUpdated(); - if (assertOnFailure) { jassertfalse } + if (assertOnFailure) { jassertfalse; } } diff --git a/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTest.h b/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTest.h index 170b9cf6f..0de339ff8 100644 --- a/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTest.h +++ b/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTest.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/xml/juce_XmlDocument.cpp b/JuceLibraryCode/modules/juce_core/xml/juce_XmlDocument.cpp index 9139e1c70..0c0a422da 100644 --- a/JuceLibraryCode/modules/juce_core/xml/juce_XmlDocument.cpp +++ b/JuceLibraryCode/modules/juce_core/xml/juce_XmlDocument.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -26,12 +29,18 @@ XmlDocument::XmlDocument (const String& documentText) : originalText (documentText), input (nullptr), + outOfData (false), + errorOccurred (false), + needToLoadDTD (false), ignoreEmptyTextElements (true) { } XmlDocument::XmlDocument (const File& file) : input (nullptr), + outOfData (false), + errorOccurred (false), + needToLoadDTD (false), ignoreEmptyTextElements (true), inputSource (new FileInputSource (file)) { diff --git a/JuceLibraryCode/modules/juce_core/xml/juce_XmlDocument.h b/JuceLibraryCode/modules/juce_core/xml/juce_XmlDocument.h index 44a6245e0..db9c31d0b 100644 --- a/JuceLibraryCode/modules/juce_core/xml/juce_XmlDocument.h +++ b/JuceLibraryCode/modules/juce_core/xml/juce_XmlDocument.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.cpp b/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.cpp index 27585047a..7b34f59f3 100644 --- a/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.cpp +++ b/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -29,9 +32,8 @@ XmlElement::XmlAttributeNode::XmlAttributeNode (const XmlAttributeNode& other) n { } -XmlElement::XmlAttributeNode::XmlAttributeNode (const String& name_, const String& value_) noexcept - : name (name_), - value (value_) +XmlElement::XmlAttributeNode::XmlAttributeNode (const String& n, const String& v) noexcept + : name (n), value (v) { #if JUCE_DEBUG // this checks whether the attribute name string contains any illegal characters.. @@ -46,14 +48,14 @@ inline bool XmlElement::XmlAttributeNode::hasName (const String& nameToMatch) co } //============================================================================== -XmlElement::XmlElement (const String& tagName_) noexcept - : tagName (tagName_) +XmlElement::XmlElement (const String& tag) noexcept + : tagName (tag) { // the tag name mustn't be empty, or it'll look like a text element! - jassert (tagName_.containsNonWhitespaceChars()) + jassert (tag.containsNonWhitespaceChars()) // The tag can't contain spaces or other characters that would create invalid XML! - jassert (! tagName_.containsAnyOf (" <>/&")); + jassert (! tag.containsAnyOf (" <>/&")); } XmlElement::XmlElement (int /*dummy*/) noexcept @@ -362,24 +364,30 @@ bool XmlElement::writeToFile (const File& file, } //============================================================================== -bool XmlElement::hasTagName (const String& tagNameWanted) const noexcept +bool XmlElement::hasTagName (const String& possibleTagName) const noexcept { - #if JUCE_DEBUG - // if debugging, check that the case is actually the same, because - // valid xml is case-sensitive, and although this lets it pass, it's - // better not to.. - if (tagName.equalsIgnoreCase (tagNameWanted)) - { - jassert (tagName == tagNameWanted); - return true; - } - else - { - return false; - } - #else - return tagName.equalsIgnoreCase (tagNameWanted); - #endif + const bool matches = tagName.equalsIgnoreCase (possibleTagName); + + // XML tags should be case-sensitive, so although this method allows a + // case-insensitive match to pass, you should try to avoid this. + jassert ((! matches) || tagName == possibleTagName); + + return matches; +} + +String XmlElement::getNamespace() const +{ + return tagName.upToFirstOccurrenceOf (":", false, false); +} + +String XmlElement::getTagNameWithoutNamespace() const +{ + return tagName.fromLastOccurrenceOf (":", false, false); +} + +bool XmlElement::hasTagNameIgnoringNamespace (const String& possibleTagName) const +{ + return hasTagName (possibleTagName) || getTagNameWithoutNamespace() == possibleTagName; } XmlElement* XmlElement::getNextElementWithTagName (const String& requiredTagName) const @@ -506,7 +514,8 @@ void XmlElement::setAttribute (const String& attributeName, const String& value) att->value = value; break; } - else if (att->nextListItem == nullptr) + + if (att->nextListItem == nullptr) { att->nextListItem = new XmlAttributeNode (attributeName, value); break; diff --git a/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.h b/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.h index cb496b9b1..a7f3e7cdb 100644 --- a/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.h +++ b/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -249,22 +252,29 @@ public: //============================================================================== /** Returns this element's tag type name. - - E.g. for an element such as \<MOOSE legs="4" antlers="2">, this would return - "MOOSE". - + E.g. for an element such as \<MOOSE legs="4" antlers="2">, this would return "MOOSE". @see hasTagName */ inline const String& getTagName() const noexcept { return tagName; } - /** Tests whether this element has a particular tag name. + /** Returns the namespace portion of the tag-name, or an empty string if none is specified. */ + String getNamespace() const; - @param possibleTagName the tag name you're comparing it with + /** Returns the part of the tag-name that follows any namespace declaration. */ + String getTagNameWithoutNamespace() const; + /** Tests whether this element has a particular tag name. + @param possibleTagName the tag name you're comparing it with @see getTagName */ bool hasTagName (const String& possibleTagName) const noexcept; + /** Tests whether this element has a particular tag name, ignoring any XML namespace prefix. + So a test for e.g. "xyz" will return true for "xyz" and also "foo:xyz", "bar::xyz", etc. + @see getTagName + */ + bool hasTagNameIgnoringNamespace (const String& possibleTagName) const; + //============================================================================== /** Returns the number of XML attributes this element contains. diff --git a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index 77f0fff4f..feea3f7f0 100644 --- a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h index d1f5d576d..c270498aa 100644 --- a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h +++ b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp index d0621900b..d67c6a557 100644 --- a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -62,6 +65,7 @@ namespace zlibNamespace #include "zlib/zutil.c" #undef Byte #undef fdopen + #undef local #if JUCE_CLANG #pragma clang diagnostic pop diff --git a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h index bef435d23..a6f1826ee 100644 --- a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h +++ b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.cpp b/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.cpp index 532000f6c..d3e83894c 100644 --- a/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.cpp +++ b/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.cpp @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ @@ -447,7 +450,8 @@ public: storedPathname (storedPath.isEmpty() ? f.getFileName() : storedPath), compressionLevel (compression), compressedSize (0), - headerStart (0) + headerStart (0), + checksum (0) { } diff --git a/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.h b/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.h index ada273e28..a8ba3f525 100644 --- a/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.h +++ b/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.h @@ -1,24 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the juce_core module of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission to use, copy, modify, and/or distribute this software for any purpose with + or without fee is hereby granted, provided that the above copyright notice and this + permission notice appear in all copies. - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ------------------------------------------------------------------------------ - ------------------------------------------------------------------------------ + NOTE! This permissive ISC license applies ONLY to files within the juce_core module! + All other JUCE modules are covered by a dual GPL/commercial license, so if you are + using any other modules, be sure to check that you also comply with their license. - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + For more details, visit www.juce.com ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.cpp b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.cpp index 2563b8db6..3ff839b39 100644 --- a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.h b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.h index 20f957929..1ad9eb471 100644 --- a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.h +++ b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_Primes.cpp b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_Primes.cpp index ee17a75e9..058635bbc 100644 --- a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_Primes.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_Primes.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_Primes.h b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_Primes.h index 02877cb72..782dc7bb1 100644 --- a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_Primes.h +++ b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_Primes.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_RSAKey.cpp b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_RSAKey.cpp index 30beceffd..fdc588e97 100644 --- a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_RSAKey.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_RSAKey.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_RSAKey.h b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_RSAKey.h index 78ef628ab..f622f631d 100644 --- a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_RSAKey.h +++ b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_RSAKey.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.cpp b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.cpp index c291036da..90d64a44e 100644 --- a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -216,7 +215,7 @@ MD5::MD5 (const void* data, const size_t numBytes) noexcept processData (data, numBytes); } -MD5::MD5 (const CharPointer_UTF8& utf8) noexcept +MD5::MD5 (CharPointer_UTF8 utf8) noexcept { jassert (utf8.getAddress() != nullptr); processData (utf8.getAddress(), utf8.sizeInBytes() - 1); diff --git a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.h b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.h index 542852963..35e727866 100644 --- a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.h +++ b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -72,7 +71,7 @@ public: @code MD5 checksum (myString.toUTF8()); @endcode */ - explicit MD5 (const CharPointer_UTF8& utf8Text) noexcept; + explicit MD5 (CharPointer_UTF8 utf8Text) noexcept; /** Destructor. */ ~MD5() noexcept; diff --git a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.cpp b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.cpp index d75f7db6f..0c1f8db34 100644 --- a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -206,7 +205,7 @@ SHA256::SHA256 (const File& file) } } -SHA256::SHA256 (const CharPointer_UTF8& utf8) noexcept +SHA256::SHA256 (CharPointer_UTF8 utf8) noexcept { jassert (utf8.getAddress() != nullptr); process (utf8.getAddress(), utf8.sizeInBytes() - 1); diff --git a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.h b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.h index c868d9d6a..71eb1eb7a 100644 --- a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.h +++ b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -82,7 +81,7 @@ public: @code SHA256 checksum (myString.toUTF8()); @endcode */ - explicit SHA256 (const CharPointer_UTF8& utf8Text) noexcept; + explicit SHA256 (CharPointer_UTF8 utf8Text) noexcept; //============================================================================== /** Returns the hash as a 32-byte block of data. */ diff --git a/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.cpp b/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.cpp index da8e2ca3e..2f7acf62f 100644 --- a/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.h b/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.h index da841c2bd..344ad723e 100644 --- a/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.h +++ b/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.mm b/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.mm index 8b73d83ae..7c3e4bfd3 100644 --- a/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.mm +++ b/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_cryptography/juce_module_info b/JuceLibraryCode/modules/juce_cryptography/juce_module_info index ff14ac73c..3c0bc4924 100644 --- a/JuceLibraryCode/modules/juce_cryptography/juce_module_info +++ b/JuceLibraryCode/modules/juce_cryptography/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_cryptography", "name": "JUCE cryptography classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for various basic cryptography functions, including RSA, Blowfish, MD5, SHA, etc.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp b/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp index 707980242..6db825e89 100644 --- a/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h b/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h index 4847374f0..7717bdf8b 100644 --- a/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h +++ b/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp b/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp index 6d91f7dfd..018bb585c 100644 --- a/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -82,9 +81,9 @@ File PropertiesFile::Options::getDefaultFile() const dir = dir.getChildFile (folderName); #elif JUCE_LINUX || JUCE_ANDROID - const File dir ((commonToAllUsers ? "/var/" : "~/") - + (folderName.isNotEmpty() ? folderName - : ("." + applicationName))); + const File dir (File (commonToAllUsers ? "/var" : "~") + .getChildFile (folderName.isNotEmpty() ? folderName + : ("." + applicationName))); #elif JUCE_WINDOWS File dir (File::getSpecialLocation (commonToAllUsers ? File::commonApplicationDataDirectory diff --git a/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_PropertiesFile.h b/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_PropertiesFile.h index cbb526047..648b0aa0b 100644 --- a/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_PropertiesFile.h +++ b/JuceLibraryCode/modules/juce_data_structures/app_properties/juce_PropertiesFile.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.cpp b/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.cpp index f59335ee1..acff7644e 100644 --- a/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h b/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h index 7ee82334e..739b905d9 100644 --- a/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h +++ b/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.mm b/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.mm index 0e3fd0e90..2eb4fb434 100644 --- a/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.mm +++ b/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/juce_module_info b/JuceLibraryCode/modules/juce_data_structures/juce_module_info index 5ab67dc13..ecc5b22f2 100644 --- a/JuceLibraryCode/modules/juce_data_structures/juce_module_info +++ b/JuceLibraryCode/modules/juce_data_structures/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_data_structures", "name": "JUCE data model helper classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for undo/redo management, and smart data structures.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.cpp b/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.cpp index c1f3dd17c..328a05233 100644 --- a/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.h b/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.h index 04e397e3e..efc54da15 100644 --- a/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.h +++ b/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoableAction.h b/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoableAction.h index a3c731ae6..6ff0d54b8 100644 --- a/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoableAction.h +++ b/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoableAction.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.cpp b/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.cpp index a0db0c4f3..f76018797 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.h b/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.h index 96f0788fe..b7b806df5 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.h +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.cpp b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.cpp index 433505d88..716986d87 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -28,7 +27,7 @@ class ValueTree::SharedObject : public ReferenceCountedObject public: typedef ReferenceCountedObjectPtr<SharedObject> Ptr; - explicit SharedObject (const Identifier& t) noexcept + explicit SharedObject (const Identifier t) noexcept : type (t), parent (nullptr) { } @@ -58,14 +57,14 @@ public: } } - void sendPropertyChangeMessage (ValueTree& tree, const Identifier& property) + void sendPropertyChangeMessage (ValueTree& tree, const Identifier property) { for (int i = valueTreesWithListeners.size(); --i >= 0;) if (ValueTree* const v = valueTreesWithListeners[i]) v->listeners.call (&ValueTree::Listener::valueTreePropertyChanged, tree, property); } - void sendPropertyChangeMessage (const Identifier& property) + void sendPropertyChangeMessage (const Identifier property) { ValueTree tree (this); @@ -131,17 +130,17 @@ public: v->listeners.call (&ValueTree::Listener::valueTreeParentChanged, tree); } - const var& getProperty (const Identifier& name) const noexcept + const var& getProperty (const Identifier name) const noexcept { return properties [name]; } - var getProperty (const Identifier& name, const var& defaultReturnValue) const + var getProperty (const Identifier name, const var& defaultReturnValue) const { return properties.getWithDefault (name, defaultReturnValue); } - void setProperty (const Identifier& name, const var& newValue, UndoManager* const undoManager) + void setProperty (const Identifier name, const var& newValue, UndoManager* const undoManager) { if (undoManager == nullptr) { @@ -162,12 +161,12 @@ public: } } - bool hasProperty (const Identifier& name) const noexcept + bool hasProperty (const Identifier name) const noexcept { return properties.contains (name); } - void removeProperty (const Identifier& name, UndoManager* const undoManager) + void removeProperty (const Identifier name, UndoManager* const undoManager) { if (undoManager == nullptr) { @@ -210,7 +209,7 @@ public: setProperty (source.properties.getName(i), source.properties.getValueAt(i), undoManager); } - ValueTree getChildWithName (const Identifier& typeToMatch) const + ValueTree getChildWithName (const Identifier typeToMatch) const { for (int i = 0; i < children.size(); ++i) { @@ -222,7 +221,7 @@ public: return ValueTree::invalid; } - ValueTree getOrCreateChildWithName (const Identifier& typeToMatch, UndoManager* undoManager) + ValueTree getOrCreateChildWithName (const Identifier typeToMatch, UndoManager* undoManager) { for (int i = 0; i < children.size(); ++i) { @@ -237,7 +236,7 @@ public: } - ValueTree getChildWithProperty (const Identifier& propertyName, const var& propertyValue) const + ValueTree getChildWithProperty (const Identifier propertyName, const var& propertyValue) const { for (int i = 0; i < children.size(); ++i) { @@ -444,7 +443,7 @@ public: class SetPropertyAction : public UndoableAction { public: - SetPropertyAction (SharedObject* const target_, const Identifier& name_, + SetPropertyAction (SharedObject* const target_, const Identifier name_, const var& newValue_, const var& oldValue_, const bool isAddingNewProperty_, const bool isDeletingProperty_) : target (target_), name (name_), newValue (newValue_), oldValue (oldValue_), @@ -616,7 +615,7 @@ ValueTree::ValueTree() noexcept const ValueTree ValueTree::invalid; -ValueTree::ValueTree (const Identifier& type_) +ValueTree::ValueTree (const Identifier type_) : object (new ValueTree::SharedObject (type_)) { jassert (type_.toString().isNotEmpty()); // All objects should be given a sensible type name! @@ -684,7 +683,7 @@ ValueTree ValueTree::createCopy() const return ValueTree (createCopyIfNotNull (object.get())); } -bool ValueTree::hasType (const Identifier& typeName) const +bool ValueTree::hasType (const Identifier typeName) const { return object != nullptr && object->type == typeName; } @@ -709,23 +708,23 @@ ValueTree ValueTree::getSibling (const int delta) const return ValueTree (object->parent->children.getObjectPointer (index)); } -const var& ValueTree::operator[] (const Identifier& name) const +const var& ValueTree::operator[] (const Identifier name) const { return object == nullptr ? var::null : object->getProperty (name); } -const var& ValueTree::getProperty (const Identifier& name) const +const var& ValueTree::getProperty (const Identifier name) const { return object == nullptr ? var::null : object->getProperty (name); } -var ValueTree::getProperty (const Identifier& name, const var& defaultReturnValue) const +var ValueTree::getProperty (const Identifier name, const var& defaultReturnValue) const { return object == nullptr ? defaultReturnValue : object->getProperty (name, defaultReturnValue); } -ValueTree& ValueTree::setProperty (const Identifier& name, const var& newValue, +ValueTree& ValueTree::setProperty (const Identifier name, const var& newValue, UndoManager* const undoManager) { jassert (name.toString().isNotEmpty()); // Must have a valid property name! @@ -737,12 +736,12 @@ ValueTree& ValueTree::setProperty (const Identifier& name, const var& newValue, return *this; } -bool ValueTree::hasProperty (const Identifier& name) const +bool ValueTree::hasProperty (const Identifier name) const { return object != nullptr && object->hasProperty (name); } -void ValueTree::removeProperty (const Identifier& name, UndoManager* const undoManager) +void ValueTree::removeProperty (const Identifier name, UndoManager* const undoManager) { if (object != nullptr) object->removeProperty (name, undoManager); @@ -780,7 +779,7 @@ class ValueTreePropertyValueSource : public Value::ValueSource, private ValueTree::Listener { public: - ValueTreePropertyValueSource (const ValueTree& vt, const Identifier& prop, UndoManager* um) + ValueTreePropertyValueSource (const ValueTree& vt, const Identifier prop, UndoManager* um) : tree (vt), property (prop), undoManager (um) { tree.addListener (this); @@ -800,21 +799,21 @@ private: UndoManager* const undoManager; void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged, - const Identifier& changedProperty) + const Identifier& changedProperty) override { if (tree == treeWhosePropertyHasChanged && property == changedProperty) sendChangeMessage (false); } - void valueTreeChildAdded (ValueTree&, ValueTree&) {} - void valueTreeChildRemoved (ValueTree&, ValueTree&) {} - void valueTreeChildOrderChanged (ValueTree&) {} - void valueTreeParentChanged (ValueTree&) {} + void valueTreeChildAdded (ValueTree&, ValueTree&) override {} + void valueTreeChildRemoved (ValueTree&, ValueTree&) override {} + void valueTreeChildOrderChanged (ValueTree&) override {} + void valueTreeParentChanged (ValueTree&) override {} JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ValueTreePropertyValueSource) }; -Value ValueTree::getPropertyAsValue (const Identifier& name, UndoManager* const undoManager) +Value ValueTree::getPropertyAsValue (const Identifier name, UndoManager* const undoManager) { return Value (new ValueTreePropertyValueSource (*this, name, undoManager)); } @@ -831,17 +830,17 @@ ValueTree ValueTree::getChild (int index) const : static_cast <SharedObject*> (nullptr)); } -ValueTree ValueTree::getChildWithName (const Identifier& type) const +ValueTree ValueTree::getChildWithName (const Identifier type) const { return object != nullptr ? object->getChildWithName (type) : ValueTree::invalid; } -ValueTree ValueTree::getOrCreateChildWithName (const Identifier& type, UndoManager* undoManager) +ValueTree ValueTree::getOrCreateChildWithName (const Identifier type, UndoManager* undoManager) { return object != nullptr ? object->getOrCreateChildWithName (type, undoManager) : ValueTree::invalid; } -ValueTree ValueTree::getChildWithProperty (const Identifier& propertyName, const var& propertyValue) const +ValueTree ValueTree::getChildWithProperty (const Identifier propertyName, const var& propertyValue) const { return object != nullptr ? object->getChildWithProperty (propertyName, propertyValue) : ValueTree::invalid; } @@ -923,7 +922,7 @@ void ValueTree::removeListener (Listener* listener) object->valueTreesWithListeners.removeValue (this); } -void ValueTree::sendPropertyChangeMessage (const Identifier& property) +void ValueTree::sendPropertyChangeMessage (const Identifier property) { if (object != nullptr) object->sendPropertyChangeMessage (property); diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.h b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.h index 5a8803060..cfa87bf22 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.h +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -83,7 +82,7 @@ public: Like an XmlElement, each ValueTree node has a type, which you can access with getType() and hasType(). */ - explicit ValueTree (const Identifier& type); + explicit ValueTree (const Identifier type); /** Creates a reference to another ValueTree. */ ValueTree (const ValueTree& other); @@ -138,7 +137,7 @@ public: /** Returns true if the node has this type. The comparison is case-sensitive. */ - bool hasType (const Identifier& typeName) const; + bool hasType (const Identifier typeName) const; //============================================================================== /** Returns the value of a named property. @@ -146,21 +145,21 @@ public: You can also use operator[] to get a property. @see var, setProperty, hasProperty */ - const var& getProperty (const Identifier& name) const; + const var& getProperty (const Identifier name) const; /** Returns the value of a named property, or a user-specified default if the property doesn't exist. If no such property has been set, this will return the value of defaultReturnValue. You can also use operator[] and getProperty to get a property. @see var, getProperty, setProperty, hasProperty */ - var getProperty (const Identifier& name, const var& defaultReturnValue) const; + var getProperty (const Identifier name, const var& defaultReturnValue) const; /** Returns the value of a named property. If no such property has been set, this will return a void variant. This is the same as calling getProperty(). @see getProperty */ - const var& operator[] (const Identifier& name) const; + const var& operator[] (const Identifier name) const; /** Changes a named property of the node. The name identifier must not be an empty string. @@ -169,16 +168,16 @@ public: @see var, getProperty, removeProperty @returns a reference to the value tree, so that you can daisy-chain calls to this method. */ - ValueTree& setProperty (const Identifier& name, const var& newValue, UndoManager* undoManager); + ValueTree& setProperty (const Identifier name, const var& newValue, UndoManager* undoManager); /** Returns true if the node contains a named property. */ - bool hasProperty (const Identifier& name) const; + bool hasProperty (const Identifier name) const; /** Removes a property from the node. If the undoManager parameter is non-null, its UndoManager::perform() method will be used, so that this change can be undone. */ - void removeProperty (const Identifier& name, UndoManager* undoManager); + void removeProperty (const Identifier name, UndoManager* undoManager); /** Removes all properties from the node. If the undoManager parameter is non-null, its UndoManager::perform() method will be used, @@ -202,7 +201,7 @@ public: it needs to change the value. Attaching a Value::Listener to the value object will provide callbacks whenever the property changes. */ - Value getPropertyAsValue (const Identifier& name, UndoManager* undoManager); + Value getPropertyAsValue (const Identifier name, UndoManager* undoManager); /** Overwrites all the properties in this tree with the properties of the source tree. Any properties that already exist will be updated; and new ones will be added, and @@ -227,7 +226,7 @@ public: whether a node is valid). @see getOrCreateChildWithName */ - ValueTree getChildWithName (const Identifier& type) const; + ValueTree getChildWithName (const Identifier type) const; /** Returns the first child node with the speficied type name, creating and adding a child with this name if there wasn't already one there. @@ -236,7 +235,7 @@ public: the method on is itself invalid. @see getChildWithName */ - ValueTree getOrCreateChildWithName (const Identifier& type, UndoManager* undoManager); + ValueTree getOrCreateChildWithName (const Identifier type, UndoManager* undoManager); /** Looks for the first child node that has the speficied property value. @@ -246,7 +245,7 @@ public: If no such node is found, it'll return an invalid node. (See isValid() to find out whether a node is valid). */ - ValueTree getChildWithProperty (const Identifier& propertyName, const var& propertyValue) const; + ValueTree getChildWithProperty (const Identifier propertyName, const var& propertyValue) const; /** Adds a child to this node. @@ -452,7 +451,7 @@ public: /** Causes a property-change callback to be triggered for the specified property, calling any listeners that are registered. */ - void sendPropertyChangeMessage (const Identifier& property); + void sendPropertyChangeMessage (const Identifier property); //============================================================================== /** This method uses a comparator object to sort the tree's children into order. diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp index 1f614a673..bd000e263 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.h b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.h index 7b4bd5d64..813a3c286 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.h +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionListener.h b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionListener.h index 364c415ea..c38c8700f 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionListener.h +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionListener.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp b/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp index 9617f6fa3..97ae3aa3e 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.h b/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.h index 862c95cde..72ddd9ede 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.h +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp index 7c9a8db8a..bff1f1a2d 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h index 950aa18e6..39b6de85e 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeListener.h b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeListener.h index 620e06ba9..6b0133e4b 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeListener.h +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ChangeListener.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ListenerList.h b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ListenerList.h index bb5117cb8..1a5165c1e 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ListenerList.h +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ListenerList.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -263,6 +262,27 @@ public: (iter.getListener()->*callbackFunction) (param1, param2, param3, param4, param5); } + //============================================================================== + /** Calls a member function on each listener in the list, with 5 parameters. */ + template <LL_TEMPLATE(1), LL_TEMPLATE(2), LL_TEMPLATE(3), LL_TEMPLATE(4), LL_TEMPLATE(5), LL_TEMPLATE(6)> + void call (void (ListenerClass::*callbackFunction) (P1, P2, P3, P4, P5, P6), + LL_PARAM(1), LL_PARAM(2), LL_PARAM(3), LL_PARAM(4), LL_PARAM(5), LL_PARAM(6)) + { + for (Iterator<DummyBailOutChecker, ThisType> iter (*this); iter.next();) + (iter.getListener()->*callbackFunction) (param1, param2, param3, param4, param5, param6); + } + + /** Calls a member function on each listener in the list, with 5 parameters and a bail-out-checker. + See the class description for info about writing a bail-out checker. */ + template <class BailOutCheckerType, LL_TEMPLATE(1), LL_TEMPLATE(2), LL_TEMPLATE(3), LL_TEMPLATE(4), LL_TEMPLATE(5), LL_TEMPLATE(6)> + void callChecked (const BailOutCheckerType& bailOutChecker, + void (ListenerClass::*callbackFunction) (P1, P2, P3, P4, P5, P6), + LL_PARAM(1), LL_PARAM(2), LL_PARAM(3), LL_PARAM(4), LL_PARAM(5), LL_PARAM(6)) + { + for (Iterator<BailOutCheckerType, ThisType> iter (*this); iter.next (bailOutChecker);) + (iter.getListener()->*callbackFunction) (param1, param2, param3, param4, param5, param6); + } + //============================================================================== /** A dummy bail-out checker that always returns false. diff --git a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.cpp b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.cpp index 9055599ba..b6e622819 100644 --- a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.cpp +++ b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.h b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.h index 775f69d3a..9a1d319ce 100644 --- a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.h +++ b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp index b7c9971e2..6d0ab1c15 100644 --- a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp +++ b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h index 864028d76..dbb34df10 100644 --- a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h +++ b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/juce_events.cpp b/JuceLibraryCode/modules/juce_events/juce_events.cpp index 4ea7ccf8e..b70fd49b2 100644 --- a/JuceLibraryCode/modules/juce_events/juce_events.cpp +++ b/JuceLibraryCode/modules/juce_events/juce_events.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/juce_events.h b/JuceLibraryCode/modules/juce_events/juce_events.h index a67f24e5e..8c4491d31 100644 --- a/JuceLibraryCode/modules/juce_events/juce_events.h +++ b/JuceLibraryCode/modules/juce_events/juce_events.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/juce_events.mm b/JuceLibraryCode/modules/juce_events/juce_events.mm index 37db5496e..45263f14d 100644 --- a/JuceLibraryCode/modules/juce_events/juce_events.mm +++ b/JuceLibraryCode/modules/juce_events/juce_events.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/juce_module_info b/JuceLibraryCode/modules/juce_events/juce_module_info index d65e16d11..a8c1d1a2f 100644 --- a/JuceLibraryCode/modules/juce_events/juce_module_info +++ b/JuceLibraryCode/modules/juce_events/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_events", "name": "JUCE message and event handling classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for running an application's main event loop and sending/receiving messages, timers, etc.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.cpp b/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.cpp index 045e604cc..7ca7761e4 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.cpp +++ b/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -42,14 +41,15 @@ JUCEApplicationBase::~JUCEApplicationBase() void JUCEApplicationBase::appWillTerminateByForce() { JUCE_AUTORELEASEPOOL - { - const ScopedPointer<JUCEApplicationBase> app (appInstance); + { + const ScopedPointer<JUCEApplicationBase> app (appInstance); - if (app != nullptr) - app->shutdownApp(); - } + if (app != nullptr) + app->shutdownApp(); + } - DeletedAtShutdown::deleteAll(); - MessageManager::deleteInstance(); + DeletedAtShutdown::deleteAll(); + MessageManager::deleteInstance(); + } } diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.h b/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.h index ea97e2dfb..f6c34f000 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.h +++ b/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_CallbackMessage.h b/JuceLibraryCode/modules/juce_events/messages/juce_CallbackMessage.h index 1249db6e1..8a9f06157 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_CallbackMessage.h +++ b/JuceLibraryCode/modules/juce_events/messages/juce_CallbackMessage.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.cpp b/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.cpp index 0769c5f61..d3c6e9725 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.cpp +++ b/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.h b/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.h index 8457579da..2128585c0 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.h +++ b/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_Message.h b/JuceLibraryCode/modules/juce_events/messages/juce_Message.h index 3754affa1..1877ffd48 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_Message.h +++ b/JuceLibraryCode/modules/juce_events/messages/juce_Message.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_MessageListener.cpp b/JuceLibraryCode/modules/juce_events/messages/juce_MessageListener.cpp index a8417e8b5..b398ffa3f 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_MessageListener.cpp +++ b/JuceLibraryCode/modules/juce_events/messages/juce_MessageListener.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_MessageListener.h b/JuceLibraryCode/modules/juce_events/messages/juce_MessageListener.h index abd1ae05c..b9c7786a6 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_MessageListener.h +++ b/JuceLibraryCode/modules/juce_events/messages/juce_MessageListener.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.cpp b/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.cpp index c99fa4a3b..289edaf45 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.cpp +++ b/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -94,8 +93,6 @@ void MessageManager::MessageBase::post() #if JUCE_MODAL_LOOPS_PERMITTED && ! (JUCE_MAC || JUCE_IOS) void MessageManager::runDispatchLoop() { - jassert (isThisTheMessageThread()); // must only be called by the message thread - runDispatchLoopUntil (-1); } @@ -111,20 +108,17 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) const int64 endTime = Time::currentTimeMillis() + millisecondsToRunFor; - while ((millisecondsToRunFor < 0 || endTime > Time::currentTimeMillis()) - && ! quitMessageReceived) + while (! quitMessageReceived) { JUCE_TRY { if (! dispatchNextMessageOnSystemQueue (millisecondsToRunFor >= 0)) - { - const int msToWait = (int) (endTime - Time::currentTimeMillis()); - - if (msToWait > 0) - Thread::sleep (jmin (5, msToWait)); - } + Thread::sleep (1); } JUCE_CATCH_EXCEPTION + + if (millisecondsToRunFor >= 0 && Time::currentTimeMillis() >= endTime) + break; } return ! quitMessageReceived; @@ -326,13 +320,17 @@ JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI(); JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI() { JUCE_AUTORELEASEPOOL - MessageManager::getInstance(); + { + MessageManager::getInstance(); + } } JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI(); JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI() { JUCE_AUTORELEASEPOOL - DeletedAtShutdown::deleteAll(); - MessageManager::deleteInstance(); + { + DeletedAtShutdown::deleteAll(); + MessageManager::deleteInstance(); + } } diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.h b/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.h index 28186500b..2b21109fb 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.h +++ b/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_NotificationType.h b/JuceLibraryCode/modules/juce_events/messages/juce_NotificationType.h index 00e0e7aff..930c30c67 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_NotificationType.h +++ b/JuceLibraryCode/modules/juce_events/messages/juce_NotificationType.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/native/juce_ScopedXLock.h b/JuceLibraryCode/modules/juce_events/native/juce_ScopedXLock.h index 6df27e31c..4a6bed713 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_ScopedXLock.h +++ b/JuceLibraryCode/modules/juce_events/native/juce_ScopedXLock.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/native/juce_android_Messaging.cpp b/JuceLibraryCode/modules/juce_events/native/juce_android_Messaging.cpp index b370e1ed5..9e814d681 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_android_Messaging.cpp +++ b/JuceLibraryCode/modules/juce_events/native/juce_android_Messaging.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/native/juce_ios_MessageManager.mm b/JuceLibraryCode/modules/juce_events/native/juce_ios_MessageManager.mm index 7eb3ff965..66050516b 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_ios_MessageManager.mm +++ b/JuceLibraryCode/modules/juce_events/native/juce_ios_MessageManager.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -38,23 +37,26 @@ void MessageManager::stopDispatchLoop() bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) { JUCE_AUTORELEASEPOOL - jassert (isThisTheMessageThread()); // must only be called by the message thread + { + jassert (isThisTheMessageThread()); // must only be called by the message thread - uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor; - NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001]; + uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor; + NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001]; - while (! quitMessagePosted) - { - JUCE_AUTORELEASEPOOL + while (! quitMessagePosted) + { + JUCE_AUTORELEASEPOOL + { + [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode + beforeDate: endDate]; - [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode - beforeDate: endDate]; + if (millisecondsToRunFor >= 0 && Time::getMillisecondCounter() >= endTime) + break; + } + } - if (millisecondsToRunFor >= 0 && Time::getMillisecondCounter() >= endTime) - break; + return ! quitMessagePosted; } - - return ! quitMessagePosted; } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_events/native/juce_linux_Messaging.cpp b/JuceLibraryCode/modules/juce_events/native/juce_linux_Messaging.cpp index 11bba2247..48e28a739 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_linux_Messaging.cpp +++ b/JuceLibraryCode/modules/juce_events/native/juce_linux_Messaging.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -196,18 +195,17 @@ private: bool dispatchNextInternalMessage() { - const MessageManager::MessageBase::Ptr msg (popNextMessage()); - - if (msg == nullptr) - return false; - - JUCE_TRY + if (const MessageManager::MessageBase::Ptr msg = popNextMessage()) { - msg->messageCallback(); + JUCE_TRY + { + msg->messageCallback(); + return true; + } + JUCE_CATCH_EXCEPTION } - JUCE_CATCH_EXCEPTION - return true; + return false; } }; diff --git a/JuceLibraryCode/modules/juce_events/native/juce_mac_MessageManager.mm b/JuceLibraryCode/modules/juce_events/native/juce_mac_MessageManager.mm index 2949921d6..8f41f16d5 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_mac_MessageManager.mm +++ b/JuceLibraryCode/modules/juce_events/native/juce_mac_MessageManager.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -208,36 +207,39 @@ void MessageManager::runDispatchLoop() if (! quitMessagePosted) // check that the quit message wasn't already posted.. { JUCE_AUTORELEASEPOOL - - // must only be called by the message thread! - jassert (isThisTheMessageThread()); - - #if JUCE_PROJUCER_LIVE_BUILD - runDispatchLoopUntil (std::numeric_limits<int>::max()); - #else - #if JUCE_CATCH_UNHANDLED_EXCEPTIONS - @try { + // must only be called by the message thread! + jassert (isThisTheMessageThread()); + + #if JUCE_PROJUCER_LIVE_BUILD + runDispatchLoopUntil (std::numeric_limits<int>::max()); + #else + #if JUCE_CATCH_UNHANDLED_EXCEPTIONS + @try + { + [NSApp run]; + } + @catch (NSException* e) + { + // An AppKit exception will kill the app, but at least this provides a chance to log it., + std::runtime_error ex (std::string ("NSException: ") + [[e name] UTF8String] + ", Reason:" + [[e reason] UTF8String]); + JUCEApplication::sendUnhandledException (&ex, __FILE__, __LINE__); + } + @finally + { + } + #else [NSApp run]; + #endif + #endif } - @catch (NSException* e) - { - // An AppKit exception will kill the app, but at least this provides a chance to log it., - std::runtime_error ex (std::string ("NSException: ") + [[e name] UTF8String] + ", Reason:" + [[e reason] UTF8String]); - JUCEApplication::sendUnhandledException (&ex, __FILE__, __LINE__); - } - @finally - { - } - #else - [NSApp run]; - #endif - #endif } } void MessageManager::stopDispatchLoop() { + jassert (isThisTheMessageThread()); // must only be called by the message thread + quitMessagePosted = true; #if ! JUCE_PROJUCER_LIVE_BUILD [NSApp stop: nil]; @@ -257,19 +259,20 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) while (! quitMessagePosted) { JUCE_AUTORELEASEPOOL + { + CFRunLoopRunInMode (kCFRunLoopDefaultMode, 0.001, true); - CFRunLoopRunInMode (kCFRunLoopDefaultMode, 0.001, true); - - NSEvent* e = [NSApp nextEventMatchingMask: NSAnyEventMask - untilDate: [NSDate dateWithTimeIntervalSinceNow: 0.001] - inMode: NSDefaultRunLoopMode - dequeue: YES]; + NSEvent* e = [NSApp nextEventMatchingMask: NSAnyEventMask + untilDate: [NSDate dateWithTimeIntervalSinceNow: 0.001] + inMode: NSDefaultRunLoopMode + dequeue: YES]; - if (e != nil && (isEventBlockedByModalComps == nullptr || ! (*isEventBlockedByModalComps) (e))) - [NSApp sendEvent: e]; + if (e != nil && (isEventBlockedByModalComps == nullptr || ! (*isEventBlockedByModalComps) (e))) + [NSApp sendEvent: e]; - if (Time::getMillisecondCounter() >= endTime) - break; + if (Time::getMillisecondCounter() >= endTime) + break; + } } return ! quitMessagePosted; @@ -281,7 +284,9 @@ void initialiseNSApplication(); void initialiseNSApplication() { JUCE_AUTORELEASEPOOL - [NSApplication sharedApplication]; + { + [NSApplication sharedApplication]; + } } static AppDelegate* appDelegate = nullptr; diff --git a/JuceLibraryCode/modules/juce_events/native/juce_osx_MessageQueue.h b/JuceLibraryCode/modules/juce_events/native/juce_osx_MessageQueue.h index f26dd60dc..5309787eb 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_osx_MessageQueue.h +++ b/JuceLibraryCode/modules/juce_events/native/juce_osx_MessageQueue.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -63,7 +62,6 @@ public: private: ReferenceCountedArray <MessageManager::MessageBase, CriticalSection> messages; - CriticalSection lock; CFRunLoopRef runLoop; CFRunLoopSourceRef runLoopSource; @@ -75,12 +73,13 @@ private: return false; JUCE_AUTORELEASEPOOL - - JUCE_TRY { - nextMessage->messageCallback(); + JUCE_TRY + { + nextMessage->messageCallback(); + } + JUCE_CATCH_EXCEPTION } - JUCE_CATCH_EXCEPTION return true; } diff --git a/JuceLibraryCode/modules/juce_events/native/juce_win32_HiddenMessageWindow.h b/JuceLibraryCode/modules/juce_events/native/juce_win32_HiddenMessageWindow.h index 213ff3919..8b5ab8a21 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_win32_HiddenMessageWindow.h +++ b/JuceLibraryCode/modules/juce_events/native/juce_win32_HiddenMessageWindow.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/native/juce_win32_Messaging.cpp b/JuceLibraryCode/modules/juce_events/native/juce_win32_Messaging.cpp index 2e8ecb73b..1c105e262 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_win32_Messaging.cpp +++ b/JuceLibraryCode/modules/juce_events/native/juce_win32_Messaging.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.cpp b/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.cpp index 753d56060..29a411a7a 100644 --- a/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.cpp +++ b/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.h b/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.h index 790731874..da3225e1f 100644 --- a/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.h +++ b/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_events/timers/juce_Timer.cpp b/JuceLibraryCode/modules/juce_events/timers/juce_Timer.cpp index fdfa34442..af011f5ac 100644 --- a/JuceLibraryCode/modules/juce_events/timers/juce_Timer.cpp +++ b/JuceLibraryCode/modules/juce_events/timers/juce_Timer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -83,7 +82,7 @@ public: when the app has a modal loop), so this is how long to wait before assuming the message has been lost and trying again. */ - const uint32 messageDeliveryTimeout = now + 2000; + const uint32 messageDeliveryTimeout = now + 300; while (callbackNeeded.get() != 0) { @@ -93,7 +92,10 @@ public: return; if (Time::getMillisecondCounter() > messageDeliveryTimeout) + { + messageToSend->post(); break; + } } } } diff --git a/JuceLibraryCode/modules/juce_events/timers/juce_Timer.h b/JuceLibraryCode/modules/juce_events/timers/juce_Timer.h index 3db51f161..7401b83bf 100644 --- a/JuceLibraryCode/modules/juce_events/timers/juce_Timer.h +++ b/JuceLibraryCode/modules/juce_events/timers/juce_Timer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.cpp b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.cpp index 8da7189e9..dcf9eeb63 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.cpp +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -32,7 +31,7 @@ namespace ColourHelpers // This is an adjusted brightness value, based on the way the human // eye responds to different colour channels.. - static float getPerceivedBrightness (const Colour& c) noexcept + static float getPerceivedBrightness (Colour c) noexcept { const float r = c.getFloatRed(); const float g = c.getFloatGreen(); @@ -46,7 +45,7 @@ namespace ColourHelpers //============================================================================== struct HSB { - HSB (const Colour& col) noexcept + HSB (Colour col) noexcept { const int r = col.getRed(); const int g = col.getGreen(); @@ -92,7 +91,7 @@ namespace ColourHelpers brightness = hi / 255.0f; } - Colour toColour (const Colour& original) const noexcept + Colour toColour (Colour original) const noexcept { return Colour (hue, saturation, brightness, original.getAlpha()); } @@ -124,7 +123,7 @@ namespace ColourHelpers //============================================================================== struct YIQ { - YIQ (const Colour& c) noexcept + YIQ (Colour c) noexcept { const float r = c.getFloatRed(); const float g = c.getFloatGreen(); @@ -169,8 +168,7 @@ bool Colour::operator== (const Colour& other) const noexcept { return argb.ge bool Colour::operator!= (const Colour& other) const noexcept { return argb.getARGB() != other.argb.getARGB(); } //============================================================================== -Colour::Colour (const uint32 argb_) noexcept - : argb (argb_) +Colour::Colour (const uint32 col) noexcept : argb (col) { } @@ -201,7 +199,9 @@ Colour::Colour (const uint8 red, const uint8 green, const uint8 blue, const floa Colour Colour::fromFloatRGBA (const float red, const float green, const float blue, const float alpha) noexcept { - return Colour (ColourHelpers::floatToUInt8 (red), ColourHelpers::floatToUInt8 (green), ColourHelpers::floatToUInt8 (blue), alpha); + return Colour (ColourHelpers::floatToUInt8 (red), + ColourHelpers::floatToUInt8 (green), + ColourHelpers::floatToUInt8 (blue), alpha); } Colour::Colour (const float hue, const float saturation, const float brightness, const float alpha) noexcept @@ -273,7 +273,7 @@ Colour Colour::withMultipliedAlpha (const float alphaMultiplier) const noexcept } //============================================================================== -Colour Colour::overlaidWith (const Colour& src) const noexcept +Colour Colour::overlaidWith (Colour src) const noexcept { const int destAlpha = getAlpha(); @@ -294,7 +294,7 @@ Colour Colour::overlaidWith (const Colour& src) const noexcept (uint8) resA); } -Colour Colour::interpolatedWith (const Colour& other, float proportionOfOther) const noexcept +Colour Colour::interpolatedWith (Colour other, float proportionOfOther) const noexcept { if (proportionOfOther <= 0) return *this; @@ -391,23 +391,23 @@ Colour Colour::contrasting (const float amount) const noexcept : Colours::white).withAlpha (amount)); } -Colour Colour::contrasting (const Colour& target, float minContrast) const noexcept +Colour Colour::contrasting (Colour target, float minContrast) const noexcept { const ColourHelpers::YIQ bg (*this); ColourHelpers::YIQ fg (target); - if (fabs (bg.y - fg.y) >= minContrast) + if (std::abs (bg.y - fg.y) >= minContrast) return target; const float y1 = jmax (0.0f, bg.y - minContrast); const float y2 = jmin (1.0f, bg.y + minContrast); - fg.y = (fabs (y1 - bg.y) > fabs (y2 - bg.y)) ? y1 : y2; + fg.y = (std::abs (y1 - bg.y) > std::abs (y2 - bg.y)) ? y1 : y2; return fg.toColour(); } -Colour Colour::contrasting (const Colour& colour1, - const Colour& colour2) noexcept +Colour Colour::contrasting (Colour colour1, + Colour colour2) noexcept { const float b1 = ColourHelpers::getPerceivedBrightness (colour1); const float b2 = ColourHelpers::getPerceivedBrightness (colour2); diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.h b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.h index ce28a6ab1..27ab3bc02 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.h +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -231,14 +230,14 @@ public: If the foreground colour is semi-transparent, it is blended onto this colour accordingly. */ - Colour overlaidWith (const Colour& foregroundColour) const noexcept; + Colour overlaidWith (Colour foregroundColour) const noexcept; /** Returns a colour that lies somewhere between this one and another. If amountOfOther is zero, the result is 100% this colour, if amountOfOther is 1.0, the result is 100% of the other colour. */ - Colour interpolatedWith (const Colour& other, float proportionOfOther) const noexcept; + Colour interpolatedWith (Colour other, float proportionOfOther) const noexcept; //============================================================================== /** Returns the colour's hue component. @@ -331,14 +330,14 @@ public: nudged up or down so that it differs from the luminosity of this colour by at least the amount specified by minLuminosityDiff. */ - Colour contrasting (const Colour& targetColour, float minLuminosityDiff) const noexcept; + Colour contrasting (Colour targetColour, float minLuminosityDiff) const noexcept; /** Returns a colour that contrasts against two colours. Looks for a colour that contrasts with both of the colours passed-in. Handy for things like choosing a highlight colour in text editors, etc. */ - static Colour contrasting (const Colour& colour1, - const Colour& colour2) noexcept; + static Colour contrasting (Colour colour1, + Colour colour2) noexcept; //============================================================================== /** Returns an opaque shade of grey. diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.cpp b/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.cpp index 9a2ba6945..efb2d715f 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.cpp +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -33,8 +32,8 @@ ColourGradient::ColourGradient() noexcept #endif } -ColourGradient::ColourGradient (const Colour& colour1, const float x1_, const float y1_, - const Colour& colour2, const float x2_, const float y2_, +ColourGradient::ColourGradient (Colour colour1, const float x1_, const float y1_, + Colour colour2, const float x2_, const float y2_, const bool isRadial_) : point1 (x1_, y1_), point2 (x2_, y2_), @@ -66,7 +65,7 @@ void ColourGradient::clearColours() colours.clear(); } -int ColourGradient::addColour (const double proportionAlongGradient, const Colour& colour) +int ColourGradient::addColour (const double proportionAlongGradient, Colour colour) { // must be within the two end-points jassert (proportionAlongGradient >= 0 && proportionAlongGradient <= 1.0); @@ -119,7 +118,7 @@ Colour ColourGradient::getColour (const int index) const noexcept return Colour(); } -void ColourGradient::setColour (int index, const Colour& newColour) noexcept +void ColourGradient::setColour (int index, Colour newColour) noexcept { if (isPositiveAndBelow (index, colours.size())) colours.getReference (index).colour = newColour; diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.h b/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.h index 59c5033b7..dde10de30 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.h +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -57,8 +56,8 @@ public: @see ColourGradient */ - ColourGradient (const Colour& colour1, float x1, float y1, - const Colour& colour2, float x2, float y2, + ColourGradient (Colour colour1, float x1, float y1, + Colour colour2, float x2, float y2, bool isRadial); /** Creates an uninitialised gradient. @@ -91,7 +90,7 @@ public: @returns the index at which the new point was added */ int addColour (double proportionAlongGradient, - const Colour& colour); + Colour colour); /** Removes one of the colours from the gradient. */ void removeColour (int index); @@ -117,7 +116,7 @@ public: /** Changes the colour at a given index. The index is from 0 to getNumColours() - 1. */ - void setColour (int index, const Colour& newColour) noexcept; + void setColour (int index, Colour newColour) noexcept; /** Returns the an interpolated colour at any position along the gradient. @param position the position along the gradient, between 0 and 1 @@ -165,7 +164,7 @@ private: { ColourPoint() noexcept {} - ColourPoint (const double pos, const Colour& col) noexcept + ColourPoint (const double pos, Colour col) noexcept : position (pos), colour (col) {} diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.cpp b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.cpp index 65d4c36d8..fbde0ba6e 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.cpp +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -166,7 +165,7 @@ const Colour Colours::yellowgreen (0xff9acd32); //============================================================================== Colour Colours::findColourForName (const String& colourName, - const Colour& defaultColour) + Colour defaultColour) { static const uint32 presets[] = { diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.h b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.h index 9871516c8..d15dd6e3b 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.h +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -96,7 +95,7 @@ public: colour passed in as the defaultColour parameter is returned. */ static JUCE_API Colour findColourForName (const String& colourName, - const Colour& defaultColour); + Colour defaultColour); private: //============================================================================== diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_FillType.cpp b/JuceLibraryCode/modules/juce_graphics/colour/juce_FillType.cpp index 9e2806ca6..5e5db5632 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_FillType.cpp +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_FillType.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -28,8 +27,8 @@ FillType::FillType() noexcept { } -FillType::FillType (const Colour& colour_) noexcept - : colour (colour_) +FillType::FillType (Colour c) noexcept + : colour (c) { } @@ -102,7 +101,7 @@ bool FillType::operator!= (const FillType& other) const return ! operator== (other); } -void FillType::setColour (const Colour& newColour) noexcept +void FillType::setColour (Colour newColour) noexcept { gradient = nullptr; image = Image::null; diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_FillType.h b/JuceLibraryCode/modules/juce_graphics/colour/juce_FillType.h index 1a59ad19d..5906a7798 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_FillType.h +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_FillType.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -49,7 +48,7 @@ public: /** Creates a fill type of a solid colour. @see setColour */ - FillType (const Colour& colour) noexcept; + FillType (Colour colour) noexcept; /** Creates a gradient fill type. @see setGradient @@ -88,7 +87,7 @@ public: /** Turns this object into a solid colour fill. If the object was an image or gradient, those fields will no longer be valid. */ - void setColour (const Colour& newColour) noexcept; + void setColour (Colour newColour) noexcept; /** Turns this object into a gradient fill. */ void setGradient (const ColourGradient& newGradient); diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_PixelFormats.h b/JuceLibraryCode/modules/juce_graphics/colour/juce_PixelFormats.h index 5dffef611..23afbad25 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_PixelFormats.h +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_PixelFormats.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -35,6 +34,16 @@ class PixelRGB; class PixelAlpha; +inline uint32 maskPixelComponents (uint32 x) noexcept +{ + return (x >> 8) & 0x00ff00ff; +} + +inline uint32 clampPixelComponents (uint32 x) noexcept +{ + return (x | (0x01000100 - maskPixelComponents (x))) & 0x00ff00ff; +} + //============================================================================== /** Represents a 32-bit ARGB pixel with premultiplied alpha, and can perform compositing @@ -98,13 +107,10 @@ public: template <class Pixel> forcedinline void blend (const Pixel& src) noexcept { - uint32 sargb = src.getARGB(); - const uint32 alpha = 0x100 - (sargb >> 24); - - sargb += 0x00ff00ff & ((getRB() * alpha) >> 8); - sargb += 0xff00ff00 & (getAG() * alpha); - - argb = sargb; + const uint32 alpha = 0x100 - src.getAlpha(); + uint32 rb = src.getRB() + maskPixelComponents (getRB() * alpha); + uint32 ag = src.getAG() + maskPixelComponents (getAG() * alpha); + argb = clampPixelComponents (rb) + (clampPixelComponents (ag) << 8); } /** Blends another pixel onto this one. @@ -112,7 +118,7 @@ public: This takes into account the opacity of the pixel being overlaid, and blends it accordingly. */ - forcedinline void blend (const PixelRGB& src) noexcept; + forcedinline void blend (const PixelRGB src) noexcept; /** Blends another pixel onto this one, applying an extra multiplier to its opacity. @@ -123,17 +129,14 @@ public: template <class Pixel> forcedinline void blend (const Pixel& src, uint32 extraAlpha) noexcept { - ++extraAlpha; - - uint32 sargb = ((extraAlpha * src.getAG()) & 0xff00ff00) - | (((extraAlpha * src.getRB()) >> 8) & 0x00ff00ff); + uint32 ag = maskPixelComponents (extraAlpha * src.getAG()); + const uint32 alpha = 0x100 - (ag >> 16); + ag += maskPixelComponents (getAG() * alpha); - const uint32 alpha = 0x100 - (sargb >> 24); + uint32 rb = maskPixelComponents (extraAlpha * src.getRB()) + + maskPixelComponents (getRB() * alpha); - sargb += 0x00ff00ff & ((getRB() * alpha) >> 8); - sargb += 0xff00ff00 & (getAG() * alpha); - - argb = sargb; + argb = clampPixelComponents(rb) + (clampPixelComponents (ag) << 8); } /** Blends another pixel with this one, creating a colour that is somewhere @@ -347,18 +350,17 @@ public: template <class Pixel> forcedinline void blend (const Pixel& src) noexcept { - uint32 sargb = src.getARGB(); - const uint32 alpha = 0x100 - (sargb >> 24); + const uint32 alpha = 0x100 - src.getAlpha(); - sargb += 0x00ff00ff & ((getRB() * alpha) >> 8); - sargb += 0x0000ff00 & (g * alpha); + uint32 rb = clampPixelComponents (src.getRB() + maskPixelComponents (getRB() * alpha)); + uint32 ag = src.getAG() + (g * alpha >> 8); - r = (uint8) (sargb >> 16); - g = (uint8) (sargb >> 8); - b = (uint8) sargb; + r = (uint8) (rb >> 16); + g = (uint8) clampPixelComponents (ag); + b = (uint8) rb; } - forcedinline void blend (const PixelRGB& src) noexcept + forcedinline void blend (const PixelRGB src) noexcept { set (src); } @@ -371,19 +373,16 @@ public: template <class Pixel> forcedinline void blend (const Pixel& src, uint32 extraAlpha) noexcept { - ++extraAlpha; - const uint32 srb = (extraAlpha * src.getRB()) >> 8; - const uint32 sag = extraAlpha * src.getAG(); - uint32 sargb = (sag & 0xff00ff00) | (srb & 0x00ff00ff); - - const uint32 alpha = 0x100 - (sargb >> 24); + uint32 ag = maskPixelComponents (extraAlpha * src.getAG()); + const uint32 alpha = 0x100 - (ag >> 16); + ag += g * alpha >> 8; - sargb += 0x00ff00ff & ((getRB() * alpha) >> 8); - sargb += 0x0000ff00 & (g * alpha); + uint32 rb = clampPixelComponents (maskPixelComponents (extraAlpha * src.getRB()) + + maskPixelComponents (getRB() * alpha)); - b = (uint8) sargb; - g = (uint8) (sargb >> 8); - r = (uint8) (sargb >> 16); + b = (uint8) rb; + g = (uint8) clampPixelComponents (ag); + r = (uint8) (rb >> 16); } /** Blends another pixel with this one, creating a colour that is somewhere @@ -467,7 +466,7 @@ private: #endif ; -forcedinline void PixelARGB::blend (const PixelRGB& src) noexcept +forcedinline void PixelARGB::blend (const PixelRGB src) noexcept { set (src); } diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.cpp b/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.cpp index 9ff39ad3c..05775072f 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.cpp +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -174,7 +173,7 @@ void Graphics::endTransparencyLayer() } //============================================================================== -void Graphics::setColour (const Colour& newColour) +void Graphics::setColour (Colour newColour) { saveStateIfPending(); context.setFill (newColour); @@ -252,16 +251,6 @@ void Graphics::drawSingleLineText (const String& text, const int startX, const i } } -void Graphics::drawTextAsPath (const String& text, const AffineTransform& transform) const -{ - if (text.isNotEmpty()) - { - GlyphArrangement arr; - arr.addLineOfText (context.getFont(), text, 0.0f, 0.0f); - arr.draw (*this, transform); - } -} - void Graphics::drawMultiLineText (const String& text, const int startX, const int baselineY, const int maximumLineWidth) const { @@ -369,7 +358,7 @@ void Graphics::fillAll() const fillRect (context.getClipBounds()); } -void Graphics::fillAll (const Colour& colourToUse) const +void Graphics::fillAll (Colour colourToUse) const { if (! colourToUse.isTransparent()) { @@ -503,7 +492,7 @@ void Graphics::drawArrow (const Line<float>& line, const float lineThickness, co void Graphics::fillCheckerBoard (const Rectangle<int>& area, const int checkWidth, const int checkHeight, - const Colour& colour1, const Colour& colour2) const + Colour colour1, Colour colour2) const { jassert (checkWidth > 0 && checkHeight > 0); // can't be zero or less! diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.h b/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.h index 2c0cf59b6..816afc412 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.h +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -81,7 +80,7 @@ public: @see setOpacity */ - void setColour (const Colour& newColour); + void setColour (Colour newColour); /** Changes the opacity to use with the current colour. @@ -117,7 +116,7 @@ public: Note there's also a setFont (float, int) method to quickly change the size and style of the current font. - @see drawSingleLineText, drawMultiLineText, drawTextAsPath, drawText, drawFittedText + @see drawSingleLineText, drawMultiLineText, drawText, drawFittedText */ void setFont (const Font& newFont); @@ -159,17 +158,6 @@ public: int startX, int baselineY, int maximumLineWidth) const; - /** Renders a string of text as a vector path. - - This allows a string to be transformed with an arbitrary AffineTransform and - rendered using the current colour/brush. It's much slower than the normal text methods - but more accurate. - - @see setFont - */ - void drawTextAsPath (const String& text, - const AffineTransform& transform) const; - /** Draws a line of text within a specified rectangle. The text will be positioned within the rectangle based on the justification @@ -251,7 +239,7 @@ public: //============================================================================== /** Fills the context's entire clip region with the current colour or brush. - (See also the fillAll (const Colour&) method which is a quick way of filling + (See also the fillAll (Colour) method which is a quick way of filling it with a given colour). */ void fillAll() const; @@ -261,7 +249,7 @@ public: This leaves the context's current colour and brush unchanged, it just uses the specified colour temporarily. */ - void fillAll (const Colour& colourToUse) const; + void fillAll (Colour colourToUse) const; //============================================================================== /** Fills a rectangle with the current colour or brush. @@ -301,7 +289,7 @@ public: */ void fillCheckerBoard (const Rectangle<int>& area, int checkWidth, int checkHeight, - const Colour& colour1, const Colour& colour2) const; + Colour colour1, Colour colour2) const; /** Draws four lines to form a rectangular outline, using the current colour or brush. diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h index e8f8a0a00..3f5ae77e0 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp index 57d7371b0..faac3f7fb 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h index 00cfcd479..8e840619d 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index 346b83d38..09d6d81a0 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -28,7 +27,7 @@ LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (const Image& { } -LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (const Image& image, const Point<int>& origin, +LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (const Image& image, Point<int> origin, const RectangleList& initialClip) : savedState (new RenderingHelpers::SoftwareRendererSavedState (image, initialClip, origin.x, origin.y)) { diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h index e9770402c..116fca689 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -42,7 +41,7 @@ class JUCE_API LowLevelGraphicsSoftwareRenderer : public LowLevelGraphicsCon public: //============================================================================== LowLevelGraphicsSoftwareRenderer (const Image& imageToRenderOnto); - LowLevelGraphicsSoftwareRenderer (const Image& imageToRenderOnto, const Point<int>& origin, + LowLevelGraphicsSoftwareRenderer (const Image& imageToRenderOnto, Point<int> origin, const RectangleList& initialClip); ~LowLevelGraphicsSoftwareRenderer(); diff --git a/JuceLibraryCode/modules/juce_graphics/effects/juce_DropShadowEffect.cpp b/JuceLibraryCode/modules/juce_graphics/effects/juce_DropShadowEffect.cpp index b3904494c..448fab876 100644 --- a/JuceLibraryCode/modules/juce_graphics/effects/juce_DropShadowEffect.cpp +++ b/JuceLibraryCode/modules/juce_graphics/effects/juce_DropShadowEffect.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -69,7 +68,7 @@ DropShadow::DropShadow() noexcept { } -DropShadow::DropShadow (const Colour& shadowColour, const int r, const Point<int>& o) noexcept +DropShadow::DropShadow (Colour shadowColour, const int r, Point<int> o) noexcept : colour (shadowColour), radius (r), offset (o) { jassert (radius > 0); diff --git a/JuceLibraryCode/modules/juce_graphics/effects/juce_DropShadowEffect.h b/JuceLibraryCode/modules/juce_graphics/effects/juce_DropShadowEffect.h index 8e3996e59..7054b9242 100644 --- a/JuceLibraryCode/modules/juce_graphics/effects/juce_DropShadowEffect.h +++ b/JuceLibraryCode/modules/juce_graphics/effects/juce_DropShadowEffect.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -39,7 +38,7 @@ struct JUCE_API DropShadow DropShadow() noexcept; /** Creates a drop-shadow object with the given parameters. */ - DropShadow (const Colour& shadowColour, int radius, const Point<int>& offset) noexcept; + DropShadow (Colour shadowColour, int radius, Point<int> offset) noexcept; /** Renders a drop-shadow based on the alpha-channel of the given image. */ void drawForImage (Graphics& g, const Image& srcImage) const; diff --git a/JuceLibraryCode/modules/juce_graphics/effects/juce_GlowEffect.cpp b/JuceLibraryCode/modules/juce_graphics/effects/juce_GlowEffect.cpp index e8d647841..7db7ef5f8 100644 --- a/JuceLibraryCode/modules/juce_graphics/effects/juce_GlowEffect.cpp +++ b/JuceLibraryCode/modules/juce_graphics/effects/juce_GlowEffect.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -34,7 +33,7 @@ GlowEffect::~GlowEffect() } void GlowEffect::setGlowProperties (const float newRadius, - const Colour& newColour) + Colour newColour) { radius = newRadius; colour = newColour; diff --git a/JuceLibraryCode/modules/juce_graphics/effects/juce_GlowEffect.h b/JuceLibraryCode/modules/juce_graphics/effects/juce_GlowEffect.h index e6540e462..191cfa8b9 100644 --- a/JuceLibraryCode/modules/juce_graphics/effects/juce_GlowEffect.h +++ b/JuceLibraryCode/modules/juce_graphics/effects/juce_GlowEffect.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -58,7 +57,7 @@ public: opacity). */ void setGlowProperties (float newRadius, - const Colour& newColour); + Colour newColour); //============================================================================== diff --git a/JuceLibraryCode/modules/juce_graphics/effects/juce_ImageEffectFilter.h b/JuceLibraryCode/modules/juce_graphics/effects/juce_ImageEffectFilter.h index d34281ee0..f1be23bcc 100644 --- a/JuceLibraryCode/modules/juce_graphics/effects/juce_ImageEffectFilter.h +++ b/JuceLibraryCode/modules/juce_graphics/effects/juce_ImageEffectFilter.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_AttributedString.cpp b/JuceLibraryCode/modules/juce_graphics/fonts/juce_AttributedString.cpp index 4dfb91fde..b4716fafd 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_AttributedString.cpp +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_AttributedString.cpp @@ -1,34 +1,33 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ -AttributedString::Attribute::Attribute (const Range<int>& range_, const Colour& colour_) +AttributedString::Attribute::Attribute (Range<int> range_, Colour colour_) : range (range_), colour (new Colour (colour_)) { } -AttributedString::Attribute::Attribute (const Range<int>& range_, const Font& font_) +AttributedString::Attribute::Attribute (Range<int> range_, const Font& font_) : range (range_), font (new Font (font_)) { } @@ -137,7 +136,7 @@ void AttributedString::append (const String& textToAppend, const Font& font) setFont (Range<int> (oldLength, oldLength + newLength), font); } -void AttributedString::append (const String& textToAppend, const Colour& colour) +void AttributedString::append (const String& textToAppend, Colour colour) { const int oldLength = text.length(); const int newLength = textToAppend.length(); @@ -146,7 +145,7 @@ void AttributedString::append (const String& textToAppend, const Colour& colour) setColour (Range<int> (oldLength, oldLength + newLength), colour); } -void AttributedString::append (const String& textToAppend, const Font& font, const Colour& colour) +void AttributedString::append (const String& textToAppend, const Font& font, Colour colour) { const int oldLength = text.length(); const int newLength = textToAppend.length(); @@ -191,12 +190,12 @@ void AttributedString::setLineSpacing (const float newLineSpacing) noexcept lineSpacing = newLineSpacing; } -void AttributedString::setColour (const Range<int>& range, const Colour& colour) +void AttributedString::setColour (Range<int> range, Colour colour) { attributes.add (new Attribute (range, colour)); } -void AttributedString::setColour (const Colour& colour) +void AttributedString::setColour (Colour colour) { for (int i = attributes.size(); --i >= 0;) if (attributes.getUnchecked(i)->getColour() != nullptr) @@ -205,7 +204,7 @@ void AttributedString::setColour (const Colour& colour) setColour (Range<int> (0, text.length()), colour); } -void AttributedString::setFont (const Range<int>& range, const Font& font) +void AttributedString::setFont (Range<int> range, const Font& font) { attributes.add (new Attribute (range, font)); } diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_AttributedString.h b/JuceLibraryCode/modules/juce_graphics/fonts/juce_AttributedString.h index 0a21dbe00..f9f1dd4dd 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_AttributedString.h +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_AttributedString.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -71,9 +70,9 @@ public: /** Appends some text, with a specified font, and the default colour (black). */ void append (const String& textToAppend, const Font& font); /** Appends some text, with a specified colour, and the default font. */ - void append (const String& textToAppend, const Colour& colour); + void append (const String& textToAppend, Colour colour); /** Appends some text, with a specified font and colour. */ - void append (const String& textToAppend, const Font& font, const Colour& colour); + void append (const String& textToAppend, const Font& font, Colour colour); /** Appends another AttributedString to this one. Note that this will only append the text, fonts, and colours - it won't copy any @@ -154,12 +153,12 @@ public: /** Creates an attribute that changes the colour for a range of characters. @see AttributedString::setColour() */ - Attribute (const Range<int>& range, const Colour& colour); + Attribute (Range<int> range, Colour colour); /** Creates an attribute that changes the font for a range of characters. @see AttributedString::setFont() */ - Attribute (const Range<int>& range, const Font& font); + Attribute (Range<int> range, const Font& font); Attribute (const Attribute&); ~Attribute(); @@ -194,13 +193,13 @@ public: //============================================================================== /** Adds a colour attribute for the specified range. */ - void setColour (const Range<int>& range, const Colour& colour); + void setColour (Range<int> range, Colour colour); /** Removes all existing colour attributes, and applies this colour to the whole string. */ - void setColour (const Colour& colour); + void setColour (Colour colour); /** Adds a font attribute for the specified range. */ - void setFont (const Range<int>& range, const Font& font); + void setFont (Range<int> range, const Font& font); /** Removes all existing font attributes, and applies this font to the whole string. */ void setFont (const Font& font); diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.cpp b/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.cpp index 5818881b5..1ab159191 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.cpp +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -26,8 +25,8 @@ class CustomTypeface::GlyphInfo { public: - GlyphInfo (const juce_wchar character_, const Path& path_, const float width_) noexcept - : character (character_), path (path_), width (width_) + GlyphInfo (const juce_wchar c, const Path& p, const float w) noexcept + : character (c), path (p), width (w) { } @@ -49,11 +48,9 @@ public: float getHorizontalSpacing (const juce_wchar subsequentCharacter) const noexcept { if (subsequentCharacter != 0) - { for (int i = kerningPairs.size(); --i >= 0;) if (kerningPairs.getReference(i).character2 == subsequentCharacter) return width + kerningPairs.getReference(i).kerningAmount; - } return width; } @@ -124,9 +121,9 @@ CustomTypeface::CustomTypeface (InputStream& serialisedTypefaceStream) ascent = in.readFloat(); defaultCharacter = CustomTypefaceHelpers::readChar (in); - int i, numChars = in.readInt(); + int numChars = in.readInt(); - for (i = 0; i < numChars; ++i) + for (int i = 0; i < numChars; ++i) { const juce_wchar c = CustomTypefaceHelpers::readChar (in); const float width = in.readFloat(); @@ -138,7 +135,7 @@ CustomTypeface::CustomTypeface (InputStream& serialisedTypefaceStream) const int numKerningPairs = in.readInt(); - for (i = 0; i < numKerningPairs; ++i) + for (int i = 0; i < numKerningPairs; ++i) { const juce_wchar char1 = CustomTypefaceHelpers::readChar (in); const juce_wchar char2 = CustomTypefaceHelpers::readChar (in); @@ -161,22 +158,22 @@ void CustomTypeface::clear() glyphs.clear(); } -void CustomTypeface::setCharacteristics (const String& name_, const float ascent_, const bool isBold, - const bool isItalic, const juce_wchar defaultCharacter_) noexcept +void CustomTypeface::setCharacteristics (const String& newName, const float newAscent, const bool isBold, + const bool isItalic, const juce_wchar newDefaultCharacter) noexcept { - name = name_; - defaultCharacter = defaultCharacter_; - ascent = ascent_; + name = newName; + defaultCharacter = newDefaultCharacter; + ascent = newAscent; style = FontStyleHelpers::getStyleName (isBold, isItalic); } -void CustomTypeface::setCharacteristics (const String& name_, const String& style_, const float ascent_, - const juce_wchar defaultCharacter_) noexcept +void CustomTypeface::setCharacteristics (const String& newName, const String& newStyle, const float newAscent, + const juce_wchar newDefaultCharacter) noexcept { - name = name_; - style = style_; - defaultCharacter = defaultCharacter_; - ascent = ascent_; + name = newName; + style = newStyle; + defaultCharacter = newDefaultCharacter; + ascent = newAscent; } void CustomTypeface::addGlyph (const juce_wchar character, const Path& path, const float width) noexcept @@ -272,9 +269,9 @@ bool CustomTypeface::writeToStream (OutputStream& outputStream) CustomTypefaceHelpers::writeChar (out, defaultCharacter); out.writeInt (glyphs.size()); - int i, numKerningPairs = 0; + int numKerningPairs = 0; - for (i = 0; i < glyphs.size(); ++i) + for (int i = 0; i < glyphs.size(); ++i) { const GlyphInfo* const g = glyphs.getUnchecked (i); CustomTypefaceHelpers::writeChar (out, g->character); @@ -286,7 +283,7 @@ bool CustomTypeface::writeToStream (OutputStream& outputStream) out.writeInt (numKerningPairs); - for (i = 0; i < glyphs.size(); ++i) + for (int i = 0; i < glyphs.size(); ++i) { const GlyphInfo* const g = glyphs.getUnchecked (i); @@ -310,23 +307,22 @@ float CustomTypeface::getHeightToPointsFactor() const { return ascent; } float CustomTypeface::getStringWidth (const String& text) { float x = 0; - String::CharPointerType t (text.getCharPointer()); - while (! t.isEmpty()) + for (String::CharPointerType t (text.getCharPointer()); ! t.isEmpty();) { const juce_wchar c = t.getAndAdvance(); - const GlyphInfo* const glyph = findGlyph (c, true); - if (glyph == nullptr) + if (const GlyphInfo* const glyph = findGlyph (c, true)) + { + x += glyph->getHorizontalSpacing (*t); + } + else { const Typeface::Ptr fallbackTypeface (Typeface::getFallbackTypeface()); if (fallbackTypeface != nullptr && fallbackTypeface != this) x += fallbackTypeface->getStringWidth (String::charToString (c)); } - - if (glyph != nullptr) - x += glyph->getHorizontalSpacing (*t); } return x; @@ -336,16 +332,22 @@ void CustomTypeface::getGlyphPositions (const String& text, Array <int>& resultG { xOffsets.add (0); float x = 0; - String::CharPointerType t (text.getCharPointer()); - while (! t.isEmpty()) + for (String::CharPointerType t (text.getCharPointer()); ! t.isEmpty();) { + float width = 0.0f; + int glyphChar = 0; + const juce_wchar c = t.getAndAdvance(); - const GlyphInfo* const glyph = findGlyph (c, true); - if (glyph == nullptr) + if (const GlyphInfo* const glyph = findGlyph (c, true)) { - const Typeface::Ptr fallbackTypeface (Typeface::getFallbackTypeface()); + width = glyph->getHorizontalSpacing (*t); + glyphChar = (int) glyph->character; + } + else + { + const Typeface::Ptr fallbackTypeface (getFallbackTypeface()); if (fallbackTypeface != nullptr && fallbackTypeface != this) { @@ -355,58 +357,50 @@ void CustomTypeface::getGlyphPositions (const String& text, Array <int>& resultG if (subGlyphs.size() > 0) { - resultGlyphs.add (subGlyphs.getFirst()); - x += subOffsets[1]; - xOffsets.add (x); + glyphChar = subGlyphs.getFirst(); + width = subOffsets[1]; } } } - if (glyph != nullptr) - { - x += glyph->getHorizontalSpacing (*t); - resultGlyphs.add ((int) glyph->character); - xOffsets.add (x); - } + x += width; + resultGlyphs.add (glyphChar); + xOffsets.add (x); } } bool CustomTypeface::getOutlineForGlyph (int glyphNumber, Path& path) { - const GlyphInfo* const glyph = findGlyph ((juce_wchar) glyphNumber, true); - - if (glyph == nullptr) - { - const Typeface::Ptr fallbackTypeface (Typeface::getFallbackTypeface()); - - if (fallbackTypeface != nullptr && fallbackTypeface != this) - fallbackTypeface->getOutlineForGlyph (glyphNumber, path); - } - - if (glyph != nullptr) + if (const GlyphInfo* const glyph = findGlyph ((juce_wchar) glyphNumber, true)) { path = glyph->path; return true; } + const Typeface::Ptr fallbackTypeface (getFallbackTypeface()); + + if (fallbackTypeface != nullptr && fallbackTypeface != this) + return fallbackTypeface->getOutlineForGlyph (glyphNumber, path); + return false; } EdgeTable* CustomTypeface::getEdgeTableForGlyph (int glyphNumber, const AffineTransform& transform) { - const GlyphInfo* const glyph = findGlyph ((juce_wchar) glyphNumber, true); - - if (glyph == nullptr) + if (const GlyphInfo* const glyph = findGlyph ((juce_wchar) glyphNumber, true)) { - const Typeface::Ptr fallbackTypeface (Typeface::getFallbackTypeface()); + if (! glyph->path.isEmpty()) + return new EdgeTable (glyph->path.getBoundsTransformed (transform) + .getSmallestIntegerContainer().expanded (1, 0), + glyph->path, transform); + } + else + { + const Typeface::Ptr fallbackTypeface (getFallbackTypeface()); if (fallbackTypeface != nullptr && fallbackTypeface != this) return fallbackTypeface->getEdgeTableForGlyph (glyphNumber, transform); } - if (glyph != nullptr && ! glyph->path.isEmpty()) - return new EdgeTable (glyph->path.getBoundsTransformed (transform).getSmallestIntegerContainer().expanded (1, 0), - glyph->path, transform); - return nullptr; } diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.h b/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.h index 5631b5ae3..a9e7aa637 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.h +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.cpp b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.cpp index 839cfdd1d..644fb593d 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.cpp +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.h b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.h index e13b773f9..9e9a1d75c 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.h +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp b/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp index 2783dc8d2..f0986a983 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.h b/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.h index 9e49d54fb..21b65d434 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.h +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_TextLayout.cpp b/JuceLibraryCode/modules/juce_graphics/fonts/juce_TextLayout.cpp index 2cef4c5a2..251e759d9 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_TextLayout.cpp +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_TextLayout.cpp @@ -1,29 +1,28 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ -TextLayout::Glyph::Glyph (const int glyphCode_, const Point<float>& anchor_, float width_) noexcept +TextLayout::Glyph::Glyph (const int glyphCode_, Point<float> anchor_, float width_) noexcept : glyphCode (glyphCode_), anchor (anchor_), width (width_) { } @@ -49,7 +48,7 @@ TextLayout::Run::Run() noexcept { } -TextLayout::Run::Run (const Range<int>& range, const int numGlyphsToPreallocate) +TextLayout::Run::Run (Range<int> range, const int numGlyphsToPreallocate) : colour (0xff000000), stringRange (range) { glyphs.ensureStorageAllocated (numGlyphsToPreallocate); @@ -71,7 +70,7 @@ TextLayout::Line::Line() noexcept { } -TextLayout::Line::Line (const Range<int>& stringRange_, const Point<float>& lineOrigin_, +TextLayout::Line::Line (Range<int> stringRange_, Point<float> lineOrigin_, const float ascent_, const float descent_, const float leading_, const int numRunsToPreallocate) : stringRange (stringRange_), lineOrigin (lineOrigin_), @@ -105,7 +104,7 @@ Range<float> TextLayout::Line::getLineBoundsX() const noexcept float minX = run.glyphs.getReference(0).anchor.x; float maxX = minX; - for (int j = run.glyphs.size(); --j > 0;) + for (int j = run.glyphs.size(); --j >= 0;) { const Glyph& glyph = run.glyphs.getReference (j); const float x = glyph.anchor.x; @@ -251,7 +250,7 @@ namespace TextLayoutHelpers struct RunAttribute { - RunAttribute (const FontAndColour& fc, const Range<int>& r) noexcept + RunAttribute (const FontAndColour& fc, const Range<int> r) noexcept : fontAndColour (fc), range (r) {} @@ -415,7 +414,7 @@ namespace TextLayoutHelpers return CharacterFunctions::isWhitespace (c) ? 2 : 1; } - void appendText (const AttributedString& text, const Range<int>& stringRange, + void appendText (const AttributedString& text, const Range<int> stringRange, const Font& font, const Colour& colour) { const String stringText (text.getText().substring (stringRange.getStart(), stringRange.getEnd())); @@ -526,7 +525,7 @@ namespace TextLayoutHelpers } } - if (i > 0 && (newFontAndColour != lastFontAndColour || i == stringLength - 1)) + if ((i > 0 && newFontAndColour != lastFontAndColour) || i == stringLength - 1) { runAttributes.add (RunAttribute (lastFontAndColour, Range<int> (rangeStart, (i < stringLength - 1) ? i : (i + 1)))); diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_TextLayout.h b/JuceLibraryCode/modules/juce_graphics/fonts/juce_TextLayout.h index a611be098..82bd2b4dc 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_TextLayout.h +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_TextLayout.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -82,7 +81,7 @@ public: class JUCE_API Glyph { public: - Glyph (int glyphCode, const Point<float>& anchor, float width) noexcept; + Glyph (int glyphCode, Point<float> anchor, float width) noexcept; Glyph (const Glyph&) noexcept; Glyph& operator= (const Glyph&) noexcept; ~Glyph() noexcept; @@ -108,7 +107,7 @@ public: public: Run() noexcept; Run (const Run&); - Run (const Range<int>& stringRange, int numGlyphsToPreallocate); + Run (Range<int> stringRange, int numGlyphsToPreallocate); ~Run() noexcept; Font font; /**< The run's font. */ @@ -128,7 +127,7 @@ public: public: Line() noexcept; Line (const Line&); - Line (const Range<int>& stringRange, const Point<float>& lineOrigin, + Line (Range<int> stringRange, Point<float> lineOrigin, float ascent, float descent, float leading, int numRunsToPreallocate); ~Line() noexcept; diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Typeface.cpp b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Typeface.cpp index c845384ae..032ee318d 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Typeface.cpp +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Typeface.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -58,10 +57,38 @@ struct FontStyleHelpers || family == Font::getDefaultMonospacedFontName(); } - static String getConcreteFamilyNameFromPlaceholder (const String& family) + struct ConcreteFamilyNames { - const Font f (family, Font::getDefaultStyle(), 15.0f); - return Font::getDefaultTypefaceForFont (f)->getName(); + ConcreteFamilyNames() + : sans (findName (Font::getDefaultSansSerifFontName())), + serif (findName (Font::getDefaultSerifFontName())), + mono (findName (Font::getDefaultMonospacedFontName())) + { + } + + String lookUp (const String& placeholder) + { + if (placeholder == Font::getDefaultSansSerifFontName()) return sans; + if (placeholder == Font::getDefaultSerifFontName()) return serif; + if (placeholder == Font::getDefaultMonospacedFontName()) return mono; + + return findName (placeholder); + } + + private: + static String findName (const String& placeholder) + { + const Font f (placeholder, Font::getDefaultStyle(), 15.0f); + return Font::getDefaultTypefaceForFont (f)->getName(); + } + + String sans, serif, mono; + }; + + static String getConcreteFamilyNameFromPlaceholder (const String& placeholder) + { + static ConcreteFamilyNames names; + return names.lookUp (placeholder); } static String getConcreteFamilyName (const Font& font) diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Typeface.h b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Typeface.h index 9a9411b56..d1c7a4602 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Typeface.h +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Typeface.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -129,6 +128,11 @@ public: /** Clears any fonts that are currently cached in memory. */ static void clearTypefaceCache(); + /** On some platforms, this allows a specific path to be scanned. + Currently only available when using FreeType. + */ + static void scanFolderForFonts (const File& folder); + protected: //============================================================================== String name, style; diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.cpp index 8cdfd28e5..3d9369291 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -105,6 +104,12 @@ AffineTransform AffineTransform::translation (const float dx, const float dy) no 0, 1.0f, dy); } +AffineTransform AffineTransform::withAbsoluteTranslation (const float tx, const float ty) const noexcept +{ + return AffineTransform (mat00, mat01, tx, + mat10, mat11, ty); +} + AffineTransform AffineTransform::rotated (const float rad) const noexcept { const float cosRad = std::cos (rad); diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.h index f9556d5f6..7385b33c8 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -133,6 +132,10 @@ public: static AffineTransform translation (float deltaX, float deltaY) noexcept; + /** Returns a copy of this transform with the specified translation matrix values. */ + AffineTransform withAbsoluteTranslation (float translationX, + float translationY) const noexcept; + /** Returns a transform which is the same as this one followed by a rotation. The rotation is specified by a number of radians to rotate clockwise, centred around diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_BorderSize.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_BorderSize.h index 2ecfaaea7..ed03c07cf 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_BorderSize.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_BorderSize.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -150,8 +149,6 @@ public: private: //============================================================================== ValueType top, left, bottom, right; - - JUCE_LEAK_DETECTOR (BorderSize) }; diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_EdgeTable.cpp b/JuceLibraryCode/modules/juce_graphics/geometry/juce_EdgeTable.cpp index af9781a36..0f697c9a9 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_EdgeTable.cpp +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_EdgeTable.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_EdgeTable.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_EdgeTable.h index bfe38950c..d377b9519 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_EdgeTable.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_EdgeTable.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Line.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Line.h index f2292e7f9..4fd5c096f 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Line.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Line.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -66,8 +65,8 @@ public: } /** Creates a line from its start and end points. */ - Line (const Point<ValueType>& startPoint, - const Point<ValueType>& endPoint) noexcept + Line (const Point<ValueType> startPoint, + const Point<ValueType> endPoint) noexcept : start (startPoint), end (endPoint) { @@ -98,10 +97,10 @@ public: inline ValueType getEndY() const noexcept { return end.y; } /** Returns the line's start point. */ - inline const Point<ValueType>& getStart() const noexcept { return start; } + inline Point<ValueType> getStart() const noexcept { return start; } /** Returns the line's end point. */ - inline const Point<ValueType>& getEnd() const noexcept { return end; } + inline Point<ValueType> getEnd() const noexcept { return end; } /** Changes this line's start point */ void setStart (ValueType newStartX, ValueType newStartY) noexcept { start.setXY (newStartX, newStartY); } @@ -110,10 +109,10 @@ public: void setEnd (ValueType newEndX, ValueType newEndY) noexcept { end.setXY (newEndX, newEndY); } /** Changes this line's start point */ - void setStart (const Point<ValueType>& newStart) noexcept { start = newStart; } + void setStart (const Point<ValueType> newStart) noexcept { start = newStart; } /** Changes this line's end point */ - void setEnd (const Point<ValueType>& newEnd) noexcept { end = newEnd; } + void setEnd (const Point<ValueType> newEnd) noexcept { end = newEnd; } /** Returns a line that is the same as this one, but with the start and end reversed, */ const Line reversed() const noexcept { return Line (end, start); } @@ -250,7 +249,7 @@ public: @returns the point's distance from the line @see getPositionAlongLineOfNearestPoint */ - ValueType getDistanceFromPoint (const Point<ValueType>& targetPoint, + ValueType getDistanceFromPoint (const Point<ValueType> targetPoint, Point<ValueType>& pointOnLine) const noexcept { const Point<ValueType> delta (end - start); @@ -291,7 +290,7 @@ public: turn this number into a position, use getPointAlongLineProportionally(). @see getDistanceFromPoint, getPointAlongLineProportionally */ - ValueType findNearestProportionalPositionTo (const Point<ValueType>& point) const noexcept + ValueType findNearestProportionalPositionTo (const Point<ValueType> point) const noexcept { const Point<ValueType> delta (end - start); const double length = delta.x * delta.x + delta.y * delta.y; @@ -305,7 +304,7 @@ public: /** Finds the point on this line which is nearest to a given point. @see getDistanceFromPoint, findNearestProportionalPositionTo */ - Point<ValueType> findNearestPointTo (const Point<ValueType>& point) const noexcept + Point<ValueType> findNearestPointTo (const Point<ValueType> point) const noexcept { return getPointAlongLineProportionally (findNearestProportionalPositionTo (point)); } @@ -316,7 +315,7 @@ public: coordinate of this line at the given x (assuming the line extends infinitely in both directions). */ - bool isPointAbove (const Point<ValueType>& point) const noexcept + bool isPointAbove (const Point<ValueType> point) const noexcept { return start.x != end.x && point.y < ((end.y - start.y) @@ -349,8 +348,8 @@ private: //============================================================================== Point<ValueType> start, end; - static bool findIntersection (const Point<ValueType>& p1, const Point<ValueType>& p2, - const Point<ValueType>& p3, const Point<ValueType>& p4, + static bool findIntersection (const Point<ValueType> p1, const Point<ValueType> p2, + const Point<ValueType> p3, const Point<ValueType> p4, Point<ValueType>& intersection) noexcept { if (p2 == p3) diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.cpp b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.cpp index a04108464..ddf02cdae 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.cpp +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -271,7 +270,7 @@ void Path::startNewSubPath (const float x, const float y) data.elements [numElements++] = y; } -void Path::startNewSubPath (const Point<float>& start) +void Path::startNewSubPath (const Point<float> start) { startNewSubPath (start.x, start.y); } @@ -292,7 +291,7 @@ void Path::lineTo (const float x, const float y) bounds.extend (x, y); } -void Path::lineTo (const Point<float>& end) +void Path::lineTo (const Point<float> end) { lineTo (end.x, end.y); } @@ -317,8 +316,8 @@ void Path::quadraticTo (const float x1, const float y1, bounds.extend (x1, y1, x2, y2); } -void Path::quadraticTo (const Point<float>& controlPoint, - const Point<float>& endPoint) +void Path::quadraticTo (const Point<float> controlPoint, + const Point<float> endPoint) { quadraticTo (controlPoint.x, controlPoint.y, endPoint.x, endPoint.y); @@ -349,9 +348,9 @@ void Path::cubicTo (const float x1, const float y1, bounds.extend (x3, y3); } -void Path::cubicTo (const Point<float>& controlPoint1, - const Point<float>& controlPoint2, - const Point<float>& endPoint) +void Path::cubicTo (const Point<float> controlPoint1, + const Point<float> controlPoint2, + const Point<float> endPoint) { cubicTo (controlPoint1.x, controlPoint1.y, controlPoint2.x, controlPoint2.y, @@ -676,7 +675,7 @@ void Path::addArrow (const Line<float>& line, float lineThickness, closeSubPath(); } -void Path::addPolygon (const Point<float>& centre, const int numberOfSides, +void Path::addPolygon (const Point<float> centre, const int numberOfSides, const float radius, const float startAngle) { jassert (numberOfSides > 1); // this would be silly. @@ -700,7 +699,7 @@ void Path::addPolygon (const Point<float>& centre, const int numberOfSides, } } -void Path::addStar (const Point<float>& centre, const int numberOfPoints, +void Path::addStar (const Point<float> centre, const int numberOfPoints, const float innerRadius, const float outerRadius, const float startAngle) { jassert (numberOfPoints > 1); // this would be silly. @@ -728,7 +727,7 @@ void Path::addStar (const Point<float>& centre, const int numberOfPoints, void Path::addBubble (const Rectangle<float>& bodyArea, const Rectangle<float>& maximumArea, - const Point<float>& arrowTip, + const Point<float> arrowTip, const float cornerSize, const float arrowBaseWidth) { @@ -1023,7 +1022,7 @@ bool Path::contains (const float x, const float y, const float tolerance) const : ((negativeCrossings + positiveCrossings) & 1) != 0; } -bool Path::contains (const Point<float>& point, const float tolerance) const +bool Path::contains (const Point<float> point, const float tolerance) const { return contains (point.x, point.y, tolerance); } @@ -1100,7 +1099,7 @@ Point<float> Path::getPointAlongPath (float distanceFromStart, const AffineTrans return Point<float> (i.x2, i.y2); } -float Path::getNearestPoint (const Point<float>& targetPoint, Point<float>& pointOnPath, +float Path::getNearestPoint (const Point<float> targetPoint, Point<float>& pointOnPath, const AffineTransform& transform) const { PathFlatteningIterator i (*this, transform); diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.h index 8df5cbd38..39861afcf 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -134,7 +133,7 @@ public: @see closeSubPath, setUsingNonZeroWinding */ - bool contains (const Point<float>& point, + bool contains (const Point<float> point, float tolerance = 1.0f) const; /** Checks whether a line crosses the path. @@ -181,7 +180,7 @@ public: This sets pointOnPath to the nearest point, and returns the distance of this point from the start of the path. */ - float getNearestPoint (const Point<float>& targetPoint, + float getNearestPoint (const Point<float> targetPoint, Point<float>& pointOnPath, const AffineTransform& transform = AffineTransform::identity) const; @@ -213,7 +212,7 @@ public: @see lineTo, quadraticTo, cubicTo, closeSubPath */ - void startNewSubPath (const Point<float>& start); + void startNewSubPath (const Point<float> start); /** Closes a the current sub-path with a line back to its start-point. @@ -249,7 +248,7 @@ public: @see startNewSubPath, quadraticTo, cubicTo, closeSubPath */ - void lineTo (const Point<float>& end); + void lineTo (const Point<float> end); /** Adds a quadratic bezier curve from the shape's last position to a new position. @@ -274,8 +273,8 @@ public: @see startNewSubPath, lineTo, cubicTo, closeSubPath */ - void quadraticTo (const Point<float>& controlPoint, - const Point<float>& endPoint); + void quadraticTo (const Point<float> controlPoint, + const Point<float> endPoint); /** Adds a cubic bezier curve from the shape's last position to a new position. @@ -302,9 +301,9 @@ public: @see startNewSubPath, lineTo, quadraticTo, closeSubPath */ - void cubicTo (const Point<float>& controlPoint1, - const Point<float>& controlPoint2, - const Point<float>& endPoint); + void cubicTo (const Point<float> controlPoint1, + const Point<float> controlPoint2, + const Point<float> endPoint); /** Returns the last point that was added to the path by one of the drawing methods. */ @@ -512,7 +511,7 @@ public: /** Adds a polygon shape to the path. @see addStar */ - void addPolygon (const Point<float>& centre, + void addPolygon (const Point<float> centre, int numberOfSides, float radius, float startAngle = 0.0f); @@ -520,7 +519,7 @@ public: /** Adds a star shape to the path. @see addPolygon */ - void addStar (const Point<float>& centre, + void addStar (const Point<float> centre, int numberOfPoints, float innerRadius, float outerRadius, @@ -538,7 +537,7 @@ public: */ void addBubble (const Rectangle<float>& bodyArea, const Rectangle<float>& maximumArea, - const Point<float>& arrowTipPosition, + const Point<float> arrowTipPosition, const float cornerSize, const float arrowBaseWidth); diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathIterator.cpp b/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathIterator.cpp index 849708ef6..965826456 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathIterator.cpp +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathIterator.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathIterator.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathIterator.h index d53a592b8..98f3bf0f2 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathIterator.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathIterator.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathStrokeType.cpp b/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathStrokeType.cpp index 059974a2a..3e5e373e7 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathStrokeType.cpp +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathStrokeType.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathStrokeType.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathStrokeType.h index 2d611c319..3f6ca48db 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathStrokeType.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathStrokeType.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Point.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Point.h index 1f7b99349..40e0f7f94 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Point.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Point.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -52,15 +51,12 @@ public: /** Creates a point from an (x, y) position. */ Point (const ValueType initialX, const ValueType initialY) noexcept : x (initialX), y (initialY) {} - /** Destructor. */ - ~Point() noexcept {} - //============================================================================== /** Copies this point from another one. */ Point& operator= (const Point& other) noexcept { x = other.x; y = other.y; return *this; } - inline bool operator== (const Point& other) const noexcept { return x == other.x && y == other.y; } - inline bool operator!= (const Point& other) const noexcept { return x != other.x || y != other.y; } + inline bool operator== (Point other) const noexcept { return x == other.x && y == other.y; } + inline bool operator!= (Point other) const noexcept { return x != other.x || y != other.y; } /** Returns true if the point is (0, 0). */ bool isOrigin() const noexcept { return x == ValueType() && y == ValueType(); } @@ -93,16 +89,16 @@ public: Point translated (const ValueType xDelta, const ValueType yDelta) const noexcept { return Point (x + xDelta, y + yDelta); } /** Adds two points together. */ - Point operator+ (const Point& other) const noexcept { return Point (x + other.x, y + other.y); } + Point operator+ (Point other) const noexcept { return Point (x + other.x, y + other.y); } /** Adds another point's co-ordinates to this one. */ - Point& operator+= (const Point& other) noexcept { x += other.x; y += other.y; return *this; } + Point& operator+= (Point other) noexcept { x += other.x; y += other.y; return *this; } /** Subtracts one points from another. */ - Point operator- (const Point& other) const noexcept { return Point (x - other.x, y - other.y); } + Point operator- (Point other) const noexcept { return Point (x - other.x, y - other.y); } /** Subtracts another point's co-ordinates to this one. */ - Point& operator-= (const Point& other) noexcept { x -= other.x; y -= other.y; return *this; } + Point& operator-= (Point other) noexcept { x -= other.x; y -= other.y; return *this; } /** Returns a point whose coordinates are multiplied by a given value. */ Point operator* (const ValueType multiplier) const noexcept { return Point (x * multiplier, y * multiplier); } @@ -123,7 +119,7 @@ public: ValueType getDistanceFromOrigin() const noexcept { return juce_hypot (x, y); } /** Returns the straight-line distance between this point and another one. */ - ValueType getDistanceFrom (const Point& other) const noexcept { return juce_hypot (x - other.x, y - other.y); } + ValueType getDistanceFrom (Point other) const noexcept { return juce_hypot (x - other.x, y - other.y); } /** This type will be double if the Point's type is double, otherwise it will be float. */ typedef typename TypeHelpers::SmallestFloatType<ValueType>::type FloatType; @@ -133,7 +129,7 @@ public: The return value is the number of radians clockwise from the 12 o'clock direction, where this point is the centre and the other point is on the circumference. */ - FloatType getAngleToPoint (const Point& other) const noexcept + FloatType getAngleToPoint (Point other) const noexcept { return static_cast<FloatType> (std::atan2 (other.x - x, y - other.y)); } /** Taking this point to be the centre of a circle, this returns a point on its circumference. @@ -164,6 +160,9 @@ public: { return Point (transform.mat00 * x + transform.mat01 * y + transform.mat02, transform.mat10 * x + transform.mat11 * y + transform.mat12); } + /** Returns the dot-product of two points (x1 * x2 + y1 * y2). */ + FloatType getDotProduct (Point other) const noexcept { return x * other.x + y * other.y; } + /** Casts this point to a Point<int> object. */ Point<int> toInt() const noexcept { return Point<int> (static_cast <int> (x), static_cast<int> (y)); } diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle.h index 13f7c0689..68768a057 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -70,7 +69,7 @@ public: } /** Creates a Rectangle from the positions of two opposite corners. */ - Rectangle (const Point<ValueType>& corner1, const Point<ValueType>& corner2) noexcept + Rectangle (const Point<ValueType> corner1, const Point<ValueType> corner2) noexcept : pos (jmin (corner1.x, corner2.x), jmin (corner1.y, corner2.y)), w (corner1.x - corner2.x), @@ -139,16 +138,16 @@ public: //============================================================================== /** Returns the rectangle's top-left position as a Point. */ - inline const Point<ValueType>& getPosition() const noexcept { return pos; } + inline Point<ValueType> getPosition() const noexcept { return pos; } /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ - inline void setPosition (const Point<ValueType>& newPos) noexcept { pos = newPos; } + inline void setPosition (const Point<ValueType> newPos) noexcept { pos = newPos; } /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ inline void setPosition (const ValueType newX, const ValueType newY) noexcept { pos.setXY (newX, newY); } /** Returns the rectangle's top-left position as a Point. */ - const Point<ValueType>& getTopLeft() const noexcept { return pos; } + Point<ValueType> getTopLeft() const noexcept { return pos; } /** Returns the rectangle's top-right position as a Point. */ Point<ValueType> getTopRight() const noexcept { return Point<ValueType> (pos.x + w, pos.y); } @@ -188,7 +187,7 @@ public: Rectangle withPosition (const ValueType newX, const ValueType newY) const noexcept { return Rectangle (newX, newY, w, h); } /** Returns a rectangle with the same size as this one, but a new position. */ - Rectangle withPosition (const Point<ValueType>& newPos) const noexcept { return Rectangle (newPos.x, newPos.y, w, h); } + Rectangle withPosition (const Point<ValueType> newPos) const noexcept { return Rectangle (newPos.x, newPos.y, w, h); } /** Returns a rectangle whose size is the same as this one, but whose top-left position is (0, 0). */ Rectangle withZeroOrigin() const noexcept { return Rectangle (w, h); } @@ -267,26 +266,26 @@ public: } /** Returns a rectangle which is the same as this one moved by a given amount. */ - Rectangle operator+ (const Point<ValueType>& deltaPosition) const noexcept + Rectangle operator+ (const Point<ValueType> deltaPosition) const noexcept { return Rectangle (pos.x + deltaPosition.x, pos.y + deltaPosition.y, w, h); } /** Moves this rectangle by a given amount. */ - Rectangle& operator+= (const Point<ValueType>& deltaPosition) noexcept + Rectangle& operator+= (const Point<ValueType> deltaPosition) noexcept { pos += deltaPosition; return *this; } /** Returns a rectangle which is the same as this one moved by a given amount. */ - Rectangle operator- (const Point<ValueType>& deltaPosition) const noexcept + Rectangle operator- (const Point<ValueType> deltaPosition) const noexcept { return Rectangle (pos.x - deltaPosition.x, pos.y - deltaPosition.y, w, h); } /** Moves this rectangle by a given amount. */ - Rectangle& operator-= (const Point<ValueType>& deltaPosition) noexcept + Rectangle& operator-= (const Point<ValueType> deltaPosition) noexcept { pos -= deltaPosition; return *this; @@ -459,7 +458,7 @@ public: } /** Returns true if this co-ordinate is inside the rectangle. */ - bool contains (const Point<ValueType>& point) const noexcept + bool contains (const Point<ValueType> point) const noexcept { return point.x >= pos.x && point.y >= pos.y && point.x < pos.x + w && point.y < pos.y + h; } @@ -472,7 +471,7 @@ public: } /** Returns the nearest point to the specified point that lies within this rectangle. */ - Point<ValueType> getConstrainedPoint (const Point<ValueType>& point) const noexcept + Point<ValueType> getConstrainedPoint (const Point<ValueType> point) const noexcept { return Point<ValueType> (jlimit (pos.x, pos.x + w, point.x), jlimit (pos.y, pos.y + h, point.y)); @@ -496,7 +495,8 @@ public: && pos.y + h > other.pos.y && pos.x < other.pos.x + other.w && pos.y < other.pos.y + other.h - && w > ValueType() && h > ValueType(); + && w > ValueType() && h > ValueType() + && other.w > ValueType() && other.h > ValueType(); } /** Returns the region that is the overlap between this and another rectangle. diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_RectangleList.cpp b/JuceLibraryCode/modules/juce_graphics/geometry/juce_RectangleList.cpp index 4a30597c3..80fd0a7e2 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_RectangleList.cpp +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_RectangleList.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_RectangleList.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_RectangleList.h index 5dfdd4bc7..7f38b45c1 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_RectangleList.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_RectangleList.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_GIFLoader.cpp b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_GIFLoader.cpp index 8b770c167..2c9066f5b 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_GIFLoader.cpp +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_GIFLoader.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp index 084791d0d..2d2a6a487 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -229,15 +228,10 @@ bool JPEGImageFormat::canUnderstand (InputStream& in) const int bytesNeeded = 10; uint8 header [bytesNeeded]; - if (in.read (header, bytesNeeded) == bytesNeeded) - { - return header[0] == 0xff + return in.read (header, bytesNeeded) == bytesNeeded + && header[0] == 0xff && header[1] == 0xd8 - && header[2] == 0xff - && (header[3] == 0xe0 || header[3] == 0xe1); - } - - return false; + && header[2] == 0xff; } #if JUCE_USING_COREIMAGE_LOADER @@ -351,7 +345,8 @@ bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out) using namespace jpeglibNamespace; using namespace JPEGHelpers; - struct jpeg_compress_struct jpegCompStruct; + jpeg_compress_struct jpegCompStruct; + zerostruct (jpegCompStruct); jpeg_create_compress (&jpegCompStruct); struct jpeg_error_mgr jerr; diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_PNGLoader.cpp b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_PNGLoader.cpp index d36c70fb9..36fb799a1 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_PNGLoader.cpp +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_PNGLoader.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -61,9 +60,200 @@ namespace pnglibNamespace #endif using std::abs; - #define PNG_INTERNAL #define NO_DUMMY_DECL - #define PNG_SETJMP_NOT_SUPPORTED + #define PNGLCONF_H 1 + + #if JUCE_ANDROID + #define PNG_ARM_NEON_SUPPORTED + #endif + + #define PNG_16BIT_SUPPORTED + #define PNG_ALIGNED_MEMORY_SUPPORTED + #define PNG_BENIGN_ERRORS_SUPPORTED + #define PNG_BENIGN_READ_ERRORS_SUPPORTED + #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED + #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED + #define PNG_COLORSPACE_SUPPORTED + #define PNG_CONSOLE_IO_SUPPORTED + #define PNG_EASY_ACCESS_SUPPORTED + #define PNG_FIXED_POINT_SUPPORTED + #define PNG_FLOATING_ARITHMETIC_SUPPORTED + #define PNG_FLOATING_POINT_SUPPORTED + #define PNG_FORMAT_AFIRST_SUPPORTED + #define PNG_FORMAT_BGR_SUPPORTED + #define PNG_GAMMA_SUPPORTED + #define PNG_GET_PALETTE_MAX_SUPPORTED + #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED + #define PNG_INCH_CONVERSIONS_SUPPORTED + #define PNG_INFO_IMAGE_SUPPORTED + #define PNG_IO_STATE_SUPPORTED + #define PNG_MNG_FEATURES_SUPPORTED + #define PNG_POINTER_INDEXING_SUPPORTED + #define PNG_PROGRESSIVE_READ_SUPPORTED + #define PNG_READ_16BIT_SUPPORTED + #define PNG_READ_ALPHA_MODE_SUPPORTED + #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED + #define PNG_READ_BACKGROUND_SUPPORTED + #define PNG_READ_BGR_SUPPORTED + #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED + #define PNG_READ_COMPOSITE_NODIV_SUPPORTED + #define PNG_READ_COMPRESSED_TEXT_SUPPORTED + #define PNG_READ_EXPAND_16_SUPPORTED + #define PNG_READ_EXPAND_SUPPORTED + #define PNG_READ_FILLER_SUPPORTED + #define PNG_READ_GAMMA_SUPPORTED + #define PNG_READ_GET_PALETTE_MAX_SUPPORTED + #define PNG_READ_GRAY_TO_RGB_SUPPORTED + #define PNG_READ_INTERLACING_SUPPORTED + #define PNG_READ_INT_FUNCTIONS_SUPPORTED + #define PNG_READ_INVERT_ALPHA_SUPPORTED + #define PNG_READ_INVERT_SUPPORTED + #define PNG_READ_OPT_PLTE_SUPPORTED + #define PNG_READ_PACKSWAP_SUPPORTED + #define PNG_READ_PACK_SUPPORTED + #define PNG_READ_QUANTIZE_SUPPORTED + #define PNG_READ_RGB_TO_GRAY_SUPPORTED + #define PNG_READ_SCALE_16_TO_8_SUPPORTED + #define PNG_READ_SHIFT_SUPPORTED + #define PNG_READ_STRIP_16_TO_8_SUPPORTED + #define PNG_READ_STRIP_ALPHA_SUPPORTED + #define PNG_READ_SUPPORTED + #define PNG_READ_SWAP_ALPHA_SUPPORTED + #define PNG_READ_SWAP_SUPPORTED + #define PNG_READ_TEXT_SUPPORTED + #define PNG_READ_TRANSFORMS_SUPPORTED + #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED + #define PNG_READ_USER_CHUNKS_SUPPORTED + #define PNG_READ_USER_TRANSFORM_SUPPORTED + #define PNG_READ_bKGD_SUPPORTED + #define PNG_READ_cHRM_SUPPORTED + #define PNG_READ_gAMA_SUPPORTED + #define PNG_READ_hIST_SUPPORTED + #define PNG_READ_iCCP_SUPPORTED + #define PNG_READ_iTXt_SUPPORTED + #define PNG_READ_oFFs_SUPPORTED + #define PNG_READ_pCAL_SUPPORTED + #define PNG_READ_pHYs_SUPPORTED + #define PNG_READ_sBIT_SUPPORTED + #define PNG_READ_sCAL_SUPPORTED + #define PNG_READ_sPLT_SUPPORTED + #define PNG_READ_sRGB_SUPPORTED + #define PNG_READ_tEXt_SUPPORTED + #define PNG_READ_tIME_SUPPORTED + #define PNG_READ_tRNS_SUPPORTED + #define PNG_READ_zTXt_SUPPORTED + #define PNG_SAVE_INT_32_SUPPORTED + #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + #define PNG_SEQUENTIAL_READ_SUPPORTED + #define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED + #define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED + #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + #define PNG_SET_USER_LIMITS_SUPPORTED + #define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED + #define PNG_SIMPLIFIED_READ_BGR_SUPPORTED + #define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED + #define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED + #define PNG_STDIO_SUPPORTED + #define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED + #define PNG_TEXT_SUPPORTED + #define PNG_TIME_RFC1123_SUPPORTED + #define PNG_UNKNOWN_CHUNKS_SUPPORTED + #define PNG_USER_CHUNKS_SUPPORTED + #define PNG_USER_LIMITS_SUPPORTED + #define PNG_USER_TRANSFORM_INFO_SUPPORTED + #define PNG_USER_TRANSFORM_PTR_SUPPORTED + #define PNG_WARNINGS_SUPPORTED + #define PNG_WRITE_16BIT_SUPPORTED + #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED + #define PNG_WRITE_BGR_SUPPORTED + #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED + #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED + #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED + #define PNG_WRITE_FILLER_SUPPORTED + #define PNG_WRITE_FILTER_SUPPORTED + #define PNG_WRITE_FLUSH_SUPPORTED + #define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED + #define PNG_WRITE_INTERLACING_SUPPORTED + #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED + #define PNG_WRITE_INVERT_ALPHA_SUPPORTED + #define PNG_WRITE_INVERT_SUPPORTED + #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED + #define PNG_WRITE_PACKSWAP_SUPPORTED + #define PNG_WRITE_PACK_SUPPORTED + #define PNG_WRITE_SHIFT_SUPPORTED + #define PNG_WRITE_SUPPORTED + #define PNG_WRITE_SWAP_ALPHA_SUPPORTED + #define PNG_WRITE_SWAP_SUPPORTED + #define PNG_WRITE_TEXT_SUPPORTED + #define PNG_WRITE_TRANSFORMS_SUPPORTED + #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + #define PNG_WRITE_USER_TRANSFORM_SUPPORTED + #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED + #define PNG_WRITE_bKGD_SUPPORTED + #define PNG_WRITE_cHRM_SUPPORTED + #define PNG_WRITE_gAMA_SUPPORTED + #define PNG_WRITE_hIST_SUPPORTED + #define PNG_WRITE_iCCP_SUPPORTED + #define PNG_WRITE_iTXt_SUPPORTED + #define PNG_WRITE_oFFs_SUPPORTED + #define PNG_WRITE_pCAL_SUPPORTED + #define PNG_WRITE_pHYs_SUPPORTED + #define PNG_WRITE_sBIT_SUPPORTED + #define PNG_WRITE_sCAL_SUPPORTED + #define PNG_WRITE_sPLT_SUPPORTED + #define PNG_WRITE_sRGB_SUPPORTED + #define PNG_WRITE_tEXt_SUPPORTED + #define PNG_WRITE_tIME_SUPPORTED + #define PNG_WRITE_tRNS_SUPPORTED + #define PNG_WRITE_zTXt_SUPPORTED + #define PNG_bKGD_SUPPORTED + #define PNG_cHRM_SUPPORTED + #define PNG_gAMA_SUPPORTED + #define PNG_hIST_SUPPORTED + #define PNG_iCCP_SUPPORTED + #define PNG_iTXt_SUPPORTED + #define PNG_oFFs_SUPPORTED + #define PNG_pCAL_SUPPORTED + #define PNG_pHYs_SUPPORTED + #define PNG_sBIT_SUPPORTED + #define PNG_sCAL_SUPPORTED + #define PNG_sPLT_SUPPORTED + #define PNG_sRGB_SUPPORTED + #define PNG_tEXt_SUPPORTED + #define PNG_tIME_SUPPORTED + #define PNG_tRNS_SUPPORTED + #define PNG_zTXt_SUPPORTED + + #define PNG_STRING_COPYRIGHT ""; + #define PNG_STRING_NEWLINE "\n" + #define PNG_LITERAL_SHARP 0x23 + #define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b + #define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d + + #define PNG_API_RULE 0 + #define PNG_CALLOC_SUPPORTED + #define PNG_COST_SHIFT 3 + #define PNG_DEFAULT_READ_MACROS 1 + #define PNG_GAMMA_THRESHOLD_FIXED 5000 + #define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE + #define PNG_INFLATE_BUF_SIZE 1024 + #define PNG_MAX_GAMMA_8 11 + #define PNG_QUANTIZE_BLUE_BITS 5 + #define PNG_QUANTIZE_GREEN_BITS 5 + #define PNG_QUANTIZE_RED_BITS 5 + #define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) + #define PNG_TEXT_Z_DEFAULT_STRATEGY 0 + #define PNG_WEIGHT_SHIFT 8 + #define PNG_ZBUF_SIZE 8192 + #define PNG_Z_DEFAULT_COMPRESSION (-1) + #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 + #define PNG_Z_DEFAULT_STRATEGY 1 + #define PNG_sCAL_PRECISION 5 + #define PNG_sRGB_PROFILE_CHECKS 2 + + #define png_debug(a, b) + #define png_debug1(a, b, c) + #define png_debug2(a, b, c, d) #include "pnglib/png.h" #include "pnglib/pngconf.h" @@ -127,6 +317,8 @@ namespace PNGHelpers { throw PNGErrorStruct(); } + + static void JUCE_CDECL warningCallback (png_structp, png_const_charp) {} #endif } @@ -160,30 +352,25 @@ Image PNGImageFormat::decodeImage (InputStream& in) using namespace pnglibNamespace; Image image; - png_structp pngReadStruct; - png_infop pngInfoStruct; - - pngReadStruct = png_create_read_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); - - if (pngReadStruct != 0) + if (png_structp pngReadStruct = png_create_read_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0)) { try { - pngInfoStruct = png_create_info_struct (pngReadStruct); + png_infop pngInfoStruct = png_create_info_struct (pngReadStruct); - if (pngInfoStruct == 0) + if (pngInfoStruct == nullptr) { png_destroy_read_struct (&pngReadStruct, 0, 0); return Image::null; } - png_set_error_fn (pngReadStruct, 0, PNGHelpers::errorCallback, PNGHelpers::errorCallback ); + png_set_error_fn (pngReadStruct, 0, PNGHelpers::errorCallback, PNGHelpers::warningCallback); // read the header.. png_set_read_fn (pngReadStruct, &in, PNGHelpers::readCallback); - png_uint_32 width, height; - int bitDepth, colorType, interlaceType; + png_uint_32 width = 0, height = 0; + int bitDepth = 0, colorType = 0, interlaceType; png_read_info (pngReadStruct, pngInfoStruct); @@ -213,21 +400,20 @@ Image PNGImageFormat::decodeImage (InputStream& in) || pngInfoStruct->num_trans > 0; // Load the image into a temp buffer in the pnglib format.. - HeapBlock <uint8> tempBuffer (height * (width << 2)); + const size_t lineStride = width * 4; + HeapBlock <uint8> tempBuffer (height * lineStride); - { - HeapBlock <png_bytep> rows (height); - for (int y = (int) height; --y >= 0;) - rows[y] = (png_bytep) (tempBuffer + (width << 2) * y); + HeapBlock <png_bytep> rows (height); + for (int y = (int) height; --y >= 0;) + rows[y] = (png_bytep) (tempBuffer + lineStride * y); - try - { - png_read_image (pngReadStruct, rows); - png_read_end (pngReadStruct, pngInfoStruct); - } - catch (PNGHelpers::PNGErrorStruct&) - {} + try + { + png_read_image (pngReadStruct, rows); + png_read_end (pngReadStruct, pngInfoStruct); } + catch (PNGHelpers::PNGErrorStruct&) + {} png_destroy_read_struct (&pngReadStruct, &pngInfoStruct, 0); @@ -239,15 +425,11 @@ Image PNGImageFormat::decodeImage (InputStream& in) hasAlphaChan = image.hasAlphaChannel(); // (the native image creator may not give back what we expect) const Image::BitmapData destData (image, Image::BitmapData::writeOnly); - uint8* srcRow = tempBuffer; - uint8* destRow = destData.data; for (int y = 0; y < (int) height; ++y) { - const uint8* src = srcRow; - srcRow += (width << 2); - uint8* dest = destRow; - destRow += destData.lineStride; + const uint8* src = rows[y]; + uint8* dest = destData.getLinePointer (y); if (hasAlphaChan) { @@ -286,14 +468,14 @@ bool PNGImageFormat::writeImageToStream (const Image& image, OutputStream& out) png_structp pngWriteStruct = png_create_write_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); - if (pngWriteStruct == 0) + if (pngWriteStruct == nullptr) return false; png_infop pngInfoStruct = png_create_info_struct (pngWriteStruct); - if (pngInfoStruct == 0) + if (pngInfoStruct == nullptr) { - png_destroy_write_struct (&pngWriteStruct, (png_infopp) 0); + png_destroy_write_struct (&pngWriteStruct, (png_infopp) nullptr); return false; } diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/png.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/png.c index c80e98d0c..e8589daf9 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/png.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/png.c @@ -1,86 +1,20 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.2.21 [October 4, 2007] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ -#define PNG_INTERNAL -#define PNG_NO_EXTERN -#include "png.h" +#include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_21 Your_png_h_is_not_version_1_2_21; - -/* Version information for C files. This had better match the version - * string defined in png.h. */ - -#ifdef PNG_USE_GLOBAL_ARRAYS -/* png_libpng_ver was changed to a function in version 1.0.5c */ -PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; - -#ifdef PNG_READ_SUPPORTED - -/* png_sig was changed to a function in version 1.0.5c */ -/* Place to hold the signature string for a PNG file. */ -PNG_CONST png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; -#endif /* PNG_READ_SUPPORTED */ - -/* Invoke global declarations for constant strings for known chunk types */ -PNG_IHDR; -PNG_IDAT; -PNG_IEND; -PNG_PLTE; -PNG_bKGD; -PNG_cHRM; -PNG_gAMA; -PNG_hIST; -PNG_iCCP; -PNG_iTXt; -PNG_oFFs; -PNG_pCAL; -PNG_sCAL; -PNG_pHYs; -PNG_sBIT; -PNG_sPLT; -PNG_sRGB; -PNG_tEXt; -PNG_tIME; -PNG_tRNS; -PNG_zTXt; - -#ifdef PNG_READ_SUPPORTED -/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - -/* start of interlace block */ -PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - -/* offset to next interlace block */ -PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - -/* start of interlace block in the y direction */ -PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - -/* offset to next interlace block in the y direction */ -PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - -/* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h -PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; -*/ - -/* Mask to determine which pixels are valid in a pass */ -PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; - -/* Mask to determine which pixels to overwrite while displaying */ -PNG_CONST int FARDATA png_pass_dsp_mask[] - = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - -#endif /* PNG_READ_SUPPORTED */ -#endif /* PNG_USE_GLOBAL_ARRAYS */ +typedef png_libpng_version_1_6_1 Your_png_h_is_not_version_1_6_1; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -90,12 +24,15 @@ PNG_CONST int FARDATA png_pass_dsp_mask[] #ifdef PNG_READ_SUPPORTED void PNGAPI -png_set_sig_bytes(png_structp png_ptr, int num_bytes) +png_set_sig_bytes(png_structrp png_ptr, int num_bytes) { - if(png_ptr == NULL) return; - png_debug(1, "in png_set_sig_bytes\n"); + png_debug(1, "in png_set_sig_bytes"); + + if (png_ptr == NULL) + return; + if (num_bytes > 8) - png_error(png_ptr, "Too many bytes for PNG signature."); + png_error(png_ptr, "Too many bytes for PNG signature"); png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); } @@ -106,14 +43,16 @@ png_set_sig_bytes(png_structp png_ptr, int num_bytes) * can simply check the remaining bytes for extra assurance. Returns * an integer less than, equal to, or greater than zero if sig is found, * respectively, to be less than, to match, or be greater than the correct - * PNG signature (this is the same behaviour as strcmp, memcmp, etc). + * PNG signature (this is the same behavior as strcmp, memcmp, etc). */ int PNGAPI -png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) +png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check) { png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + if (num_to_check > 8) num_to_check = 8; + else if (num_to_check < 1) return (-1); @@ -123,84 +62,47 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) if (start + num_to_check > 8) num_to_check = 8 - start; - return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); + return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check))); } -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* (Obsolete) function to check signature bytes. It does not allow one - * to check a partial signature. This function might be removed in the - * future - use png_sig_cmp(). Returns true (nonzero) if the file is PNG. - */ -int PNGAPI -png_check_sig(png_bytep sig, int num) -{ - return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); -} -#endif #endif /* PNG_READ_SUPPORTED */ #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Function to allocate memory for zlib and clear it to 0. */ -#ifdef PNG_1_0_X -voidpf PNGAPI -#else -voidpf /* private */ -#endif -png_zalloc(voidpf png_ptr, uInt items, uInt size) +/* Function to allocate memory for zlib */ +PNG_FUNCTION(voidpf /* PRIVATE */, +png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED) { - png_voidp ptr; - png_structp p=(png_structp)png_ptr; - png_uint_32 save_flags=p->flags; - png_uint_32 num_bytes; - - if(png_ptr == NULL) return (NULL); - if (items > PNG_UINT_32_MAX/size) - { - png_warning (p, "Potential overflow in png_zalloc()"); - return (NULL); - } - num_bytes = (png_uint_32)items * size; + png_alloc_size_t num_bytes = size; - p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); - p->flags=save_flags; + if (png_ptr == NULL) + return NULL; -#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) - if (ptr == NULL) - return ((voidpf)ptr); - - if (num_bytes > (png_uint_32)0x8000L) - { - png_memset(ptr, 0, (png_size_t)0x8000L); - png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, - (png_size_t)(num_bytes - (png_uint_32)0x8000L)); - } - else + if (items >= (~(png_alloc_size_t)0)/size) { - png_memset(ptr, 0, (png_size_t)num_bytes); + png_warning (png_voidcast(png_structrp, png_ptr), + "Potential overflow in png_zalloc()"); + return NULL; } -#endif - return ((voidpf)ptr); + + num_bytes *= items; + return png_malloc_warn(png_voidcast(png_structrp, png_ptr), num_bytes); } -/* function to free memory for zlib */ -#ifdef PNG_1_0_X -void PNGAPI -#else -void /* private */ -#endif +/* Function to free memory for zlib */ +void /* PRIVATE */ png_zfree(voidpf png_ptr, voidpf ptr) { - png_free((png_structp)png_ptr, (png_voidp)ptr); + png_free(png_voidcast(png_const_structrp,png_ptr), ptr); } /* Reset the CRC variable to 32 bits of 1's. Care must be taken * in case CRC is > 32 bits to leave the top bits 0. */ void /* PRIVATE */ -png_reset_crc(png_structp png_ptr) +png_reset_crc(png_structrp png_ptr) { - png_ptr->crc = crc32(0, Z_NULL, 0); + /* The cast is safe because the crc is a 32 bit value. */ + png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0); } /* Calculate the CRC over a section of data. We can only pass as @@ -209,403 +111,524 @@ png_reset_crc(png_structp png_ptr) * trouble of calculating it. */ void /* PRIVATE */ -png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) +png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length) { int need_crc = 1; - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ + if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name)) { if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) need_crc = 0; } - else /* critical */ + + else /* critical */ { if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) need_crc = 0; } - if (need_crc) - png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); + /* 'uLong' is defined in zlib.h as unsigned long; this means that on some + * systems it is a 64 bit value. crc32, however, returns 32 bits so the + * following cast is safe. 'uInt' may be no more than 16 bits, so it is + * necessary to perform a loop here. + */ + if (need_crc && length > 0) + { + uLong crc = png_ptr->crc; /* Should never issue a warning */ + + do + { + uInt safe_length = (uInt)length; + if (safe_length == 0) + safe_length = (uInt)-1; /* evil, but safe */ + + crc = crc32(crc, ptr, safe_length); + + /* The following should never issue compiler warnings; if they do the + * target system has characteristics that will probably violate other + * assumptions within the libpng code. + */ + ptr += safe_length; + length -= safe_length; + } + while (length > 0); + + /* And the following is always safe because the crc is only 32 bits. */ + png_ptr->crc = (png_uint_32)crc; + } } -/* Allocate the memory for an info_struct for the application. We don't - * really need the png_ptr, but it could potentially be useful in the - * future. This should be used in favour of malloc(png_sizeof(png_info)) - * and png_info_init() so that applications that want to use a shared - * libpng don't have to be recompiled if png_info changes size. +/* Check a user supplied version number, called from both read and write + * functions that create a png_struct. */ -png_infop PNGAPI -png_create_info_struct(png_structp png_ptr) +int +png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) { - png_infop info_ptr; + if (user_png_ver) + { + int i = 0; - png_debug(1, "in png_create_info_struct\n"); - if(png_ptr == NULL) return (NULL); -#ifdef PNG_USER_MEM_SUPPORTED - info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, - png_ptr->malloc_fn, png_ptr->mem_ptr); -#else - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); + do + { + if (user_png_ver[i] != png_libpng_ver[i]) + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + } while (png_libpng_ver[i++]); + } + + else + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + + if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) + { + /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so + * we must recompile any applications that use any older library version. + * For versions after libpng 1.0, we will be compatible, so we need + * only check the first and third digits (note that when we reach version + * 1.10 we will need to check the fourth symbol, namely user_png_ver[3]). + */ + if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || + (user_png_ver[0] == '1' && (user_png_ver[2] != png_libpng_ver[2] || + user_png_ver[3] != png_libpng_ver[3])) || + (user_png_ver[0] == '0' && user_png_ver[2] < '9')) + { +#ifdef PNG_WARNINGS_SUPPORTED + size_t pos = 0; + char m[128]; + + pos = png_safecat(m, (sizeof m), pos, + "Application built with libpng-"); + pos = png_safecat(m, (sizeof m), pos, user_png_ver); + pos = png_safecat(m, (sizeof m), pos, " but running with "); + pos = png_safecat(m, (sizeof m), pos, png_libpng_ver); + + png_warning(png_ptr, m); #endif + +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags = 0; +#endif + + return 0; + } + } + + /* Success return. */ + return 1; +} + +/* Generic function to create a png_struct for either read or write - this + * contains the common initialization. + */ +PNG_FUNCTION(png_structp /* PRIVATE */, +png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp, + png_malloc_ptr, png_free_ptr),PNG_ALLOCATED) +{ + png_struct create_struct; +# ifdef PNG_SETJMP_SUPPORTED + jmp_buf create_jmp_buf; +# endif + + /* This temporary stack-allocated structure is used to provide a place to + * build enough context to allow the user provided memory allocator (if any) + * to be called. + */ + memset(&create_struct, 0, (sizeof create_struct)); + + /* Added at libpng-1.2.6 */ +# ifdef PNG_USER_LIMITS_SUPPORTED + create_struct.user_width_max = PNG_USER_WIDTH_MAX; + create_struct.user_height_max = PNG_USER_HEIGHT_MAX; + +# ifdef PNG_USER_CHUNK_CACHE_MAX + /* Added at libpng-1.2.43 and 1.4.0 */ + create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX; +# endif + +# ifdef PNG_USER_CHUNK_MALLOC_MAX + /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists + * in png_struct regardless. + */ + create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX; +# endif +# endif + + /* The following two API calls simply set fields in png_struct, so it is safe + * to do them now even though error handling is not yet set up. + */ +# ifdef PNG_USER_MEM_SUPPORTED + png_set_mem_fn(&create_struct, mem_ptr, malloc_fn, free_fn); +# endif + + /* (*error_fn) can return control to the caller after the error_ptr is set, + * this will result in a memory leak unless the error_fn does something + * extremely sophisticated. The design lacks merit but is implicit in the + * API. + */ + png_set_error_fn(&create_struct, error_ptr, error_fn, warn_fn); + +# ifdef PNG_SETJMP_SUPPORTED + if (!setjmp(create_jmp_buf)) + { + /* Temporarily fake out the longjmp information until we have + * successfully completed this function. This only works if we have + * setjmp() support compiled in, but it is safe - this stuff should + * never happen. + */ + create_struct.jmp_buf_ptr = &create_jmp_buf; + create_struct.jmp_buf_size = 0; /*stack allocation*/ + create_struct.longjmp_fn = longjmp; +# else + { +# endif + /* Call the general version checker (shared with read and write code): + */ + if (png_user_version_check(&create_struct, user_png_ver)) + { + png_structrp png_ptr = png_voidcast(png_structrp, + png_malloc_warn(&create_struct, (sizeof *png_ptr))); + + if (png_ptr != NULL) + { + /* png_ptr->zstream holds a back-pointer to the png_struct, so + * this can only be done now: + */ + create_struct.zstream.zalloc = png_zalloc; + create_struct.zstream.zfree = png_zfree; + create_struct.zstream.opaque = png_ptr; + +# ifdef PNG_SETJMP_SUPPORTED + /* Eliminate the local error handling: */ + create_struct.jmp_buf_ptr = NULL; + create_struct.jmp_buf_size = 0; + create_struct.longjmp_fn = 0; +# endif + + *png_ptr = create_struct; + + /* This is the successful return point */ + return png_ptr; + } + } + } + + /* A longjmp because of a bug in the application storage allocator or a + * simple failure to allocate the png_struct. + */ + return NULL; +} + +/* Allocate the memory for an info_struct for the application. */ +PNG_FUNCTION(png_infop,PNGAPI +png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED) +{ + png_inforp info_ptr; + + png_debug(1, "in png_create_info_struct"); + + if (png_ptr == NULL) + return NULL; + + /* Use the internal API that does not (or at least should not) error out, so + * that this call always returns ok. The application typically sets up the + * error handling *after* creating the info_struct because this is the way it + * has always been done in 'example.c'. + */ + info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr, + (sizeof *info_ptr))); + if (info_ptr != NULL) - png_info_init_3(&info_ptr, png_sizeof(png_info)); + memset(info_ptr, 0, (sizeof *info_ptr)); - return (info_ptr); + return info_ptr; } /* This function frees the memory associated with a single info struct. * Normally, one would use either png_destroy_read_struct() or * png_destroy_write_struct() to free an info struct, but this may be - * useful for some applications. + * useful for some applications. From libpng 1.6.0 this function is also used + * internally to implement the png_info release part of the 'struct' destroy + * APIs. This ensures that all possible approaches free the same data (all of + * it). */ void PNGAPI -png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) +png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr) { - png_infop info_ptr = NULL; - if(png_ptr == NULL) return; + png_inforp info_ptr = NULL; + + png_debug(1, "in png_destroy_info_struct"); + + if (png_ptr == NULL) + return; - png_debug(1, "in png_destroy_info_struct\n"); if (info_ptr_ptr != NULL) info_ptr = *info_ptr_ptr; if (info_ptr != NULL) { - png_info_destroy(png_ptr, info_ptr); - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, - png_ptr->mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif + /* Do this first in case of an error below; if the app implements its own + * memory management this can lead to png_free calling png_error, which + * will abort this routine and return control to the app error handler. + * An infinite loop may result if it then tries to free the same info + * ptr. + */ *info_ptr_ptr = NULL; + + png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); + memset(info_ptr, 0, (sizeof *info_ptr)); + png_free(png_ptr, info_ptr); } } /* Initialize the info structure. This is now an internal function (0.89) * and applications using it are urged to use png_create_info_struct() - * instead. + * instead. Use deprecated in 1.6.0, internal use removed (used internally it + * is just a memset). + * + * NOTE: it is almost inconceivable that this API is used because it bypasses + * the user-memory mechanism and the user error handling/warning mechanisms in + * those cases where it does anything other than a memset. */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#undef png_info_init -void PNGAPI -png_info_init(png_infop info_ptr) -{ - /* We only come here via pre-1.0.12-compiled applications */ - png_info_init_3(&info_ptr, 0); -} -#endif - -void PNGAPI -png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) +PNG_FUNCTION(void,PNGAPI +png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size), + PNG_DEPRECATED) { - png_infop info_ptr = *ptr_ptr; + png_inforp info_ptr = *ptr_ptr; - if(info_ptr == NULL) return; + png_debug(1, "in png_info_init_3"); - png_debug(1, "in png_info_init_3\n"); + if (info_ptr == NULL) + return; - if(png_sizeof(png_info) > png_info_struct_size) - { - png_destroy_struct(info_ptr); - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); - *ptr_ptr = info_ptr; - } + if ((sizeof (png_info)) > png_info_struct_size) + { + *ptr_ptr = NULL; + /* The following line is why this API should not be used: */ + free(info_ptr); + info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL, + (sizeof *info_ptr))); + *ptr_ptr = info_ptr; + } - /* set everything to 0 */ - png_memset(info_ptr, 0, png_sizeof (png_info)); + /* Set everything to 0 */ + memset(info_ptr, 0, (sizeof *info_ptr)); } -#ifdef PNG_FREE_ME_SUPPORTED +/* The following API is not called internally */ void PNGAPI -png_data_freer(png_structp png_ptr, png_infop info_ptr, +png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr, int freer, png_uint_32 mask) { - png_debug(1, "in png_data_freer\n"); + png_debug(1, "in png_data_freer"); + if (png_ptr == NULL || info_ptr == NULL) return; - if(freer == PNG_DESTROY_WILL_FREE_DATA) + + if (freer == PNG_DESTROY_WILL_FREE_DATA) info_ptr->free_me |= mask; - else if(freer == PNG_USER_WILL_FREE_DATA) + + else if (freer == PNG_USER_WILL_FREE_DATA) info_ptr->free_me &= ~mask; + else - png_warning(png_ptr, - "Unknown freer parameter in png_data_freer."); + png_error(png_ptr, "Unknown freer parameter in png_data_freer"); } -#endif void PNGAPI -png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, +png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, int num) { - png_debug(1, "in png_free_data\n"); + png_debug(1, "in png_free_data"); + if (png_ptr == NULL || info_ptr == NULL) return; -#if defined(PNG_TEXT_SUPPORTED) -/* free text item num or (if num == -1) all text items */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_TEXT) -#endif -{ - if (num != -1) - { - if (info_ptr->text && info_ptr->text[num].key) - { - png_free(png_ptr, info_ptr->text[num].key); - info_ptr->text[num].key = NULL; - } - } - else +#ifdef PNG_TEXT_SUPPORTED + /* Free text item num or (if num == -1) all text items */ + if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) { - int i; - for (i = 0; i < info_ptr->num_text; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); - png_free(png_ptr, info_ptr->text); - info_ptr->text = NULL; - info_ptr->num_text=0; + if (num != -1) + { + if (info_ptr->text && info_ptr->text[num].key) + { + png_free(png_ptr, info_ptr->text[num].key); + info_ptr->text[num].key = NULL; + } + } + + else + { + int i; + for (i = 0; i < info_ptr->num_text; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); + png_free(png_ptr, info_ptr->text); + info_ptr->text = NULL; + info_ptr->num_text=0; + } } -} #endif -#if defined(PNG_tRNS_SUPPORTED) -/* free any tRNS entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) -#endif -{ - png_free(png_ptr, info_ptr->trans); - info_ptr->valid &= ~PNG_INFO_tRNS; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif - info_ptr->trans = NULL; -} +#ifdef PNG_tRNS_SUPPORTED + /* Free any tRNS entry */ + if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) + { + png_free(png_ptr, info_ptr->trans_alpha); + info_ptr->trans_alpha = NULL; + info_ptr->valid &= ~PNG_INFO_tRNS; + } #endif -#if defined(PNG_sCAL_SUPPORTED) -/* free any sCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SCAL) -#endif -{ -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, info_ptr->scal_s_width); - png_free(png_ptr, info_ptr->scal_s_height); - info_ptr->scal_s_width = NULL; - info_ptr->scal_s_height = NULL; -#endif - info_ptr->valid &= ~PNG_INFO_sCAL; -} +#ifdef PNG_sCAL_SUPPORTED + /* Free any sCAL entry */ + if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) + { + png_free(png_ptr, info_ptr->scal_s_width); + png_free(png_ptr, info_ptr->scal_s_height); + info_ptr->scal_s_width = NULL; + info_ptr->scal_s_height = NULL; + info_ptr->valid &= ~PNG_INFO_sCAL; + } #endif -#if defined(PNG_pCAL_SUPPORTED) -/* free any pCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_PCAL) -#endif -{ - png_free(png_ptr, info_ptr->pcal_purpose); - png_free(png_ptr, info_ptr->pcal_units); - info_ptr->pcal_purpose = NULL; - info_ptr->pcal_units = NULL; - if (info_ptr->pcal_params != NULL) - { - int i; - for (i = 0; i < (int)info_ptr->pcal_nparams; i++) - { - png_free(png_ptr, info_ptr->pcal_params[i]); - info_ptr->pcal_params[i]=NULL; - } - png_free(png_ptr, info_ptr->pcal_params); - info_ptr->pcal_params = NULL; - } - info_ptr->valid &= ~PNG_INFO_pCAL; -} +#ifdef PNG_pCAL_SUPPORTED + /* Free any pCAL entry */ + if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) + { + png_free(png_ptr, info_ptr->pcal_purpose); + png_free(png_ptr, info_ptr->pcal_units); + info_ptr->pcal_purpose = NULL; + info_ptr->pcal_units = NULL; + if (info_ptr->pcal_params != NULL) + { + unsigned int i; + for (i = 0; i < info_ptr->pcal_nparams; i++) + { + png_free(png_ptr, info_ptr->pcal_params[i]); + info_ptr->pcal_params[i] = NULL; + } + png_free(png_ptr, info_ptr->pcal_params); + info_ptr->pcal_params = NULL; + } + info_ptr->valid &= ~PNG_INFO_pCAL; + } #endif -#if defined(PNG_iCCP_SUPPORTED) -/* free any iCCP entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ICCP) -#endif -{ - png_free(png_ptr, info_ptr->iccp_name); - png_free(png_ptr, info_ptr->iccp_profile); - info_ptr->iccp_name = NULL; - info_ptr->iccp_profile = NULL; - info_ptr->valid &= ~PNG_INFO_iCCP; -} +#ifdef PNG_iCCP_SUPPORTED + /* Free any profile entry */ + if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) + { + png_free(png_ptr, info_ptr->iccp_name); + png_free(png_ptr, info_ptr->iccp_profile); + info_ptr->iccp_name = NULL; + info_ptr->iccp_profile = NULL; + info_ptr->valid &= ~PNG_INFO_iCCP; + } #endif -#if defined(PNG_sPLT_SUPPORTED) -/* free a given sPLT entry, or (if num == -1) all sPLT entries */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SPLT) -#endif -{ - if (num != -1) +#ifdef PNG_sPLT_SUPPORTED + /* Free a given sPLT entry, or (if num == -1) all sPLT entries */ + if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) { - if(info_ptr->splt_palettes) + if (num != -1) { - png_free(png_ptr, info_ptr->splt_palettes[num].name); - png_free(png_ptr, info_ptr->splt_palettes[num].entries); - info_ptr->splt_palettes[num].name = NULL; - info_ptr->splt_palettes[num].entries = NULL; + if (info_ptr->splt_palettes) + { + png_free(png_ptr, info_ptr->splt_palettes[num].name); + png_free(png_ptr, info_ptr->splt_palettes[num].entries); + info_ptr->splt_palettes[num].name = NULL; + info_ptr->splt_palettes[num].entries = NULL; + } } - } - else - { - if(info_ptr->splt_palettes_num) - { - int i; - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = NULL; - info_ptr->splt_palettes_num = 0; - } - info_ptr->valid &= ~PNG_INFO_sPLT; + else + { + if (info_ptr->splt_palettes_num) + { + int i; + for (i = 0; i < info_ptr->splt_palettes_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, (int)i); + + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes = NULL; + info_ptr->splt_palettes_num = 0; + } + info_ptr->valid &= ~PNG_INFO_sPLT; + } } -} #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if(png_ptr->unknown_chunk.data) - { - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) -#else -if (mask & PNG_FREE_UNKN) -#endif -{ - if (num != -1) - { - if(info_ptr->unknown_chunks) - { - png_free(png_ptr, info_ptr->unknown_chunks[num].data); - info_ptr->unknown_chunks[num].data = NULL; - } - } - else +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED + if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) { - int i; - - if(info_ptr->unknown_chunks_num) - { - for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = NULL; - info_ptr->unknown_chunks_num = 0; - } - } -} -#endif + if (num != -1) + { + if (info_ptr->unknown_chunks) + { + png_free(png_ptr, info_ptr->unknown_chunks[num].data); + info_ptr->unknown_chunks[num].data = NULL; + } + } -#if defined(PNG_hIST_SUPPORTED) -/* free any hIST entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_HIST) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) -#endif -{ - png_free(png_ptr, info_ptr->hist); - info_ptr->hist = NULL; - info_ptr->valid &= ~PNG_INFO_hIST; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -} -#endif + else + { + int i; -/* free any PLTE entry that was internally allocated */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) -#endif -{ - png_zfree(png_ptr, info_ptr->palette); - info_ptr->palette = NULL; - info_ptr->valid &= ~PNG_INFO_PLTE; -#ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif - info_ptr->num_palette = 0; -} + if (info_ptr->unknown_chunks_num) + { + for (i = 0; i < info_ptr->unknown_chunks_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, (int)i); -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* free any image bits attached to the info structure */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ROWS) -#endif -{ - if(info_ptr->row_pointers) - { - int row; - for (row = 0; row < (int)info_ptr->height; row++) - { - png_free(png_ptr, info_ptr->row_pointers[row]); - info_ptr->row_pointers[row]=NULL; - } - png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers=NULL; - } - info_ptr->valid &= ~PNG_INFO_IDAT; -} + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks = NULL; + info_ptr->unknown_chunks_num = 0; + } + } + } #endif -#ifdef PNG_FREE_ME_SUPPORTED - if(num == -1) - info_ptr->free_me &= ~mask; - else - info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); +#ifdef PNG_hIST_SUPPORTED + /* Free any hIST entry */ + if ((mask & PNG_FREE_HIST) & info_ptr->free_me) + { + png_free(png_ptr, info_ptr->hist); + info_ptr->hist = NULL; + info_ptr->valid &= ~PNG_INFO_hIST; + } #endif -} - -/* This is an internal routine to free any memory that the info struct is - * pointing to before re-using it or freeing the struct itself. Recall - * that png_free() checks for NULL pointers for us. - */ -void /* PRIVATE */ -png_info_destroy(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_info_destroy\n"); - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); + /* Free any PLTE entry that was internally allocated */ + if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) + { + png_free(png_ptr, info_ptr->palette); + info_ptr->palette = NULL; + info_ptr->valid &= ~PNG_INFO_PLTE; + info_ptr->num_palette = 0; + } -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) +#ifdef PNG_INFO_IMAGE_SUPPORTED + /* Free any image bits attached to the info structure */ + if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; + if (info_ptr->row_pointers) + { + png_uint_32 row; + for (row = 0; row < info_ptr->height; row++) + { + png_free(png_ptr, info_ptr->row_pointers[row]); + info_ptr->row_pointers[row] = NULL; + } + png_free(png_ptr, info_ptr->row_pointers); + info_ptr->row_pointers = NULL; + } + info_ptr->valid &= ~PNG_INFO_IDAT; } #endif - png_info_init_3(&info_ptr, png_sizeof(png_info)); + if (num != -1) + mask &= ~PNG_FREE_MUL; + + info_ptr->free_me &= ~mask; } #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ @@ -614,88 +637,149 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr) * pointer before png_write_destroy() or png_read_destroy() are called. */ png_voidp PNGAPI -png_get_io_ptr(png_structp png_ptr) +png_get_io_ptr(png_const_structrp png_ptr) { - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); + return (png_ptr->io_ptr); } #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if !defined(PNG_NO_STDIO) +# ifdef PNG_STDIO_SUPPORTED /* Initialize the default input/output functions for the PNG file. If you * use your own read or write routines, you can call either png_set_read_fn() * or png_set_write_fn() instead of png_init_io(). If you have defined - * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't - * necessarily available. + * PNG_NO_STDIO or otherwise disabled PNG_STDIO_SUPPORTED, you must use a + * function of your own because "FILE *" isn't necessarily available. */ void PNGAPI -png_init_io(png_structp png_ptr, png_FILE_p fp) +png_init_io(png_structrp png_ptr, png_FILE_p fp) { - png_debug(1, "in png_init_io\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_init_io"); + + if (png_ptr == NULL) + return; + png_ptr->io_ptr = (png_voidp)fp; } +# endif + +#ifdef PNG_SAVE_INT_32_SUPPORTED +/* The png_save_int_32 function assumes integers are stored in two's + * complement format. If this isn't the case, then this routine needs to + * be modified to write data in two's complement format. Note that, + * the following works correctly even if png_int_32 has more than 32 bits + * (compare the more complex code required on read for sign extension.) + */ +void PNGAPI +png_save_int_32(png_bytep buf, png_int_32 i) +{ + buf[0] = (png_byte)((i >> 24) & 0xff); + buf[1] = (png_byte)((i >> 16) & 0xff); + buf[2] = (png_byte)((i >> 8) & 0xff); + buf[3] = (png_byte)(i & 0xff); +} #endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) +# ifdef PNG_TIME_RFC1123_SUPPORTED /* Convert the supplied time into an RFC 1123 string suitable for use in * a "Creation Time" or other text-based time string. */ -png_charp PNGAPI -png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) +int PNGAPI +png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime) { static PNG_CONST char short_months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - if(png_ptr == NULL) return (NULL); - if (png_ptr->time_buffer == NULL) - { - png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* - png_sizeof(char))); - } + if (out == NULL) + return 0; + + if (ptime->year > 9999 /* RFC1123 limitation */ || + ptime->month == 0 || ptime->month > 12 || + ptime->day == 0 || ptime->day > 31 || + ptime->hour > 23 || ptime->minute > 59 || + ptime->second > 60) + return 0; -#if defined(_WIN32_WCE) { - wchar_t time_buf[29]; - wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, - NULL, NULL); + size_t pos = 0; + char number_buf[5]; /* enough for a four-digit year */ + +# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string)) +# define APPEND_NUMBER(format, value)\ + APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value))) +# define APPEND(ch) if (pos < 28) out[pos++] = (ch) + + APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day); + APPEND(' '); + APPEND_STRING(short_months[(ptime->month - 1)]); + APPEND(' '); + APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->year); + APPEND(' '); + APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour); + APPEND(':'); + APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute); + APPEND(':'); + APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second); + APPEND_STRING(" +0000"); /* This reliably terminates the buffer */ + +# undef APPEND +# undef APPEND_NUMBER +# undef APPEND_STRING } -#else -#ifdef USE_FAR_KEYWORD + + return 1; +} + +# if PNG_LIBPNG_VER < 10700 +/* To do: remove the following from libpng-1.7 */ +/* Original API that uses a private buffer in png_struct. + * Deprecated because it causes png_struct to carry a spurious temporary + * buffer (png_struct::time_buffer), better to have the caller pass this in. + */ +png_const_charp PNGAPI +png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime) +{ + if (png_ptr != NULL) { - char near_time_buf[29]; - png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - png_memcpy(png_ptr->time_buffer, near_time_buf, - 29*png_sizeof(char)); + /* The only failure above if png_ptr != NULL is from an invalid ptime */ + if (!png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime)) + png_warning(png_ptr, "Ignoring invalid time value"); + + else + return png_ptr->time_buffer; } -#else - png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); -#endif -#endif /* _WIN32_WCE */ - return ((png_charp)png_ptr->time_buffer); + + return NULL; } -#endif /* PNG_TIME_RFC1123_SUPPORTED */ +# endif +# endif /* PNG_TIME_RFC1123_SUPPORTED */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ -png_charp PNGAPI -png_get_copyright(png_structp) +png_const_charp PNGAPI +png_get_copyright(png_const_structrp png_ptr) { - return ((png_charp) "\n libpng version 1.2.21 - October 4, 2007\n\ - Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\ - Copyright (c) 1996-1997 Andreas Dilger\n\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); + PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ +#ifdef PNG_STRING_COPYRIGHT + return PNG_STRING_COPYRIGHT +#else +# ifdef __STDC__ + return PNG_STRING_NEWLINE \ + "libpng version 1.6.1 - March 28, 2013" PNG_STRING_NEWLINE \ + "Copyright (c) 1998-2013 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ + "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ + "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ + PNG_STRING_NEWLINE; +# else + return "libpng version 1.6.1 - March 28, 2013\ + Copyright (c) 1998-2013 Glenn Randers-Pehrson\ + Copyright (c) 1996-1997 Andreas Dilger\ + Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; +# endif +#endif } /* The following return the library version as a short string in the @@ -706,89 +790,3506 @@ png_get_copyright(png_structp) * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, * it is guaranteed that png.c uses the correct version of png.h. */ -png_charp PNGAPI -png_get_libpng_ver(png_structp) +png_const_charp PNGAPI +png_get_libpng_ver(png_const_structrp png_ptr) { /* Version of *.c files used when building libpng */ - return ((png_charp) PNG_LIBPNG_VER_STRING); + return png_get_header_ver(png_ptr); } -png_charp PNGAPI -png_get_header_ver(png_structp) +png_const_charp PNGAPI +png_get_header_ver(png_const_structrp png_ptr) { /* Version of *.h files used when building libpng */ - return ((png_charp) PNG_LIBPNG_VER_STRING); + PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ + return PNG_LIBPNG_VER_STRING; } -png_charp PNGAPI -png_get_header_version(png_structp) +png_const_charp PNGAPI +png_get_header_version(png_const_structrp png_ptr) { /* Returns longer string containing both version and date */ - return ((png_charp) PNG_HEADER_VERSION_STRING -#ifndef PNG_READ_SUPPORTED + PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ +#ifdef __STDC__ + return PNG_HEADER_VERSION_STRING +# ifndef PNG_READ_SUPPORTED " (NO READ SUPPORT)" +# endif + PNG_STRING_NEWLINE; +#else + return PNG_HEADER_VERSION_STRING; #endif - "\n"); } -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED int PNGAPI -png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) +png_handle_as_unknown(png_const_structrp png_ptr, png_const_bytep chunk_name) { - /* check chunk_name and return "keep" value if it's on the list, else 0 */ - int i; - png_bytep p; - if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0) - return 0; - p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; - for (i = png_ptr->num_chunk_list; i; i--, p-=5) - if (!png_memcmp(chunk_name, p, 4)) - return ((int)*(p+4)); - return 0; + /* Check chunk_name and return "keep" value if it's on the list, else 0 */ + png_const_bytep p, p_end; + + if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list == 0) + return PNG_HANDLE_CHUNK_AS_DEFAULT; + + p_end = png_ptr->chunk_list; + p = p_end + png_ptr->num_chunk_list*5; /* beyond end */ + + /* The code is the fifth byte after each four byte string. Historically this + * code was always searched from the end of the list, this is no longer + * necessary because the 'set' routine handles duplicate entries correcty. + */ + do /* num_chunk_list > 0, so at least one */ + { + p -= 5; + + if (!memcmp(chunk_name, p, 4)) + return p[4]; + } + while (p > p_end); + + /* This means that known chunks should be processed and unknown chunks should + * be handled according to the value of png_ptr->unknown_default; this can be + * confusing because, as a result, there are two levels of defaulting for + * unknown chunks. + */ + return PNG_HANDLE_CHUNK_AS_DEFAULT; } -#endif +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +int /* PRIVATE */ +png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name) +{ + png_byte chunk_string[5]; + + PNG_CSTRING_FROM_CHUNK(chunk_string, chunk_name); + return png_handle_as_unknown(png_ptr, chunk_string); +} +#endif /* READ_UNKNOWN_CHUNKS */ +#endif /* SET_UNKNOWN_CHUNKS */ + +#ifdef PNG_READ_SUPPORTED /* This function, added to libpng-1.0.6g, is untested. */ int PNGAPI -png_reset_zstream(png_structp png_ptr) +png_reset_zstream(png_structrp png_ptr) { - if (png_ptr == NULL) return Z_STREAM_ERROR; + if (png_ptr == NULL) + return Z_STREAM_ERROR; + + /* WARNING: this resets the window bits to the maximum! */ return (inflateReset(&png_ptr->zstream)); } -#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ +#endif /* PNG_READ_SUPPORTED */ /* This function was added to libpng-1.0.7 */ png_uint_32 PNGAPI png_access_version_number(void) { /* Version of *.c files used when building libpng */ - return((png_uint_32) PNG_LIBPNG_VER); + return((png_uint_32)PNG_LIBPNG_VER); } -#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) -/* this function was added to libpng 1.2.0 */ -int PNGAPI -png_mmx_support(void) + +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +/* Ensure that png_ptr->zstream.msg holds some appropriate error message string. + * If it doesn't 'ret' is used to set it to something appropriate, even in cases + * like Z_OK or Z_STREAM_END where the error code is apparently a success code. + */ +void /* PRIVATE */ +png_zstream_error(png_structrp png_ptr, int ret) +{ + /* Translate 'ret' into an appropriate error string, priority is given to the + * one in zstream if set. This always returns a string, even in cases like + * Z_OK or Z_STREAM_END where the error code is a success code. + */ + if (png_ptr->zstream.msg == NULL) switch (ret) + { + default: + case Z_OK: + png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return code"); + break; + + case Z_STREAM_END: + /* Normal exit */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected end of LZ stream"); + break; + + case Z_NEED_DICT: + /* This means the deflate stream did not have a dictionary; this + * indicates a bogus PNG. + */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("missing LZ dictionary"); + break; + + case Z_ERRNO: + /* gz APIs only: should not happen */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("zlib IO error"); + break; + + case Z_STREAM_ERROR: + /* internal libpng error */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("bad parameters to zlib"); + break; + + case Z_DATA_ERROR: + png_ptr->zstream.msg = PNGZ_MSG_CAST("damaged LZ stream"); + break; + + case Z_MEM_ERROR: + png_ptr->zstream.msg = PNGZ_MSG_CAST("insufficient memory"); + break; + + case Z_BUF_ERROR: + /* End of input or output; not a problem if the caller is doing + * incremental read or write. + */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("truncated"); + break; + + case Z_VERSION_ERROR: + png_ptr->zstream.msg = PNGZ_MSG_CAST("unsupported zlib version"); + break; + + case PNG_UNEXPECTED_ZLIB_RETURN: + /* Compile errors here mean that zlib now uses the value co-opted in + * pngpriv.h for PNG_UNEXPECTED_ZLIB_RETURN; update the switch above + * and change pngpriv.h. Note that this message is "... return", + * whereas the default/Z_OK one is "... return code". + */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return"); + break; + } +} + +/* png_convert_size: a PNGAPI but no longer in png.h, so deleted + * at libpng 1.5.5! + */ + +/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ +#ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */ +static int +png_colorspace_check_gamma(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_fixed_point gAMA, int from) + /* This is called to check a new gamma value against an existing one. The + * routine returns false if the new gamma value should not be written. + * + * 'from' says where the new gamma value comes from: + * + * 0: the new gamma value is the libpng estimate for an ICC profile + * 1: the new gamma value comes from a gAMA chunk + * 2: the new gamma value comes from an sRGB chunk + */ { - /* obsolete, to be removed from libpng-1.4.0 */ - return -1; + png_fixed_point gtest; + + if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && + (!png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) || + png_gamma_significant(gtest))) + { + /* Either this is an sRGB image, in which case the calculated gamma + * approximation should match, or this is an image with a profile and the + * value libpng calculates for the gamma of the profile does not match the + * value recorded in the file. The former, sRGB, case is an error, the + * latter is just a warning. + */ + if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2) + { + png_chunk_report(png_ptr, "gamma value does not match sRGB", + PNG_CHUNK_ERROR); + /* Do not overwrite an sRGB value */ + return from == 2; + } + + else /* sRGB tag not involved */ + { + png_chunk_report(png_ptr, "gamma value does not match libpng estimate", + PNG_CHUNK_WARNING); + return from == 1; + } + } + + return 1; } -#endif /* PNG_1_0_X */ -#endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */ -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#ifdef PNG_SIZE_T -/* Added at libpng version 1.2.6 */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -png_size_t PNGAPI -png_convert_size(size_t size) +void /* PRIVATE */ +png_colorspace_set_gamma(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_fixed_point gAMA) +{ + /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't + * occur. Since the fixed point representation is assymetrical it is + * possible for 1/gamma to overflow the limit of 21474 and this means the + * gamma value must be at least 5/100000 and hence at most 20000.0. For + * safety the limits here are a little narrower. The values are 0.00016 to + * 6250.0, which are truly ridiculous gamma values (and will produce + * displays that are all black or all white.) + * + * In 1.6.0 this test replaces the ones in pngrutil.c, in the gAMA chunk + * handling code, which only required the value to be >0. + */ + png_const_charp errmsg; + + if (gAMA < 16 || gAMA > 625000000) + errmsg = "gamma value out of range"; + +# ifdef PNG_READ_gAMA_SUPPORTED + /* Allow the application to set the gamma value more than once */ + else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && + (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0) + errmsg = "duplicate"; +# endif + + /* Do nothing if the colorspace is already invalid */ + else if (colorspace->flags & PNG_COLORSPACE_INVALID) + return; + + else + { + if (png_colorspace_check_gamma(png_ptr, colorspace, gAMA, 1/*from gAMA*/)) + { + /* Store this gamma value. */ + colorspace->gamma = gAMA; + colorspace->flags |= + (PNG_COLORSPACE_HAVE_GAMMA | PNG_COLORSPACE_FROM_gAMA); + } + + /* At present if the check_gamma test fails the gamma of the colorspace is + * not updated however the colorspace is not invalidated. This + * corresponds to the case where the existing gamma comes from an sRGB + * chunk or profile. An error message has already been output. + */ + return; + } + + /* Error exit - errmsg has been set. */ + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_chunk_report(png_ptr, errmsg, PNG_CHUNK_WRITE_ERROR); +} + +void /* PRIVATE */ +png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr) +{ + if (info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) + { + /* Everything is invalid */ + info_ptr->valid &= ~(PNG_INFO_gAMA|PNG_INFO_cHRM|PNG_INFO_sRGB| + PNG_INFO_iCCP); + +# ifdef PNG_COLORSPACE_SUPPORTED + /* Clean up the iCCP profile now if it won't be used. */ + png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/); +# else + PNG_UNUSED(png_ptr) +# endif + } + + else + { +# ifdef PNG_COLORSPACE_SUPPORTED + /* Leave the INFO_iCCP flag set if the pngset.c code has already set + * it; this allows a PNG to contain a profile which matches sRGB and + * yet still have that profile retrievable by the application. + */ + if (info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) + info_ptr->valid |= PNG_INFO_sRGB; + + else + info_ptr->valid &= ~PNG_INFO_sRGB; + + if (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) + info_ptr->valid |= PNG_INFO_cHRM; + + else + info_ptr->valid &= ~PNG_INFO_cHRM; +# endif + + if (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) + info_ptr->valid |= PNG_INFO_gAMA; + + else + info_ptr->valid &= ~PNG_INFO_gAMA; + } +} + +#ifdef PNG_READ_SUPPORTED +void /* PRIVATE */ +png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr) +{ + if (info_ptr == NULL) /* reduce code size; check here not in the caller */ + return; + + info_ptr->colorspace = png_ptr->colorspace; + png_colorspace_sync_info(png_ptr, info_ptr); +} +#endif +#endif + +#ifdef PNG_COLORSPACE_SUPPORTED +/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for + * cHRM, as opposed to using chromaticities. These internal APIs return + * non-zero on a parameter error. The X, Y and Z values are required to be + * positive and less than 1.0. + */ +static int +png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ) +{ + png_int_32 d, dwhite, whiteX, whiteY; + + d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z; + if (!png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d)) return 1; + if (!png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d)) return 1; + dwhite = d; + whiteX = XYZ->red_X; + whiteY = XYZ->red_Y; + + d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z; + if (!png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d)) return 1; + if (!png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d)) return 1; + dwhite += d; + whiteX += XYZ->green_X; + whiteY += XYZ->green_Y; + + d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z; + if (!png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d)) return 1; + if (!png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d)) return 1; + dwhite += d; + whiteX += XYZ->blue_X; + whiteY += XYZ->blue_Y; + + /* The reference white is simply the sum of the end-point (X,Y,Z) vectors, + * thus: + */ + if (!png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite)) return 1; + if (!png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite)) return 1; + + return 0; +} + +static int +png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) +{ + png_fixed_point red_inverse, green_inverse, blue_scale; + png_fixed_point left, right, denominator; + + /* Check xy and, implicitly, z. Note that wide gamut color spaces typically + * have end points with 0 tristimulus values (these are impossible end + * points, but they are used to cover the possible colors.) + */ + if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1; + if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1; + if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1; + if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1; + if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1; + if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1; + if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1; + if (xy->whitey < 0 || xy->whitey > PNG_FP_1-xy->whitex) return 1; + + /* The reverse calculation is more difficult because the original tristimulus + * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8 + * derived values were recorded in the cHRM chunk; + * (red,green,blue,white)x(x,y). This loses one degree of freedom and + * therefore an arbitrary ninth value has to be introduced to undo the + * original transformations. + * + * Think of the original end-points as points in (X,Y,Z) space. The + * chromaticity values (c) have the property: + * + * C + * c = --------- + * X + Y + Z + * + * For each c (x,y,z) from the corresponding original C (X,Y,Z). Thus the + * three chromaticity values (x,y,z) for each end-point obey the + * relationship: + * + * x + y + z = 1 + * + * This describes the plane in (X,Y,Z) space that intersects each axis at the + * value 1.0; call this the chromaticity plane. Thus the chromaticity + * calculation has scaled each end-point so that it is on the x+y+z=1 plane + * and chromaticity is the intersection of the vector from the origin to the + * (X,Y,Z) value with the chromaticity plane. + * + * To fully invert the chromaticity calculation we would need the three + * end-point scale factors, (red-scale, green-scale, blue-scale), but these + * were not recorded. Instead we calculated the reference white (X,Y,Z) and + * recorded the chromaticity of this. The reference white (X,Y,Z) would have + * given all three of the scale factors since: + * + * color-C = color-c * color-scale + * white-C = red-C + green-C + blue-C + * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale + * + * But cHRM records only white-x and white-y, so we have lost the white scale + * factor: + * + * white-C = white-c*white-scale + * + * To handle this the inverse transformation makes an arbitrary assumption + * about white-scale: + * + * Assume: white-Y = 1.0 + * Hence: white-scale = 1/white-y + * Or: red-Y + green-Y + blue-Y = 1.0 + * + * Notice the last statement of the assumption gives an equation in three of + * the nine values we want to calculate. 8 more equations come from the + * above routine as summarised at the top above (the chromaticity + * calculation): + * + * Given: color-x = color-X / (color-X + color-Y + color-Z) + * Hence: (color-x - 1)*color-X + color.x*color-Y + color.x*color-Z = 0 + * + * This is 9 simultaneous equations in the 9 variables "color-C" and can be + * solved by Cramer's rule. Cramer's rule requires calculating 10 9x9 matrix + * determinants, however this is not as bad as it seems because only 28 of + * the total of 90 terms in the various matrices are non-zero. Nevertheless + * Cramer's rule is notoriously numerically unstable because the determinant + * calculation involves the difference of large, but similar, numbers. It is + * difficult to be sure that the calculation is stable for real world values + * and it is certain that it becomes unstable where the end points are close + * together. + * + * So this code uses the perhaps slightly less optimal but more + * understandable and totally obvious approach of calculating color-scale. + * + * This algorithm depends on the precision in white-scale and that is + * (1/white-y), so we can immediately see that as white-y approaches 0 the + * accuracy inherent in the cHRM chunk drops off substantially. + * + * libpng arithmetic: a simple invertion of the above equations + * ------------------------------------------------------------ + * + * white_scale = 1/white-y + * white-X = white-x * white-scale + * white-Y = 1.0 + * white-Z = (1 - white-x - white-y) * white_scale + * + * white-C = red-C + green-C + blue-C + * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale + * + * This gives us three equations in (red-scale,green-scale,blue-scale) where + * all the coefficients are now known: + * + * red-x*red-scale + green-x*green-scale + blue-x*blue-scale + * = white-x/white-y + * red-y*red-scale + green-y*green-scale + blue-y*blue-scale = 1 + * red-z*red-scale + green-z*green-scale + blue-z*blue-scale + * = (1 - white-x - white-y)/white-y + * + * In the last equation color-z is (1 - color-x - color-y) so we can add all + * three equations together to get an alternative third: + * + * red-scale + green-scale + blue-scale = 1/white-y = white-scale + * + * So now we have a Cramer's rule solution where the determinants are just + * 3x3 - far more tractible. Unfortunately 3x3 determinants still involve + * multiplication of three coefficients so we can't guarantee to avoid + * overflow in the libpng fixed point representation. Using Cramer's rule in + * floating point is probably a good choice here, but it's not an option for + * fixed point. Instead proceed to simplify the first two equations by + * eliminating what is likely to be the largest value, blue-scale: + * + * blue-scale = white-scale - red-scale - green-scale + * + * Hence: + * + * (red-x - blue-x)*red-scale + (green-x - blue-x)*green-scale = + * (white-x - blue-x)*white-scale + * + * (red-y - blue-y)*red-scale + (green-y - blue-y)*green-scale = + * 1 - blue-y*white-scale + * + * And now we can trivially solve for (red-scale,green-scale): + * + * green-scale = + * (white-x - blue-x)*white-scale - (red-x - blue-x)*red-scale + * ----------------------------------------------------------- + * green-x - blue-x + * + * red-scale = + * 1 - blue-y*white-scale - (green-y - blue-y) * green-scale + * --------------------------------------------------------- + * red-y - blue-y + * + * Hence: + * + * red-scale = + * ( (green-x - blue-x) * (white-y - blue-y) - + * (green-y - blue-y) * (white-x - blue-x) ) / white-y + * ------------------------------------------------------------------------- + * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) + * + * green-scale = + * ( (red-y - blue-y) * (white-x - blue-x) - + * (red-x - blue-x) * (white-y - blue-y) ) / white-y + * ------------------------------------------------------------------------- + * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) + * + * Accuracy: + * The input values have 5 decimal digits of accuracy. The values are all in + * the range 0 < value < 1, so simple products are in the same range but may + * need up to 10 decimal digits to preserve the original precision and avoid + * underflow. Because we are using a 32-bit signed representation we cannot + * match this; the best is a little over 9 decimal digits, less than 10. + * + * The approach used here is to preserve the maximum precision within the + * signed representation. Because the red-scale calculation above uses the + * difference between two products of values that must be in the range -1..+1 + * it is sufficient to divide the product by 7; ceil(100,000/32767*2). The + * factor is irrelevant in the calculation because it is applied to both + * numerator and denominator. + * + * Note that the values of the differences of the products of the + * chromaticities in the above equations tend to be small, for example for + * the sRGB chromaticities they are: + * + * red numerator: -0.04751 + * green numerator: -0.08788 + * denominator: -0.2241 (without white-y multiplication) + * + * The resultant Y coefficients from the chromaticities of some widely used + * color space definitions are (to 15 decimal places): + * + * sRGB + * 0.212639005871510 0.715168678767756 0.072192315360734 + * Kodak ProPhoto + * 0.288071128229293 0.711843217810102 0.000085653960605 + * Adobe RGB + * 0.297344975250536 0.627363566255466 0.075291458493998 + * Adobe Wide Gamut RGB + * 0.258728243040113 0.724682314948566 0.016589442011321 + */ + /* By the argument, above overflow should be impossible here. The return + * value of 2 indicates an internal error to the caller. + */ + if (!png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7)) + return 2; + if (!png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7)) + return 2; + denominator = left - right; + + /* Now find the red numerator. */ + if (!png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7)) + return 2; + if (!png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7)) + return 2; + + /* Overflow is possible here and it indicates an extreme set of PNG cHRM + * chunk values. This calculation actually returns the reciprocal of the + * scale value because this allows us to delay the multiplication of white-y + * into the denominator, which tends to produce a small number. + */ + if (!png_muldiv(&red_inverse, xy->whitey, denominator, left-right) || + red_inverse <= xy->whitey /* r+g+b scales = white scale */) + return 1; + + /* Similarly for green_inverse: */ + if (!png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7)) + return 2; + if (!png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7)) + return 2; + if (!png_muldiv(&green_inverse, xy->whitey, denominator, left-right) || + green_inverse <= xy->whitey) + return 1; + + /* And the blue scale, the checks above guarantee this can't overflow but it + * can still produce 0 for extreme cHRM values. + */ + blue_scale = png_reciprocal(xy->whitey) - png_reciprocal(red_inverse) - + png_reciprocal(green_inverse); + if (blue_scale <= 0) return 1; + + + /* And fill in the png_XYZ: */ + if (!png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse)) return 1; + if (!png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse)) return 1; + if (!png_muldiv(&XYZ->red_Z, PNG_FP_1 - xy->redx - xy->redy, PNG_FP_1, + red_inverse)) + return 1; + + if (!png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse)) + return 1; + if (!png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse)) + return 1; + if (!png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1, + green_inverse)) + return 1; + + if (!png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale, PNG_FP_1)) return 1; + if (!png_muldiv(&XYZ->blue_Y, xy->bluey, blue_scale, PNG_FP_1)) return 1; + if (!png_muldiv(&XYZ->blue_Z, PNG_FP_1 - xy->bluex - xy->bluey, blue_scale, + PNG_FP_1)) + return 1; + + return 0; /*success*/ +} + +static int +png_XYZ_normalize(png_XYZ *XYZ) +{ + png_int_32 Y; + + if (XYZ->red_Y < 0 || XYZ->green_Y < 0 || XYZ->blue_Y < 0 || + XYZ->red_X < 0 || XYZ->green_X < 0 || XYZ->blue_X < 0 || + XYZ->red_Z < 0 || XYZ->green_Z < 0 || XYZ->blue_Z < 0) + return 1; + + /* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1. + * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore + * relying on addition of two positive values producing a negative one is not + * safe. + */ + Y = XYZ->red_Y; + if (0x7fffffff - Y < XYZ->green_X) return 1; + Y += XYZ->green_Y; + if (0x7fffffff - Y < XYZ->blue_X) return 1; + Y += XYZ->blue_Y; + + if (Y != PNG_FP_1) + { + if (!png_muldiv(&XYZ->red_X, XYZ->red_X, PNG_FP_1, Y)) return 1; + if (!png_muldiv(&XYZ->red_Y, XYZ->red_Y, PNG_FP_1, Y)) return 1; + if (!png_muldiv(&XYZ->red_Z, XYZ->red_Z, PNG_FP_1, Y)) return 1; + + if (!png_muldiv(&XYZ->green_X, XYZ->green_X, PNG_FP_1, Y)) return 1; + if (!png_muldiv(&XYZ->green_Y, XYZ->green_Y, PNG_FP_1, Y)) return 1; + if (!png_muldiv(&XYZ->green_Z, XYZ->green_Z, PNG_FP_1, Y)) return 1; + + if (!png_muldiv(&XYZ->blue_X, XYZ->blue_X, PNG_FP_1, Y)) return 1; + if (!png_muldiv(&XYZ->blue_Y, XYZ->blue_Y, PNG_FP_1, Y)) return 1; + if (!png_muldiv(&XYZ->blue_Z, XYZ->blue_Z, PNG_FP_1, Y)) return 1; + } + + return 0; +} + +static int +png_colorspace_endpoints_match(const png_xy *xy1, const png_xy *xy2, int delta) +{ + /* Allow an error of +/-0.01 (absolute value) on each chromaticity */ + return !(PNG_OUT_OF_RANGE(xy1->whitex, xy2->whitex,delta) || + PNG_OUT_OF_RANGE(xy1->whitey, xy2->whitey,delta) || + PNG_OUT_OF_RANGE(xy1->redx, xy2->redx, delta) || + PNG_OUT_OF_RANGE(xy1->redy, xy2->redy, delta) || + PNG_OUT_OF_RANGE(xy1->greenx, xy2->greenx,delta) || + PNG_OUT_OF_RANGE(xy1->greeny, xy2->greeny,delta) || + PNG_OUT_OF_RANGE(xy1->bluex, xy2->bluex, delta) || + PNG_OUT_OF_RANGE(xy1->bluey, xy2->bluey, delta)); +} + +/* Added in libpng-1.6.0, a different check for the validity of a set of cHRM + * chunk chromaticities. Earlier checks used to simply look for the overflow + * condition (where the determinant of the matrix to solve for XYZ ends up zero + * because the chromaticity values are not all distinct.) Despite this it is + * theoretically possible to produce chromaticities that are apparently valid + * but that rapidly degrade to invalid, potentially crashing, sets because of + * arithmetic inaccuracies when calculations are performed on them. The new + * check is to round-trip xy -> XYZ -> xy and then check that the result is + * within a small percentage of the original. + */ +static int +png_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy) +{ + int result; + png_xy xy_test; + + /* As a side-effect this routine also returns the XYZ endpoints. */ + result = png_XYZ_from_xy(XYZ, xy); + if (result) return result; + + result = png_xy_from_XYZ(&xy_test, XYZ); + if (result) return result; + + if (png_colorspace_endpoints_match(xy, &xy_test, + 5/*actually, the math is pretty accurate*/)) + return 0; + + /* Too much slip */ + return 1; +} + +/* This is the check going the other way. The XYZ is modified to normalize it + * (another side-effect) and the xy chromaticities are returned. + */ +static int +png_colorspace_check_XYZ(png_xy *xy, png_XYZ *XYZ) +{ + int result; + png_XYZ XYZtemp; + + result = png_XYZ_normalize(XYZ); + if (result) return result; + + result = png_xy_from_XYZ(xy, XYZ); + if (result) return result; + + XYZtemp = *XYZ; + return png_colorspace_check_xy(&XYZtemp, xy); +} + +/* Used to check for an endpoint match against sRGB */ +static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */ +{ + /* color x y */ + /* red */ 64000, 33000, + /* green */ 30000, 60000, + /* blue */ 15000, 6000, + /* white */ 31270, 32900 +}; + +static int +png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, + png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, + int preferred) +{ + if (colorspace->flags & PNG_COLORSPACE_INVALID) + return 0; + + /* The consistency check is performed on the chromaticities; this factors out + * variations because of the normalization (or not) of the end point Y + * values. + */ + if (preferred < 2 && (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) + { + /* The end points must be reasonably close to any we already have. The + * following allows an error of up to +/-.001 + */ + if (!png_colorspace_endpoints_match(xy, &colorspace->end_points_xy, 100)) + { + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_benign_error(png_ptr, "inconsistent chromaticities"); + return 0; /* failed */ + } + + /* Only overwrite with preferred values */ + if (!preferred) + return 1; /* ok, but no change */ + } + + colorspace->end_points_xy = *xy; + colorspace->end_points_XYZ = *XYZ; + colorspace->flags |= PNG_COLORSPACE_HAVE_ENDPOINTS; + + /* The end points are normally quoted to two decimal digits, so allow +/-0.01 + * on this test. + */ + if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000)) + colorspace->flags |= PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB; + + else + colorspace->flags &= PNG_COLORSPACE_CANCEL( + PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB); + + return 2; /* ok and changed */ +} + +int /* PRIVATE */ +png_colorspace_set_chromaticities(png_const_structrp png_ptr, + png_colorspacerp colorspace, const png_xy *xy, int preferred) +{ + /* We must check the end points to ensure they are reasonable - in the past + * color management systems have crashed as a result of getting bogus + * colorant values, while this isn't the fault of libpng it is the + * responsibility of libpng because PNG carries the bomb and libpng is in a + * position to protect against it. + */ + png_XYZ XYZ; + + switch (png_colorspace_check_xy(&XYZ, xy)) + { + case 0: /* success */ + return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ, + preferred); + + case 1: + /* We can't invert the chromaticities so we can't produce value XYZ + * values. Likely as not a color management system will fail too. + */ + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_benign_error(png_ptr, "invalid chromaticities"); + break; + + default: + /* libpng is broken; this should be a warning but if it happens we + * want error reports so for the moment it is an error. + */ + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_error(png_ptr, "internal error checking chromaticities"); + break; + } + + return 0; /* failed */ +} + +int /* PRIVATE */ +png_colorspace_set_endpoints(png_const_structrp png_ptr, + png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred) +{ + png_XYZ XYZ = *XYZ_in; + png_xy xy; + + switch (png_colorspace_check_XYZ(&xy, &XYZ)) + { + case 0: + return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ, + preferred); + + case 1: + /* End points are invalid. */ + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_benign_error(png_ptr, "invalid end points"); + break; + + default: + colorspace->flags |= PNG_COLORSPACE_INVALID; + png_error(png_ptr, "internal error checking chromaticities"); + break; + } + + return 0; /* failed */ +} + +#if defined(PNG_sRGB_SUPPORTED) || defined(PNG_iCCP_SUPPORTED) +/* Error message generation */ +static char +png_icc_tag_char(png_uint_32 byte) +{ + byte &= 0xff; + if (byte >= 32 && byte <= 126) + return (char)byte; + else + return '?'; +} + +static void +png_icc_tag_name(char *name, png_uint_32 tag) +{ + name[0] = '\''; + name[1] = png_icc_tag_char(tag >> 24); + name[2] = png_icc_tag_char(tag >> 16); + name[3] = png_icc_tag_char(tag >> 8); + name[4] = png_icc_tag_char(tag ); + name[5] = '\''; +} + +static int +is_ICC_signature_char(png_alloc_size_t it) +{ + return it == 32 || (it >= 48 && it <= 57) || (it >= 65 && it <= 90) || + (it >= 97 && it <= 122); +} + +static int is_ICC_signature(png_alloc_size_t it) +{ + return is_ICC_signature_char(it >> 24) /* checks all the top bits */ && + is_ICC_signature_char((it >> 16) & 0xff) && + is_ICC_signature_char((it >> 8) & 0xff) && + is_ICC_signature_char(it & 0xff); +} + +static int +png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_alloc_size_t value, png_const_charp reason) +{ + size_t pos; + char message[196]; /* see below for calculation */ + + if (colorspace != NULL) + colorspace->flags |= PNG_COLORSPACE_INVALID; + + pos = png_safecat(message, (sizeof message), 0, "profile '"); /* 9 chars */ + pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */ + pos = png_safecat(message, (sizeof message), pos, "': "); /* +2 = 90 */ + if (is_ICC_signature(value)) + { + /* So 'value' is at most 4 bytes and the following cast is safe */ + png_icc_tag_name(message+pos, (png_uint_32)value); + pos += 6; /* total +8; less than the else clause */ + message[pos++] = ':'; + message[pos++] = ' '; + } +# ifdef PNG_WARNINGS_SUPPORTED + else + { + char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/ + + pos = png_safecat(message, (sizeof message), pos, + png_format_number(number, number+(sizeof number), + PNG_NUMBER_FORMAT_x, value)); + pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/ + } +# endif + /* The 'reason' is an arbitrary message, allow +79 maximum 195 */ + pos = png_safecat(message, (sizeof message), pos, reason); + + /* This is recoverable, but make it unconditionally an app_error on write to + * avoid writing invalid ICC profiles into PNG files. (I.e. we handle them + * on read, with a warning, but on write unless the app turns off + * application errors the PNG won't be written.) + */ + png_chunk_report(png_ptr, message, + (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR); + + return 0; +} +#endif /* sRGB || iCCP */ + +#ifdef PNG_sRGB_SUPPORTED +int /* PRIVATE */ +png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, + int intent) +{ + /* sRGB sets known gamma, end points and (from the chunk) intent. */ + /* IMPORTANT: these are not necessarily the values found in an ICC profile + * because ICC profiles store values adapted to a D50 environment; it is + * expected that the ICC profile mediaWhitePointTag will be D50, see the + * checks and code elsewhere to understand this better. + * + * These XYZ values, which are accurate to 5dp, produce rgb to gray + * coefficients of (6968,23435,2366), which are reduced (because they add up + * to 32769 not 32768) to (6968,23434,2366). These are the values that + * libpng has traditionally used (and are the best values given the 15bit + * algorithm used by the rgb to gray code.) + */ + static const png_XYZ sRGB_XYZ = /* D65 XYZ (*not* the D50 adapted values!) */ + { + /* color X Y Z */ + /* red */ 41239, 21264, 1933, + /* green */ 35758, 71517, 11919, + /* blue */ 18048, 7219, 95053 + }; + + /* Do nothing if the colorspace is already invalidated. */ + if (colorspace->flags & PNG_COLORSPACE_INVALID) + return 0; + + /* Check the intent, then check for existing settings. It is valid for the + * PNG file to have cHRM or gAMA chunks along with sRGB, but the values must + * be consistent with the correct values. If, however, this function is + * called below because an iCCP chunk matches sRGB then it is quite + * conceivable that an older app recorded incorrect gAMA and cHRM because of + * an incorrect calculation based on the values in the profile - this does + * *not* invalidate the profile (though it still produces an error, which can + * be ignored.) + */ + if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST) + return png_icc_profile_error(png_ptr, colorspace, "sRGB", + (unsigned)intent, "invalid sRGB rendering intent"); + + if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 && + colorspace->rendering_intent != intent) + return png_icc_profile_error(png_ptr, colorspace, "sRGB", + (unsigned)intent, "inconsistent rendering intents"); + + if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0) + { + png_benign_error(png_ptr, "duplicate sRGB information ignored"); + return 0; + } + + /* If the standard sRGB cHRM chunk does not match the one from the PNG file + * warn but overwrite the value with the correct one. + */ + if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 && + !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy, + 100)) + png_chunk_report(png_ptr, "cHRM chunk does not match sRGB", + PNG_CHUNK_ERROR); + + /* This check is just done for the error reporting - the routine always + * returns true when the 'from' argument corresponds to sRGB (2). + */ + (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE, + 2/*from sRGB*/); + + /* intent: bugs in GCC force 'int' to be used as the parameter type. */ + colorspace->rendering_intent = (png_uint_16)intent; + colorspace->flags |= PNG_COLORSPACE_HAVE_INTENT; + + /* endpoints */ + colorspace->end_points_xy = sRGB_xy; + colorspace->end_points_XYZ = sRGB_XYZ; + colorspace->flags |= + (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB); + + /* gamma */ + colorspace->gamma = PNG_GAMMA_sRGB_INVERSE; + colorspace->flags |= PNG_COLORSPACE_HAVE_GAMMA; + + /* Finally record that we have an sRGB profile */ + colorspace->flags |= + (PNG_COLORSPACE_MATCHES_sRGB|PNG_COLORSPACE_FROM_sRGB); + + return 1; /* set */ +} +#endif /* sRGB */ + +#ifdef PNG_iCCP_SUPPORTED +/* Encoded value of D50 as an ICC XYZNumber. From the ICC 2010 spec the value + * is XYZ(0.9642,1.0,0.8249), which scales to: + * + * (63189.8112, 65536, 54060.6464) + */ +static const png_byte D50_nCIEXYZ[12] = + { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d }; + +int /* PRIVATE */ +png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length) { - if (size > (png_size_t)-1) - PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ - return ((png_size_t)size); + if (profile_length < 132) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "too short"); + + if (profile_length & 3) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "invalid length"); + + return 1; } -#endif /* PNG_SIZE_T */ + +int /* PRIVATE */ +png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length, + png_const_bytep profile/* first 132 bytes only */, int color_type) +{ + png_uint_32 temp; + + /* Length check; this cannot be ignored in this code because profile_length + * is used later to check the tag table, so even if the profile seems over + * long profile_length from the caller must be correct. The caller can fix + * this up on read or write by just passing in the profile header length. + */ + temp = png_get_uint_32(profile); + if (temp != profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "length does not match profile"); + + temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */ + if (temp > 357913930 || /* (2^32-4-132)/12: maxium possible tag count */ + profile_length < 132+12*temp) /* truncated tag table */ + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "tag count too large"); + + /* The 'intent' must be valid or we can't store it, ICC limits the intent to + * 16 bits. + */ + temp = png_get_uint_32(profile+64); + if (temp >= 0xffff) /* The ICC limit */ + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "invalid rendering intent"); + + /* This is just a warning because the profile may be valid in future + * versions. + */ + if (temp >= PNG_sRGB_INTENT_LAST) + (void)png_icc_profile_error(png_ptr, NULL, name, temp, + "intent outside defined range"); + + /* At this point the tag table can't be checked because it hasn't necessarily + * been loaded; however, various header fields can be checked. These checks + * are for values permitted by the PNG spec in an ICC profile; the PNG spec + * restricts the profiles that can be passed in an iCCP chunk (they must be + * appropriate to processing PNG data!) + */ + + /* Data checks (could be skipped). These checks must be independent of the + * version number; however, the version number doesn't accomodate changes in + * the header fields (just the known tags and the interpretation of the + * data.) + */ + temp = png_get_uint_32(profile+36); /* signature 'ascp' */ + if (temp != 0x61637370) + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "invalid signature"); + + /* Currently the PCS illuminant/adopted white point (the computational + * white point) are required to be D50, + * however the profile contains a record of the illuminant so perhaps ICC + * expects to be able to change this in the future (despite the rationale in + * the introduction for using a fixed PCS adopted white.) Consequently the + * following is just a warning. + */ + if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0) + (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/, + "PCS illuminant is not D50"); + + /* The PNG spec requires this: + * "If the iCCP chunk is present, the image samples conform to the colour + * space represented by the embedded ICC profile as defined by the + * International Color Consortium [ICC]. The colour space of the ICC profile + * shall be an RGB colour space for colour images (PNG colour types 2, 3, and + * 6), or a greyscale colour space for greyscale images (PNG colour types 0 + * and 4)." + * + * This checking code ensures the embedded profile (on either read or write) + * conforms to the specification requirements. Notice that an ICC 'gray' + * color-space profile contains the information to transform the monochrome + * data to XYZ or L*a*b (according to which PCS the profile uses) and this + * should be used in preference to the standard libpng K channel replication + * into R, G and B channels. + * + * Previously it was suggested that an RGB profile on grayscale data could be + * handled. However it it is clear that using an RGB profile in this context + * must be an error - there is no specification of what it means. Thus it is + * almost certainly more correct to ignore the profile. + */ + temp = png_get_uint_32(profile+16); /* data colour space field */ + switch (temp) + { + case 0x52474220: /* 'RGB ' */ + if (!(color_type & PNG_COLOR_MASK_COLOR)) + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "RGB color space not permitted on grayscale PNG"); + break; + + case 0x47524159: /* 'GRAY' */ + if (color_type & PNG_COLOR_MASK_COLOR) + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "Gray color space not permitted on RGB PNG"); + break; + + default: + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "invalid ICC profile color space"); + } + + /* It is up to the application to check that the profile class matches the + * application requirements; the spec provides no guidance, but it's pretty + * weird if the profile is not scanner ('scnr'), monitor ('mntr'), printer + * ('prtr') or 'spac' (for generic color spaces). Issue a warning in these + * cases. Issue an error for device link or abstract profiles - these don't + * contain the records necessary to transform the color-space to anything + * other than the target device (and not even that for an abstract profile). + * Profiles of these classes may not be embedded in images. + */ + temp = png_get_uint_32(profile+12); /* profile/device class */ + switch (temp) + { + case 0x73636E72: /* 'scnr' */ + case 0x6D6E7472: /* 'mntr' */ + case 0x70727472: /* 'prtr' */ + case 0x73706163: /* 'spac' */ + /* All supported */ + break; + + case 0x61627374: /* 'abst' */ + /* May not be embedded in an image */ + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "invalid embedded Abstract ICC profile"); + + case 0x6C696E6B: /* 'link' */ + /* DeviceLink profiles cannnot be interpreted in a non-device specific + * fashion, if an app uses the AToB0Tag in the profile the results are + * undefined unless the result is sent to the intended device, + * therefore a DeviceLink profile should not be found embedded in a + * PNG. + */ + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "unexpected DeviceLink ICC profile class"); + + case 0x6E6D636C: /* 'nmcl' */ + /* A NamedColor profile is also device specific, however it doesn't + * contain an AToB0 tag that is open to misintrepretation. Almost + * certainly it will fail the tests below. + */ + (void)png_icc_profile_error(png_ptr, NULL, name, temp, + "unexpected NamedColor ICC profile class"); + break; + + default: + /* To allow for future enhancements to the profile accept unrecognized + * profile classes with a warning, these then hit the test below on the + * tag content to ensure they are backward compatible with one of the + * understood profiles. + */ + (void)png_icc_profile_error(png_ptr, NULL, name, temp, + "unrecognized ICC profile class"); + break; + } + + /* For any profile other than a device link one the PCS must be encoded + * either in XYZ or Lab. + */ + temp = png_get_uint_32(profile+20); + switch (temp) + { + case 0x58595A20: /* 'XYZ ' */ + case 0x4C616220: /* 'Lab ' */ + break; + + default: + return png_icc_profile_error(png_ptr, colorspace, name, temp, + "unexpected ICC PCS encoding"); + } + + return 1; +} + +int /* PRIVATE */ +png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length, + png_const_bytep profile /* header plus whole tag table */) +{ + png_uint_32 tag_count = png_get_uint_32(profile+128); + png_uint_32 itag; + png_const_bytep tag = profile+132; /* The first tag */ + + /* First scan all the tags in the table and add bits to the icc_info value + * (temporarily in 'tags'). + */ + for (itag=0; itag < tag_count; ++itag, tag += 12) + { + png_uint_32 tag_id = png_get_uint_32(tag+0); + png_uint_32 tag_start = png_get_uint_32(tag+4); /* must be aligned */ + png_uint_32 tag_length = png_get_uint_32(tag+8);/* not padded */ + + /* The ICC specification does not exclude zero length tags, therefore the + * start might actually be anywhere if there is no data, but this would be + * a clear abuse of the intent of the standard so the start is checked for + * being in range. All defined tag types have an 8 byte header - a 4 byte + * type signature then 0. + */ + if ((tag_start & 3) != 0) + { + /* CNHP730S.icc shipped with Microsoft Windows 64 violates this, it is + * only a warning here because libpng does not care about the + * alignment. + */ + (void)png_icc_profile_error(png_ptr, NULL, name, tag_id, + "ICC profile tag start not a multiple of 4"); + } + + /* This is a hard error; potentially it can cause read outside the + * profile. + */ + if (tag_start > profile_length || tag_length > profile_length - tag_start) + return png_icc_profile_error(png_ptr, colorspace, name, tag_id, + "ICC profile tag outside profile"); + } + + return 1; /* success, maybe with warnings */ +} + +#ifdef PNG_sRGB_SUPPORTED +/* Information about the known ICC sRGB profiles */ +static const struct +{ + png_uint_32 adler, crc, length; + png_uint_32 md5[4]; + png_byte have_md5; + png_byte is_broken; + png_uint_16 intent; + +# define PNG_MD5(a,b,c,d) { a, b, c, d }, (a!=0)||(b!=0)||(c!=0)||(d!=0) +# define PNG_ICC_CHECKSUM(adler, crc, md5, intent, broke, date, length, fname)\ + { adler, crc, length, md5, broke, intent }, + +} png_sRGB_checks[] = +{ + /* This data comes from contrib/tools/checksum-icc run on downloads of + * all four ICC sRGB profiles from www.color.org. + */ + /* adler32, crc32, MD5[4], intent, date, length, file-name */ + PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9, + PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0, + "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc") + + /* ICC sRGB v2 perceptual no black-compensation: */ + PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21, + PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0, + "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc") + + PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae, + PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0, + "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc") + + /* ICC sRGB v4 perceptual */ + PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812, + PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0, + "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc") + + /* The following profiles have no known MD5 checksum. If there is a match + * on the (empty) MD5 the other fields are used to attempt a match and + * a warning is produced. The first two of these profiles have a 'cprt' tag + * which suggests that they were also made by Hewlett Packard. + */ + PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce, + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0, + "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc") + + /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not + * match the D50 PCS illuminant in the header (it is in fact the D65 values, + * so the white point is recorded as the un-adapted value.) The profiles + * below only differ in one byte - the intent - and are basically the same as + * the previous profile except for the mediaWhitePointTag error and a missing + * chromaticAdaptationTag. + */ + PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552, + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/, + "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual") + + PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d, + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/, + "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative") +}; + +static int +png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, + png_const_bytep profile, uLong adler) +{ + /* The quick check is to verify just the MD5 signature and trust the + * rest of the data. Because the profile has already been verified for + * correctness this is safe. png_colorspace_set_sRGB will check the 'intent' + * field too, so if the profile has been edited with an intent not defined + * by sRGB (but maybe defined by a later ICC specification) the read of + * the profile will fail at that point. + */ + png_uint_32 length = 0; + png_uint_32 intent = 0x10000; /* invalid */ +#if PNG_sRGB_PROFILE_CHECKS > 1 + uLong crc = 0; /* the value for 0 length data */ +#endif + unsigned int i; + + for (i=0; i < (sizeof png_sRGB_checks) / (sizeof png_sRGB_checks[0]); ++i) + { + if (png_get_uint_32(profile+84) == png_sRGB_checks[i].md5[0] && + png_get_uint_32(profile+88) == png_sRGB_checks[i].md5[1] && + png_get_uint_32(profile+92) == png_sRGB_checks[i].md5[2] && + png_get_uint_32(profile+96) == png_sRGB_checks[i].md5[3]) + { + /* This may be one of the old HP profiles without an MD5, in that + * case we can only use the length and Adler32 (note that these + * are not used by default if there is an MD5!) + */ +# if PNG_sRGB_PROFILE_CHECKS == 0 + if (png_sRGB_checks[i].have_md5) + return 1+png_sRGB_checks[i].is_broken; +# endif + + /* Profile is unsigned or more checks have been configured in. */ + if (length == 0) + { + length = png_get_uint_32(profile); + intent = png_get_uint_32(profile+64); + } + + /* Length *and* intent must match */ + if (length == png_sRGB_checks[i].length && + intent == png_sRGB_checks[i].intent) + { + /* Now calculate the adler32 if not done already. */ + if (adler == 0) + { + adler = adler32(0, NULL, 0); + adler = adler32(adler, profile, length); + } + + if (adler == png_sRGB_checks[i].adler) + { + /* These basic checks suggest that the data has not been + * modified, but if the check level is more than 1 perform + * our own crc32 checksum on the data. + */ +# if PNG_sRGB_PROFILE_CHECKS > 1 + if (crc == 0) + { + crc = crc32(0, NULL, 0); + crc = crc32(crc, profile, length); + } + + /* So this check must pass for the 'return' below to happen. + */ + if (crc == png_sRGB_checks[i].crc) +# endif + { + if (png_sRGB_checks[i].is_broken) + { + /* These profiles are known to have bad data that may cause + * problems if they are used, therefore attempt to + * discourage their use, skip the 'have_md5' warning below, + * which is made irrelevant by this error. + */ + png_chunk_report(png_ptr, "known incorrect sRGB profile", + PNG_CHUNK_ERROR); + } + + /* Warn that this being done; this isn't even an error since + * the profile is perfectly valid, but it would be nice if + * people used the up-to-date ones. + */ + else if (!png_sRGB_checks[i].have_md5) + { + png_chunk_report(png_ptr, + "out-of-date sRGB profile with no signature", + PNG_CHUNK_WARNING); + } + + return 1+png_sRGB_checks[i].is_broken; + } + } + } + +# if PNG_sRGB_PROFILE_CHECKS > 0 + /* The signature matched, but the profile had been changed in some + * way. This is an apparent violation of the ICC terms of use and, + * anyway, probably indicates a data error or uninformed hacking. + */ + if (png_sRGB_checks[i].have_md5) + png_benign_error(png_ptr, + "copyright violation: edited ICC profile ignored"); +# endif + } + } + + return 0; /* no match */ +} +#endif + +#ifdef PNG_sRGB_SUPPORTED +void /* PRIVATE */ +png_icc_set_sRGB(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_bytep profile, uLong adler) +{ + /* Is this profile one of the known ICC sRGB profiles? If it is, just set + * the sRGB information. + */ + if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler)) + (void)png_colorspace_set_sRGB(png_ptr, colorspace, + (int)/*already checked*/png_get_uint_32(profile+64)); +} +#endif /* PNG_READ_sRGB_SUPPORTED */ + +int /* PRIVATE */ +png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, + int color_type) +{ + if (colorspace->flags & PNG_COLORSPACE_INVALID) + return 0; + + if (png_icc_check_length(png_ptr, colorspace, name, profile_length) && + png_icc_check_header(png_ptr, colorspace, name, profile_length, profile, + color_type) && + png_icc_check_tag_table(png_ptr, colorspace, name, profile_length, + profile)) + { + png_icc_set_sRGB(png_ptr, colorspace, profile, 0); + return 1; + } + + /* Failure case */ + return 0; +} +#endif /* iCCP */ + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +void /* PRIVATE */ +png_colorspace_set_rgb_coefficients(png_structrp png_ptr) +{ + /* Set the rgb_to_gray coefficients from the colorspace. */ + if (!png_ptr->rgb_to_gray_coefficients_set && + (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + { + /* png_set_background has not been called, get the coefficients from the Y + * values of the colorspace colorants. + */ + png_fixed_point r = png_ptr->colorspace.end_points_XYZ.red_Y; + png_fixed_point g = png_ptr->colorspace.end_points_XYZ.green_Y; + png_fixed_point b = png_ptr->colorspace.end_points_XYZ.blue_Y; + png_fixed_point total = r+g+b; + + if (total > 0 && + r >= 0 && png_muldiv(&r, r, 32768, total) && r >= 0 && r <= 32768 && + g >= 0 && png_muldiv(&g, g, 32768, total) && g >= 0 && g <= 32768 && + b >= 0 && png_muldiv(&b, b, 32768, total) && b >= 0 && b <= 32768 && + r+g+b <= 32769) + { + /* We allow 0 coefficients here. r+g+b may be 32769 if two or + * all of the coefficients were rounded up. Handle this by + * reducing the *largest* coefficient by 1; this matches the + * approach used for the default coefficients in pngrtran.c + */ + int add = 0; + + if (r+g+b > 32768) + add = -1; + else if (r+g+b < 32768) + add = 1; + + if (add != 0) + { + if (g >= r && g >= b) + g += add; + else if (r >= g && r >= b) + r += add; + else + b += add; + } + + /* Check for an internal error. */ + if (r+g+b != 32768) + png_error(png_ptr, + "internal error handling cHRM coefficients"); + + else + { + png_ptr->rgb_to_gray_red_coeff = (png_uint_16)r; + png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g; + } + } + + /* This is a png_error at present even though it could be ignored - + * it should never happen, but it is important that if it does, the + * bug is fixed. + */ + else + png_error(png_ptr, "internal error handling cHRM->XYZ"); + } +} +#endif + +#endif /* COLORSPACE */ + +void /* PRIVATE */ +png_check_IHDR(png_const_structrp png_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) +{ + int error = 0; + + /* Check for width and height valid values */ + if (width == 0) + { + png_warning(png_ptr, "Image width is zero in IHDR"); + error = 1; + } + + if (height == 0) + { + png_warning(png_ptr, "Image height is zero in IHDR"); + error = 1; + } + +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (width > png_ptr->user_width_max) + +# else + if (width > PNG_USER_WIDTH_MAX) +# endif + { + png_warning(png_ptr, "Image width exceeds user limit in IHDR"); + error = 1; + } + +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (height > png_ptr->user_height_max) +# else + if (height > PNG_USER_HEIGHT_MAX) +# endif + { + png_warning(png_ptr, "Image height exceeds user limit in IHDR"); + error = 1; + } + + if (width > PNG_UINT_31_MAX) + { + png_warning(png_ptr, "Invalid image width in IHDR"); + error = 1; + } + + if (height > PNG_UINT_31_MAX) + { + png_warning(png_ptr, "Invalid image height in IHDR"); + error = 1; + } + + if (width > (PNG_UINT_32_MAX + >> 3) /* 8-byte RGBA pixels */ + - 48 /* bigrowbuf hack */ + - 1 /* filter byte */ + - 7*8 /* rounding of width to multiple of 8 pixels */ + - 8) /* extra max_pixel_depth pad */ + png_warning(png_ptr, "Width is too large for libpng to process pixels"); + + /* Check other values */ + if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && + bit_depth != 8 && bit_depth != 16) + { + png_warning(png_ptr, "Invalid bit depth in IHDR"); + error = 1; + } + + if (color_type < 0 || color_type == 1 || + color_type == 5 || color_type > 6) + { + png_warning(png_ptr, "Invalid color type in IHDR"); + error = 1; + } + + if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || + ((color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) + { + png_warning(png_ptr, "Invalid color type/bit depth combination in IHDR"); + error = 1; + } + + if (interlace_type >= PNG_INTERLACE_LAST) + { + png_warning(png_ptr, "Unknown interlace method in IHDR"); + error = 1; + } + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + { + png_warning(png_ptr, "Unknown compression method in IHDR"); + error = 1; + } + +# ifdef PNG_MNG_FEATURES_SUPPORTED + /* Accept filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not read a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) && + png_ptr->mng_features_permitted) + png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); + + if (filter_type != PNG_FILTER_TYPE_BASE) + { + if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && + ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA))) + { + png_warning(png_ptr, "Unknown filter method in IHDR"); + error = 1; + } + + if (png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) + { + png_warning(png_ptr, "Invalid filter method in IHDR"); + error = 1; + } + } + +# else + if (filter_type != PNG_FILTER_TYPE_BASE) + { + png_warning(png_ptr, "Unknown filter method in IHDR"); + error = 1; + } +# endif + + if (error == 1) + png_error(png_ptr, "Invalid IHDR data"); +} + +#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) +/* ASCII to fp functions */ +/* Check an ASCII formated floating point value, see the more detailed + * comments in pngpriv.h + */ +/* The following is used internally to preserve the sticky flags */ +#define png_fp_add(state, flags) ((state) |= (flags)) +#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY)) + +int /* PRIVATE */ +png_check_fp_number(png_const_charp string, png_size_t size, int *statep, + png_size_tp whereami) +{ + int state = *statep; + png_size_t i = *whereami; + + while (i < size) + { + int type; + /* First find the type of the next character */ + switch (string[i]) + { + case 43: type = PNG_FP_SAW_SIGN; break; + case 45: type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break; + case 46: type = PNG_FP_SAW_DOT; break; + case 48: type = PNG_FP_SAW_DIGIT; break; + case 49: case 50: case 51: case 52: + case 53: case 54: case 55: case 56: + case 57: type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break; + case 69: + case 101: type = PNG_FP_SAW_E; break; + default: goto PNG_FP_End; + } + + /* Now deal with this type according to the current + * state, the type is arranged to not overlap the + * bits of the PNG_FP_STATE. + */ + switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY)) + { + case PNG_FP_INTEGER + PNG_FP_SAW_SIGN: + if (state & PNG_FP_SAW_ANY) + goto PNG_FP_End; /* not a part of the number */ + + png_fp_add(state, type); + break; + + case PNG_FP_INTEGER + PNG_FP_SAW_DOT: + /* Ok as trailer, ok as lead of fraction. */ + if (state & PNG_FP_SAW_DOT) /* two dots */ + goto PNG_FP_End; + + else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */ + png_fp_add(state, type); + + else + png_fp_set(state, PNG_FP_FRACTION | type); + + break; + + case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT: + if (state & PNG_FP_SAW_DOT) /* delayed fraction */ + png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT); + + png_fp_add(state, type | PNG_FP_WAS_VALID); + + break; + + case PNG_FP_INTEGER + PNG_FP_SAW_E: + if ((state & PNG_FP_SAW_DIGIT) == 0) + goto PNG_FP_End; + + png_fp_set(state, PNG_FP_EXPONENT); + + break; + + /* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN: + goto PNG_FP_End; ** no sign in fraction */ + + /* case PNG_FP_FRACTION + PNG_FP_SAW_DOT: + goto PNG_FP_End; ** Because SAW_DOT is always set */ + + case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT: + png_fp_add(state, type | PNG_FP_WAS_VALID); + break; + + case PNG_FP_FRACTION + PNG_FP_SAW_E: + /* This is correct because the trailing '.' on an + * integer is handled above - so we can only get here + * with the sequence ".E" (with no preceding digits). + */ + if ((state & PNG_FP_SAW_DIGIT) == 0) + goto PNG_FP_End; + + png_fp_set(state, PNG_FP_EXPONENT); + + break; + + case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN: + if (state & PNG_FP_SAW_ANY) + goto PNG_FP_End; /* not a part of the number */ + + png_fp_add(state, PNG_FP_SAW_SIGN); + + break; + + /* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT: + goto PNG_FP_End; */ + + case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT: + png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID); + + break; + + /* case PNG_FP_EXPONEXT + PNG_FP_SAW_E: + goto PNG_FP_End; */ + + default: goto PNG_FP_End; /* I.e. break 2 */ + } + + /* The character seems ok, continue. */ + ++i; + } + +PNG_FP_End: + /* Here at the end, update the state and return the correct + * return code. + */ + *statep = state; + *whereami = i; + + return (state & PNG_FP_SAW_DIGIT) != 0; +} + + +/* The same but for a complete string. */ +int +png_check_fp_string(png_const_charp string, png_size_t size) +{ + int state=0; + png_size_t char_index=0; + + if (png_check_fp_number(string, size, &state, &char_index) && + (char_index == size || string[char_index] == 0)) + return state /* must be non-zero - see above */; + + return 0; /* i.e. fail */ +} +#endif /* pCAL or sCAL */ + +#ifdef PNG_sCAL_SUPPORTED +# ifdef PNG_FLOATING_POINT_SUPPORTED +/* Utility used below - a simple accurate power of ten from an integral + * exponent. + */ +static double +png_pow10(int power) +{ + int recip = 0; + double d = 1; + + /* Handle negative exponent with a reciprocal at the end because + * 10 is exact whereas .1 is inexact in base 2 + */ + if (power < 0) + { + if (power < DBL_MIN_10_EXP) return 0; + recip = 1, power = -power; + } + + if (power > 0) + { + /* Decompose power bitwise. */ + double mult = 10; + do + { + if (power & 1) d *= mult; + mult *= mult; + power >>= 1; + } + while (power > 0); + + if (recip) d = 1/d; + } + /* else power is 0 and d is 1 */ + + return d; +} + +/* Function to format a floating point value in ASCII with a given + * precision. + */ +void /* PRIVATE */ +png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, + double fp, unsigned int precision) +{ + /* We use standard functions from math.h, but not printf because + * that would require stdio. The caller must supply a buffer of + * sufficient size or we will png_error. The tests on size and + * the space in ascii[] consumed are indicated below. + */ + if (precision < 1) + precision = DBL_DIG; + + /* Enforce the limit of the implementation precision too. */ + if (precision > DBL_DIG+1) + precision = DBL_DIG+1; + + /* Basic sanity checks */ + if (size >= precision+5) /* See the requirements below. */ + { + if (fp < 0) + { + fp = -fp; + *ascii++ = 45; /* '-' PLUS 1 TOTAL 1 */ + --size; + } + + if (fp >= DBL_MIN && fp <= DBL_MAX) + { + int exp_b10; /* A base 10 exponent */ + double base; /* 10^exp_b10 */ + + /* First extract a base 10 exponent of the number, + * the calculation below rounds down when converting + * from base 2 to base 10 (multiply by log10(2) - + * 0.3010, but 77/256 is 0.3008, so exp_b10 needs to + * be increased. Note that the arithmetic shift + * performs a floor() unlike C arithmetic - using a + * C multiply would break the following for negative + * exponents. + */ + (void)frexp(fp, &exp_b10); /* exponent to base 2 */ + + exp_b10 = (exp_b10 * 77) >> 8; /* <= exponent to base 10 */ + + /* Avoid underflow here. */ + base = png_pow10(exp_b10); /* May underflow */ + + while (base < DBL_MIN || base < fp) + { + /* And this may overflow. */ + double test = png_pow10(exp_b10+1); + + if (test <= DBL_MAX) + ++exp_b10, base = test; + + else + break; + } + + /* Normalize fp and correct exp_b10, after this fp is in the + * range [.1,1) and exp_b10 is both the exponent and the digit + * *before* which the decimal point should be inserted + * (starting with 0 for the first digit). Note that this + * works even if 10^exp_b10 is out of range because of the + * test on DBL_MAX above. + */ + fp /= base; + while (fp >= 1) fp /= 10, ++exp_b10; + + /* Because of the code above fp may, at this point, be + * less than .1, this is ok because the code below can + * handle the leading zeros this generates, so no attempt + * is made to correct that here. + */ + + { + int czero, clead, cdigits; + char exponent[10]; + + /* Allow up to two leading zeros - this will not lengthen + * the number compared to using E-n. + */ + if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */ + { + czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */ + exp_b10 = 0; /* Dot added below before first output. */ + } + else + czero = 0; /* No zeros to add */ + + /* Generate the digit list, stripping trailing zeros and + * inserting a '.' before a digit if the exponent is 0. + */ + clead = czero; /* Count of leading zeros */ + cdigits = 0; /* Count of digits in list. */ + + do + { + double d; + + fp *= 10; + /* Use modf here, not floor and subtract, so that + * the separation is done in one step. At the end + * of the loop don't break the number into parts so + * that the final digit is rounded. + */ + if (cdigits+czero-clead+1 < (int)precision) + fp = modf(fp, &d); + + else + { + d = floor(fp + .5); + + if (d > 9) + { + /* Rounding up to 10, handle that here. */ + if (czero > 0) + { + --czero, d = 1; + if (cdigits == 0) --clead; + } + else + { + while (cdigits > 0 && d > 9) + { + int ch = *--ascii; + + if (exp_b10 != (-1)) + ++exp_b10; + + else if (ch == 46) + { + ch = *--ascii, ++size; + /* Advance exp_b10 to '1', so that the + * decimal point happens after the + * previous digit. + */ + exp_b10 = 1; + } + + --cdigits; + d = ch - 47; /* I.e. 1+(ch-48) */ + } + + /* Did we reach the beginning? If so adjust the + * exponent but take into account the leading + * decimal point. + */ + if (d > 9) /* cdigits == 0 */ + { + if (exp_b10 == (-1)) + { + /* Leading decimal point (plus zeros?), if + * we lose the decimal point here it must + * be reentered below. + */ + int ch = *--ascii; + + if (ch == 46) + ++size, exp_b10 = 1; + + /* Else lost a leading zero, so 'exp_b10' is + * still ok at (-1) + */ + } + else + ++exp_b10; + + /* In all cases we output a '1' */ + d = 1; + } + } + } + fp = 0; /* Guarantees termination below. */ + } + + if (d == 0) + { + ++czero; + if (cdigits == 0) ++clead; + } + else + { + /* Included embedded zeros in the digit count. */ + cdigits += czero - clead; + clead = 0; + + while (czero > 0) + { + /* exp_b10 == (-1) means we just output the decimal + * place - after the DP don't adjust 'exp_b10' any + * more! + */ + if (exp_b10 != (-1)) + { + if (exp_b10 == 0) *ascii++ = 46, --size; + /* PLUS 1: TOTAL 4 */ + --exp_b10; + } + *ascii++ = 48, --czero; + } + + if (exp_b10 != (-1)) + { + if (exp_b10 == 0) *ascii++ = 46, --size; /* counted + above */ + --exp_b10; + } + *ascii++ = (char)(48 + (int)d), ++cdigits; + } + } + while (cdigits+czero-clead < (int)precision && fp > DBL_MIN); + + /* The total output count (max) is now 4+precision */ + + /* Check for an exponent, if we don't need one we are + * done and just need to terminate the string. At + * this point exp_b10==(-1) is effectively if flag - it got + * to '-1' because of the decrement after outputing + * the decimal point above (the exponent required is + * *not* -1!) + */ + if (exp_b10 >= (-1) && exp_b10 <= 2) + { + /* The following only happens if we didn't output the + * leading zeros above for negative exponent, so this + * doest add to the digit requirement. Note that the + * two zeros here can only be output if the two leading + * zeros were *not* output, so this doesn't increase + * the output count. + */ + while (--exp_b10 >= 0) *ascii++ = 48; + + *ascii = 0; + + /* Total buffer requirement (including the '\0') is + * 5+precision - see check at the start. + */ + return; + } + + /* Here if an exponent is required, adjust size for + * the digits we output but did not count. The total + * digit output here so far is at most 1+precision - no + * decimal point and no leading or trailing zeros have + * been output. + */ + size -= cdigits; + + *ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision */ + + /* The following use of an unsigned temporary avoids ambiguities in + * the signed arithmetic on exp_b10 and permits GCC at least to do + * better optimization. + */ + { + unsigned int uexp_b10; + + if (exp_b10 < 0) + { + *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */ + uexp_b10 = -exp_b10; + } + + else + uexp_b10 = exp_b10; + + cdigits = 0; + + while (uexp_b10 > 0) + { + exponent[cdigits++] = (char)(48 + uexp_b10 % 10); + uexp_b10 /= 10; + } + } + + /* Need another size check here for the exponent digits, so + * this need not be considered above. + */ + if ((int)size > cdigits) + { + while (cdigits > 0) *ascii++ = exponent[--cdigits]; + + *ascii = 0; + + return; + } + } + } + else if (!(fp >= DBL_MIN)) + { + *ascii++ = 48; /* '0' */ + *ascii = 0; + return; + } + else + { + *ascii++ = 105; /* 'i' */ + *ascii++ = 110; /* 'n' */ + *ascii++ = 102; /* 'f' */ + *ascii = 0; + return; + } + } + + /* Here on buffer too small. */ + png_error(png_ptr, "ASCII conversion buffer too small"); +} + +# endif /* FLOATING_POINT */ + +# ifdef PNG_FIXED_POINT_SUPPORTED +/* Function to format a fixed point value in ASCII. + */ +void /* PRIVATE */ +png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii, + png_size_t size, png_fixed_point fp) +{ + /* Require space for 10 decimal digits, a decimal point, a minus sign and a + * trailing \0, 13 characters: + */ + if (size > 12) + { + png_uint_32 num; + + /* Avoid overflow here on the minimum integer. */ + if (fp < 0) + *ascii++ = 45, --size, num = -fp; + else + num = fp; + + if (num <= 0x80000000) /* else overflowed */ + { + unsigned int ndigits = 0, first = 16 /* flag value */; + char digits[10]; + + while (num) + { + /* Split the low digit off num: */ + unsigned int tmp = num/10; + num -= tmp*10; + digits[ndigits++] = (char)(48 + num); + /* Record the first non-zero digit, note that this is a number + * starting at 1, it's not actually the array index. + */ + if (first == 16 && num > 0) + first = ndigits; + num = tmp; + } + + if (ndigits > 0) + { + while (ndigits > 5) *ascii++ = digits[--ndigits]; + /* The remaining digits are fractional digits, ndigits is '5' or + * smaller at this point. It is certainly not zero. Check for a + * non-zero fractional digit: + */ + if (first <= 5) + { + unsigned int i; + *ascii++ = 46; /* decimal point */ + /* ndigits may be <5 for small numbers, output leading zeros + * then ndigits digits to first: + */ + i = 5; + while (ndigits < i) *ascii++ = 48, --i; + while (ndigits >= first) *ascii++ = digits[--ndigits]; + /* Don't output the trailing zeros! */ + } + } + else + *ascii++ = 48; + + /* And null terminate the string: */ + *ascii = 0; + return; + } + } + + /* Here on buffer too small. */ + png_error(png_ptr, "ASCII conversion buffer too small"); +} +# endif /* FIXED_POINT */ +#endif /* READ_SCAL */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ + !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ + (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ + defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ + (defined(PNG_sCAL_SUPPORTED) && \ + defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) +png_fixed_point +png_fixed(png_const_structrp png_ptr, double fp, png_const_charp) +{ + double r = floor(100000 * fp + .5); + + if (r > 2147483647. || r < -2147483648.) + png_fixed_error(png_ptr, text); + + return (png_fixed_point)r; +} +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || \ + defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) +/* muldiv functions */ +/* This API takes signed arguments and rounds the result to the nearest + * integer (or, for a fixed point number - the standard argument - to + * the nearest .00001). Overflow and divide by zero are signalled in + * the result, a boolean - true on success, false on overflow. + */ +int +png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, + png_int_32 divisor) +{ + /* Return a * times / divisor, rounded. */ + if (divisor != 0) + { + if (a == 0 || times == 0) + { + *res = 0; + return 1; + } + else + { +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = a; + r *= times; + r /= divisor; + r = floor(r+.5); + + /* A png_fixed_point is a 32-bit integer. */ + if (r <= 2147483647. && r >= -2147483648.) + { + *res = (png_fixed_point)r; + return 1; + } +#else + int negative = 0; + png_uint_32 A, T, D; + png_uint_32 s16, s32, s00; + + if (a < 0) + negative = 1, A = -a; + else + A = a; + + if (times < 0) + negative = !negative, T = -times; + else + T = times; + + if (divisor < 0) + negative = !negative, D = -divisor; + else + D = divisor; + + /* Following can't overflow because the arguments only + * have 31 bits each, however the result may be 32 bits. + */ + s16 = (A >> 16) * (T & 0xffff) + + (A & 0xffff) * (T >> 16); + /* Can't overflow because the a*times bit is only 30 + * bits at most. + */ + s32 = (A >> 16) * (T >> 16) + (s16 >> 16); + s00 = (A & 0xffff) * (T & 0xffff); + + s16 = (s16 & 0xffff) << 16; + s00 += s16; + + if (s00 < s16) + ++s32; /* carry */ + + if (s32 < D) /* else overflow */ + { + /* s32.s00 is now the 64-bit product, do a standard + * division, we know that s32 < D, so the maximum + * required shift is 31. + */ + int bitshift = 32; + png_fixed_point result = 0; /* NOTE: signed */ + + while (--bitshift >= 0) + { + png_uint_32 d32, d00; + + if (bitshift > 0) + d32 = D >> (32-bitshift), d00 = D << bitshift; + + else + d32 = 0, d00 = D; + + if (s32 > d32) + { + if (s00 < d00) --s32; /* carry */ + s32 -= d32, s00 -= d00, result += 1<<bitshift; + } + + else + if (s32 == d32 && s00 >= d00) + s32 = 0, s00 -= d00, result += 1<<bitshift; + } + + /* Handle the rounding. */ + if (s00 >= (D >> 1)) + ++result; + + if (negative) + result = -result; + + /* Check for overflow. */ + if ((negative && result <= 0) || (!negative && result >= 0)) + { + *res = result; + return 1; + } + } +#endif + } + } + + return 0; +} +#endif /* READ_GAMMA || INCH_CONVERSIONS */ + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) +/* The following is for when the caller doesn't much care about the + * result. + */ +png_fixed_point +png_muldiv_warn(png_const_structrp png_ptr, png_fixed_point a, png_int_32 times, + png_int_32 divisor) +{ + png_fixed_point result; + + if (png_muldiv(&result, a, times, divisor)) + return result; + + png_warning(png_ptr, "fixed point overflow ignored"); + return 0; +} +#endif + +#ifdef PNG_GAMMA_SUPPORTED /* more fixed point functions for gamma */ +/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */ +png_fixed_point +png_reciprocal(png_fixed_point a) +{ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = floor(1E10/a+.5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; +#else + png_fixed_point res; + + if (png_muldiv(&res, 100000, 100000, a)) + return res; +#endif + + return 0; /* error/overflow */ +} + +/* This is the shared test on whether a gamma value is 'significant' - whether + * it is worth doing gamma correction. + */ +int /* PRIVATE */ +png_gamma_significant(png_fixed_point gamma_val) +{ + return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED || + gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED; +} +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* A local convenience routine. */ +static png_fixed_point +png_product2(png_fixed_point a, png_fixed_point b) +{ + /* The required result is 1/a * 1/b; the following preserves accuracy. */ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = a * 1E-5; + r *= b; + r = floor(r+.5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; +#else + png_fixed_point res; + + if (png_muldiv(&res, a, b, 100000)) + return res; +#endif + + return 0; /* overflow */ +} + +/* The inverse of the above. */ +png_fixed_point +png_reciprocal2(png_fixed_point a, png_fixed_point b) +{ + /* The required result is 1/a * 1/b; the following preserves accuracy. */ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = 1E15/a; + r /= b; + r = floor(r+.5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; +#else + /* This may overflow because the range of png_fixed_point isn't symmetric, + * but this API is only used for the product of file and screen gamma so it + * doesn't matter that the smallest number it can produce is 1/21474, not + * 1/100000 + */ + png_fixed_point res = png_product2(a, b); + + if (res != 0) + return png_reciprocal(res); +#endif + + return 0; /* overflow */ +} +#endif /* READ_GAMMA */ + +#ifdef PNG_READ_GAMMA_SUPPORTED /* gamma table code */ +#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED +/* Fixed point gamma. + * + * The code to calculate the tables used below can be found in the shell script + * contrib/tools/intgamma.sh + * + * To calculate gamma this code implements fast log() and exp() calls using only + * fixed point arithmetic. This code has sufficient precision for either 8-bit + * or 16-bit sample values. + * + * The tables used here were calculated using simple 'bc' programs, but C double + * precision floating point arithmetic would work fine. + * + * 8-bit log table + * This is a table of -log(value/255)/log(2) for 'value' in the range 128 to + * 255, so it's the base 2 logarithm of a normalized 8-bit floating point + * mantissa. The numbers are 32-bit fractions. + */ +static const png_uint_32 +png_8bit_l2[128] = +{ + 4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U, + 3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U, + 3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U, + 3455425220U, 3413129301U, 3371120137U, 3329393864U, 3287946700U, 3246774933U, + 3205874930U, 3165243125U, 3124876025U, 3084770202U, 3044922296U, 3005329011U, + 2965987113U, 2926893432U, 2888044853U, 2849438323U, 2811070844U, 2772939474U, + 2735041326U, 2697373562U, 2659933400U, 2622718104U, 2585724991U, 2548951424U, + 2512394810U, 2476052606U, 2439922311U, 2404001468U, 2368287663U, 2332778523U, + 2297471715U, 2262364947U, 2227455964U, 2192742551U, 2158222529U, 2123893754U, + 2089754119U, 2055801552U, 2022034013U, 1988449497U, 1955046031U, 1921821672U, + 1888774511U, 1855902668U, 1823204291U, 1790677560U, 1758320682U, 1726131893U, + 1694109454U, 1662251657U, 1630556815U, 1599023271U, 1567649391U, 1536433567U, + 1505374214U, 1474469770U, 1443718700U, 1413119487U, 1382670639U, 1352370686U, + 1322218179U, 1292211689U, 1262349810U, 1232631153U, 1203054352U, 1173618059U, + 1144320946U, 1115161701U, 1086139034U, 1057251672U, 1028498358U, 999877854U, + 971388940U, 943030410U, 914801076U, 886699767U, 858725327U, 830876614U, + 803152505U, 775551890U, 748073672U, 720716771U, 693480120U, 666362667U, + 639363374U, 612481215U, 585715177U, 559064263U, 532527486U, 506103872U, + 479792461U, 453592303U, 427502463U, 401522014U, 375650043U, 349885648U, + 324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U, + 172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U, + 24347096U, 0U + +#if 0 + /* The following are the values for 16-bit tables - these work fine for the + * 8-bit conversions but produce very slightly larger errors in the 16-bit + * log (about 1.2 as opposed to 0.7 absolute error in the final value). To + * use these all the shifts below must be adjusted appropriately. + */ + 65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054, + 57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803, + 50170, 49542, 48918, 48298, 47682, 47070, 46462, 45858, 45257, 44661, 44068, + 43479, 42894, 42312, 41733, 41159, 40587, 40020, 39455, 38894, 38336, 37782, + 37230, 36682, 36137, 35595, 35057, 34521, 33988, 33459, 32932, 32408, 31887, + 31369, 30854, 30341, 29832, 29325, 28820, 28319, 27820, 27324, 26830, 26339, + 25850, 25364, 24880, 24399, 23920, 23444, 22970, 22499, 22029, 21562, 21098, + 20636, 20175, 19718, 19262, 18808, 18357, 17908, 17461, 17016, 16573, 16132, + 15694, 15257, 14822, 14390, 13959, 13530, 13103, 12678, 12255, 11834, 11415, + 10997, 10582, 10168, 9756, 9346, 8937, 8531, 8126, 7723, 7321, 6921, 6523, + 6127, 5732, 5339, 4947, 4557, 4169, 3782, 3397, 3014, 2632, 2251, 1872, 1495, + 1119, 744, 372 +#endif +}; + +static png_int_32 +png_log8bit(unsigned int x) +{ + unsigned int lg2 = 0; + /* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log, + * because the log is actually negate that means adding 1. The final + * returned value thus has the range 0 (for 255 input) to 7.994 (for 1 + * input), return -1 for the overflow (log 0) case, - so the result is + * always at most 19 bits. + */ + if ((x &= 0xff) == 0) + return -1; + + if ((x & 0xf0) == 0) + lg2 = 4, x <<= 4; + + if ((x & 0xc0) == 0) + lg2 += 2, x <<= 2; + + if ((x & 0x80) == 0) + lg2 += 1, x <<= 1; + + /* result is at most 19 bits, so this cast is safe: */ + return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16)); +} + +/* The above gives exact (to 16 binary places) log2 values for 8-bit images, + * for 16-bit images we use the most significant 8 bits of the 16-bit value to + * get an approximation then multiply the approximation by a correction factor + * determined by the remaining up to 8 bits. This requires an additional step + * in the 16-bit case. + * + * We want log2(value/65535), we have log2(v'/255), where: + * + * value = v' * 256 + v'' + * = v' * f + * + * So f is value/v', which is equal to (256+v''/v') since v' is in the range 128 + * to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less + * than 258. The final factor also needs to correct for the fact that our 8-bit + * value is scaled by 255, whereas the 16-bit values must be scaled by 65535. + * + * This gives a final formula using a calculated value 'x' which is value/v' and + * scaling by 65536 to match the above table: + * + * log2(x/257) * 65536 + * + * Since these numbers are so close to '1' we can use simple linear + * interpolation between the two end values 256/257 (result -368.61) and 258/257 + * (result 367.179). The values used below are scaled by a further 64 to give + * 16-bit precision in the interpolation: + * + * Start (256): -23591 + * Zero (257): 0 + * End (258): 23499 + */ +static png_int_32 +png_log16bit(png_uint_32 x) +{ + unsigned int lg2 = 0; + + /* As above, but now the input has 16 bits. */ + if ((x &= 0xffff) == 0) + return -1; + + if ((x & 0xff00) == 0) + lg2 = 8, x <<= 8; + + if ((x & 0xf000) == 0) + lg2 += 4, x <<= 4; + + if ((x & 0xc000) == 0) + lg2 += 2, x <<= 2; + + if ((x & 0x8000) == 0) + lg2 += 1, x <<= 1; + + /* Calculate the base logarithm from the top 8 bits as a 28-bit fractional + * value. + */ + lg2 <<= 28; + lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4; + + /* Now we need to interpolate the factor, this requires a division by the top + * 8 bits. Do this with maximum precision. + */ + x = ((x << 16) + (x >> 9)) / (x >> 8); + + /* Since we divided by the top 8 bits of 'x' there will be a '1' at 1<<24, + * the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly + * 16 bits to interpolate to get the low bits of the result. Round the + * answer. Note that the end point values are scaled by 64 to retain overall + * precision and that 'lg2' is current scaled by an extra 12 bits, so adjust + * the overall scaling by 6-12. Round at every step. + */ + x -= 1U << 24; + + if (x <= 65536U) /* <= '257' */ + lg2 += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12); + + else + lg2 -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12); + + /* Safe, because the result can't have more than 20 bits: */ + return (png_int_32)((lg2 + 2048) >> 12); +} + +/* The 'exp()' case must invert the above, taking a 20-bit fixed point + * logarithmic value and returning a 16 or 8-bit number as appropriate. In + * each case only the low 16 bits are relevant - the fraction - since the + * integer bits (the top 4) simply determine a shift. + * + * The worst case is the 16-bit distinction between 65535 and 65534, this + * requires perhaps spurious accuracty in the decoding of the logarithm to + * distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance + * of getting this accuracy in practice. + * + * To deal with this the following exp() function works out the exponent of the + * frational part of the logarithm by using an accurate 32-bit value from the + * top four fractional bits then multiplying in the remaining bits. + */ +static const png_uint_32 +png_32bit_exp[16] = +{ + /* NOTE: the first entry is deliberately set to the maximum 32-bit value. */ + 4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U, + 3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U, + 2553802834U, 2445529972U, 2341847524U, 2242560872U +}; + +/* Adjustment table; provided to explain the numbers in the code below. */ +#if 0 +for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"} + 11 44937.64284865548751208448 + 10 45180.98734845585101160448 + 9 45303.31936980687359311872 + 8 45364.65110595323018870784 + 7 45395.35850361789624614912 + 6 45410.72259715102037508096 + 5 45418.40724413220722311168 + 4 45422.25021786898173001728 + 3 45424.17186732298419044352 + 2 45425.13273269940811464704 + 1 45425.61317555035558641664 + 0 45425.85339951654943850496 +#endif + +static png_uint_32 +png_exp(png_fixed_point x) +{ + if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */ + { + /* Obtain a 4-bit approximation */ + png_uint_32 e = png_32bit_exp[(x >> 12) & 0xf]; + + /* Incorporate the low 12 bits - these decrease the returned value by + * multiplying by a number less than 1 if the bit is set. The multiplier + * is determined by the above table and the shift. Notice that the values + * converge on 45426 and this is used to allow linear interpolation of the + * low bits. + */ + if (x & 0x800) + e -= (((e >> 16) * 44938U) + 16U) >> 5; + + if (x & 0x400) + e -= (((e >> 16) * 45181U) + 32U) >> 6; + + if (x & 0x200) + e -= (((e >> 16) * 45303U) + 64U) >> 7; + + if (x & 0x100) + e -= (((e >> 16) * 45365U) + 128U) >> 8; + + if (x & 0x080) + e -= (((e >> 16) * 45395U) + 256U) >> 9; + + if (x & 0x040) + e -= (((e >> 16) * 45410U) + 512U) >> 10; + + /* And handle the low 6 bits in a single block. */ + e -= (((e >> 16) * 355U * (x & 0x3fU)) + 256U) >> 9; + + /* Handle the upper bits of x. */ + e >>= x >> 16; + return e; + } + + /* Check for overflow */ + if (x <= 0) + return png_32bit_exp[0]; + + /* Else underflow */ + return 0; +} + +static png_byte +png_exp8bit(png_fixed_point lg2) +{ + /* Get a 32-bit value: */ + png_uint_32 x = png_exp(lg2); + + /* Convert the 32-bit value to 0..255 by multiplying by 256-1, note that the + * second, rounding, step can't overflow because of the first, subtraction, + * step. + */ + x -= x >> 8; + return (png_byte)((x + 0x7fffffU) >> 24); +} + +static png_uint_16 +png_exp16bit(png_fixed_point lg2) +{ + /* Get a 32-bit value: */ + png_uint_32 x = png_exp(lg2); + + /* Convert the 32-bit value to 0..65535 by multiplying by 65536-1: */ + x -= x >> 16; + return (png_uint_16)((x + 32767U) >> 16); +} +#endif /* FLOATING_ARITHMETIC */ + +png_byte +png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val) +{ + if (value > 0 && value < 255) + { +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = floor(255*pow(value/255.,gamma_val*.00001)+.5); + return (png_byte)r; +# else + png_int_32 lg2 = png_log8bit(value); + png_fixed_point res; + + if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1)) + return png_exp8bit(res); + + /* Overflow. */ + value = 0; +# endif + } + + return (png_byte)value; +} + +png_uint_16 +png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) +{ + if (value > 0 && value < 65535) + { +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5); + return (png_uint_16)r; +# else + png_int_32 lg2 = png_log16bit(value); + png_fixed_point res; + + if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1)) + return png_exp16bit(res); + + /* Overflow. */ + value = 0; +# endif + } + + return (png_uint_16)value; +} + +/* This does the right thing based on the bit_depth field of the + * png_struct, interpreting values as 8-bit or 16-bit. While the result + * is nominally a 16-bit value if bit depth is 8 then the result is + * 8-bit (as are the arguments.) + */ +png_uint_16 /* PRIVATE */ +png_gamma_correct(png_structrp png_ptr, unsigned int value, + png_fixed_point gamma_val) +{ + if (png_ptr->bit_depth == 8) + return png_gamma_8bit_correct(value, gamma_val); + + else + return png_gamma_16bit_correct(value, gamma_val); +} + +/* Internal function to build a single 16-bit table - the table consists of + * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount + * to shift the input values right (or 16-number_of_signifiant_bits). + * + * The caller is responsible for ensuring that the table gets cleaned up on + * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument + * should be somewhere that will be cleaned. + */ +static void +png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) +{ + /* Various values derived from 'shift': */ + PNG_CONST unsigned int num = 1U << (8U - shift); + PNG_CONST unsigned int max = (1U << (16U - shift))-1U; + PNG_CONST unsigned int max_by_2 = 1U << (15U-shift); + unsigned int i; + + png_uint_16pp table = *ptable = + (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); + + for (i = 0; i < num; i++) + { + png_uint_16p sub_table = table[i] = + (png_uint_16p)png_malloc(png_ptr, 256 * (sizeof (png_uint_16))); + + /* The 'threshold' test is repeated here because it can arise for one of + * the 16-bit tables even if the others don't hit it. + */ + if (png_gamma_significant(gamma_val)) + { + /* The old code would overflow at the end and this would cause the + * 'pow' function to return a result >1, resulting in an + * arithmetic error. This code follows the spec exactly; ig is + * the recovered input sample, it always has 8-16 bits. + * + * We want input * 65535/max, rounded, the arithmetic fits in 32 + * bits (unsigned) so long as max <= 32767. + */ + unsigned int j; + for (j = 0; j < 256; j++) + { + png_uint_32 ig = (j << (8-shift)) + i; +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + /* Inline the 'max' scaling operation: */ + double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5); + sub_table[j] = (png_uint_16)d; +# else + if (shift) + ig = (ig * 65535U + max_by_2)/max; + + sub_table[j] = png_gamma_16bit_correct(ig, gamma_val); +# endif + } + } + else + { + /* We must still build a table, but do it the fast way. */ + unsigned int j; + + for (j = 0; j < 256; j++) + { + png_uint_32 ig = (j << (8-shift)) + i; + + if (shift) + ig = (ig * 65535U + max_by_2)/max; + + sub_table[j] = (png_uint_16)ig; + } + } + } +} + +/* NOTE: this function expects the *inverse* of the overall gamma transformation + * required. + */ +static void +png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) +{ + PNG_CONST unsigned int num = 1U << (8U - shift); + PNG_CONST unsigned int max = (1U << (16U - shift))-1U; + unsigned int i; + png_uint_32 last; + + png_uint_16pp table = *ptable = + (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); + + /* 'num' is the number of tables and also the number of low bits of low + * bits of the input 16-bit value used to select a table. Each table is + * itself index by the high 8 bits of the value. + */ + for (i = 0; i < num; i++) + table[i] = (png_uint_16p)png_malloc(png_ptr, + 256 * (sizeof (png_uint_16))); + + /* 'gamma_val' is set to the reciprocal of the value calculated above, so + * pow(out,g) is an *input* value. 'last' is the last input value set. + * + * In the loop 'i' is used to find output values. Since the output is + * 8-bit there are only 256 possible values. The tables are set up to + * select the closest possible output value for each input by finding + * the input value at the boundary between each pair of output values + * and filling the table up to that boundary with the lower output + * value. + * + * The boundary values are 0.5,1.5..253.5,254.5. Since these are 9-bit + * values the code below uses a 16-bit value in i; the values start at + * 128.5 (for 0.5) and step by 257, for a total of 254 values (the last + * entries are filled with 255). Start i at 128 and fill all 'last' + * table entries <= 'max' + */ + last = 0; + for (i = 0; i < 255; ++i) /* 8-bit output value */ + { + /* Find the corresponding maximum input value */ + png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */ + + /* Find the boundary value in 16 bits: */ + png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val); + + /* Adjust (round) to (16-shift) bits: */ + bound = (bound * max + 32768U)/65535U + 1U; + + while (last < bound) + { + table[last & (0xffU >> shift)][last >> (8U - shift)] = out; + last++; + } + } + + /* And fill in the final entries. */ + while (last < (num << 8)) + { + table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U; + last++; + } +} + +/* Build a single 8-bit table: same as the 16-bit case but much simpler (and + * typically much faster). Note that libpng currently does no sBIT processing + * (apparently contrary to the spec) so a 256 entry table is always generated. + */ +static void +png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, + PNG_CONST png_fixed_point gamma_val) +{ + unsigned int i; + png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); + + if (png_gamma_significant(gamma_val)) for (i=0; i<256; i++) + table[i] = png_gamma_8bit_correct(i, gamma_val); + + else for (i=0; i<256; ++i) + table[i] = (png_byte)i; +} + +/* Used from png_read_destroy and below to release the memory used by the gamma + * tables. + */ +void /* PRIVATE */ +png_destroy_gamma_table(png_structrp png_ptr) +{ + png_free(png_ptr, png_ptr->gamma_table); + png_ptr->gamma_table = NULL; + + if (png_ptr->gamma_16_table != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_table[i]); + } + png_free(png_ptr, png_ptr->gamma_16_table); + png_ptr->gamma_16_table = NULL; + } + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_free(png_ptr, png_ptr->gamma_from_1); + png_ptr->gamma_from_1 = NULL; + png_free(png_ptr, png_ptr->gamma_to_1); + png_ptr->gamma_to_1 = NULL; + + if (png_ptr->gamma_16_from_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_from_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_from_1); + png_ptr->gamma_16_from_1 = NULL; + } + if (png_ptr->gamma_16_to_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_to_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_to_1); + png_ptr->gamma_16_to_1 = NULL; + } +#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ +} + +/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit + * tables, we don't make a full table if we are reducing to 8-bit in + * the future. Note also how the gamma_16 tables are segmented so that + * we don't need to allocate > 64K chunks for a full 16-bit table. + */ +void /* PRIVATE */ +png_build_gamma_table(png_structrp png_ptr, int bit_depth) +{ + png_debug(1, "in png_build_gamma_table"); + + /* Remove any existing table; this copes with multiple calls to + * png_read_update_info. The warning is because building the gamma tables + * multiple times is a performance hit - it's harmless but the ability to call + * png_read_update_info() multiple times is new in 1.5.6 so it seems sensible + * to warn if the app introduces such a hit. + */ + if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL) + { + png_warning(png_ptr, "gamma table being rebuilt"); + png_destroy_gamma_table(png_ptr); + } + + if (bit_depth <= 8) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_table, + png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, + png_reciprocal(png_ptr->colorspace.gamma)); + + png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, + png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : + png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); + } +#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ + } + else + { + png_byte shift, sig_bit; + + if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + { + sig_bit = png_ptr->sig_bit.red; + + if (png_ptr->sig_bit.green > sig_bit) + sig_bit = png_ptr->sig_bit.green; + + if (png_ptr->sig_bit.blue > sig_bit) + sig_bit = png_ptr->sig_bit.blue; + } + else + sig_bit = png_ptr->sig_bit.gray; + + /* 16-bit gamma code uses this equation: + * + * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8] + * + * Where 'iv' is the input color value and 'ov' is the output value - + * pow(iv, gamma). + * + * Thus the gamma table consists of up to 256 256 entry tables. The table + * is selected by the (8-gamma_shift) most significant of the low 8 bits of + * the color value then indexed by the upper 8 bits: + * + * table[low bits][high 8 bits] + * + * So the table 'n' corresponds to all those 'iv' of: + * + * <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1> + * + */ + if (sig_bit > 0 && sig_bit < 16U) + shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */ + + else + shift = 0; /* keep all 16 bits */ + + if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) + { + /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively + * the significant bits in the *input* when the output will + * eventually be 8 bits. By default it is 11. + */ + if (shift < (16U - PNG_MAX_GAMMA_8)) + shift = (16U - PNG_MAX_GAMMA_8); + } + + if (shift > 8U) + shift = 8U; /* Guarantees at least one table! */ + + png_ptr->gamma_shift = shift; + +#ifdef PNG_16BIT_SUPPORTED + /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now + * PNG_COMPOSE). This effectively smashed the background calculation for + * 16-bit output because the 8-bit table assumes the result will be reduced + * to 8 bits. + */ + if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) +#endif + png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); + +#ifdef PNG_16BIT_SUPPORTED + else + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) + { + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, + png_reciprocal(png_ptr->colorspace.gamma)); + + /* Notice that the '16 from 1' table should be full precision, however + * the lookup on this table still uses gamma_shift, so it can't be. + * TODO: fix this. + */ + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : + png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); + } +#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ + } +} +#endif /* READ_GAMMA */ + +/* HARDWARE OPTION SUPPORT */ +#ifdef PNG_SET_OPTION_SUPPORTED +int PNGAPI +png_set_option(png_structrp png_ptr, int option, int onoff) +{ + if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT && + (option & 1) == 0) + { + int mask = 3 << option; + int setting = (2 + (onoff != 0)) << option; + int current = png_ptr->options; + + png_ptr->options = (png_byte)((current & ~mask) | setting); + + return (current & mask) >> option; + } + + return PNG_OPTION_INVALID; +} +#endif + +/* sRGB support */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) +/* sRGB conversion tables; these are machine generated with the code in + * contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the + * specification (see the article at http://en.wikipedia.org/wiki/SRGB) + * is used, not the gamma=1/2.2 approximation use elsewhere in libpng. + * The sRGB to linear table is exact (to the nearest 16 bit linear fraction). + * The inverse (linear to sRGB) table has accuracies as follows: + * + * For all possible (255*65535+1) input values: + * + * error: -0.515566 - 0.625971, 79441 (0.475369%) of readings inexact + * + * For the input values corresponding to the 65536 16-bit values: + * + * error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact + * + * In all cases the inexact readings are off by one. + */ + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED +/* The convert-to-sRGB table is only currently required for read. */ +const png_uint_16 png_sRGB_table[256] = +{ + 0,20,40,60,80,99,119,139, + 159,179,199,219,241,264,288,313, + 340,367,396,427,458,491,526,562, + 599,637,677,718,761,805,851,898, + 947,997,1048,1101,1156,1212,1270,1330, + 1391,1453,1517,1583,1651,1720,1790,1863, + 1937,2013,2090,2170,2250,2333,2418,2504, + 2592,2681,2773,2866,2961,3058,3157,3258, + 3360,3464,3570,3678,3788,3900,4014,4129, + 4247,4366,4488,4611,4736,4864,4993,5124, + 5257,5392,5530,5669,5810,5953,6099,6246, + 6395,6547,6700,6856,7014,7174,7335,7500, + 7666,7834,8004,8177,8352,8528,8708,8889, + 9072,9258,9445,9635,9828,10022,10219,10417, + 10619,10822,11028,11235,11446,11658,11873,12090, + 12309,12530,12754,12980,13209,13440,13673,13909, + 14146,14387,14629,14874,15122,15371,15623,15878, + 16135,16394,16656,16920,17187,17456,17727,18001, + 18277,18556,18837,19121,19407,19696,19987,20281, + 20577,20876,21177,21481,21787,22096,22407,22721, + 23038,23357,23678,24002,24329,24658,24990,25325, + 25662,26001,26344,26688,27036,27386,27739,28094, + 28452,28813,29176,29542,29911,30282,30656,31033, + 31412,31794,32179,32567,32957,33350,33745,34143, + 34544,34948,35355,35764,36176,36591,37008,37429, + 37852,38278,38706,39138,39572,40009,40449,40891, + 41337,41785,42236,42690,43147,43606,44069,44534, + 45002,45473,45947,46423,46903,47385,47871,48359, + 48850,49344,49841,50341,50844,51349,51858,52369, + 52884,53401,53921,54445,54971,55500,56032,56567, + 57105,57646,58190,58737,59287,59840,60396,60955, + 61517,62082,62650,63221,63795,64372,64952,65535 +}; + +#endif /* simplified read only */ + +/* The base/delta tables are required for both read and write (but currently + * only the simplified versions.) + */ +const png_uint_16 png_sRGB_base[512] = +{ + 128,1782,3383,4644,5675,6564,7357,8074, + 8732,9346,9921,10463,10977,11466,11935,12384, + 12816,13233,13634,14024,14402,14769,15125,15473, + 15812,16142,16466,16781,17090,17393,17690,17981, + 18266,18546,18822,19093,19359,19621,19879,20133, + 20383,20630,20873,21113,21349,21583,21813,22041, + 22265,22487,22707,22923,23138,23350,23559,23767, + 23972,24175,24376,24575,24772,24967,25160,25352, + 25542,25730,25916,26101,26284,26465,26645,26823, + 27000,27176,27350,27523,27695,27865,28034,28201, + 28368,28533,28697,28860,29021,29182,29341,29500, + 29657,29813,29969,30123,30276,30429,30580,30730, + 30880,31028,31176,31323,31469,31614,31758,31902, + 32045,32186,32327,32468,32607,32746,32884,33021, + 33158,33294,33429,33564,33697,33831,33963,34095, + 34226,34357,34486,34616,34744,34873,35000,35127, + 35253,35379,35504,35629,35753,35876,35999,36122, + 36244,36365,36486,36606,36726,36845,36964,37083, + 37201,37318,37435,37551,37668,37783,37898,38013, + 38127,38241,38354,38467,38580,38692,38803,38915, + 39026,39136,39246,39356,39465,39574,39682,39790, + 39898,40005,40112,40219,40325,40431,40537,40642, + 40747,40851,40955,41059,41163,41266,41369,41471, + 41573,41675,41777,41878,41979,42079,42179,42279, + 42379,42478,42577,42676,42775,42873,42971,43068, + 43165,43262,43359,43456,43552,43648,43743,43839, + 43934,44028,44123,44217,44311,44405,44499,44592, + 44685,44778,44870,44962,45054,45146,45238,45329, + 45420,45511,45601,45692,45782,45872,45961,46051, + 46140,46229,46318,46406,46494,46583,46670,46758, + 46846,46933,47020,47107,47193,47280,47366,47452, + 47538,47623,47709,47794,47879,47964,48048,48133, + 48217,48301,48385,48468,48552,48635,48718,48801, + 48884,48966,49048,49131,49213,49294,49376,49458, + 49539,49620,49701,49782,49862,49943,50023,50103, + 50183,50263,50342,50422,50501,50580,50659,50738, + 50816,50895,50973,51051,51129,51207,51285,51362, + 51439,51517,51594,51671,51747,51824,51900,51977, + 52053,52129,52205,52280,52356,52432,52507,52582, + 52657,52732,52807,52881,52956,53030,53104,53178, + 53252,53326,53400,53473,53546,53620,53693,53766, + 53839,53911,53984,54056,54129,54201,54273,54345, + 54417,54489,54560,54632,54703,54774,54845,54916, + 54987,55058,55129,55199,55269,55340,55410,55480, + 55550,55620,55689,55759,55828,55898,55967,56036, + 56105,56174,56243,56311,56380,56448,56517,56585, + 56653,56721,56789,56857,56924,56992,57059,57127, + 57194,57261,57328,57395,57462,57529,57595,57662, + 57728,57795,57861,57927,57993,58059,58125,58191, + 58256,58322,58387,58453,58518,58583,58648,58713, + 58778,58843,58908,58972,59037,59101,59165,59230, + 59294,59358,59422,59486,59549,59613,59677,59740, + 59804,59867,59930,59993,60056,60119,60182,60245, + 60308,60370,60433,60495,60558,60620,60682,60744, + 60806,60868,60930,60992,61054,61115,61177,61238, + 61300,61361,61422,61483,61544,61605,61666,61727, + 61788,61848,61909,61969,62030,62090,62150,62211, + 62271,62331,62391,62450,62510,62570,62630,62689, + 62749,62808,62867,62927,62986,63045,63104,63163, + 63222,63281,63340,63398,63457,63515,63574,63632, + 63691,63749,63807,63865,63923,63981,64039,64097, + 64155,64212,64270,64328,64385,64443,64500,64557, + 64614,64672,64729,64786,64843,64900,64956,65013, + 65070,65126,65183,65239,65296,65352,65409,65465 +}; + +const png_byte png_sRGB_delta[512] = +{ + 207,201,158,129,113,100,90,82,77,72,68,64,61,59,56,54, + 52,50,49,47,46,45,43,42,41,40,39,39,38,37,36,36, + 35,34,34,33,33,32,32,31,31,30,30,30,29,29,28,28, + 28,27,27,27,27,26,26,26,25,25,25,25,24,24,24,24, + 23,23,23,23,23,22,22,22,22,22,22,21,21,21,21,21, + 21,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19, + 19,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17, + 17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16, + 16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15, + 15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14, + 14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13, + 13,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12, + 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, + 12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11, + 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, + 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, + 11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 +}; +#endif /* SIMPLIFIED READ/WRITE sRGB support */ + +/* SIMPLIFIED READ/WRITE SUPPORT */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) +static int +png_image_free_function(png_voidp argument) +{ + png_imagep image = png_voidcast(png_imagep, argument); + png_controlp cp = image->opaque; + png_control c; + + /* Double check that we have a png_ptr - it should be impossible to get here + * without one. + */ + if (cp->png_ptr == NULL) + return 0; + + /* First free any data held in the control structure. */ +# ifdef PNG_STDIO_SUPPORTED + if (cp->owned_file) + { + FILE *fp = png_voidcast(FILE*, cp->png_ptr->io_ptr); + cp->owned_file = 0; + + /* Ignore errors here. */ + if (fp != NULL) + { + cp->png_ptr->io_ptr = NULL; + (void)fclose(fp); + } + } +# endif + + /* Copy the control structure so that the original, allocated, version can be + * safely freed. Notice that a png_error here stops the remainder of the + * cleanup, but this is probably fine because that would indicate bad memory + * problems anyway. + */ + c = *cp; + image->opaque = &c; + png_free(c.png_ptr, cp); + + /* Then the structures, calling the correct API. */ + if (c.for_write) + { +# ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED + png_destroy_write_struct(&c.png_ptr, &c.info_ptr); +# else + png_error(c.png_ptr, "simplified write not supported"); +# endif + } + else + { +# ifdef PNG_SIMPLIFIED_READ_SUPPORTED + png_destroy_read_struct(&c.png_ptr, &c.info_ptr, NULL); +# else + png_error(c.png_ptr, "simplified read not supported"); +# endif + } + + /* Success. */ + return 1; +} + +void PNGAPI +png_image_free(png_imagep image) +{ + /* Safely call the real function, but only if doing so is safe at this point + * (if not inside an error handling context). Otherwise assume + * png_safe_execute will call this API after the return. + */ + if (image != NULL && image->opaque != NULL && + image->opaque->error_buf == NULL) + { + /* Ignore errors here: */ + (void)png_safe_execute(image, png_image_free_function, image); + image->opaque = NULL; + } +} + +int /* PRIVATE */ +png_image_error(png_imagep image, png_const_charp error_message) +{ + /* Utility to log an error. */ + png_safecat(image->message, (sizeof image->message), 0, error_message); + image->warning_or_error |= PNG_IMAGE_ERROR; + png_image_free(image); + return 0; +} + +#endif /* SIMPLIFIED READ/WRITE */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/png.h b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/png.h index a20bbd4bf..3ebb82079 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/png.h +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/png.h @@ -1,24 +1,26 @@ /* png.h - header file for PNG reference library * - * libpng version 1.2.21 - October 4, 2007 - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * libpng version 1.6.1 - March 28, 2013 + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license (See LICENSE, below) + * * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.2.21 - October 4, 2007: Glenn - * See also "Contributing Authors", below. + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.6.1 - March 28, 2013: Glenn + * See also "Contributing Authors", below. * * Note about libpng version numbers: * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: * * source png.h png.h shared-lib * version string int version @@ -103,88 +105,94 @@ * 1.0.16 10 10016 10.so.0.1.0.16 * 1.2.6 13 10206 12.so.0.1.2.6 * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 - * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 + * 1.0.17rc1 10 10017 12.so.0.1.0.17rc1 * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 - * 1.0.17 10 10017 10.so.0.1.0.17 + * 1.0.17 10 10017 12.so.0.1.0.17 * 1.2.7 13 10207 12.so.0.1.2.7 * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 + * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5 * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - * 1.0.18 10 10018 10.so.0.1.0.18 + * 1.0.18 10 10018 12.so.0.1.0.18 * 1.2.8 13 10208 12.so.0.1.2.8 * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 * 1.2.9beta4-11 13 10209 12.so.0.9[.0] * 1.2.9rc1 13 10209 12.so.0.9[.0] * 1.2.9 13 10209 12.so.0.9[.0] - * 1.2.10beta1-8 13 10210 12.so.0.10[.0] - * 1.2.10rc1-3 13 10210 12.so.0.10[.0] + * 1.2.10beta1-7 13 10210 12.so.0.10[.0] + * 1.2.10rc1-2 13 10210 12.so.0.10[.0] * 1.2.10 13 10210 12.so.0.10[.0] + * 1.4.0beta1-5 14 10400 14.so.0.0[.0] * 1.2.11beta1-4 13 10211 12.so.0.11[.0] - * 1.0.19rc1-5 10 10019 10.so.0.19[.0] - * 1.2.11rc1-5 13 10211 12.so.0.11[.0] - * 1.0.19 10 10019 10.so.0.19[.0] + * 1.4.0beta7-8 14 10400 14.so.0.0[.0] * 1.2.11 13 10211 12.so.0.11[.0] - * 1.0.20 10 10020 10.so.0.20[.0] * 1.2.12 13 10212 12.so.0.12[.0] - * 1.2.13beta1 13 10213 12.so.0.13[.0] - * 1.0.21 10 10021 10.so.0.21[.0] + * 1.4.0beta9-14 14 10400 14.so.0.0[.0] * 1.2.13 13 10213 12.so.0.13[.0] - * 1.2.14beta1-2 13 10214 12.so.0.14[.0] - * 1.0.22rc1 10 10022 10.so.0.22[.0] - * 1.2.14rc1 13 10214 12.so.0.14[.0] - * 1.0.22 10 10022 10.so.0.22[.0] - * 1.2.14 13 10214 12.so.0.14[.0] - * 1.2.15beta1-6 13 10215 12.so.0.15[.0] - * 1.0.23rc1-5 10 10023 10.so.0.23[.0] - * 1.2.15rc1-5 13 10215 12.so.0.15[.0] - * 1.0.23 10 10023 10.so.0.23[.0] - * 1.2.15 13 10215 12.so.0.15[.0] - * 1.2.16beta1-2 13 10216 12.so.0.16[.0] - * 1.2.16rc1 13 10216 12.so.0.16[.0] - * 1.0.24 10 10024 10.so.0.24[.0] - * 1.2.16 13 10216 12.so.0.16[.0] - * 1.2.17beta1-2 13 10217 12.so.0.17[.0] - * 1.0.25rc1 10 10025 10.so.0.25[.0] - * 1.2.17rc1-3 13 10217 12.so.0.17[.0] - * 1.0.25 10 10025 10.so.0.25[.0] - * 1.2.17 13 10217 12.so.0.17[.0] - * 1.0.26 10 10026 10.so.0.26[.0] - * 1.2.18 13 10218 12.so.0.18[.0] - * 1.2.19beta1-31 13 10219 12.so.0.19[.0] - * 1.0.27rc1-6 10 10027 10.so.0.27[.0] - * 1.2.19rc1-6 13 10219 12.so.0.19[.0] - * 1.0.27 10 10027 10.so.0.27[.0] - * 1.2.19 13 10219 12.so.0.19[.0] - * 1.2.20beta01-04 13 10220 12.so.0.20[.0] - * 1.0.28rc1-6 10 10028 10.so.0.28[.0] - * 1.2.20rc1-6 13 10220 12.so.0.20[.0] - * 1.0.28 10 10028 10.so.0.28[.0] - * 1.2.20 13 10220 12.so.0.20[.0] - * 1.2.21beta1-2 13 10221 12.so.0.21[.0] - * 1.2.21rc1-3 13 10221 12.so.0.21[.0] - * 1.0.29 10 10029 10.so.0.29[.0] - * 1.2.21 13 10221 12.so.0.21[.0] - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as a W3C Recommendation and as an ISO Specification, - * <http://www.w3.org/TR/2003/REC-PNG-20031110/ + * 1.4.0beta15-36 14 10400 14.so.0.0[.0] + * 1.4.0beta37-87 14 10400 14.so.14.0[.0] + * 1.4.0rc01 14 10400 14.so.14.0[.0] + * 1.4.0beta88-109 14 10400 14.so.14.0[.0] + * 1.4.0rc02-08 14 10400 14.so.14.0[.0] + * 1.4.0 14 10400 14.so.14.0[.0] + * 1.4.1beta01-03 14 10401 14.so.14.1[.0] + * 1.4.1rc01 14 10401 14.so.14.1[.0] + * 1.4.1beta04-12 14 10401 14.so.14.1[.0] + * 1.4.1 14 10401 14.so.14.1[.0] + * 1.4.2 14 10402 14.so.14.2[.0] + * 1.4.3 14 10403 14.so.14.3[.0] + * 1.4.4 14 10404 14.so.14.4[.0] + * 1.5.0beta01-58 15 10500 15.so.15.0[.0] + * 1.5.0rc01-07 15 10500 15.so.15.0[.0] + * 1.5.0 15 10500 15.so.15.0[.0] + * 1.5.1beta01-11 15 10501 15.so.15.1[.0] + * 1.5.1rc01-02 15 10501 15.so.15.1[.0] + * 1.5.1 15 10501 15.so.15.1[.0] + * 1.5.2beta01-03 15 10502 15.so.15.2[.0] + * 1.5.2rc01-03 15 10502 15.so.15.2[.0] + * 1.5.2 15 10502 15.so.15.2[.0] + * 1.5.3beta01-10 15 10503 15.so.15.3[.0] + * 1.5.3rc01-02 15 10503 15.so.15.3[.0] + * 1.5.3beta11 15 10503 15.so.15.3[.0] + * 1.5.3 [omitted] + * 1.5.4beta01-08 15 10504 15.so.15.4[.0] + * 1.5.4rc01 15 10504 15.so.15.4[.0] + * 1.5.4 15 10504 15.so.15.4[.0] + * 1.5.5beta01-08 15 10505 15.so.15.5[.0] + * 1.5.5rc01 15 10505 15.so.15.5[.0] + * 1.5.5 15 10505 15.so.15.5[.0] + * 1.5.6beta01-07 15 10506 15.so.15.6[.0] + * 1.5.6rc01-03 15 10506 15.so.15.6[.0] + * 1.5.6 15 10506 15.so.15.6[.0] + * 1.5.7beta01-05 15 10507 15.so.15.7[.0] + * 1.5.7rc01-03 15 10507 15.so.15.7[.0] + * 1.5.7 15 10507 15.so.15.7[.0] + * 1.6.0beta01-40 16 10600 16.so.16.0[.0] + * 1.6.0rc01-08 16 10600 16.so.16.0[.0] + * 1.6.0 16 10600 16.so.16.0[.0] + * 1.6.1beta01-10 16 10601 16.so.16.1[.0] + * 1.6.1rc01 16 10601 16.so.16.1[.0] + * 1.6.1 16 10601 16.so.16.1[.0] + * + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcNN". + * + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. + * + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). + * + * See libpng-manual.txt or libpng.3 for more information. The PNG + * specification is available as a W3C Recommendation and as an ISO + * Specification, <http://www.w3.org/TR/2003/REC-PNG-20031110/ */ /* @@ -193,8 +201,10 @@ * If you modify libpng you may insert additional notices immediately following * this sentence. * - * libpng versions 1.2.6, August 15, 2004, through 1.2.21, October 4, 2007, are - * Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are + * This code is released under the libpng license. + * + * libpng versions 1.2.6, August 15, 2004, through 1.6.1, March 28, 2013, are + * Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are * distributed according to the same disclaimer and license as libpng-1.2.5 * with the following individual added to the list of Contributing Authors: * @@ -263,13 +273,13 @@ * source code, or portions hereof, for any purpose, without fee, subject * to the following restrictions: * - * 1. The origin of this source code must not be misrepresented. + * 1. The origin of this source code must not be misrepresented. * - * 2. Altered versions must be plainly marked as such and - * must not be misrepresented as being the original source. + * 2. Altered versions must be plainly marked as such and must not + * be misrepresented as being the original source. * - * 3. This Copyright notice may not be removed or altered from - * any source or altered source distribution. + * 3. This Copyright notice may not be removed or altered from + * any source or altered source distribution. * * The Contributing Authors and Group 42, Inc. specifically permit, without * fee, and encourage the use of this source code as a component to @@ -282,7 +292,7 @@ * A "png_get_copyright" function is available, for convenient use in "about" * boxes and the like: * - * printf("%s",png_get_copyright(NULL)); + * printf("%s", png_get_copyright(NULL)); * * Also, the PNG logo (in PNG format, of course) is supplied in the * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). @@ -305,29 +315,30 @@ * Y2K compliance in libpng: * ========================= * - * October 4, 2007 + * March 28, 2013 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.2.21 are Y2K compliant. It is my belief that earlier - * versions were also Y2K compliant. + * upward through 1.6.1 are Y2K compliant. It is my belief that + * earlier versions were also Y2K compliant. * - * Libpng only has three year fields. One is a 2-byte unsigned integer - * that will hold years up to 65535. The other two hold the date in text - * format, and will hold years up to 9999. + * Libpng only has two year fields. One is a 2-byte unsigned integer + * that will hold years up to 65535. The other, which is deprecated, + * holds the date in text format, and will hold years up to 9999. * * The integer is * "png_uint_16 year" in png_time_struct. * - * The strings are - * "png_charp time_buffer" in png_struct and - * "near_time_buffer", which is a local character string in png.c. + * The string is + * "char time_buffer[29]" in png_struct. This is no longer used + * in libpng-1.6.x and will be removed from libpng-1.7.0. * * There are seven time-related functions: - * png.c: png_convert_to_rfc_1123() in png.c - * (formerly png_convert_to_rfc_1152() in error) + * png.c: png_convert_to_rfc_1123_buffer() in png.c + * (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and + * png_convert_to_rfc_1152() in error prior to libpng-0.98) * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c * png_convert_from_time_t() in pngwrite.c * png_get_tIME() in pngget.c @@ -338,8 +349,8 @@ * All handle dates properly in a Y2K environment. The * png_convert_from_time_t() function calls gmtime() to convert from system * clock time, which returns (year - 1900), which we properly convert to - * the full 4-digit year. There is a possibility that applications using - * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() + * the full 4-digit year. There is a possibility that libpng applications + * are not passing 4-digit years into the png_convert_to_rfc_1123_buffer() * function, or that they are incorrectly passing only a 2-digit year * instead of "year - 1900" into the png_convert_from_struct_tm() function, * but this is not under our control. The libpng documentation has always @@ -360,26 +371,31 @@ #ifndef PNG_H #define PNG_H -/* This is not the place to learn how to use libpng. The file libpng.txt +/* This is not the place to learn how to use libpng. The file libpng-manual.txt * describes how to use libpng, and the file example.c summarizes it * with some code on which to build. This file is useful for looking * at the actual function definitions and structure components. + * + * If you just need to read a PNG file and don't want to read the documentation + * skip to the end of this file and read the section entitled 'simplified API'. */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.2.21" +#define PNG_LIBPNG_VER_STRING "1.6.1" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.2.21 - October 4, 2007\n" + " libpng version 1.6.1 - March 28, 2013\n" -#define PNG_LIBPNG_VER_SONUM 0 -#define PNG_LIBPNG_VER_DLLNUM 13 +#define PNG_LIBPNG_VER_SONUM 16 +#define PNG_LIBPNG_VER_DLLNUM 16 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 -#define PNG_LIBPNG_VER_MINOR 2 -#define PNG_LIBPNG_VER_RELEASE 21 +#define PNG_LIBPNG_VER_MINOR 6 +#define PNG_LIBPNG_VER_RELEASE 1 + /* This should match the numeric part of the final component of - * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ + * PNG_LIBPNG_VER_STRING, omitting any leading zero: + */ #define PNG_LIBPNG_VER_BUILD 0 @@ -404,24 +420,29 @@ * We must not include leading zeros. * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only * version 1.0.0 was mis-numbered 100 instead of 10000). From - * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10221 /* 1.2.21 */ + * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release + */ +#define PNG_LIBPNG_VER 10601 /* 1.6.1 */ -#ifndef PNG_VERSION_INFO_ONLY -/* include the compression library's header */ -#include "../../../juce_core/zip/zlib/zlib.h" +/* Library configuration: these options cannot be changed after + * the library has been built. + */ +#ifndef PNGLCONF_H + /* If pnglibconf.h is missing, you can + * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h + */ +# include "pnglibconf.h" #endif -/* include all user configurable info, including optional assembler routines */ -#include "pngconf.h" - -#ifdef _MSC_VER - #pragma warning (disable: 4996 4100) +#ifndef PNG_VERSION_INFO_ONLY + /* Machine specific configuration. */ +# include "pngconf.h" #endif /* - * Added at libpng-1.2.8 */ -/* Ref MSDN: Private as priority over Special + * Added at libpng-1.2.8 + * + * Ref MSDN: Private as priority over Special * VS_FF_PRIVATEBUILD File *was not* built using standard release * procedures. If this value is given, the StringFileInfo block must * contain a PrivateBuild string. @@ -432,13 +453,13 @@ * StringFileInfo block must contain a SpecialBuild string. */ -#if defined(PNG_USER_PRIVATEBUILD) +#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */ # define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) + (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) #else -# if defined(PNG_LIBPNG_SPECIALBUILD) +# ifdef PNG_LIBPNG_SPECIALBUILD # define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) + (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) # else # define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) # endif @@ -448,76 +469,106 @@ /* Inhibit C++ name-mangling for libpng functions but not for system calls. */ #ifdef __cplusplus -//extern "C" { +extern "C" { #endif /* __cplusplus */ -/* This file is arranged in several sections. The first section contains - * structure and type definitions. The second section contains the external - * library functions, while the third has the internal library functions, - * which applications aren't expected to use directly. - */ - -#ifndef PNG_NO_TYPECAST_NULL -#define int_p_NULL (int *)NULL -#define png_bytep_NULL (png_bytep)NULL -#define png_bytepp_NULL (png_bytepp)NULL -#define png_doublep_NULL (png_doublep)NULL -#define png_error_ptr_NULL (png_error_ptr)NULL -#define png_flush_ptr_NULL (png_flush_ptr)NULL -#define png_free_ptr_NULL (png_free_ptr)NULL -#define png_infopp_NULL (png_infopp)NULL -#define png_malloc_ptr_NULL (png_malloc_ptr)NULL -#define png_read_status_ptr_NULL (png_read_status_ptr)NULL -#define png_rw_ptr_NULL (png_rw_ptr)NULL -#define png_structp_NULL (png_structp)NULL -#define png_uint_16p_NULL (png_uint_16p)NULL -#define png_voidp_NULL (png_voidp)NULL -#define png_write_status_ptr_NULL (png_write_status_ptr)NULL -#else -#define int_p_NULL NULL -#define png_bytep_NULL NULL -#define png_bytepp_NULL NULL -#define png_doublep_NULL NULL -#define png_error_ptr_NULL NULL -#define png_flush_ptr_NULL NULL -#define png_free_ptr_NULL NULL -#define png_infopp_NULL NULL -#define png_malloc_ptr_NULL NULL -#define png_read_status_ptr_NULL NULL -#define png_rw_ptr_NULL NULL -#define png_structp_NULL NULL -#define png_uint_16p_NULL NULL -#define png_voidp_NULL NULL -#define png_write_status_ptr_NULL NULL -#endif - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) /* Version information for C files, stored in png.c. This had better match * the version above. */ -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18]; - /* need room for 99.99.99beta99z */ -#else #define png_libpng_ver png_get_header_ver(NULL) -#endif -#ifdef PNG_USE_GLOBAL_ARRAYS -/* This was removed in version 1.0.5c */ -/* Structures to facilitate easy interlacing. See png.c for more details */ -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_start[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_inc[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_ystart[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_yinc[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_mask[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_dsp_mask[7]; -/* This isn't currently used. If you need it, see png.c for more details. -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_height[7]; -*/ -#endif +/* This file is arranged in several sections: + * + * 1. Any configuration options that can be specified by for the application + * code when it is built. (Build time configuration is in pnglibconf.h) + * 2. Type definitions (base types are defined in pngconf.h), structure + * definitions. + * 3. Exported library functions. + * 4. Simplified API. + * + * The library source code has additional files (principally pngpriv.h) that + * allow configuration of the library. + */ +/* Section 1: run time configuration + * See pnglibconf.h for build time configuration + * + * Run time configuration allows the application to choose between + * implementations of certain arithmetic APIs. The default is set + * at build time and recorded in pnglibconf.h, but it is safe to + * override these (and only these) settings. Note that this won't + * change what the library does, only application code, and the + * settings can (and probably should) be made on a per-file basis + * by setting the #defines before including png.h + * + * Use macros to read integers from PNG data or use the exported + * functions? + * PNG_USE_READ_MACROS: use the macros (see below) Note that + * the macros evaluate their argument multiple times. + * PNG_NO_USE_READ_MACROS: call the relevant library function. + * + * Use the alternative algorithm for compositing alpha samples that + * does not use division? + * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division' + * algorithm. + * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm. + * + * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is + * false? + * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error + * APIs to png_warning. + * Otherwise the calls are mapped to png_error. + */ + +/* Section 2: type definitions, including structures and compile time + * constants. + * See pngconf.h for base types that vary by machine/system + */ + +/* This triggers a compiler error in png.c, if png.c and png.h + * do not agree upon the version number. + */ +typedef char* png_libpng_version_1_6_1; -#endif /* PNG_NO_EXTERN */ +/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. + * + * png_struct is the cache of information used while reading or writing a single + * PNG file. One of these is always required, although the simplified API + * (below) hides the creation and destruction of it. + */ +typedef struct png_struct_def png_struct; +typedef const png_struct * png_const_structp; +typedef png_struct * png_structp; +typedef png_struct * * png_structpp; + +/* png_info contains information read from or to be written to a PNG file. One + * or more of these must exist while reading or creating a PNG file. The + * information is not used by libpng during read but is used to control what + * gets written when a PNG file is created. "png_get_" function calls read + * information during read and "png_set_" functions calls write information + * when creating a PNG. + * been moved into a separate header file that is not accessible to + * applications. Read libpng-manual.txt or libpng.3 for more info. + */ +typedef struct png_info_def png_info; +typedef png_info * png_infop; +typedef const png_info * png_const_infop; +typedef png_info * * png_infopp; + +/* Types with names ending 'p' are pointer types. The corresponding types with + * names ending 'rp' are identical pointer types except that the pointer is + * marked 'restrict', which means that it is the only pointer to the object + * passed to the function. Applications should not use the 'restrict' types; + * it is always valid to pass 'p' to a pointer with a function argument of the + * corresponding 'rp' type. Different compilers have different rules with + * regard to type matching in the presence of 'restrict'. For backward + * compatibility libpng callbacks never have 'restrict' in their parameters and, + * consequentially, writing portable application code is extremely difficult if + * an attempt is made to use 'restrict'. + */ +typedef png_struct * PNG_RESTRICT png_structrp; +typedef const png_struct * PNG_RESTRICT png_const_structrp; +typedef png_info * PNG_RESTRICT png_inforp; +typedef const png_info * PNG_RESTRICT png_const_inforp; /* Three color definitions. The order of the red, green, and blue, (and the * exact size) is not important, although the size of the fields need to @@ -529,8 +580,9 @@ typedef struct png_color_struct png_byte green; png_byte blue; } png_color; -typedef png_color FAR * png_colorp; -typedef png_color FAR * FAR * png_colorpp; +typedef png_color * png_colorp; +typedef const png_color * png_const_colorp; +typedef png_color * * png_colorpp; typedef struct png_color_16_struct { @@ -540,8 +592,9 @@ typedef struct png_color_16_struct png_uint_16 blue; png_uint_16 gray; /* for use in grayscale files */ } png_color_16; -typedef png_color_16 FAR * png_color_16p; -typedef png_color_16 FAR * FAR * png_color_16pp; +typedef png_color_16 * png_color_16p; +typedef const png_color_16 * png_const_color_16p; +typedef png_color_16 * * png_color_16pp; typedef struct png_color_8_struct { @@ -551,8 +604,9 @@ typedef struct png_color_8_struct png_byte gray; /* for use in grayscale files */ png_byte alpha; /* for alpha channel files */ } png_color_8; -typedef png_color_8 FAR * png_color_8p; -typedef png_color_8 FAR * FAR * png_color_8pp; +typedef png_color_8 * png_color_8p; +typedef const png_color_8 * png_const_color_8p; +typedef png_color_8 * * png_color_8pp; /* * The following two structures are used for the in-core representation @@ -566,8 +620,9 @@ typedef struct png_sPLT_entry_struct png_uint_16 alpha; png_uint_16 frequency; } png_sPLT_entry; -typedef png_sPLT_entry FAR * png_sPLT_entryp; -typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; +typedef png_sPLT_entry * png_sPLT_entryp; +typedef const png_sPLT_entry * png_const_sPLT_entryp; +typedef png_sPLT_entry * * png_sPLT_entrypp; /* When the depth of the sPLT palette is 8 bits, the color and alpha samples * occupy the LSB of their respective members, and the MSB of each member @@ -581,17 +636,27 @@ typedef struct png_sPLT_struct png_sPLT_entryp entries; /* palette entries */ png_int_32 nentries; /* number of palette entries */ } png_sPLT_t; -typedef png_sPLT_t FAR * png_sPLT_tp; -typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; +typedef png_sPLT_t * png_sPLT_tp; +typedef const png_sPLT_t * png_const_sPLT_tp; +typedef png_sPLT_t * * png_sPLT_tpp; #ifdef PNG_TEXT_SUPPORTED /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, * and whether that contents is compressed or not. The "key" field - * points to a regular zero-terminated C string. The "text", "lang", and - * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. - * However, the * structure returned by png_get_text() will always contain - * regular zero-terminated C strings (possibly empty), never NULL pointers, - * so they can be safely used in printf() and other string-handling functions. + * points to a regular zero-terminated C string. The "text" fields can be a + * regular C string, an empty string, or a NULL pointer. + * However, the structure returned by png_get_text() will always contain + * the "text" field as a regular zero-terminated C string (possibly + * empty), never a NULL pointer, so it can be safely used in printf() and + * other string-handling functions. Note that the "itxt_length", "lang", and + * "lang_key" members of the structure only exist when the library is built + * with iTXt chunk support. Prior to libpng-1.4.0 the library was built by + * default without iTXt support. Also note that when iTXt *is* supported, + * the "lang" and "lang_key" fields contain NULL pointers when the + * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or + * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the + * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag" + * which is always 0 or 1, or its "compression method" which is always 0. */ typedef struct png_text_struct { @@ -604,16 +669,15 @@ typedef struct png_text_struct png_charp text; /* comment, may be an empty string (ie "") or a NULL pointer */ png_size_t text_length; /* length of the text string */ -#ifdef PNG_iTXt_SUPPORTED png_size_t itxt_length; /* length of the itxt string */ png_charp lang; /* language code, 0-79 characters or a NULL pointer */ png_charp lang_key; /* keyword translated UTF-8 string, 0 or more chars or a NULL pointer */ -#endif } png_text; -typedef png_text FAR * png_textp; -typedef png_text FAR * FAR * png_textpp; +typedef png_text * png_textp; +typedef const png_text * png_const_textp; +typedef png_text * * png_textpp; #endif /* Supported compression types for text in PNG files (tEXt, and zTXt). @@ -641,317 +705,56 @@ typedef struct png_time_struct png_byte minute; /* minute of hour, 0 - 59 */ png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ } png_time; -typedef png_time FAR * png_timep; -typedef png_time FAR * FAR * png_timepp; +typedef png_time * png_timep; +typedef const png_time * png_const_timep; +typedef png_time * * png_timepp; -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED /* png_unknown_chunk is a structure to hold queued chunks for which there is * no specific support. The idea is that we can use this to queue * up private chunks for output even though the library doesn't actually * know about their semantics. + * + * The data in the structure is set by libpng on read and used on write. */ typedef struct png_unknown_chunk_t { - png_byte name[5]; - png_byte *data; + png_byte name[5]; /* Textual chunk name with '\0' terminator */ + png_byte *data; /* Data, should not be modified on read! */ png_size_t size; - /* libpng-using applications should NOT directly modify this byte. */ + /* On write 'location' must be set using the flag values listed below. + * Notice that on read it is set by libpng however the values stored have + * more bits set than are listed below. Always treat the value as a + * bitmask. On write set only one bit - setting multiple bits may cause the + * chunk to be written in multiple places. + */ png_byte location; /* mode of operation at read time */ } png_unknown_chunk; -typedef png_unknown_chunk FAR * png_unknown_chunkp; -typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; -#endif - -/* png_info is a structure that holds the information in a PNG file so - * that the application can find out the characteristics of the image. - * If you are reading the file, this structure will tell you what is - * in the PNG file. If you are writing the file, fill in the information - * you want to put into the PNG file, then call png_write_info(). - * The names chosen should be very close to the PNG specification, so - * consult that document for information about the meaning of each field. - * - * With libpng < 0.95, it was only possible to directly set and read the - * the values in the png_info_struct, which meant that the contents and - * order of the values had to remain fixed. With libpng 0.95 and later, - * however, there are now functions that abstract the contents of - * png_info_struct from the application, so this makes it easier to use - * libpng with dynamic libraries, and even makes it possible to use - * libraries that don't have all of the libpng ancillary chunk-handing - * functionality. - * - * In any case, the order of the parameters in png_info_struct should NOT - * be changed for as long as possible to keep compatibility with applications - * that use the old direct-access method with png_info_struct. - * - * The following members may have allocated storage attached that should be - * cleaned up before the structure is discarded: palette, trans, text, - * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, - * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these - * are automatically freed when the info structure is deallocated, if they were - * allocated internally by libpng. This behavior can be changed by means - * of the png_data_freer() function. - * - * More allocation details: all the chunk-reading functions that - * change these members go through the corresponding png_set_* - * functions. A function to clear these members is available: see - * png_free_data(). The png_set_* functions do not depend on being - * able to point info structure members to any of the storage they are - * passed (they make their own copies), EXCEPT that the png_set_text - * functions use the same storage passed to them in the text_ptr or - * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns - * functions do not make their own copies. - */ -typedef struct png_info_struct -{ - /* the following are necessary for every PNG file */ - png_uint_32 width; /* width of image in pixels (from IHDR) */ - png_uint_32 height; /* height of image in pixels (from IHDR) */ - png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ - png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ - png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ - png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ - png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ - png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ - png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ - /* The following three should have been named *_method not *_type */ - png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ - png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ - png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - - /* The following is informational only on read, and not used on writes. */ - png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte spare_byte; /* to align the data, and for future use */ - png_byte signature[8]; /* magic bytes read by libpng from start of file */ - - /* The rest of the data is optional. If you are reading, check the - * valid field to see if the information in these are valid. If you - * are writing, set the valid field to those chunks you want written, - * and initialize the appropriate fields below. - */ - -#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - /* The gAMA chunk describes the gamma characteristics of the system - * on which the image was created, normally in the range [1.0, 2.5]. - * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. - */ - float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_sRGB_SUPPORTED) - /* GR-P, 0.96a */ - /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ - png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ -#endif - -#if defined(PNG_TEXT_SUPPORTED) - /* The tEXt, and zTXt chunks contain human-readable textual data in - * uncompressed, compressed, and optionally compressed forms, respectively. - * The data in "text" is an array of pointers to uncompressed, - * null-terminated C strings. Each chunk has a keyword that describes the - * textual data contained in that chunk. Keywords are not required to be - * unique, and the text string may be empty. Any number of text chunks may - * be in an image. - */ - int num_text; /* number of comments read/to write */ - int max_text; /* current size of text array */ - png_textp text; /* array of comments read/to write */ -#endif /* PNG_TEXT_SUPPORTED */ - -#if defined(PNG_tIME_SUPPORTED) - /* The tIME chunk holds the last time the displayed image data was - * modified. See the png_time struct for the contents of this struct. - */ - png_time mod_time; -#endif - -#if defined(PNG_sBIT_SUPPORTED) - /* The sBIT chunk specifies the number of significant high-order bits - * in the pixel data. Values are in the range [1, bit_depth], and are - * only specified for the channels in the pixel data. The contents of - * the low-order bits is not specified. Data is valid if - * (valid & PNG_INFO_sBIT) is non-zero. - */ - png_color_8 sig_bit; /* significant bits in color channels */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ -defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The tRNS chunk supplies transparency data for paletted images and - * other image types that don't need a full alpha channel. There are - * "num_trans" transparency values for a paletted image, stored in the - * same order as the palette colors, starting from index 0. Values - * for the data are in the range [0, 255], ranging from fully transparent - * to fully opaque, respectively. For non-paletted images, there is a - * single color specified that should be treated as fully transparent. - * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. - */ - png_bytep trans; /* transparent values for paletted image */ - png_color_16 trans_values; /* transparent color for non-palette image */ -#endif - -#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The bKGD chunk gives the suggested image background color if the - * display program does not have its own background color and the image - * is needs to composited onto a background before display. The colors - * in "background" are normally in the same color space/depth as the - * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. - */ - png_color_16 background; -#endif - -#if defined(PNG_oFFs_SUPPORTED) - /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards - * and downwards from the top-left corner of the display, page, or other - * application-specific co-ordinate space. See the PNG_OFFSET_ defines - * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. - */ - png_int_32 x_offset; /* x offset on page */ - png_int_32 y_offset; /* y offset on page */ - png_byte offset_unit_type; /* offset units type */ -#endif - -#if defined(PNG_pHYs_SUPPORTED) - /* The pHYs chunk gives the physical pixel density of the image for - * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ - * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. - */ - png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ - png_uint_32 y_pixels_per_unit; /* vertical pixel density */ - png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ -#endif - -#if defined(PNG_hIST_SUPPORTED) - /* The hIST chunk contains the relative frequency or importance of the - * various palette entries, so that a viewer can intelligently select a - * reduced-color palette, if required. Data is an array of "num_palette" - * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) - * is non-zero. - */ - png_uint_16p hist; -#endif - -#ifdef PNG_cHRM_SUPPORTED - /* The cHRM chunk describes the CIE color characteristics of the monitor - * on which the PNG was created. This data allows the viewer to do gamut - * mapping of the input image to ensure that the viewer sees the same - * colors in the image as the creator. Values are in the range - * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float x_white; - float y_white; - float x_red; - float y_red; - float x_green; - float y_green; - float x_blue; - float y_blue; -#endif -#endif - -#if defined(PNG_pCAL_SUPPORTED) - /* The pCAL chunk describes a transformation between the stored pixel - * values and original physical data values used to create the image. - * The integer range [0, 2^bit_depth - 1] maps to the floating-point - * range given by [pcal_X0, pcal_X1], and are further transformed by a - * (possibly non-linear) transformation function given by "pcal_type" - * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ - * defines below, and the PNG-Group's PNG extensions document for a - * complete description of the transformations and how they should be - * implemented, and for a description of the ASCII parameter strings. - * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. - */ - png_charp pcal_purpose; /* pCAL chunk description string */ - png_int_32 pcal_X0; /* minimum value */ - png_int_32 pcal_X1; /* maximum value */ - png_charp pcal_units; /* Latin-1 string giving physical units */ - png_charpp pcal_params; /* ASCII strings containing parameter values */ - png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ - png_byte pcal_nparams; /* number of parameters given in pcal_params */ -#endif - -/* New members added in libpng-1.0.6 */ -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunks that the library doesn't recognize. */ - png_unknown_chunkp unknown_chunks; - png_size_t unknown_chunks_num; -#endif - -#if defined(PNG_iCCP_SUPPORTED) - /* iCCP chunk data. */ - png_charp iccp_name; /* profile name */ - png_charp iccp_profile; /* International Color Consortium profile data */ - /* Note to maintainer: should be png_bytep */ - png_uint_32 iccp_proflen; /* ICC profile data length */ - png_byte iccp_compression; /* Always zero */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) - /* data on sPLT chunks (there may be more than one). */ - png_sPLT_tp splt_palettes; - png_uint_32 splt_palettes_num; -#endif - -#if defined(PNG_sCAL_SUPPORTED) - /* The sCAL chunk describes the actual physical dimensions of the - * subject matter of the graphic. The chunk contains a unit specification - * a byte value, and two ASCII strings representing floating-point - * values. The values are width and height corresponsing to one pixel - * in the image. This external representation is converted to double - * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. - */ - png_byte scal_unit; /* unit of physical scale */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - double scal_pixel_width; /* width of one pixel */ - double scal_pixel_height; /* height of one pixel */ -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp scal_s_width; /* string containing height */ - png_charp scal_s_height; /* string containing width */ -#endif -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) - /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ - /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ - png_bytepp row_pointers; /* the image bits */ -#endif -#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) - png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ +typedef png_unknown_chunk * png_unknown_chunkp; +typedef const png_unknown_chunk * png_const_unknown_chunkp; +typedef png_unknown_chunk * * png_unknown_chunkpp; #endif -#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) - png_fixed_point int_x_white; - png_fixed_point int_y_white; - png_fixed_point int_x_red; - png_fixed_point int_y_red; - png_fixed_point int_x_green; - png_fixed_point int_y_green; - png_fixed_point int_x_blue; - png_fixed_point int_y_blue; -#endif - -} png_info; - -typedef png_info FAR * png_infop; -typedef png_info FAR * FAR * png_infopp; +/* Flag values for the unknown chunk location byte. */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_AFTER_IDAT 0x08 /* Maximum positive integer used in PNG is (2^31)-1 */ #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) #define PNG_UINT_32_MAX ((png_uint_32)(-1)) #define PNG_SIZE_MAX ((png_size_t)(-1)) -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */ -#define PNG_MAX_UINT PNG_UINT_31_MAX -#endif + +/* These are constants for fixed point values encoded in the + * PNG specification manner (x100000) + */ +#define PNG_FP_1 100000 +#define PNG_FP_HALF 50000 +#define PNG_FP_MAX ((png_fixed_point)0x7fffffffL) +#define PNG_FP_MIN (-PNG_FP_MAX) /* These describe the color_type field in png_info. */ /* color type masks */ @@ -1039,7 +842,7 @@ typedef png_info FAR * FAR * png_infopp; #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */ /* This is used for the transformation routines, as some of them * change these values for the row. It also should enable using @@ -1047,53 +850,79 @@ typedef png_info FAR * FAR * png_infopp; */ typedef struct png_row_info_struct { - png_uint_32 width; /* width of row */ - png_uint_32 rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ + png_uint_32 width; /* width of row */ + png_size_t rowbytes; /* number of bytes in row */ + png_byte color_type; /* color type of row */ + png_byte bit_depth; /* bit depth of row */ + png_byte channels; /* number of channels (1, 2, 3, or 4) */ png_byte pixel_depth; /* bits per pixel (depth * channels) */ } png_row_info; -typedef png_row_info FAR * png_row_infop; -typedef png_row_info FAR * FAR * png_row_infopp; +typedef png_row_info * png_row_infop; +typedef png_row_info * * png_row_infopp; /* These are the function types for the I/O functions and for the functions * that allow the user to override the default I/O functions with his or her * own. The png_error_ptr type should match that of user-supplied warning * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. + * user read/write data functions. Note that the 'write' function must not + * modify the buffer it is passed. The 'read' function, on the other hand, is + * expected to return the read data in the buffer. */ -typedef struct png_struct_def png_struct; -typedef png_struct FAR * png_structp; - -typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); -typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); -typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); -typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, - int)); -typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, - int)); +typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); +typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t)); +typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); +typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, + int)); +typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, + int)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, - png_uint_32, int)); +typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); +typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); + +/* The following callback receives png_uint_32 row_number, int pass for the + * png_bytep data of the row. When transforming an interlaced image the + * row number is the row number within the sub-image of the interlace pass, so + * the value will increase to the height of the sub-image (not the full image) + * then reset to 0 for the next pass. + * + * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to + * find the output pixel (x,y) given an interlaced sub-image pixel + * (row,col,pass). (See below for these macros.) + */ +typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, + png_uint_32, int)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, - png_row_infop, png_bytep)); + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, + png_bytep)); #endif -#if defined(PNG_USER_CHUNKS_SUPPORTED) -typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); +#ifdef PNG_USER_CHUNKS_SUPPORTED +typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, + png_unknown_chunkp)); #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED +/* not used anywhere */ +/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */ +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This must match the function definition in <setjmp.h>, and the application + * must include this before png.h to obtain the definition of jmp_buf. The + * function is required to be PNG_NORETURN, but this is not checked. If the + * function does return the application will crash via an abort() or similar + * system level call. + * + * If you get a warning here while building the library you may need to make + * changes to ensure that pnglibconf.h records the calling convention used by + * your compiler. This may be very difficult - try using a different compiler + * to build the library! + */ +PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); #endif /* Transform masks for the high-level interface */ @@ -1109,666 +938,663 @@ typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ +/* Added to libpng-1.2.34 */ +#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER +#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ +/* Added to libpng-1.4.0 */ +#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ +/* Added to libpng-1.5.4 */ +#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ +#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 #define PNG_FLAG_MNG_FILTER_64 0x04 #define PNG_ALL_MNG_FEATURES 0x05 -typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); -typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); - -/* The structure that holds the information to read and write PNG files. - * The only people who need to care about what is inside of this are the - * people who will be modifying the library for their own special needs. - * It should NOT be accessed directly by an application, except to store - * the jmp_buf. - */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmpbuf; /* used in png_error */ -#endif - png_error_ptr error_fn; /* function for printing errors and aborting */ - png_error_ptr warning_fn; /* function for printing warnings */ - png_voidp error_ptr; /* user supplied struct for error functions */ - png_rw_ptr write_data_fn; /* function for writing output data */ - png_rw_ptr read_data_fn; /* function for reading input data */ - png_voidp io_ptr; /* ptr to application struct for I/O functions */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr read_user_transform_fn; /* user read transform */ -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr write_user_transform_fn; /* user write transform */ -#endif - -/* These were added in libpng-1.0.2 */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_voidp user_transform_ptr; /* user supplied struct for user transform */ - png_byte user_transform_depth; /* bit depth of user transformed pixels */ - png_byte user_transform_channels; /* channels in user transformed pixels */ -#endif -#endif - - png_uint_32 mode; /* tells us where we are in the PNG file */ - png_uint_32 flags; /* flags indicating various things to libpng */ - png_uint_32 transformations; /* which transformations to perform */ - - z_stream zstream; /* pointer to decompression structure (below) */ - png_bytep zbuf; /* buffer for zlib */ - png_size_t zbuf_size; /* size of zbuf */ - int zlib_level; /* holds zlib compression level */ - int zlib_method; /* holds zlib compression method */ - int zlib_window_bits; /* holds zlib compression window bits */ - int zlib_mem_level; /* holds zlib compression memory level */ - int zlib_strategy; /* holds zlib compression strategy */ - - png_uint_32 width; /* width of image in pixels */ - png_uint_32 height; /* height of image in pixels */ - png_uint_32 num_rows; /* number of rows in current pass */ - png_uint_32 usr_width; /* width of row at start of write */ - png_uint_32 rowbytes; /* size of row in bytes */ - png_uint_32 irowbytes; /* size of current interlaced row in bytes */ - png_uint_32 iwidth; /* width of current interlaced row in pixels */ - png_uint_32 row_number; /* current row in interlace pass */ - png_bytep prev_row; /* buffer to save previous (unfiltered) row */ - png_bytep row_buf; /* buffer to save current (unfiltered) row */ - png_bytep sub_row; /* buffer to save "sub" row when filtering */ - png_bytep up_row; /* buffer to save "up" row when filtering */ - png_bytep avg_row; /* buffer to save "avg" row when filtering */ - png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ - png_row_info row_info; /* used for transformation routines */ - - png_uint_32 idat_size; /* current IDAT size for read */ - png_uint_32 crc; /* current chunk CRC value */ - png_colorp palette; /* palette from the input file */ - png_uint_16 num_palette; /* number of color entries in palette */ - png_uint_16 num_trans; /* number of transparency values */ - png_byte chunk_name[5]; /* null-terminated name of current chunk */ - png_byte compression; /* file compression type (always 0) */ - png_byte filter; /* file filter type (always 0) */ - png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ - png_byte color_type; /* color type of file */ - png_byte bit_depth; /* bit depth of file */ - png_byte usr_bit_depth; /* bit depth of users row */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte channels; /* number of channels in file */ - png_byte usr_channels; /* channels at start of write */ - png_byte sig_bytes; /* magic bytes read/written from start of file */ - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -#ifdef PNG_LEGACY_SUPPORTED - png_byte filler; /* filler byte for pixel expansion */ -#else - png_uint_16 filler; /* filler bytes for pixel expansion */ -#endif -#endif - -#if defined(PNG_bKGD_SUPPORTED) - png_byte background_gamma_type; -# ifdef PNG_FLOATING_POINT_SUPPORTED - float background_gamma; -# endif - png_color_16 background; /* background color in screen gamma space */ -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_color_16 background_1; /* background normalized to gamma 1.0 */ -#endif -#endif /* PNG_bKGD_SUPPORTED */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_flush_ptr output_flush_fn;/* Function for flushing output */ - png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ - png_uint_32 flush_rows; /* number of rows written since last flush */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float gamma; /* file gamma value */ - float screen_gamma; /* screen gamma value (display_exponent) */ -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep gamma_table; /* gamma table for 8-bit depth files */ - png_bytep gamma_from_1; /* converts from 1.0 to screen */ - png_bytep gamma_to_1; /* converts from file to 1.0 */ - png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ - png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ - png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) - png_color_8 sig_bit; /* significant bits in each available channel */ -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) - png_color_8 shift; /* shift for significant bit tranformation */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ - || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans; /* transparency values for paletted files */ - png_color_16 trans_values; /* transparency values for non-paletted files */ -#endif - - png_read_status_ptr read_row_fn; /* called after each row is decoded */ - png_write_status_ptr write_row_fn; /* called after each row is encoded */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_progressive_info_ptr info_fn; /* called after header data fully read */ - png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ - png_progressive_end_ptr end_fn; /* called after image is complete */ - png_bytep save_buffer_ptr; /* current location in save_buffer */ - png_bytep save_buffer; /* buffer for previously read data */ - png_bytep current_buffer_ptr; /* current location in current_buffer */ - png_bytep current_buffer; /* buffer for recently used data */ - png_uint_32 push_length; /* size of current input chunk */ - png_uint_32 skip_length; /* bytes to skip in input data */ - png_size_t save_buffer_size; /* amount of data now in save_buffer */ - png_size_t save_buffer_max; /* total size of save_buffer */ - png_size_t buffer_size; /* total amount of available input data */ - png_size_t current_buffer_size; /* amount of data now in current_buffer */ - int process_mode; /* what push library is currently doing */ - int cur_palette; /* current push library palette index */ - -# if defined(PNG_TEXT_SUPPORTED) - png_size_t current_text_size; /* current size of text input data */ - png_size_t current_text_left; /* how much text left to read in input */ - png_charp current_text; /* current text chunk buffer */ - png_charp current_text_ptr; /* current location in current_text */ -# endif /* PNG_TEXT_SUPPORTED */ -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* for the Borland special 64K segment handler */ - png_bytepp offset_table_ptr; - png_bytep offset_table; - png_uint_16 offset_table_number; - png_uint_16 offset_table_count; - png_uint_16 offset_table_count_free; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - png_bytep palette_lookup; /* lookup table for dithering */ - png_bytep dither_index; /* index translation for palette files */ -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) - png_uint_16p hist; /* histogram */ -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_byte heuristic_method; /* heuristic for row filter selection */ - png_byte num_prev_filters; /* number of weights for previous rows */ - png_bytep prev_filters; /* filter type(s) of previous row(s) */ - png_uint_16p filter_weights; /* weight(s) for previous line(s) */ - png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ - png_uint_16p filter_costs; /* relative filter calculation cost */ - png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_charp time_buffer; /* String to hold RFC 1123 time text */ -#endif - -/* New members added in libpng-1.0.6 */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) - png_voidp user_chunk_ptr; - png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - int num_chunk_list; - png_bytep chunk_list; -#endif - -/* New members added in libpng-1.0.3 */ -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_byte rgb_to_gray_status; - /* These were changed from png_byte in libpng-1.0.6 */ - png_uint_16 rgb_to_gray_red_coeff; - png_uint_16 rgb_to_gray_green_coeff; - png_uint_16 rgb_to_gray_blue_coeff; -#endif - -/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* changed from png_byte to png_uint_32 at version 1.2.0 */ -#ifdef PNG_1_0_X - png_byte mng_features_permitted; -#else - png_uint_32 mng_features_permitted; -#endif /* PNG_1_0_X */ -#endif - -/* New member added in libpng-1.0.7 */ -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_fixed_point int_gamma; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_byte filter_type; -#endif - -#if defined(PNG_1_0_X) -/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ - png_uint_32 row_buf_size; -#endif - -/* New members added in libpng-1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -# if !defined(PNG_1_0_X) -# if defined(PNG_MMX_CODE_SUPPORTED) - png_byte mmx_bitdepth_threshold; - png_uint_32 mmx_rowbytes_threshold; -# endif - png_uint_32 asm_flags; -# endif -#endif - -/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -#ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ -#endif - -/* New member added in libpng-1.0.13 and 1.2.0 */ - png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep dither_sort; /* working sort array */ - png_bytep index_to_palette; /* where the original index currently is */ - /* in the palette */ - png_bytep palette_to_index; /* which original index points to this */ - /* palette color */ -#endif - -/* New members added in libpng-1.0.16 and 1.2.6 */ - png_byte compression_type; - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_uint_32 user_width_max; - png_uint_32 user_height_max; -#endif - -/* New member added in libpng-1.0.25 and 1.2.17 */ -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunk that the library doesn't recognize. */ - png_unknown_chunk unknown_chunk; -#endif -}; - - -/* This triggers a compiler error in png.c, if png.c and png.h - * do not agree upon the version number. +/* NOTE: prior to 1.5 these functions had no 'API' style declaration, + * this allowed the zlib default functions to be used on Windows + * platforms. In 1.5 the zlib default malloc (which just calls malloc and + * ignores the first argument) should be completely compatible with the + * following. */ -typedef png_structp version_1_2_21; +typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, + png_alloc_size_t)); +typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); -typedef png_struct FAR * FAR * png_structpp; - -/* Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng.txt for the +/* Section 3: exported functions + * Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng-manual.txt for the * full explanation, see example.c for the summary. This just provides * a simple one line description of the use of each function. + * + * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in + * pngconf.h and in the *.dfn files in the scripts directory. + * + * PNG_EXPORT(ordinal, type, name, (args)); + * + * ordinal: ordinal that is used while building + * *.def files. The ordinal value is only + * relevant when preprocessing png.h with + * the *.dfn files for building symbol table + * entries, and are removed by pngconf.h. + * type: return type of the function + * name: function name + * args: function arguments, with types + * + * When we wish to append attributes to a function prototype we use + * the PNG_EXPORTA() macro instead. + * + * PNG_EXPORTA(ordinal, type, name, (args), attributes); + * + * ordinal, type, name, and args: same as in PNG_EXPORT(). + * attributes: function attributes */ /* Returns the version number of the library */ -extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); +PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); /* Tell lib we have already handled the first <num_bytes> magic bytes. * Handling more than 8 bytes from the beginning of the file is an error. */ -extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, - int num_bytes)); +PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or * start > 7 will always fail (ie return non-zero). */ -extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, - png_size_t num_to_check)); +PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, + png_size_t num_to_check)); /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ -extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); +#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) /* Allocate and initialize png_ptr struct for reading, and any other memory. */ -extern PNG_EXPORT(png_structp,png_create_read_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); +PNG_EXPORTA(4, png_structp, png_create_read_struct, + (png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn), + PNG_ALLOCATED); /* Allocate and initialize png_ptr struct for writing, and any other memory */ -extern PNG_EXPORT(png_structp,png_create_write_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); +PNG_EXPORTA(5, png_structp, png_create_write_struct, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn), + PNG_ALLOCATED); -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) - PNGARG((png_structp png_ptr)); -#endif +PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, + (png_const_structrp png_ptr)); -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(void,png_set_compression_buffer_size) - PNGARG((png_structp png_ptr, png_uint_32 size)); +PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, + png_size_t size)); + +/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp + * match up. + */ +#ifdef PNG_SETJMP_SUPPORTED +/* This function returns the jmp_buf built in to *png_ptr. It must be + * supplied with an appropriate 'longjmp' function to use on that jmp_buf + * unless the default error function is overridden in which case NULL is + * acceptable. The size of the jmp_buf is checked against the actual size + * allocated by the library - the call will return NULL on a mismatch + * indicating an ABI mismatch. + */ +PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, + png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); +# define png_jmpbuf(png_ptr) \ + (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) #endif +/* This function should be used by libpng applications in place of + * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it + * will use it; otherwise it will call PNG_ABORT(). This function was + * added in libpng-1.5.0. + */ +PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), + PNG_NORETURN); +#ifdef PNG_READ_SUPPORTED /* Reset the compression stream */ -extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); +PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); +#endif /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_structp,png_create_read_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -extern PNG_EXPORT(png_structp,png_create_write_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +PNG_EXPORTA(11, png_structp, png_create_read_struct_2, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), + PNG_ALLOCATED); +PNG_EXPORTA(12, png_structp, png_create_write_struct_2, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), + PNG_ALLOCATED); #endif +/* Write the PNG file signature. */ +PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); + /* Write a PNG chunk - size, type, (optional) data, CRC. */ -extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_bytep data, png_size_t length)); +PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep + chunk_name, png_const_bytep data, png_size_t length)); /* Write the start of a PNG chunk - length and chunk name. */ -extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_uint_32 length)); +PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, + png_const_bytep chunk_name, png_uint_32 length)); /* Write the data of a PNG chunk started with png_write_chunk_start(). */ -extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); +PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, + png_const_bytep data, png_size_t length)); /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); +PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); /* Allocate and initialize the info structure */ -extern PNG_EXPORT(png_infop,png_create_info_struct) - PNGARG((png_structp png_ptr)); - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize the info structure (old interface - DEPRECATED) */ -extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); -#undef png_info_init -#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ - png_sizeof(png_info)); -#endif +PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), + PNG_ALLOCATED); -extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, - png_size_t png_info_struct_size)); +/* DEPRECATED: this function allowed init structures to be created using the + * default allocation method (typically malloc). Use is deprecated in 1.6.0 and + * the API will be removed in the future. + */ +PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, + png_size_t png_info_struct_size), PNG_DEPRECATED); /* Writes all the PNG information before the image. */ -extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +PNG_EXPORT(20, void, png_write_info_before_PLTE, + (png_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(21, void, png_write_info, + (png_structrp png_ptr, png_const_inforp info_ptr)); -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the information before the actual image data. */ -extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the information before the actual image data. */ +PNG_EXPORT(22, void, png_read_info, + (png_structrp png_ptr, png_inforp info_ptr)); #endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) -extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) - PNGARG((png_structp png_ptr, png_timep ptime)); +#ifdef PNG_TIME_RFC1123_SUPPORTED + /* Convert to a US string format: there is no localization support in this + * routine. The original implementation used a 29 character buffer in + * png_struct, this will be removed in future versions. + */ +#if PNG_LIBPNG_VER < 10700 +/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ +PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, + png_const_timep ptime),PNG_DEPRECATED); +#endif +PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], + png_const_timep ptime)); #endif -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* convert from a struct tm to png_time */ -extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, - struct tm FAR * ttime)); +#ifdef PNG_CONVERT_tIME_SUPPORTED +/* Convert from a struct tm to png_time */ +PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, + const struct tm * ttime)); -/* convert from time_t to png_time. Uses gmtime() */ -extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, - time_t ttime)); -#endif /* PNG_WRITE_tIME_SUPPORTED */ -#endif /* _WIN32_WCE */ +/* Convert from time_t to png_time. Uses gmtime() */ +PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); +#endif /* PNG_CONVERT_tIME_SUPPORTED */ -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp - png_ptr)); -#endif -extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated */ -extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); +PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); +PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); +PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); +PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); #endif + +#ifdef PNG_READ_EXPAND_16_SUPPORTED +/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion + * of a tRNS chunk if present. + */ +PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ -extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); +PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); #endif -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* Expand the grayscale to 24-bit RGB if necessary. */ -extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); +PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED /* Reduce RGB to grayscale. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, - int error_action, double red, double green )); +#define PNG_ERROR_ACTION_NONE 1 +#define PNG_ERROR_ACTION_WARN 2 +#define PNG_ERROR_ACTION_ERROR 3 +#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ + +PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, + int error_action, double red, double green)) +PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green)) + +PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp + png_ptr)); +#endif + +#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED +PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, + png_colorp palette)); #endif -extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green )); -extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp - png_ptr)); + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED +/* How the alpha channel is interpreted - this affects how the color channels of + * a PNG file are returned when an alpha channel, or tRNS chunk in a palette + * file, is present. + * + * This has no effect on the way pixels are written into a PNG output + * datastream. The color samples in a PNG datastream are never premultiplied + * with the alpha samples. + * + * The default is to return data according to the PNG specification: the alpha + * channel is a linear measure of the contribution of the pixel to the + * corresponding composited pixel. The gamma encoded color channels must be + * scaled according to the contribution and to do this it is necessary to undo + * the encoding, scale the color values, perform the composition and reencode + * the values. This is the 'PNG' mode. + * + * The alternative is to 'associate' the alpha with the color information by + * storing color channel values that have been scaled by the alpha. The + * advantage is that the color channels can be resampled (the image can be + * scaled) in this form. The disadvantage is that normal practice is to store + * linear, not (gamma) encoded, values and this requires 16-bit channels for + * still images rather than the 8-bit channels that are just about sufficient if + * gamma encoding is used. In addition all non-transparent pixel values, + * including completely opaque ones, must be gamma encoded to produce the final + * image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the + * latter being the two common names for associated alpha color channels.) + * + * Since it is not necessary to perform arithmetic on opaque color values so + * long as they are not to be resampled and are in the final color space it is + * possible to optimize the handling of alpha by storing the opaque pixels in + * the PNG format (adjusted for the output color space) while storing partially + * opaque pixels in the standard, linear, format. The accuracy required for + * standard alpha composition is relatively low, because the pixels are + * isolated, therefore typically the accuracy loss in storing 8-bit linear + * values is acceptable. (This is not true if the alpha channel is used to + * simulate transparency over large areas - use 16 bits or the PNG mode in + * this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is + * treated as opaque only if the alpha value is equal to the maximum value. + * + * The final choice is to gamma encode the alpha channel as well. This is + * broken because, in practice, no implementation that uses this choice + * correctly undoes the encoding before handling alpha composition. Use this + * choice only if other serious errors in the software or hardware you use + * mandate it; the typical serious error is for dark halos to appear around + * opaque areas of the composited PNG image because of arithmetic overflow. + * + * The API function png_set_alpha_mode specifies which of these choices to use + * with an enumerated 'mode' value and the gamma of the required output: + */ +#define PNG_ALPHA_PNG 0 /* according to the PNG standard */ +#define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ +#define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ +#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ +#define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ +#define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ + +PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, + double output_gamma)) +PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, + int mode, png_fixed_point output_gamma)) +#endif + +#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) +/* The output_gamma value is a screen gamma in libpng terminology: it expresses + * how to decode the output values, not how they are encoded. The values used + * correspond to the normal numbers used to describe the overall gamma of a + * computer display system; for example 2.2 for an sRGB conformant system. The + * values are scaled by 100000 in the _fixed version of the API (so 220000 for + * sRGB.) + * + * The inverse of the value is always used to provide a default for the PNG file + * encoding if it has no gAMA chunk and if png_set_gamma() has not been called + * to override the PNG gamma information. + * + * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode + * opaque pixels however pixels with lower alpha values are not encoded, + * regardless of the output gamma setting. + * + * When the standard Porter Duff handling is requested with mode 1 the output + * encoding is set to be linear and the output_gamma value is only relevant + * as a default for input data that has no gamma information. The linear output + * encoding will be overridden if png_set_gamma() is called - the results may be + * highly unexpected! + * + * The following numbers are derived from the sRGB standard and the research + * behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of + * 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing + * correction required to take account of any differences in the color + * environment of the original scene and the intended display environment; the + * value expresses how to *decode* the image for display, not how the original + * data was *encoded*. + * + * sRGB provides a peg for the PNG standard by defining a viewing environment. + * sRGB itself, and earlier TV standards, actually use a more complex transform + * (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is + * limited to simple power laws.) By saying that an image for direct display on + * an sRGB conformant system should be stored with a gAMA chunk value of 45455 + * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification + * makes it possible to derive values for other display systems and + * environments. + * + * The Mac value is deduced from the sRGB based on an assumption that the actual + * extra viewing correction used in early Mac display systems was implemented as + * a power 1.45 lookup table. + * + * Any system where a programmable lookup table is used or where the behavior of + * the final display device characteristics can be changed requires system + * specific code to obtain the current characteristic. However this can be + * difficult and most PNG gamma correction only requires an approximate value. + * + * By default, if png_set_alpha_mode() is not called, libpng assumes that all + * values are unencoded, linear, values and that the output device also has a + * linear characteristic. This is only very rarely correct - it is invariably + * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the + * default if you don't know what the right answer is! + * + * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS + * 10.6) which used a correction table to implement a somewhat lower gamma on an + * otherwise sRGB system. + * + * Both these values are reserved (not simple gamma values) in order to allow + * more precise correction internally in the future. + * + * NOTE: the following values can be passed to either the fixed or floating + * point APIs, but the floating point API will also accept floating point + * values. + */ +#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ +#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ +#define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ +#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ #endif -extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, - png_colorp palette)); +/* The following are examples of calls to png_set_alpha_mode to achieve the + * required overall gamma correction and, where necessary, alpha + * premultiplication. + * + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); + * This is the default libpng handling of the alpha channel - it is not + * pre-multiplied into the color components. In addition the call states + * that the output is for a sRGB system and causes all PNG files without gAMA + * chunks to be assumed to be encoded using sRGB. + * + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); + * In this case the output is assumed to be something like an sRGB conformant + * display preceeded by a power-law lookup table of power 1.45. This is how + * early Mac systems behaved. + * + * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); + * This is the classic Jim Blinn approach and will work in academic + * environments where everything is done by the book. It has the shortcoming + * of assuming that input PNG data with no gamma information is linear - this + * is unlikely to be correct unless the PNG files where generated locally. + * Most of the time the output precision will be so low as to show + * significant banding in dark areas of the image. + * + * png_set_expand_16(pp); + * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); + * This is a somewhat more realistic Jim Blinn inspired approach. PNG files + * are assumed to have the sRGB encoding if not marked with a gamma value and + * the output is always 16 bits per component. This permits accurate scaling + * and processing of the data. If you know that your input PNG files were + * generated locally you might need to replace PNG_DEFAULT_sRGB with the + * correct value for your system. + * + * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); + * If you just need to composite the PNG image onto an existing background + * and if you control the code that does this you can use the optimization + * setting. In this case you just copy completely opaque pixels to the + * output. For pixels that are not completely transparent (you just skip + * those) you do the composition math using png_composite or png_composite_16 + * below then encode the resultant 8-bit or 16-bit values to match the output + * encoding. + * + * Other cases + * If neither the PNG nor the standard linear encoding work for you because + * of the software or hardware you use then you have a big problem. The PNG + * case will probably result in halos around the image. The linear encoding + * will probably result in a washed out, too bright, image (it's actually too + * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably + * substantially reduce the halos. Alternatively try: + * + * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); + * This option will also reduce the halos, but there will be slight dark + * halos round the opaque parts of the image where the background is light. + * In the OPTIMIZED mode the halos will be light halos where the background + * is dark. Take your pick - the halos are unavoidable unless you can get + * your hardware/software fixed! (The OPTIMIZED approach is slightly + * faster.) + * + * When the default gamma of PNG files doesn't match the output gamma. + * If you have PNG files with no gamma information png_set_alpha_mode allows + * you to provide a default gamma, but it also sets the ouput gamma to the + * matching value. If you know your PNG files have a gamma that doesn't + * match the output you can take advantage of the fact that + * png_set_alpha_mode always sets the output gamma but only sets the PNG + * default if it is not already set: + * + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); + * The first call sets both the default and the output gamma values, the + * second call overrides the output gamma without changing the default. This + * is easier than achieving the same effect with png_set_gamma. You must use + * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will + * fire if more than one call to png_set_alpha_mode and png_set_background is + * made in the same read operation, however multiple calls with PNG_ALPHA_PNG + * are ignored. + */ -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); +PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); +PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ -extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); +PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, + int flags)); /* The values of the PNG_FILLER_ defines should NOT be changed */ -#define PNG_FILLER_BEFORE 0 -#define PNG_FILLER_AFTER 1 +# define PNG_FILLER_BEFORE 0 +# define PNG_FILLER_AFTER 1 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -#endif +PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, + png_uint_32 filler, int flags)); #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* Swap bytes in 16-bit depth files. */ -extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); +PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); +PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); #endif -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ + defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* Swap packing order of pixels in bytes. */ -extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); +PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) /* Converts files to legal bit depths. */ -extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, - png_color_8p true_bits)); +PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p + true_bits)); #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. */ -extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); +/* Have the code handle the interlacing. Returns the number of passes. + * MUST be called before png_read_update_info or png_start_read_image, + * otherwise it will not have the desired effect. Note that it is still + * necessary to call png_read_row or png_read_rows png_get_image_height + * times for each pass. +*/ +PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) /* Invert monochrome files */ -extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); +PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Handle alpha and tRNS by replacing with a background color. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); +#ifdef PNG_READ_BACKGROUND_SUPPORTED +/* Handle alpha and tRNS by replacing with a background color. Prior to + * libpng-1.5.4 this API must not be called before the PNG file header has been + * read. Doing so will result in unexpected behavior and possible warnings or + * errors if the PNG file contains a bKGD chunk. + */ +PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)) +PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, png_fixed_point background_gamma)) #endif -#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -#define PNG_BACKGROUND_GAMMA_SCREEN 1 -#define PNG_BACKGROUND_GAMMA_FILE 2 -#define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#ifdef PNG_READ_BACKGROUND_SUPPORTED +# define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +# define PNG_BACKGROUND_GAMMA_SCREEN 1 +# define PNG_BACKGROUND_GAMMA_FILE 2 +# define PNG_BACKGROUND_GAMMA_UNIQUE 3 #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip the second byte of information from a 16-bit depth file. */ -extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED +/* Scale a 16-bit depth file down to 8-bit, accurately. */ +PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); #endif -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Turn on dithering, and reduce the palette to the number of colors available. */ -extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_uint_16p histogram, int full_dither)); +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED +#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ +/* Strip the second byte of information from a 16-bit depth file. */ +PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Handle gamma correction. Screen_gamma=(display_exponent) */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, - double screen_gamma, double default_file_gamma)); -#endif +#ifdef PNG_READ_QUANTIZE_SUPPORTED +/* Turn on quantizing, and reduce the palette to the number of colors + * available. + */ +PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, + png_colorp palette, int num_palette, int maximum_colors, + png_const_uint_16p histogram, int full_quantize)); #endif -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ -/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ -extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, - int empty_plte_permitted)); -#endif +#ifdef PNG_READ_GAMMA_SUPPORTED +/* The threshold on gamma processing is configurable but hard-wired into the + * library. The following is the floating point variant. + */ +#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) + +/* Handle gamma correction. Screen_gamma=(display_exponent). + * NOTE: this API simply sets the screen and file gamma values. It will + * therefore override the value for gamma in a PNG file if it is called after + * the file header has been read - use with care - call before reading the PNG + * file for best results! + * + * These routines accept the same gamma values as png_set_alpha_mode (described + * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either + * API (floating point or fixed.) Notice, however, that the 'file_gamma' value + * is the inverse of a 'screen gamma' value. + */ +PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, + double screen_gamma, double override_file_gamma)) +PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, + png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) #endif -#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#ifdef PNG_WRITE_FLUSH_SUPPORTED /* Set how many lines between output flushes - 0 for no flushing */ -extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); +PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); /* Flush the current PNG output buffer */ -extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); +PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); #endif -/* optional update palette with requested transformations */ -extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); +/* Optional update palette with requested transformations */ +PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); -/* optional call to update the users info structure */ -extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +/* Optional call to update the users info structure */ +PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, + png_inforp info_ptr)); -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read one or more rows of image data. */ -extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read one or more rows of image data. */ +PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, + png_bytepp display_row, png_uint_32 num_rows)); #endif -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read a row of data. */ -extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, - png_bytep row, - png_bytep display_row)); +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read a row of data. */ +PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, + png_bytep display_row)); #endif -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the whole image into memory at once. */ -extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, - png_bytepp image)); +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the whole image into memory at once. */ +PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); #endif -/* write a row of image data */ -extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, - png_bytep row)); +/* Write a row of image data */ +PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, + png_const_bytep row)); -/* write a few rows of image data */ -extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_uint_32 num_rows)); +/* Write a few rows of image data: (*row) is not written; however, the type + * is declared as writeable to maintain compatibility with previous versions + * of libpng and to allow the 'display_row' array from read_rows to be passed + * unchanged to write_rows. + */ +PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, + png_uint_32 num_rows)); -/* write the image data */ -extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, - png_bytepp image)); +/* Write the image data */ +PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); -/* writes the end of the PNG file. */ -extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +/* Write the end of the PNG file. */ +PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, + png_inforp info_ptr)); -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the end of the PNG file. */ -extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the end of the PNG file. */ +PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); #endif -/* free any memory associated with the png_info_struct */ -extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, - png_infopp info_ptr_ptr)); +/* Free any memory associated with the png_info_struct */ +PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, + png_infopp info_ptr_ptr)); -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp - png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); +/* Free any memory associated with the png_struct and the png_info_structs */ +PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, + png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); -/* free all memory used by the read (old method - NOT DLL EXPORTED) */ -extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, - png_infop end_info_ptr)); +/* Free any memory associated with the png_struct and the png_info_structs */ +PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, + png_infopp info_ptr_ptr)); -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_write_struct) - PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); +/* Set the libpng method of handling chunk CRC errors */ +PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, + int ancil_action)); -/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ -extern void png_write_destroy PNGARG((png_structp png_ptr)); - -/* set the libpng method of handling chunk CRC errors */ -extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, - int crit_action, int ancil_action)); - -/* Values for png_set_crc_action() to say how to handle CRC errors in +/* Values for png_set_crc_action() say how to handle CRC errors in * ancillary and critical chunks, and whether to use the data contained * therein. Note that it is impossible to "discard" data in a critical * chunk. For versions prior to 0.90, the action was always error/quit, @@ -1792,11 +1618,11 @@ extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, * header file (zlib.h) for an explination of the compression functions. */ -/* set the filtering method(s) used by libpng. Currently, the only valid +/* Set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ -extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, - int filters)); +PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, + int filters)); /* Flags for png_set_filter() to say which filters to use. The flags * are chosen so that they don't conflict with real filter types @@ -1822,7 +1648,7 @@ extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, #define PNG_FILTER_VALUE_PAETH 4 #define PNG_FILTER_VALUE_LAST 5 -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */ /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ * defines, either the default (minimum-sum-of-absolute-differences), or * the experimental method (weighted-minimum-sum-of-absolute-differences). @@ -1851,11 +1677,13 @@ extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, * the weights and costs are set to 1.0, this degenerates the WEIGHTED method * to the UNWEIGHTED method, but with added encoding time/computation. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, - int heuristic_method, int num_weights, png_doublep filter_weights, - png_doublep filter_costs)); -#endif +PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, + int heuristic_method, int num_weights, png_const_doublep filter_weights, + png_const_doublep filter_costs)) +PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, + (png_structrp png_ptr, int heuristic_method, int num_weights, + png_const_fixed_point_p filter_weights, + png_const_fixed_point_p filter_costs)) #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ /* Heuristic used for row filter selection. These defines should NOT be @@ -1866,6 +1694,7 @@ extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ +#ifdef PNG_WRITE_SUPPORTED /* Set the library compression level. Currently, valid values range from * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * (0 - no compression, 9 - "maximal" compression). Note that tests have @@ -1873,33 +1702,58 @@ extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, * for PNG images, and do considerably fewer caclulations. In the future, * these values may not correspond directly to the zlib compression levels. */ -extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, - int level)); +PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, + int level)); + +PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, + int mem_level)); + +PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, + int strategy)); + +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ +PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, + int window_bits)); + +PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, + int method)); +#endif + +#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED +/* Also set zlib parameters for compressing non-IDAT chunks */ +PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, + int level)); -extern PNG_EXPORT(void,png_set_compression_mem_level) - PNGARG((png_structp png_ptr, int mem_level)); +PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, + int mem_level)); -extern PNG_EXPORT(void,png_set_compression_strategy) - PNGARG((png_structp png_ptr, int strategy)); +PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, + int strategy)); -extern PNG_EXPORT(void,png_set_compression_window_bits) - PNGARG((png_structp png_ptr, int window_bits)); +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ +PNG_EXPORT(225, void, png_set_text_compression_window_bits, + (png_structrp png_ptr, int window_bits)); -extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, - int method)); +PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, + int method)); +#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ /* These next functions are called for input/output, memory, and error * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, * and call standard C I/O routines such as fread(), fwrite(), and * fprintf(). These functions can be made to use other I/O routines * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng.txt for + * different manner by calling png_set_???_fn(). See libpng-manual.txt for * more information. */ -#if !defined(PNG_NO_STDIO) +#ifdef PNG_STDIO_SUPPORTED /* Initialize the input/output for the PNG file to the default functions. */ -extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); +PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); #endif /* Replace the (error and abort), and warning functions with user @@ -1910,128 +1764,181 @@ extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)) * default function will be used. */ -extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); +PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); /* Return the user pointer associated with the error functions */ -extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); +PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); /* Replace the default data output functions with a user supplied one(s). * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). + * It is probably a mistake to use NULL for output_flush_fn if + * write_data_fn is not also NULL unless you have built libpng with + * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's + * default flush function, which uses the standard *FILE structure, will + * be used. */ -extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); +PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, + png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); /* Replace the default data input function with a user supplied one. */ -extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr read_data_fn)); +PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, + png_rw_ptr read_data_fn)); /* Return the user pointer associated with the I/O functions */ -extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); +PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); -extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, - png_read_status_ptr read_row_fn)); +PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, + png_read_status_ptr read_row_fn)); -extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, - png_write_status_ptr write_row_fn)); +PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, + png_write_status_ptr write_row_fn)); #ifdef PNG_USER_MEM_SUPPORTED /* Replace the default memory allocation functions with user supplied one(s). */ -extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); /* Return the user pointer associated with the memory functions */ -extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); +PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); #endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr read_user_transform_fn)); +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, + png_user_transform_ptr read_user_transform_fn)); #endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr write_user_transform_fn)); +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED +PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, + png_user_transform_ptr write_user_transform_fn)); #endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp - png_ptr, png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED +PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, + png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); /* Return the user pointer associated with the user transform functions */ -extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) - PNGARG((png_structp png_ptr)); +PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, + (png_const_structrp png_ptr)); +#endif + +#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED +/* Return information about the row currently being processed. Note that these + * APIs do not fail but will return unexpected results if called outside a user + * transform callback. Also note that when transforming an interlaced image the + * row number is the row number within the sub-image of the interlace pass, so + * the value will increase to the height of the sub-image (not the full image) + * then reset to 0 for the next pass. + * + * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to + * find the output pixel (x,y) given an interlaced sub-image pixel + * (row,col,pass). (See below for these macros.) + */ +PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); +PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); +#endif + +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED +/* This callback is called only for *unknown* chunks. If + * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known + * chunks to be treated as unknown, however in this case the callback must do + * any processing required by the chunk (e.g. by calling the appropriate + * png_set_ APIs.) + * + * There is no write support - on write, by default, all the chunks in the + * 'unknown' list are written in the specified position. + * + * The integer return from the callback function is interpreted thus: + * + * negative: An error occured, png_chunk_error will be called. + * zero: The chunk was not handled, the chunk will be saved. A critical + * chunk will cause an error at this point unless it is to be saved. + * positive: The chunk was handled, libpng will ignore/discard it. + * + * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about + * how this behavior will change in libpng 1.7 + */ +PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED -extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp - png_ptr)); +PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. */ -extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, - png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn)); - -/* returns the user pointer associated with the push read functions */ -extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) - PNGARG((png_structp png_ptr)); +PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, + png_voidp progressive_ptr, png_progressive_info_ptr info_fn, + png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); + +/* Returns the user pointer associated with the push read functions */ +PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, + (png_const_structrp png_ptr)); + +/* Function to be called when data becomes available */ +PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, + png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size)); + +/* A function which may be called *only* within png_process_data to stop the + * processing of any more data. The function returns the number of bytes + * remaining, excluding any that libpng has cached internally. A subsequent + * call to png_process_data must supply these bytes again. If the argument + * 'save' is set to true the routine will first save all the pending data and + * will always return 0. + */ +PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save)); -/* function to be called when data becomes available */ -extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); +/* A function which may be called *only* outside (after) a call to + * png_process_data. It returns the number of bytes of data to skip in the + * input. Normally it will return 0, but if it returns a non-zero value the + * application must skip than number of bytes of input data and pass the + * following data to the next call to png_process_data. + */ +PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); -/* function that combines rows. Not very much different than the - * png_combine_row() call. Is this even used????? +#ifdef PNG_READ_INTERLACING_SUPPORTED +/* Function that combines rows. 'new_row' is a flag that should come from + * the callback and be non-NULL if anything needs to be done; the library + * stores its own version of the new data internally and ignores the passed + * in value. */ -extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, - png_bytep old_row, png_bytep new_row)); +PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, + png_bytep old_row, png_const_bytep new_row)); +#endif /* PNG_READ_INTERLACING_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ -extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, - png_uint_32 size)); +PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED); +/* Added at libpng version 1.4.0 */ +PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED); -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else /* Added at libpng version 1.2.4 */ -extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, - png_uint_32 size)); -#endif +PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED); -/* frees a pointer allocated by png_malloc() */ -extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); - -#if defined(PNG_1_0_X) -/* Function to allocate memory for zlib. */ -extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, - uInt size)); - -/* Function to free memory for zlib */ -extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); -#endif +/* Frees a pointer allocated by png_malloc() */ +PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); /* Free data that was allocated internally */ -extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 free_me, int num)); -#ifdef PNG_FREE_ME_SUPPORTED +PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_32 free_me, int num)); + /* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application */ -extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, - png_infop info_ptr, int freer, png_uint_32 mask)); -#endif -/* assignments for png_data_freer */ + * by libpng or by the application; this works on the png_info structure passed + * in, it does not change the state for other png_info structures. + * + * It is unlikely that this function works correctly as of 1.6.0 and using it + * may result either in memory leaks or double free of allocated data. + */ +PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr, + png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED); + +/* Assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 @@ -2042,8 +1949,10 @@ extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, #define PNG_FREE_ROWS 0x0040 #define PNG_FREE_PCAL 0x0080 #define PNG_FREE_SCAL 0x0100 -#define PNG_FREE_UNKN 0x0200 -#define PNG_FREE_LIST 0x0400 +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_FREE_UNKN 0x0200 +#endif +/* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */ #define PNG_FREE_PLTE 0x1000 #define PNG_FREE_TRNS 0x2000 #define PNG_FREE_TEXT 0x4000 @@ -2051,47 +1960,59 @@ extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, - png_uint_32 size)); -extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, - png_voidp ptr)); +PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); +PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, + png_voidp ptr), PNG_DEPRECATED); #endif -extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, - png_voidp s1, png_voidp s2, png_uint_32 size)); - -extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, - png_voidp s1, int value, png_uint_32 size)); - -#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ -extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, - int check)); -#endif /* USE_FAR_KEYWORD */ - -#ifndef PNG_NO_ERROR_TEXT +#ifdef PNG_ERROR_TEXT_SUPPORTED /* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); +PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, + png_const_charp error_message), PNG_NORETURN); /* The same, but the chunk name is prepended to the error string. */ -extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); +PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, + png_const_charp error_message), PNG_NORETURN); + #else /* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr)); +PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); #endif -#ifndef PNG_NO_WARNINGS +#ifdef PNG_WARNINGS_SUPPORTED /* Non-fatal error in libpng. Can continue, but may have a problem. */ -extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); +PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, + png_const_charp warning_message)); -#ifdef PNG_READ_SUPPORTED /* Non-fatal error in libpng, chunk name is prepended to message. */ -extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); -#endif /* PNG_READ_SUPPORTED */ -#endif /* PNG_NO_WARNINGS */ +PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, + png_const_charp warning_message)); +#endif + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +/* Benign error in libpng. Can continue, but may have a problem. + * User can choose whether to handle as a fatal error or as a warning. */ +PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, + png_const_charp warning_message)); + +#ifdef PNG_READ_SUPPORTED +/* Same, chunk name is prepended to message (only during read) */ +PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, + png_const_charp warning_message)); +#endif + +PNG_EXPORT(109, void, png_set_benign_errors, + (png_structrp png_ptr, int allowed)); +#else +# ifdef PNG_ALLOW_BENIGN_ERRORS +# define png_benign_error png_warning +# define png_chunk_benign_error png_chunk_warning +# else +# define png_benign_error png_error +# define png_chunk_benign_error png_chunk_error +# endif +#endif /* The png_set_<chunk> functions are for storing values in the png_info_struct. * Similarly, the png_get_<chunk> calls are used to read values from the @@ -2106,421 +2027,495 @@ extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, * png_info_struct. */ /* Returns "flag" if chunk data is valid in info_ptr. */ -extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 flag)); +PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 flag)); /* Returns number of bytes needed to hold a transformed row. */ -extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, -png_infop info_ptr)); +PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_INFO_IMAGE_SUPPORTED /* Returns row_pointers, which is an array of pointers to scanlines that was -returned from png_read_png(). */ -extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, -png_infop info_ptr)); + * returned from png_read_png(). + */ +PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); + /* Set row_pointers, which is an array of pointers to scanlines for use -by png_write_png(). */ -extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytepp row_pointers)); + * by png_write_png(). + */ +PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, + png_inforp info_ptr, png_bytepp row_pointers)); #endif /* Returns number of color channels in image. */ -extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, -png_infop info_ptr)); +PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); #ifdef PNG_EASY_ACCESS_SUPPORTED /* Returns image width in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); /* Returns image height in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); /* Returns image bit_depth. */ -extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); /* Returns image color_type. */ -extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); /* Returns image filter_type. */ -extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); /* Returns image interlace_type. */ -extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); /* Returns image compression_type. */ -extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); /* Returns image resolution in pixels per meter, from pHYs chunk data. */ -extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns pixel aspect ratio, computed from pHYs chunk data. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -#endif +PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) +PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); +PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif /* PNG_EASY_ACCESS_SUPPORTED */ +#ifdef PNG_READ_SUPPORTED /* Returns pointer to signature string read from PNG header */ -extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p *background)); -#endif - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p background)); -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point - *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point - *int_blue_x, png_fixed_point *int_blue_y)); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double white_x, double white_y, double red_x, - double red_y, double green_x, double green_y, double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif +PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, + png_const_inforp info_ptr)); #endif -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *file_gamma)); -#endif -extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_file_gamma)); -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double file_gamma)); -#endif -extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); +#ifdef PNG_bKGD_SUPPORTED +PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, + png_inforp info_ptr, png_color_16p *background)); #endif -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p *hist)); +#ifdef PNG_bKGD_SUPPORTED +PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_color_16p background)); #endif -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p hist)); +#ifdef PNG_cHRM_SUPPORTED +PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, + png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)) +PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, + png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, + double *green_X, double *green_Y, double *green_Z, double *blue_X, + double *blue_Y, double *blue_Z)) +PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *int_white_x, png_fixed_point *int_white_y, + png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, + png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) +PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *int_red_X, png_fixed_point *int_red_Y, + png_fixed_point *int_red_Z, png_fixed_point *int_green_X, + png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, + png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, + png_fixed_point *int_blue_Z)) #endif -extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, +#ifdef PNG_cHRM_SUPPORTED +PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, + png_inforp info_ptr, + double white_x, double white_y, double red_x, double red_y, double green_x, + double green_y, double blue_x, double blue_y)) +PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, + png_inforp info_ptr, double red_X, double red_Y, double red_Z, + double green_X, double green_Y, double green_Z, double blue_X, + double blue_Y, double blue_Z)) +PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, png_fixed_point int_white_x, + png_fixed_point int_white_y, png_fixed_point int_red_x, + png_fixed_point int_red_y, png_fixed_point int_green_x, + png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)) +PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, + png_fixed_point int_red_Z, png_fixed_point int_green_X, + png_fixed_point int_green_Y, png_fixed_point int_green_Z, + png_fixed_point int_blue_X, png_fixed_point int_blue_Y, + png_fixed_point int_blue_Z)) +#endif + +#ifdef PNG_gAMA_SUPPORTED +PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, + png_const_inforp info_ptr, double *file_gamma)) +PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *int_file_gamma)) +#endif + +#ifdef PNG_gAMA_SUPPORTED +PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, + png_inforp info_ptr, double file_gamma)) +PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, png_fixed_point int_file_gamma)) +#endif + +#ifdef PNG_hIST_SUPPORTED +PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_16p *hist)); +#endif + +#ifdef PNG_hIST_SUPPORTED +PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_uint_16p hist)); +#endif + +PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, + int *bit_depth, int *color_type, int *interlace_method, + int *compression_method, int *filter_method)); + +PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); + +#ifdef PNG_oFFs_SUPPORTED +PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); #endif -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); +#ifdef PNG_oFFs_SUPPORTED +PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, + png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); #endif -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, - int *type, int *nparams, png_charp *units, png_charpp *params)); +#ifdef PNG_pCAL_SUPPORTED +PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, + png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, + png_int_32 *X1, int *type, int *nparams, png_charp *units, + png_charpp *params)); #endif -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_charp units, png_charpp params)); +#ifdef PNG_pCAL_SUPPORTED +PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_const_charp units, png_charpp params)); #endif -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#ifdef PNG_pHYs_SUPPORTED +PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, + int *unit_type)); #endif -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#ifdef PNG_pHYs_SUPPORTED +PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); #endif -extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp *palette, int *num_palette)); +PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, + png_inforp info_ptr, png_colorp *palette, int *num_palette)); -extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp palette, int num_palette)); +PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, + png_inforp info_ptr, png_const_colorp palette, int num_palette)); -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p *sig_bit)); +#ifdef PNG_sBIT_SUPPORTED +PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_color_8p *sig_bit)); #endif -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p sig_bit)); +#ifdef PNG_sBIT_SUPPORTED +PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_color_8p sig_bit)); #endif -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *intent)); +#ifdef PNG_sRGB_SUPPORTED +PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, + png_const_inforp info_ptr, int *file_srgb_intent)); #endif -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); +#ifdef PNG_sRGB_SUPPORTED +PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, + png_inforp info_ptr, int srgb_intent)); +PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, + png_inforp info_ptr, int srgb_intent)); #endif -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen)); - /* Note to maintainer: profile should be png_bytepp */ +#ifdef PNG_iCCP_SUPPORTED +PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, + png_inforp info_ptr, png_charpp name, int *compression_type, + png_bytepp profile, png_uint_32 *proflen)); #endif -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen)); - /* Note to maintainer: profile should be png_bytep */ +#ifdef PNG_iCCP_SUPPORTED +PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_charp name, int compression_type, + png_const_bytep profile, png_uint_32 proflen)); #endif -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tpp entries)); +#ifdef PNG_sPLT_SUPPORTED +PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_sPLT_tpp entries)); #endif -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries)); +#ifdef PNG_sPLT_SUPPORTED +PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); #endif -#if defined(PNG_TEXT_SUPPORTED) +#ifdef PNG_TEXT_SUPPORTED /* png_get_text also returns the number of text chunks in *num_text */ -extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp *text_ptr, int *num_text)); +PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, + png_inforp info_ptr, png_textp *text_ptr, int *num_text)); #endif -/* - * Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. +/* Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. */ -#if defined(PNG_TEXT_SUPPORTED) -extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep *mod_time)); +#ifdef PNG_TEXT_SUPPORTED +PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_textp text_ptr, int num_text)); #endif -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep mod_time)); +#ifdef PNG_tIME_SUPPORTED +PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, + png_inforp info_ptr, png_timep *mod_time)); #endif -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep *trans, int *num_trans, - png_color_16p *trans_values)); +#ifdef PNG_tIME_SUPPORTED +PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_timep mod_time)); #endif -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep trans, int num_trans, - png_color_16p trans_values)); +#ifdef PNG_tRNS_SUPPORTED +PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, + png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, + png_color_16p *trans_color)); #endif -#if defined(PNG_tRNS_SUPPORTED) +#ifdef PNG_tRNS_SUPPORTED +PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, + png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, + png_const_color_16p trans_color)); #endif -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, double *width, double *height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); -#endif -#endif +#ifdef PNG_sCAL_SUPPORTED +PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, + png_const_inforp info_ptr, int *unit, double *width, double *height)) +#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ + defined(PNG_FLOATING_POINT_SUPPORTED) +/* NOTE: this API is currently implemented using floating point arithmetic, + * consequently it can only be used on systems with floating point support. + * In any case the range of values supported by png_fixed_point is small and it + * is highly recommended that png_get_sCAL_s be used instead. + */ +PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, + png_fixed_point *width, png_fixed_point *height)) +#endif +PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, + (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, + png_charpp swidth, png_charpp sheight)); + +PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, + png_inforp info_ptr, int unit, double width, double height)) +PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, int unit, png_fixed_point width, + png_fixed_point height)) +PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, + png_inforp info_ptr, int unit, + png_const_charp swidth, png_const_charp sheight)); #endif /* PNG_sCAL_SUPPORTED */ -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* provide a list of chunks and how they are to be handled, if the built-in - handling or default unknown chunk handling is not desired. Any chunks not - listed will be handled in the default manner. The IHDR and IEND chunks - must not be listed. - keep = 0: follow default behaviour - = 1: do not keep - = 2: keep only if safe-to-copy - = 3: keep even if unsafe-to-copy -*/ -extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp - png_ptr, int keep, png_bytep chunk_list, int num_chunks)); -extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); -extern PNG_EXPORT(void, png_set_unknown_chunk_location) - PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); -extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp - png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); -#endif -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep - chunk_name)); +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED +/* Provide the default handling for all unknown chunks or, optionally, for + * specific unknown chunks. + * + * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was + * ignored and the default was used, the per-chunk setting only had an effect on + * write. If you wish to have chunk-specific handling on read in code that must + * work on earlier versions you must use a user chunk callback to specify the + * desired handling (keep or discard.) + * + * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The + * parameter is interpreted as follows: + * + * READ: + * PNG_HANDLE_CHUNK_AS_DEFAULT: + * Known chunks: do normal libpng processing, do not keep the chunk (but + * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) + * Unknown chunks: for a specific chunk use the global default, when used + * as the default discard the chunk data. + * PNG_HANDLE_CHUNK_NEVER: + * Discard the chunk data. + * PNG_HANDLE_CHUNK_IF_SAFE: + * Keep the chunk data if the chunk is not critical else raise a chunk + * error. + * PNG_HANDLE_CHUNK_ALWAYS: + * Keep the chunk data. + * + * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, + * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent + * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks + * it simply resets the behavior to the libpng default. + * + * INTERACTION WTIH USER CHUNK CALLBACKS: + * The per-chunk handling is always used when there is a png_user_chunk_ptr + * callback and the callback returns 0; the chunk is then always stored *unless* + * it is critical and the per-chunk setting is other than ALWAYS. Notice that + * the global default is *not* used in this case. (In effect the per-chunk + * value is incremented to at least IF_SAFE.) + * + * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and + * per-chunk defaults will be honored. If you want to preserve the current + * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE + * as the default - if you don't do this libpng 1.6 will issue a warning. + * + * If you want unhandled unknown chunks to be discarded in libpng 1.6 and + * earlier simply return '1' (handled). + * + * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: + * If this is *not* set known chunks will always be handled by libpng and + * will never be stored in the unknown chunk list. Known chunks listed to + * png_set_keep_unknown_chunks will have no effect. If it is set then known + * chunks listed with a keep other than AS_DEFAULT will *never* be processed + * by libpng, in addition critical chunks must either be processed by the + * callback or saved. + * + * The IHDR and IEND chunks must not be listed. Because this turns off the + * default handling for chunks that would otherwise be recognized the + * behavior of libpng transformations may well become incorrect! + * + * WRITE: + * When writing chunks the options only apply to the chunks specified by + * png_set_unknown_chunks (below), libpng will *always* write known chunks + * required by png_set_ calls and will always write the core critical chunks + * (as required for PLTE). + * + * Each chunk in the png_set_unknown_chunks list is looked up in the + * png_set_keep_unknown_chunks list to find the keep setting, this is then + * interpreted as follows: + * + * PNG_HANDLE_CHUNK_AS_DEFAULT: + * Write safe-to-copy chunks and write other chunks if the global + * default is set to _ALWAYS, otherwise don't write this chunk. + * PNG_HANDLE_CHUNK_NEVER: + * Do not write the chunk. + * PNG_HANDLE_CHUNK_IF_SAFE: + * Write the chunk if it is safe-to-copy, otherwise do not write it. + * PNG_HANDLE_CHUNK_ALWAYS: + * Write the chunk. + * + * Note that the default behavior is effectively the opposite of the read case - + * in read unknown chunks are not stored by default, in write they are written + * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different + * - on write the safe-to-copy bit is checked, on read the critical bit is + * checked and on read if the chunk is critical an error will be raised. + * + * num_chunks: + * =========== + * If num_chunks is positive, then the "keep" parameter specifies the manner + * for handling only those chunks appearing in the chunk_list array, + * otherwise the chunk list array is ignored. + * + * If num_chunks is 0 the "keep" parameter specifies the default behavior for + * unknown chunks, as described above. + * + * If num_chunks is negative, then the "keep" parameter specifies the manner + * for handling all unknown chunks plus all chunks recognized by libpng + * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to + * be processed by libpng. + */ +PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, + int keep, png_const_bytep chunk_list, int num_chunks)); + +/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; + * the result is therefore true (non-zero) if special handling is required, + * false for the default handling. + */ +PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, + png_const_bytep chunk_name)); +#endif + +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_unknown_chunkp unknowns, + int num_unknowns)); + /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added + * unknowns to the location currently stored in the png_struct. This is + * invariably the wrong value on write. To fix this call the following API + * for each chunk in the list with the correct location. If you know your + * code won't be compiled on earlier versions you can rely on + * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing + * the correct thing. + */ + +PNG_EXPORT(175, void, png_set_unknown_chunk_location, + (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); + +PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, + png_inforp info_ptr, png_unknown_chunkpp entries)); #endif /* Png_free_data() will turn off the "valid" flag for anything it frees. - If you need to turn it off for a chunk that your application has freed, - you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ -extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, - png_infop info_ptr, int mask)); + * If you need to turn it off for a chunk that your application has freed, + * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); + */ +PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, + png_inforp info_ptr, int mask)); -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_INFO_IMAGE_SUPPORTED /* The "params" pointer is currently not used and is for future expansion. */ -extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -#endif - -/* Define PNG_DEBUG at compile time for debugging information. Higher - * numbers for PNG_DEBUG mean more debugging information. This has - * only been added since version 0.95 so it is not implemented throughout - * libpng yet, but more support will be added as needed. - */ -#ifdef PNG_DEBUG -#if (PNG_DEBUG > 0) -#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -#include <crtdbg.h> -#if (PNG_DEBUG > 1) -#define png_debug(l,m) _RPT0(_CRT_WARN,m) -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) -#endif -#else /* PNG_DEBUG_FILE || !_MSC_VER */ -#ifndef PNG_DEBUG_FILE -#define PNG_DEBUG_FILE stderr -#endif /* PNG_DEBUG_FILE */ -#if (PNG_DEBUG > 1) -#define png_debug(l,m) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ -} -#define png_debug1(l,m,p1) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ -} -#define png_debug2(l,m,p1,p2) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ -} -#endif /* (PNG_DEBUG > 1) */ -#endif /* _MSC_VER */ -#endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -#define png_debug(l, m) -#endif -#ifndef png_debug1 -#define png_debug1(l, m, p1) -#endif -#ifndef png_debug2 -#define png_debug2(l, m, p1, p2) +PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, + int transforms, png_voidp params)); +PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, + int transforms, png_voidp params)); #endif -extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); +PNG_EXPORT(180, png_const_charp, png_get_copyright, + (png_const_structrp png_ptr)); +PNG_EXPORT(181, png_const_charp, png_get_header_ver, + (png_const_structrp png_ptr)); +PNG_EXPORT(182, png_const_charp, png_get_header_version, + (png_const_structrp png_ptr)); +PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, + (png_const_structrp png_ptr)); #ifdef PNG_MNG_FEATURES_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp - png_ptr, png_uint_32 mng_features_permitted)); +PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, + png_uint_32 mng_features_permitted)); #endif /* For use in png_set_keep_unknown, added to version 1.2.6 */ @@ -2528,94 +2523,151 @@ extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp #define PNG_HANDLE_CHUNK_NEVER 1 #define PNG_HANDLE_CHUNK_IF_SAFE 2 #define PNG_HANDLE_CHUNK_ALWAYS 3 - -/* Added to version 1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 -#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 -#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 -#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 -#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 -#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 -#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ - -#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) -#define PNG_MMX_WRITE_FLAGS ( 0 ) - -#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ - | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ - | PNG_MMX_READ_FLAGS \ - | PNG_MMX_WRITE_FLAGS ) - -#define PNG_SELECT_READ 1 -#define PNG_SELECT_WRITE 2 -#endif /* PNG_MMX_CODE_SUPPORTED */ - -#if !defined(PNG_1_0_X) -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) - PNGARG((int flag_select, int *compilerID)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) - PNGARG((int flag_select)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flags) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) - PNGARG((png_structp png_ptr)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_asm_flags) - PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_mmx_thresholds) - PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold)); - -#endif /* PNG_1_0_X */ - -#if !defined(PNG_1_0_X) -/* png.c, pnggccrd.c, or pngvcrd.c */ -extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ +#define PNG_HANDLE_CHUNK_LAST 4 /* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. */ + * messages before passing them to the error or warning handler. + */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED -extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp - png_ptr, png_uint_32 strip_mode)); +PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, + png_uint_32 strip_mode)); #endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ +/* Added in libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED -extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp - png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); -extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp - png_ptr)); -extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp - png_ptr)); -#endif +PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, + png_uint_32 user_width_max, png_uint_32 user_height_max)); +PNG_EXPORT(187, png_uint_32, png_get_user_width_max, + (png_const_structrp png_ptr)); +PNG_EXPORT(188, png_uint_32, png_get_user_height_max, + (png_const_structrp png_ptr)); +/* Added in libpng-1.4.0 */ +PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, + png_uint_32 user_chunk_cache_max)); +PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, + (png_const_structrp png_ptr)); +/* Added in libpng-1.4.1 */ +PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, + png_alloc_size_t user_chunk_cache_max)); +PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, + (png_const_structrp png_ptr)); +#endif + +#if defined(PNG_INCH_CONVERSIONS_SUPPORTED) +PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); + +PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); + +PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, + (png_const_structrp png_ptr, png_const_inforp info_ptr)); + +PNG_FP_EXPORT(196, float, png_get_x_offset_inches, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) +#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ +PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) +#endif + +PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, + png_const_inforp info_ptr)) +#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ +PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr)) +#endif + +# ifdef PNG_pHYs_SUPPORTED +PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, + int *unit_type)); +# endif /* PNG_pHYs_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ + +/* Added in libpng-1.4.0 */ +#ifdef PNG_IO_STATE_SUPPORTED +PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); + +/* Removed from libpng 1.6; use png_get_io_chunk_type. */ +PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), + PNG_DEPRECATED) + +PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, + (png_const_structrp png_ptr)); + +/* The flags returned by png_get_io_state() are the following: */ +# define PNG_IO_NONE 0x0000 /* no I/O at this moment */ +# define PNG_IO_READING 0x0001 /* currently reading */ +# define PNG_IO_WRITING 0x0002 /* currently writing */ +# define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ +# define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ +# define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ +# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ +# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ +# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ +#endif /* ?PNG_IO_STATE_SUPPORTED */ + +/* Interlace support. The following macros are always defined so that if + * libpng interlace handling is turned off the macros may be used to handle + * interlaced images within the application. + */ +#define PNG_INTERLACE_ADAM7_PASSES 7 + +/* Two macros to return the first row and first column of the original, + * full, image which appears in a given pass. 'pass' is in the range 0 + * to 6 and the result is in the range 0 to 7. + */ +#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) +#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) + +/* A macro to return the offset between pixels in the output row for a pair of + * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that + * follows. Note that ROW_OFFSET is the offset from one row to the next whereas + * COL_OFFSET is from one column to the next, within a row. + */ +#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) +#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) + +/* Two macros to help evaluate the number of rows or columns in each + * pass. This is expressed as a shift - effectively log2 of the number or + * rows or columns in each 8x8 tile of the original image. + */ +#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) +#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) + +/* Hence two macros to determine the number of rows or columns in a given + * pass of an image given its height or width. In fact these macros may + * return non-zero even though the sub-image is empty, because the other + * dimension may be empty for a small image. + */ +#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\ + -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass)) +#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\ + -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass)) + +/* For the reader row callbacks (both progressive and sequential) it is + * necessary to find the row in the output image given a row in an interlaced + * image, so two more macros: + */ +#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ + (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass)) +#define PNG_COL_FROM_PASS_COL(x_in, pass) \ + (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass)) + +/* Two macros which return a boolean (0 or 1) saying whether the given row + * or column is in a particular pass. These use a common utility macro that + * returns a mask for a given pass - the offset 'off' selects the row or + * column version. The mask has the appropriate bit set for each column in + * the tile. + */ +#define PNG_PASS_MASK(pass,off) ( \ + ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \ + ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ +#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ + ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) +#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ + ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on @@ -2630,910 +2682,620 @@ extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] */ - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 - \ - (png_uint_16)(alpha)) + (png_uint_16)128); \ +# define png_composite(composite, fg, alpha, bg) \ + { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ + * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 \ + - (png_uint_16)(alpha)) + 128); \ (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(png_uint_32)(65535L - \ - (png_uint_32)(alpha)) + (png_uint_32)32768L); \ +# define png_composite_16(composite, fg, alpha, bg) \ + { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ + * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(65535 \ + - (png_uint_32)(alpha)) + 32768); \ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } -#else /* standard method using integer division */ +#else /* Standard method using integer division */ -# define png_composite(composite, fg, alpha, bg) \ - (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - (png_uint_16)127) / 255) +# define png_composite(composite, fg, alpha, bg) \ + (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + 127) / 255) # define png_composite_16(composite, fg, alpha, bg) \ (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ - (png_uint_32)32767) / (png_uint_32)65535L) - + (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ + 32767) / 65535) #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ -/* Inline macros to do direct reads of bytes from the input buffer. These - * require that you are using an architecture that uses PNG byte ordering - * (MSB first) and supports unaligned data storage. I think that PowerPC - * in big-endian mode and 680x0 are the only ones that will support this. - * The x86 line of processors definitely do not. The png_get_int_32() - * routine also assumes we are using two's complement format for negative - * values, which is almost certainly true. - */ -#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) -# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) -# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) -# define png_get_int_32(buf) ( *((png_int_32p) (buf))) -#else -extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); -#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ -extern PNG_EXPORT(png_uint_32,png_get_uint_31) - PNGARG((png_structp png_ptr, png_bytep buf)); +#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); +PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); +PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); +#endif + +PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, + png_const_bytep buf)); /* No png_get_int_16 -- may be added if there's a real need for it. */ -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). - */ -extern PNG_EXPORT(void,png_save_uint_32) - PNGARG((png_bytep buf, png_uint_32 i)); -extern PNG_EXPORT(void,png_save_int_32) - PNGARG((png_bytep buf, png_int_32 i)); +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); +#endif +#ifdef PNG_SAVE_INT_32_SUPPORTED +PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); +#endif /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ -extern PNG_EXPORT(void,png_save_uint_16) - PNGARG((png_bytep buf, unsigned int i)); +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); /* No png_save_int_16 -- may be added if there's a real need for it. */ - -/* ************************************************************************* */ - -/* These next functions are used internally in the code. They generally - * shouldn't be used unless you are writing code to add or replace some - * functionality in libpng. More information about most functions can - * be found in the files where the functions are located. - */ - - -/* Various modes of operation, that are visible to applications because - * they are used for unknown chunk location. - */ -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_HAVE_IDAT 0x04 -#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ -#define PNG_HAVE_IEND 0x10 - -#if defined(PNG_INTERNAL) - -/* More modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. - */ -#define PNG_HAVE_gAMA 0x20 -#define PNG_HAVE_cHRM 0x40 -#define PNG_HAVE_sRGB 0x80 -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ - -/* flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_DITHER 0x0040 -#define PNG_BACKGROUND 0x0080 -#define PNG_BACKGROUND_EXPAND 0x0100 - /* 0x0200 unused */ -#define PNG_16_TO_8 0x0400 -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000L -#define PNG_PACKSWAP 0x10000L -#define PNG_SWAP_ALPHA 0x20000L -#define PNG_STRIP_ALPHA 0x40000L -#define PNG_INVERT_ALPHA 0x80000L -#define PNG_USER_TRANSFORM 0x100000L -#define PNG_RGB_TO_GRAY_ERR 0x200000L -#define PNG_RGB_TO_GRAY_WARN 0x400000L -#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ - /* 0x800000L Unused */ -#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -/* flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 - -/* Scaling factor for filter heuristic weighting calculations */ -#define PNG_WEIGHT_SHIFT 8 -#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) -#define PNG_COST_SHIFT 3 -#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) - -/* flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 -#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 -#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 -#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 -#define PNG_FLAG_ZLIB_FINISHED 0x0020 -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_FREE_PLTE 0x1000 -#define PNG_FLAG_FREE_TRNS 0x2000 -#define PNG_FLAG_FREE_HIST 0x4000 -#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L -#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L -#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L -#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ -#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ - /* 0x800000L unused */ - /* 0x1000000L unused */ - /* 0x2000000L unused */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* save typing and make code easier to understand */ - -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* Added to libpng-1.2.6 JB */ -#define PNG_ROWBYTES(pixel_bits, width) \ - ((pixel_bits) >= 8 ? \ - ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ - (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) - -/* PNG_OUT_OF_RANGE returns true if value is outside the range - ideal-delta..ideal+delta. Each argument is evaluated twice. - "ideal" and "delta" should be constants, normally simple - integers, "value" a variable. Added to libpng-1.2.6 JB */ -#define PNG_OUT_OF_RANGE(value, ideal, delta) \ - ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* place to hold the signature string for a PNG file. */ -#ifdef PNG_USE_GLOBAL_ARRAYS - PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8]; -#else -#endif -#endif /* PNG_NO_EXTERN */ - -/* Constant strings for known chunk types. If you need to add a chunk, - * define the name here, and add an invocation of the macro in png.c and - * wherever it's needed. - */ -#define PNG_IHDR png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} -#define PNG_IDAT png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} -#define PNG_IEND png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} -#define PNG_PLTE png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} -#define PNG_bKGD png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} -#define PNG_cHRM png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} -#define PNG_gAMA png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} -#define PNG_hIST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} -#define PNG_iCCP png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} -#define PNG_iTXt png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} -#define PNG_oFFs png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} -#define PNG_pCAL png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} -#define PNG_sCAL png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} -#define PNG_pHYs png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} -#define PNG_sBIT png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} -#define PNG_sPLT png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} -#define PNG_sRGB png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} -#define PNG_tEXt png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} -#define PNG_tIME png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} -#define PNG_tRNS png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} -#define PNG_zTXt png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} - -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5]; -#endif /* PNG_USE_GLOBAL_ARRAYS */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for reading, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_read_struct instead). - */ -extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); -#undef png_read_init -#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for writing, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_write_struct instead). - */ -extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); -#undef png_write_init -#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Allocate memory for an internal libpng struct */ -PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); - -/* Free memory from internal libpng struct */ -PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); - -PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr - malloc_fn, png_voidp mem_ptr)); -PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, - png_free_ptr free_fn, png_voidp mem_ptr)); - -/* Free any memory that info_ptr points to and reset struct. */ -PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_1_0_X -/* Function to allocate memory for zlib. */ -PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); - -/* Function to free memory for zlib */ -PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); - -#ifdef PNG_SIZE_T -/* Function to convert a sizeof an item to png_sizeof item */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -#endif - -/* Next four functions are used internally as callbacks. PNGAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ - -PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif - -PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) -PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); -#endif -#endif -#else /* PNG_1_0_X */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif -#endif /* PNG_1_0_X */ - -/* Reset the CRC variable */ -PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); - -/* Write the "data" buffer to whatever output you are using. */ -PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, - png_size_t length)); - -/* Decompress data in a chunk that uses compression */ -#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ - defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_length, png_size_t *data_length)); #endif -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. +#ifdef PNG_USE_READ_MACROS +/* Inline macros to do direct reads of bytes from the input buffer. + * The png_get_int_32() routine assumes we are using two's complement + * format for negative values, which is almost certainly true. */ -PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, - png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); +# define PNG_get_uint_32(buf) \ + (((png_uint_32)(*(buf)) << 24) + \ + ((png_uint_32)(*((buf) + 1)) << 16) + \ + ((png_uint_32)(*((buf) + 2)) << 8) + \ + ((png_uint_32)(*((buf) + 3)))) + + /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the + * function) incorrectly returned a value of type png_uint_32. + */ +# define PNG_get_uint_16(buf) \ + ((png_uint_16) \ + (((unsigned int)(*(buf)) << 8) + \ + ((unsigned int)(*((buf) + 1))))) + +# define PNG_get_int_32(buf) \ + ((png_int_32)((*(buf) & 0x80) \ + ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \ + : (png_int_32)png_get_uint_32(buf))) + + /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, + * but defining a macro name prefixed with PNG_PREFIX. + */ +# ifndef PNG_PREFIX +# define png_get_uint_32(buf) PNG_get_uint_32(buf) +# define png_get_uint_16(buf) PNG_get_uint_16(buf) +# define png_get_int_32(buf) PNG_get_int_32(buf) +# endif +#else +# ifdef PNG_PREFIX + /* No macros; revert to the (redefined) function */ +# define PNG_get_uint_32 (png_get_uint_32) +# define PNG_get_uint_16 (png_get_uint_16) +# define PNG_get_int_32 (png_get_int_32) +# endif #endif -/* simple function to write the signature */ -PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); - -/* write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. +/******************************************************************************* + * SIMPLIFIED API + ******************************************************************************* + * + * Please read the documentation in libpng-manual.txt (TODO: write said + * documentation) if you don't understand what follows. + * + * The simplified API hides the details of both libpng and the PNG file format + * itself. It allows PNG files to be read into a very limited number of + * in-memory bitmap formats or to be written from the same formats. If these + * formats do not accomodate your needs then you can, and should, use the more + * sophisticated APIs above - these support a wide variety of in-memory formats + * and a wide variety of sophisticated transformations to those formats as well + * as a wide variety of APIs to manipulate ancillary information. + * + * To read a PNG file using the simplified API: + * + * 1) Declare a 'png_image' structure (see below) on the stack and set the + * version field to PNG_IMAGE_VERSION. + * 2) Call the appropriate png_image_begin_read... function. + * 3) Set the png_image 'format' member to the required sample format. + * 4) Allocate a buffer for the image and, if required, the color-map. + * 5) Call png_image_finish_read to read the image and, if required, the + * color-map into your buffers. + * + * There are no restrictions on the format of the PNG input itself; all valid + * color types, bit depths, and interlace methods are acceptable, and the + * input image is transformed as necessary to the requested in-memory format + * during the png_image_finish_read() step. The only caveat is that if you + * request a color-mapped image from a PNG that is full-color or makes + * complex use of an alpha channel the transformation is extremely lossy and the + * result may look terrible. + * + * To write a PNG file using the simplified API: + * + * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. + * 2) Initialize the members of the structure that describe the image, setting + * the 'format' member to the format of the image samples. + * 3) Call the appropriate png_image_write... function with a pointer to the + * image and, if necessary, the color-map to write the PNG data. + * + * png_image is a structure that describes the in-memory format of an image + * when it is being read or defines the in-memory format of an image that you + * need to write: */ -PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, - png_uint_32 height, - int bit_depth, int color_type, int compression_method, int filter_method, - int interlace_method)); - -PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, - png_uint_32 num_pal)); - -PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); +#define PNG_IMAGE_VERSION 1 -#if defined(PNG_WRITE_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point - file_gamma)); -#endif -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, - int color_type)); -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, - double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, - png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, - int intent)); -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, - png_charp name, int compression_type, - png_charp profile, int proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_sPLT_tp palette)); -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, - png_color_16p values, int number, int color_type)); -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, - png_color_16p values, int color_type)); -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, - int num_hist)); -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, - png_charp key, png_charpp new_key)); -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len)); -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len, int compression)); -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, - int compression, png_charp key, png_charp lang, png_charp lang_key, - png_charp text)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ -PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif +typedef struct png_control *png_controlp; +typedef struct +{ + png_controlp opaque; /* Initialize to NULL, free with png_image_free */ + png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ + png_uint_32 width; /* Image width in pixels (columns) */ + png_uint_32 height; /* Image height in pixels (rows) */ + png_uint_32 format; /* Image format as defined below */ + png_uint_32 flags; /* A bit mask containing informational flags */ + png_uint_32 colormap_entries; + /* Number of entries in the color-map */ + + /* In the event of an error or warning the following field will be set to a + * non-zero value and the 'message' field will contain a '\0' terminated + * string with the libpng error or warning message. If both warnings and + * an error were encountered, only the error is recorded. If there + * are multiple warnings, only the first one is recorded. + * + * The upper 30 bits of this value are reserved, the low two bits contain + * a value as follows: + */ +# define PNG_IMAGE_WARNING 1 +# define PNG_IMAGE_ERROR 2 + /* + * The result is a two bit code such that a value more than 1 indicates + * a failure in the API just called: + * + * 0 - no warning or error + * 1 - warning + * 2 - error + * 3 - error preceded by warning + */ +# define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) -#if defined(PNG_WRITE_oFFs_SUPPORTED) -PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, - png_int_32 x_offset, png_int_32 y_offset, int unit_type)); -#endif + png_uint_32 warning_or_error; -#if defined(PNG_WRITE_pCAL_SUPPORTED) -PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, - png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params)); -#endif + char message[64]; +} png_image, *png_imagep; -#if defined(PNG_WRITE_pHYs_SUPPORTED) -PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type)); -#endif +/* The samples of the image have one to four channels whose components have + * original values in the range 0 to 1.0: + * + * 1: A single gray or luminance channel (G). + * 2: A gray/luminance channel and an alpha channel (GA). + * 3: Three red, green, blue color channels (RGB). + * 4: Three color channels and an alpha channel (RGBA). + * + * The components are encoded in one of two ways: + * + * a) As a small integer, value 0..255, contained in a single byte. For the + * alpha channel the original value is simply value/255. For the color or + * luminance channels the value is encoded according to the sRGB specification + * and matches the 8-bit format expected by typical display devices. + * + * The color/gray channels are not scaled (pre-multiplied) by the alpha + * channel and are suitable for passing to color management software. + * + * b) As a value in the range 0..65535, contained in a 2-byte integer. All + * channels can be converted to the original value by dividing by 65535; all + * channels are linear. Color channels use the RGB encoding (RGB end-points) of + * the sRGB specification. This encoding is identified by the + * PNG_FORMAT_FLAG_LINEAR flag below. + * + * When the simplified API needs to convert between sRGB and linear colorspaces, + * the actual sRGB transfer curve defined in the sRGB specification (see the + * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 + * approximation used elsewhere in libpng. + * + * When an alpha channel is present it is expected to denote pixel coverage + * of the color or luminance channels and is returned as an associated alpha + * channel: the color/gray channels are scaled (pre-multiplied) by the alpha + * value. + * + * The samples are either contained directly in the image data, between 1 and 8 + * bytes per pixel according to the encoding, or are held in a color-map indexed + * by bytes in the image data. In the case of a color-map the color-map entries + * are individual samples, encoded as above, and the image data has one byte per + * pixel to select the relevant sample from the color-map. + */ -#if defined(PNG_WRITE_tIME_SUPPORTED) -PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, - png_timep mod_time)); -#endif +/* PNG_FORMAT_* + * + * #defines to be used in png_image::format. Each #define identifies a + * particular layout of sample data and, if present, alpha values. There are + * separate defines for each of the two component encodings. + * + * A format is built up using single bit flag values. All combinations are + * valid. Formats can be built up from the flag values or you can use one of + * the predefined values below. When testing formats always use the FORMAT_FLAG + * macros to test for individual features - future versions of the library may + * add new flags. + * + * When reading or writing color-mapped images the format should be set to the + * format of the entries in the color-map then png_image_{read,write}_colormap + * called to read or write the color-map and set the format correctly for the + * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! + * + * NOTE: libpng can be built with particular features disabled, if you see + * compiler errors because the definition of one of the following flags has been + * compiled out it is because libpng does not have the required support. It is + * possible, however, for the libpng configuration to enable the format on just + * read or just write; in that case you may see an error at run time. You can + * guard against this by checking for the definition of the appropriate + * "_SUPPORTED" macro, one of: + * + * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED + */ +#define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ +#define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ +#define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2 byte channels else 1 byte */ +#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ -#if defined(PNG_WRITE_sCAL_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, - int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, - int unit, png_charp width, png_charp height)); -#endif -#endif +#ifdef PNG_FORMAT_BGR_SUPPORTED +# define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ #endif -/* Called when finished processing a row of data */ -PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); - -/* Internal use only. Called before first row of data */ -PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ #endif -/* combine a row of data, dealing with alpha, etc. if requested */ -PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, - int mask)); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -/* expand an interlaced row */ -/* OLD pre-1.0.9 interface: -PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations)); +/* Commonly used formats have predefined macros. + * + * First the single byte (sRGB) formats: */ -PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* grab pixels out of a row for an interlaced pass */ -PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass)); -#endif - -/* unfilter a row */ -PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, - png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); - -/* Choose the best filter to use and filter the row data */ -PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, - png_row_infop row_info)); - -/* Write out the filtered row. */ -PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, - png_bytep filtered_row)); -/* finish a row while reading, dealing with interlacing passes, etc. */ -PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); - -/* initialize the row buffers, etc. */ -PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ -PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); +#define PNG_FORMAT_GRAY 0 +#define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA +#define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) +#define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR +#define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) +#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) +#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) +#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) +#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) + +/* Then the linear 2-byte formats. When naming these "Y" is used to + * indicate a luminance (gray) channel. + */ +#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR +#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) +#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) +#define PNG_FORMAT_LINEAR_RGB_ALPHA \ + (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) + +/* With color-mapped formats the image data is one byte for each pixel, the byte + * is an index into the color-map which is formatted as above. To obtain a + * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP + * to one of the above definitions, or you can use one of the definitions below. + */ +#define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) +#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) + +/* PNG_IMAGE macros + * + * These are convenience macros to derive information from a png_image + * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the + * actual image sample values - either the entries in the color-map or the + * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values + * for the pixels and will always return 1 for color-mapped formats. The + * remaining macros return information about the rows in the image and the + * complete image. + * + * NOTE: All the macros that take a png_image::format parameter are compile time + * constants if the format parameter is, itself, a constant. Therefore these + * macros can be used in array declarations and case labels where required. + * Similarly the macros are also pre-processor constants (sizeof is not used) so + * they can be used in #if tests. + * + * First the information about the samples. + */ +#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ + (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) + /* Return the total number of channels in a given format: 1..4 */ + +#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ + ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) + /* Return the size in bytes of a single component of a pixel or color-map + * entry (as appropriate) in the image: 1 or 2. + */ -/* these are the functions that do the transformations */ -#if defined(PNG_READ_FILLER_SUPPORTED) -PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 filler, png_uint_32 flags)); -#endif +#define PNG_IMAGE_SAMPLE_SIZE(fmt)\ + (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) + /* This is the size of the sample data for one sample. If the image is + * color-mapped it is the size of one color-map entry (and image pixels are + * one byte in size), otherwise it is the size of one image pixel. + */ -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif +#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ + (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) + /* The maximum size of the color-map required by the format expressed in a + * count of components. This can be used to compile-time allocate a + * color-map: + * + * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; + * + * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; + * + * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the + * information from one of the png_image_begin_read_ APIs and dynamically + * allocate the required memory. + */ -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif +/* Corresponding information about the pixels */ +#define PNG_IMAGE_PIXEL_(test,fmt)\ + (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif +#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ + PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) + /* The number of separate channels (components) in a pixel; 1 for a + * color-mapped image. + */ -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif +#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ + PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) + /* The size, in bytes, of each component in a pixel; 1 for a color-mapped + * image. + */ -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 flags)); -#endif +#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) + /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); -#endif +/* Information about the whole row, or whole image */ +#define PNG_IMAGE_ROW_STRIDE(image)\ + (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) + /* Return the total number of components in a single row of the image; this + * is the minimum 'row stride', the minimum count of components between each + * row. For a color-mapped image this is the minimum number of bytes in a + * row. + */ -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); -#endif +#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ + (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) + /* Return the size, in bytes, of an image buffer given a png_image and a row + * stride - the number of components to leave space for in each row. + */ -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop - row_info, png_bytep row)); -#endif +#define PNG_IMAGE_SIZE(image)\ + PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) + /* Return the size, in bytes, of the image in memory given just a png_image; + * the row stride is the minimum stride required for the image. + */ -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, - png_bytep row)); -#endif +#define PNG_IMAGE_COLORMAP_SIZE(image)\ + (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) + /* Return the size, in bytes, of the color-map of this image. If the image + * format is not a color-map format this will return a size sufficient for + * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if + * you don't want to allocate a color-map in this case. + */ -#if defined(PNG_READ_PACK_SUPPORTED) -PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); -#endif +/* PNG_IMAGE_FLAG_* + * + * Flags containing additional information about the image are held in the + * 'flags' field of png_image. + */ +#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 + /* This indicates the the RGB values of the in-memory bitmap do not + * correspond to the red, green and blue end-points defined by sRGB. + */ -#if defined(PNG_READ_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p sig_bits)); -#endif +#define PNG_IMAGE_FLAG_FAST 0x02 + /* On write emphasise speed over compression; the resultant PNG file will be + * larger but will be produced significantly faster, particular for large + * images. Do not use this option for images which will be distributed, only + * used it when producing intermediate files that will be read back in + * repeatedly. For a typical 24-bit image the option will double the read + * speed at the cost of increasing the image size by 25%, however for many + * more compressible images the PNG file can be 10 times larger with only a + * slight speed gain. + */ -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); -#endif +#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 + /* On read if the image is a 16-bit per component image and there is no gAMA + * or sRGB chunk assume that the components are sRGB encoded. Notice that + * images output by the simplified API always have gamma information; setting + * this flag only affects the interpretation of 16-bit images from an + * external source. It is recommended that the application expose this flag + * to the user; the user can normally easily recognize the difference between + * linear and sRGB encoding. This flag has no effect on write - the data + * passed to the write APIs must have the correct encoding (as defined + * above.) + * + * If the flag is not set (the default) input 16-bit per component data is + * assumed to be linear. + * + * NOTE: the flag can only be set after the png_image_begin_read_ call, + * because that call initializes the 'flags' field. + */ -#if defined(PNG_READ_16_TO_8_SUPPORTED) -PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); -#endif +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED +/* READ APIs + * --------- + * + * The png_image passed to the read APIs must have been initialized by setting + * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) + */ +#ifdef PNG_STDIO_SUPPORTED +PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, + const char *file_name)); + /* The named file is opened for read and the image header is filled in + * from the PNG header in the file. + */ -#if defined(PNG_READ_DITHER_SUPPORTED) -PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, - png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); +PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, + FILE* file)); + /* The PNG header is read from the stdio FILE object. */ +#endif /* PNG_STDIO_SUPPORTED */ + +PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, + png_const_voidp memory, png_size_t size)); + /* The PNG header is read from the given memory buffer. */ + +PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, + png_const_colorp background, void *buffer, png_int_32 row_stride, + void *colormap)); + /* Finish reading the image into the supplied buffer and clean up the + * png_image structure. + * + * row_stride is the step, in byte or 2-byte units as appropriate, + * between adjacent rows. A positive stride indicates that the top-most row + * is first in the buffer - the normal top-down arrangement. A negative + * stride indicates that the bottom-most row is first in the buffer. + * + * background need only be supplied if an alpha channel must be removed from + * a png_byte format and the removal is to be done by compositing on a solid + * color; otherwise it may be NULL and any composition will be done directly + * onto the buffer. The value is an sRGB color to use for the background, + * for grayscale output the green channel is used. + * + * background must be supplied when an alpha channel must be removed from a + * single byte color-mapped output format, in other words if: + * + * 1) The original format from png_image_begin_read_from_* had + * PNG_FORMAT_FLAG_ALPHA set. + * 2) The format set by the application does not. + * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and + * PNG_FORMAT_FLAG_LINEAR *not* set. + * + * For linear output removing the alpha channel is always done by compositing + * on black and background is ignored. + * + * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must + * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. + * image->colormap_entries will be updated to the actual number of entries + * written to the colormap; this may be less than the original value. + */ -# if defined(PNG_CORRECT_PALETTE_SUPPORTED) -PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette)); +PNG_EXPORT(238, void, png_image_free, (png_imagep image)); + /* Free any data allocated by libpng in image->opaque, setting the pointer to + * NULL. May be called at any time after the structure is initialized. + */ +#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ + +#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED +/* WRITE APIS + * ---------- + * For write you must initialize a png_image structure to describe the image to + * be written. To do this use memset to set the whole structure to 0 then + * initialize fields describing your image. + * + * version: must be set to PNG_IMAGE_VERSION + * opaque: must be initialized to NULL + * width: image width in pixels + * height: image height in rows + * format: the format of the data (image and color-map) you wish to write + * flags: set to 0 unless one of the defined flags applies; set + * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB + * values do not correspond to the colors in sRGB. + * colormap_entries: set to the number of entries in the color-map (0 to 256) + */ +PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, + const char *file, int convert_to_8bit, const void *buffer, + png_int_32 row_stride, const void *colormap)); + /* Write the image to the named file. */ + +PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, + int convert_to_8_bit, const void *buffer, png_int_32 row_stride, + const void *colormap)); + /* Write the image to the given (FILE*). */ + +/* With both write APIs if image is in one of the linear formats with 16-bit + * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG + * gamma encoded according to the sRGB specification, otherwise a 16-bit linear + * encoded PNG file is written. + * + * With color-mapped data formats the colormap parameter point to a color-map + * with at least image->colormap_entries encoded in the specified format. If + * the format is linear the written PNG color-map will be converted to sRGB + * regardless of the convert_to_8_bit flag. + * + * With all APIs row_stride is handled as in the read APIs - it is the spacing + * from one row to the next in component sized units (1 or 2 bytes) and if + * negative indicates a bottom-up row layout in the buffer. + * + * Note that the write API does not support interlacing or sub-8-bit pixels. + */ +#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */ +/******************************************************************************* + * END OF SIMPLIFIED API + ******************************************************************************/ + +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED +PNG_EXPORT(242, void, png_set_check_for_invalid_index, + (png_structrp png_ptr, int allowed)); +# ifdef PNG_GET_PALETTE_MAX_SUPPORTED +PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, + png_const_infop info_ptr)); # endif -#endif +#endif /* CHECK_FOR_INVALID_INDEX */ -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) -PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 bit_depth)); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p bit_depth)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift)); -#else -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background)); -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift)); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, - png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); -PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, - png_bytep row, png_color_16p trans_value)); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. +/******************************************************************************* + * IMPLEMENTATION OPTIONS + ******************************************************************************* + * + * Support for arbitrary implementation-specific optimizations. The API allows + * particular options to be turned on or off. 'Option' is the number of the + * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given + * by the PNG_OPTION_ defines below. + * + * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions, + * are detected at run time, however sometimes it may be impossible + * to do this in user mode, in which case it is necessary to discover + * the capabilities in an OS specific way. Such capabilities are + * listed here when libpng has support for them and must be turned + * ON by the application if present. + * + * SOFTWARE: sometimes software optimizations actually result in performance + * decrease on some architectures or systems, or with some sets of + * PNG images. 'Software' options allow such optimizations to be + * selected at run time. */ - -/* decode the IHDR chunk */ -PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); - -#if defined(PNG_READ_bKGD_SUPPORTED) -PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_gAMA_SUPPORTED) -PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_iCCP_SUPPORTED) -extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sPLT_SUPPORTED) -extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_sRGB_SUPPORTED) -PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); +#ifdef PNG_SET_OPTION_SUPPORTED +#ifdef PNG_ARM_NEON_API_SUPPORTED +# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ #endif +#define PNG_OPTION_NEXT 2 /* Next option - numbers must be even */ -#if defined(PNG_READ_tRNS_SUPPORTED) -PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); - -PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, - png_bytep chunk_name)); - -/* handle the transformations for reading and writing */ -PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); +/* Return values: NOTE: there are four values and 'off' is *not* zero */ +#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ +#define PNG_OPTION_INVALID 1 /* Option number out of range */ +#define PNG_OPTION_OFF 2 +#define PNG_OPTION_ON 3 -PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, - png_uint_32 length)); -PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); -PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); +PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, + int onoff)); #endif -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ +/******************************************************************************* + * END OF HARDWARE OPTIONS + ******************************************************************************/ -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -#endif +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project + * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt + */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -/* png.c */ /* PRIVATE */ -PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); -#endif +/* The last ordinal number (this is the *last* one already used; the next + * one to use is one more than this.) Maintainer, remember to add an entry to + * scripts/symbols.def as well. + */ +#ifdef PNG_EXPORT_LAST_ORDINAL + PNG_EXPORT_LAST_ORDINAL(244); #endif -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_pHYs_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ - -#endif /* PNG_INTERNAL */ - #ifdef __cplusplus -//} +} #endif #endif /* PNG_VERSION_INFO_ONLY */ -/* do not put anything past this line */ +/* Do not put anything past this line */ #endif /* PNG_H */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngconf.h b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngconf.h index 34115f082..b3ceeae42 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngconf.h +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngconf.h @@ -1,11 +1,16 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.2.21 - October 4, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * libpng version 1.6.1 - March 28, 2013 + * + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * */ /* Any machine specific code is near the front of this file, so if you @@ -17,1489 +22,595 @@ #ifndef PNGCONF_H #define PNGCONF_H -#define PNG_1_2_X - -//============================================================================== -// These are some Juce config settings that should remove any unnecessary code bloat.. - -#define PNG_NO_STDIO 1 -#define PNG_DEBUG 0 -#define PNG_NO_WARNINGS 1 -#define PNG_NO_ERROR_TEXT 1 -#define PNG_NO_ERROR_NUMBERS 1 -#define PNG_NO_USER_MEM 1 -#define PNG_NO_READ_iCCP 1 -#define PNG_NO_READ_UNKNOWN_CHUNKS 1 -#define PNG_NO_READ_USER_CHUNKS 1 -#define PNG_NO_READ_iTXt 1 -#define PNG_NO_READ_sCAL 1 -#define PNG_NO_READ_sPLT 1 - -#define png_error(a, b) png_err(a) -#define png_warning(a, b) (void)0 -#define png_chunk_error(a, b) png_err(a) -#define png_chunk_warning(a, b) png_warning(a, b) - -//============================================================================== - -/* - * PNG_USER_CONFIG has to be defined on the compiler command line. This - * includes the resource compiler for Windows DLL configurations. - */ -#ifdef PNG_USER_CONFIG -# ifndef PNG_USER_PRIVATEBUILD -# define PNG_USER_PRIVATEBUILD +/* To do: Do all of this in scripts/pnglibconf.dfa */ +#ifdef PNG_SAFE_LIMITS_SUPPORTED +# ifdef PNG_USER_WIDTH_MAX +# undef PNG_USER_WIDTH_MAX +# define PNG_USER_WIDTH_MAX 1000000L +# endif +# ifdef PNG_USER_HEIGHT_MAX +# undef PNG_USER_HEIGHT_MAX +# define PNG_USER_HEIGHT_MAX 1000000L +# endif +# ifdef PNG_USER_CHUNK_MALLOC_MAX +# undef PNG_USER_CHUNK_MALLOC_MAX +# define PNG_USER_CHUNK_MALLOC_MAX 4000000L +# endif +# ifdef PNG_USER_CHUNK_CACHE_MAX +# undef PNG_USER_CHUNK_CACHE_MAX +# define PNG_USER_CHUNK_CACHE_MAX 128 # endif -#include "pngusr.h" #endif -/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ -#ifdef PNG_CONFIGURE_LIBPNG -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#endif +#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ -/* - * Added at libpng-1.2.8 - * - * If you create a private DLL you need to define in "pngusr.h" the followings: - * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of - * the DLL was built> - * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." - * #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to - * distinguish your DLL from those of the official release. These - * correspond to the trailing letters that come after the version - * number and must match your private DLL name> - * e.g. // private DLL "libpng13gx.dll" - * #define PNG_USER_DLLFNAME_POSTFIX "gx" - * - * The following macros are also at your disposal if you want to complete the - * DLL VERSIONINFO structure. - * - PNG_USER_VERSIONINFO_COMMENTS - * - PNG_USER_VERSIONINFO_COMPANYNAME - * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS +/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C + * compiler for correct compilation. The following header files are required by + * the standard. If your compiler doesn't provide these header files, or they + * do not match the standard, you will need to provide/improve them. */ +#include <limits.h> +#include <stddef.h> -#ifdef __STDC__ -#ifdef SPECIALBUILD -# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ - are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") -#endif - -#ifdef PRIVATEBUILD -# pragma message("PRIVATEBUILD is deprecated.\ - Use PNG_USER_PRIVATEBUILD instead.") -# define PNG_USER_PRIVATEBUILD PRIVATEBUILD -#endif -#endif /* __STDC__ */ - -#ifndef PNG_VERSION_INFO_ONLY - -/* End of material added to libpng-1.2.8 */ - -/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble - Restored at libpng-1.2.21 */ -# define PNG_WARN_UNINITIALIZED_ROW 1 -/* End of material added at libpng-1.2.19/1.2.21 */ - -/* This is the size of the compression buffer, and thus the size of - * an IDAT chunk. Make this whatever size you feel is best for your - * machine. One of these will be allocated per png_struct. When this - * is full, it writes the data to the disk, and does some other - * calculations. Making this an extremely small size will slow - * the library down, but you may want to experiment to determine - * where it becomes significant, if you are concerned with memory - * usage. Note that zlib allocates at least 32Kb also. For readers, - * this describes the size of the buffer available to read the data in. - * Unless this gets smaller than the size of a row (compressed), - * it should not make much difference how big this is. +/* Library header files. These header files are all defined by ISOC90; libpng + * expects conformant implementations, however, an ISOC90 conformant system need + * not provide these header files if the functionality cannot be implemented. + * In this case it will be necessary to disable the relevant parts of libpng in + * the build of pnglibconf.h. + * + * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not + * include this unnecessary header file. */ -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif - -/* Enable if you want a write-only libpng */ - -#ifndef PNG_NO_READ_SUPPORTED -# define PNG_READ_SUPPORTED +#ifdef PNG_STDIO_SUPPORTED + /* Required for the definition of FILE: */ +# include <stdio.h> #endif -/* Enable if you want a read-only libpng */ - -#ifndef PNG_NO_WRITE_SUPPORTED -# define PNG_WRITE_SUPPORTED +#ifdef PNG_SETJMP_SUPPORTED + /* Required for the definition of jmp_buf and the declaration of longjmp: */ +# include <setjmp.h> #endif -/* Enabled by default in 1.2.0. You can disable this if you don't need to - support PNGs that are embedded in MNG datastreams */ -#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) -# ifndef PNG_MNG_FEATURES_SUPPORTED -# define PNG_MNG_FEATURES_SUPPORTED -# endif +#ifdef PNG_CONVERT_tIME_SUPPORTED + /* Required for struct tm: */ +# include <time.h> #endif -#ifndef PNG_NO_FLOATING_POINT_SUPPORTED -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FLOATING_POINT_SUPPORTED -# endif -#endif +#endif /* PNG_BUILDING_SYMBOL_TABLE */ -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. -#define PNG_MAX_MALLOC_64K +/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using + * PNG_NO_CONST; this is no longer supported except for data declarations which + * apparently still cause problems in 2011 on some compilers. */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K -#endif +#define PNG_CONST const /* backward compatibility only */ -/* Special munging to support doing things the 'cygwin' way: - * 'Normal' png-on-win32 defines/defaults: - * PNG_BUILD_DLL -- building dll - * PNG_USE_DLL -- building an application, linking to dll - * (no define) -- building static library, or building an - * application and linking to the static lib - * 'Cygwin' defines/defaults: - * PNG_BUILD_DLL -- (ignored) building the dll - * (no define) -- (ignored) building an application, linking to the dll - * PNG_STATIC -- (ignored) building the static lib, or building an - * application that links to the static lib. - * ALL_STATIC -- (ignored) building various static libs, or building an - * application that links to the static libs. - * Thus, - * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and - * this bit of #ifdefs will define the 'correct' config variables based on - * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but - * unnecessary. - * - * Also, the precedence order is: - * ALL_STATIC (since we can't #undef something outside our namespace) - * PNG_BUILD_DLL - * PNG_STATIC - * (nothing) == PNG_USE_DLL - * - * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent - * of auto-import in binutils, we no longer need to worry about - * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, - * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes - * to __declspec() stuff. However, we DO need to worry about - * PNG_BUILD_DLL and PNG_STATIC because those change some defaults - * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. +/* This controls optimization of the reading of 16 and 32 bit values + * from PNG files. It can be set on a per-app-file basis - it + * just changes whether a macro is used when the function is called. + * The library builder sets the default; if read functions are not + * built into the library the macro implementation is forced on. */ -#if defined(__CYGWIN__) -# if defined(ALL_STATIC) -# if defined(PNG_BUILD_DLL) -# undef PNG_BUILD_DLL -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# if !defined(PNG_STATIC) -# define PNG_STATIC -# endif -# else -# if defined (PNG_BUILD_DLL) -# if defined(PNG_STATIC) -# undef PNG_STATIC -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# else -# if defined(PNG_STATIC) -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# else -# if !defined(PNG_USE_DLL) -# define PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# endif -# endif +#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED +# define PNG_USE_READ_MACROS +#endif +#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) +# if PNG_DEFAULT_READ_MACROS +# define PNG_USE_READ_MACROS # endif #endif -/* This protects us against compilers that run on a windowing system - * and thus don't have or would rather us not use the stdio types: - * stdin, stdout, and stderr. The only one currently used is stderr - * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will - * prevent these from being compiled and used. #defining PNG_NO_STDIO - * will also prevent these, plus will prevent the entire set of stdio - * macros and functions (FILE *, printf, etc.) from being compiled and used, - * unless (PNG_DEBUG > 0) has been #defined. +/* COMPILER SPECIFIC OPTIONS. * - * #define PNG_NO_CONSOLE_IO - * #define PNG_NO_STDIO + * These options are provided so that a variety of difficult compilers + * can be used. Some are fixed at build time (e.g. PNG_API_RULE + * below) but still have compiler specific implementations, others + * may be changed on a per-file basis when compiling against libpng. */ -#if defined(_WIN32_WCE) -# include <windows.h> - /* Console I/O functions are not supported on WindowsCE */ -# define PNG_NO_CONSOLE_IO -# ifdef PNG_DEBUG -# undef PNG_DEBUG -# endif -#endif - -#ifdef PNG_BUILD_DLL -# ifndef PNG_CONSOLE_IO_SUPPORTED -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# endif -#endif - -# ifdef PNG_NO_STDIO -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# include <stdio.h> -# endif -# endif -# else -# if !defined(_WIN32_WCE) -/* "stdio.h" functions are not supported on WindowsCE */ -# include <stdio.h> -# endif -# endif - -/* This macro protects us against machines that don't have function - * prototypes (ie K&R style headers). If your compiler does not handle - * function prototypes, define this macro and use the included ansi2knr. - * I've always been able to use _NO_PROTO as the indicator, but you may - * need to drag the empty declaration out in front of here, or change the - * ifdef to suit your own needs. +/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect + * against legacy (pre ISOC90) compilers that did not understand function + * prototypes. It is not required for modern C compilers. */ #ifndef PNGARG - -#ifdef OF /* zlib prototype munger */ -# define PNGARG(arglist) OF(arglist) -#else - -#ifdef _NO_PROTO -# define PNGARG(arglist) () -# ifndef PNG_TYPECAST_NULL -# define PNG_TYPECAST_NULL -# endif -#else # define PNGARG(arglist) arglist -#endif /* _NO_PROTO */ - - -#endif /* OF */ - -#endif /* PNGARG */ - -/* Try to determine if we are compiling on a Mac. Note that testing for - * just __MWERKS__ is not good enough, because the Codewarrior is now used - * on non-Mac platforms. - */ -#ifndef MACOS -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) -# define MACOS -# endif -#endif - -/* enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) -# include <sys/types.h> #endif -#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) -# define PNG_SETJMP_SUPPORTED -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This is an attempt to force a single setjmp behaviour on Linux. If - * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. - */ - -# ifdef __linux__ -# ifdef _BSD_SOURCE -# define PNG_SAVE_BSD_SOURCE -# undef _BSD_SOURCE +/* Function calling conventions. + * ============================= + * Normally it is not necessary to specify to the compiler how to call + * a function - it just does it - however on x86 systems derived from + * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems + * and some others) there are multiple ways to call a function and the + * default can be changed on the compiler command line. For this reason + * libpng specifies the calling convention of every exported function and + * every function called via a user supplied function pointer. This is + * done in this file by defining the following macros: + * + * PNGAPI Calling convention for exported functions. + * PNGCBAPI Calling convention for user provided (callback) functions. + * PNGCAPI Calling convention used by the ANSI-C library (required + * for longjmp callbacks and sometimes used internally to + * specify the calling convention for zlib). + * + * These macros should never be overridden. If it is necessary to + * change calling convention in a private build this can be done + * by setting PNG_API_RULE (which defaults to 0) to one of the values + * below to select the correct 'API' variants. + * + * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. + * This is correct in every known environment. + * PNG_API_RULE=1 Use the operating system convention for PNGAPI and + * the 'C' calling convention (from PNGCAPI) for + * callbacks (PNGCBAPI). This is no longer required + * in any known environment - if it has to be used + * please post an explanation of the problem to the + * libpng mailing list. + * + * These cases only differ if the operating system does not use the C + * calling convention, at present this just means the above cases + * (x86 DOS/Windows sytems) and, even then, this does not apply to + * Cygwin running on those systems. + * + * Note that the value must be defined in pnglibconf.h so that what + * the application uses to call the library matches the conventions + * set when building the library. + */ + +/* Symbol export + * ============= + * When building a shared library it is almost always necessary to tell + * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' + * is used to mark the symbols. On some systems these symbols can be + * extracted at link time and need no special processing by the compiler, + * on other systems the symbols are flagged by the compiler and just + * the declaration requires a special tag applied (unfortunately) in a + * compiler dependent way. Some systems can do either. + * + * A small number of older systems also require a symbol from a DLL to + * be flagged to the program that calls it. This is a problem because + * we do not know in the header file included by application code that + * the symbol will come from a shared library, as opposed to a statically + * linked one. For this reason the application must tell us by setting + * the magic flag PNG_USE_DLL to turn on the special processing before + * it includes png.h. + * + * Four additional macros are used to make this happen: + * + * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from + * the build or imported if PNG_USE_DLL is set - compiler + * and system specific. + * + * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to + * 'type', compiler specific. + * + * PNG_DLL_EXPORT Set to the magic to use during a libpng build to + * make a symbol exported from the DLL. Not used in the + * public header files; see pngpriv.h for how it is used + * in the libpng build. + * + * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come + * from a DLL - used to define PNG_IMPEXP when + * PNG_USE_DLL is set. + */ + +/* System specific discovery. + * ========================== + * This code is used at build time to find PNG_IMPEXP, the API settings + * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL + * import processing is possible. On Windows systems it also sets + * compiler-specific macros to the values required to change the calling + * conventions of the various functions. + */ +#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ + defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) + /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or + * MinGW on any architecture currently supported by Windows. Also includes + * Watcom builds but these need special treatment because they are not + * compatible with GCC or Visual C because of different calling conventions. + */ +# if PNG_API_RULE == 2 + /* If this line results in an error, either because __watcall is not + * understood or because of a redefine just below you cannot use *this* + * build of the library with the compiler you are using. *This* build was + * build using Watcom and applications must also be built using Watcom! + */ +# define PNGCAPI __watcall +# endif + +# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) +# define PNGCAPI __cdecl +# if PNG_API_RULE == 1 + /* If this line results in an error __stdcall is not understood and + * PNG_API_RULE should not have been set to '1'. + */ +# define PNGAPI __stdcall # endif -# ifdef _SETJMP_H - /* If you encounter a compiler error here, see the explanation - * near the end of INSTALL. - */ - __png.h__ already includes setjmp.h; - __dont__ include it again.; +# else + /* An older compiler, or one not detected (erroneously) above, + * if necessary override on the command line to get the correct + * variants for the compiler. + */ +# ifndef PNGCAPI +# define PNGCAPI _cdecl # endif -# endif /* __linux__ */ - - /* include setjmp.h for error handling */ -# include <setjmp.h> - -# ifdef __linux__ -# ifdef PNG_SAVE_BSD_SOURCE -# define _BSD_SOURCE -# undef PNG_SAVE_BSD_SOURCE +# if PNG_API_RULE == 1 && !defined(PNGAPI) +# define PNGAPI _stdcall # endif -# endif /* __linux__ */ -#endif /* PNG_SETJMP_SUPPORTED */ - -#ifdef BSD -#if ! JUCE_MAC -# include <strings.h> -#endif -#else -# include <string.h> -#endif - -/* Other defines for things like memory and the like can go here. */ -#ifdef PNG_INTERNAL - -#include <stdlib.h> +# endif /* compiler/api */ + /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ -/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which - * aren't usually used outside the library (as far as I know), so it is - * debatable if they should be exported at all. In the future, when it is - * possible to have run-time registry of chunk-handling functions, some of - * these will be made available again. -#define PNG_EXTERN extern - */ -#define PNG_EXTERN - -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) -# if defined(MACOS) - /* We need to check that <math.h> hasn't already been included earlier - * as it seems it doesn't agree with <fp.h>, yet we should really use - * <fp.h> if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include <fp.h> -# endif -# else -# include <math.h> -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include <m68881.h> +# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) +# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" # endif -#endif - -/* Codewarrior on NT has linking problems without this. */ -#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) -# define PNG_ALWAYS_EXTERN -#endif - -/* This provides the non-ANSI (far) memory allocation routines. */ -#if defined(__TURBOC__) && defined(__MSDOS__) -# include <mem.h> -# include <alloc.h> -#endif - -/* I have no idea why is this necessary... */ -#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ - defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) -# include <malloc.h> -#endif -/* This controls how fine the dithering gets. As this allocates - * a largish chunk of memory (32K), those who are not as concerned - * with dithering quality can decrease some or all of these. - */ -#ifndef PNG_DITHER_RED_BITS -# define PNG_DITHER_RED_BITS 5 -#endif -#ifndef PNG_DITHER_GREEN_BITS -# define PNG_DITHER_GREEN_BITS 5 -#endif -#ifndef PNG_DITHER_BLUE_BITS -# define PNG_DITHER_BLUE_BITS 5 -#endif +# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ + (defined(__BORLANDC__) && __BORLANDC__ < 0x500) + /* older Borland and MSC + * compilers used '__export' and required this to be after + * the type. + */ +# ifndef PNG_EXPORT_TYPE +# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP +# endif +# define PNG_DLL_EXPORT __export +# else /* newer compiler */ +# define PNG_DLL_EXPORT __declspec(dllexport) +# ifndef PNG_DLL_IMPORT +# define PNG_DLL_IMPORT __declspec(dllimport) +# endif +# endif /* compiler */ -/* This controls how fine the gamma correction becomes when you - * are only interested in 8 bits anyway. Increasing this value - * results in more memory being used, and more pow() functions - * being called to fill in the gamma tables. Don't set this value - * less then 8, and even that may not work (I haven't tested it). - */ +#else /* !Windows */ +# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) +# define PNGAPI _System +# else /* !Windows/x86 && !OS/2 */ + /* Use the defaults, or define PNG*API on the command line (but + * this will have to be done for every compile!) + */ +# endif /* other system, !OS/2 */ +#endif /* !Windows/x86 */ -#ifndef PNG_MAX_GAMMA_8 -# define PNG_MAX_GAMMA_8 11 +/* Now do all the defaulting . */ +#ifndef PNGCAPI +# define PNGCAPI #endif - -/* This controls how much a difference in gamma we can tolerate before - * we actually start doing gamma conversion. - */ -#ifndef PNG_GAMMA_THRESHOLD -# define PNG_GAMMA_THRESHOLD 0.05 +#ifndef PNGCBAPI +# define PNGCBAPI PNGCAPI #endif - -#endif /* PNG_INTERNAL */ - -/* The following uses const char * instead of char * for error - * and warning message functions, so some compilers won't complain. - * If you do not want to use const, define PNG_NO_CONST here. - */ - -#ifndef PNG_NO_CONST -# define PNG_CONST const -#else -# define PNG_CONST +#ifndef PNGAPI +# define PNGAPI PNGCAPI #endif -/* The following defines give you the ability to remove code from the - * library that you will not be using. I wish I could figure out how to - * automate this, but I can't do that without making it seriously hard - * on the users. So if you are not using an ability, change the #define - * to and #undef, and that part of the library will not be compiled. If - * your linker can't find a function, you may want to make sure the - * ability is defined here. Some of these depend upon some others being - * defined. I haven't figured out all the interactions here, so you may - * have to experiment awhile to get everything to compile. If you are - * creating or using a shared library, you probably shouldn't touch this, - * as it will affect the size of the structures, and this will cause bad - * things to happen if the library and/or application ever change. +/* PNG_IMPEXP may be set on the compilation system command line or (if not set) + * then in an internal header file when building the library, otherwise (when + * using the library) it is set here. */ - -/* Any features you will not be using can be undef'ed here */ - -/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user - * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS - * on the compile line, then pick and choose which ones to define without - * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED - * if you only want to have a png-compliant reader/writer but don't need - * any of the extra transformations. This saves about 80 kbytes in a - * typical installation of the library. (PNG_NO_* form added in version - * 1.0.1c, for consistency) - */ - -/* The size of the png_text structure changed in libpng-1.0.6 when - * iTXt support was added. iTXt support was turned off by default through - * libpng-1.2.x, to support old apps that malloc the png_text structure - * instead of calling png_set_text() and letting libpng malloc it. It - * was turned on by default in libpng-1.3.0. - */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -# ifndef PNG_NO_iTXt_SUPPORTED -# define PNG_NO_iTXt_SUPPORTED -# endif -# ifndef PNG_NO_READ_iTXt -# define PNG_NO_READ_iTXt -# endif -# ifndef PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_iTXt +#ifndef PNG_IMPEXP +# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) + /* This forces use of a DLL, disallowing static linking */ +# define PNG_IMPEXP PNG_DLL_IMPORT # endif -#endif -#if !defined(PNG_NO_iTXt_SUPPORTED) -# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) -# define PNG_READ_iTXt -# endif -# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) -# define PNG_WRITE_iTXt +# ifndef PNG_IMPEXP +# define PNG_IMPEXP # endif #endif -/* The following support, added after version 1.0.0, can be turned off here en - * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility - * with old applications that require the length of png_struct and png_info - * to remain unchanged. +/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat + * 'attributes' as a storage class - the attributes go at the start of the + * function definition, and attributes are always appended regardless of the + * compiler. This considerably simplifies these macros but may cause problems + * if any compilers both need function attributes and fail to handle them as + * a storage class (this is unlikely.) */ - -#ifdef PNG_LEGACY_SUPPORTED -# define PNG_NO_FREE_ME -# define PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_NO_READ_USER_CHUNKS -# define PNG_NO_READ_iCCP -# define PNG_NO_WRITE_iCCP -# define PNG_NO_READ_iTXt -# define PNG_NO_WRITE_iTXt -# define PNG_NO_READ_sCAL -# define PNG_NO_WRITE_sCAL -# define PNG_NO_READ_sPLT -# define PNG_NO_WRITE_sPLT -# define PNG_NO_INFO_IMAGE -# define PNG_NO_READ_RGB_TO_GRAY -# define PNG_NO_READ_USER_TRANSFORM -# define PNG_NO_WRITE_USER_TRANSFORM -# define PNG_NO_USER_MEM -# define PNG_NO_READ_EMPTY_PLTE -# define PNG_NO_MNG_FEATURES -# define PNG_NO_FIXED_POINT_SUPPORTED -#endif - -/* Ignore attempt to turn off both floating and fixed point support */ -#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ - !defined(PNG_NO_FIXED_POINT_SUPPORTED) -# define PNG_FIXED_POINT_SUPPORTED -#endif - -#ifndef PNG_NO_FREE_ME -# define PNG_FREE_ME_SUPPORTED -#endif - -#if defined(PNG_READ_SUPPORTED) - -#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_TRANSFORMS) -# define PNG_READ_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_READ_EXPAND -# define PNG_READ_EXPAND_SUPPORTED -# endif -# ifndef PNG_NO_READ_SHIFT -# define PNG_READ_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACK -# define PNG_READ_PACK_SUPPORTED -# endif -# ifndef PNG_NO_READ_BGR -# define PNG_READ_BGR_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP -# define PNG_READ_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACKSWAP -# define PNG_READ_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT -# define PNG_READ_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_READ_DITHER -# define PNG_READ_DITHER_SUPPORTED -# endif -# ifndef PNG_NO_READ_BACKGROUND -# define PNG_READ_BACKGROUND_SUPPORTED -# endif -# ifndef PNG_NO_READ_16_TO_8 -# define PNG_READ_16_TO_8_SUPPORTED -# endif -# ifndef PNG_NO_READ_FILLER -# define PNG_READ_FILLER_SUPPORTED -# endif -# ifndef PNG_NO_READ_GAMMA -# define PNG_READ_GAMMA_SUPPORTED -# endif -# ifndef PNG_NO_READ_GRAY_TO_RGB -# define PNG_READ_GRAY_TO_RGB_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP_ALPHA -# define PNG_READ_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT_ALPHA -# define PNG_READ_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_STRIP_ALPHA -# define PNG_READ_STRIP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_USER_TRANSFORM -# define PNG_READ_USER_TRANSFORM_SUPPORTED -# endif -# ifndef PNG_NO_READ_RGB_TO_GRAY -# define PNG_READ_RGB_TO_GRAY_SUPPORTED -# endif -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_PROGRESSIVE_READ) && \ - !defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */ -# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ -#endif /* about interlacing capability! You'll */ - /* still have interlacing unless you change the following line: */ - -#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */ - -#ifndef PNG_NO_READ_COMPOSITE_NODIV -# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ -# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ -# endif -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, will be removed from version 2.0.0. - Use PNG_MNG_FEATURES_SUPPORTED instead. */ -#ifndef PNG_NO_READ_EMPTY_PLTE -# define PNG_READ_EMPTY_PLTE_SUPPORTED -#endif -#endif - -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_WRITE_SUPPORTED) - -# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_TRANSFORMS) -# define PNG_WRITE_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_WRITE_SHIFT -# define PNG_WRITE_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACK -# define PNG_WRITE_PACK_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_BGR -# define PNG_WRITE_BGR_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_SWAP -# define PNG_WRITE_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACKSWAP -# define PNG_WRITE_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT -# define PNG_WRITE_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_FILLER -# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ -# endif -# ifndef PNG_NO_WRITE_SWAP_ALPHA -# define PNG_WRITE_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT_ALPHA -# define PNG_WRITE_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_USER_TRANSFORM -# define PNG_WRITE_USER_TRANSFORM_SUPPORTED -# endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ - !defined(PNG_WRITE_INTERLACING_SUPPORTED) -#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant - encoders, but can cause trouble - if left undefined */ +#ifndef PNG_FUNCTION +# define PNG_FUNCTION(type, name, args, attributes) attributes type name args #endif -#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ - !defined(PNG_WRITE_WEIGHTED_FILTER) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#ifndef PNG_EXPORT_TYPE +# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type #endif -#ifndef PNG_NO_WRITE_FLUSH -# define PNG_WRITE_FLUSH_SUPPORTED -#endif + /* The ordinal value is only relevant when preprocessing png.h for symbol + * table entries, so we discard it here. See the .dfn files in the + * scripts directory. + */ +#ifndef PNG_EXPORTA -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ -#ifndef PNG_NO_WRITE_EMPTY_PLTE -# define PNG_WRITE_EMPTY_PLTE_SUPPORTED -#endif +# define PNG_EXPORTA(ordinal, type, name, args, attributes)\ + PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ + extern attributes) #endif -#endif /* PNG_WRITE_SUPPORTED */ +/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, + * so make something non-empty to satisfy the requirement: + */ +#define PNG_EMPTY /*empty list*/ -#ifndef PNG_1_0_X -# ifndef PNG_NO_ERROR_NUMBERS -# define PNG_ERROR_NUMBERS_SUPPORTED -# endif -#endif /* PNG_1_0_X */ +#define PNG_EXPORT(ordinal, type, name, args)\ + PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -# ifndef PNG_NO_USER_TRANSFORM_PTR -# define PNG_USER_TRANSFORM_PTR_SUPPORTED -# endif +/* Use PNG_REMOVED to comment out a removed interface. */ +#ifndef PNG_REMOVED +# define PNG_REMOVED(ordinal, type, name, args, attributes) #endif -#ifndef PNG_NO_STDIO -# define PNG_TIME_RFC1123_SUPPORTED +#ifndef PNG_CALLBACK +# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) #endif -/* This adds extra functions in pngget.c for accessing data from the - * info pointer (added in version 0.99) - * png_get_image_width() - * png_get_image_height() - * png_get_bit_depth() - * png_get_color_type() - * png_get_compression_type() - * png_get_filter_type() - * png_get_interlace_type() - * png_get_pixel_aspect_ratio() - * png_get_pixels_per_meter() - * png_get_x_offset_pixels() - * png_get_y_offset_pixels() - * png_get_x_offset_microns() - * png_get_y_offset_microns() +/* Support for compiler specific function attributes. These are used + * so that where compiler support is available incorrect use of API + * functions in png.h will generate compiler warnings. + * + * Added at libpng-1.2.41. */ -#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) -# define PNG_EASY_ACCESS_SUPPORTED -#endif - -/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 - * and removed from version 1.2.20. The following will be removed - * from libpng-1.4.0 -*/ -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE) -# ifndef PNG_OPTIMIZED_CODE_SUPPORTED -# define PNG_OPTIMIZED_CODE_SUPPORTED +#ifndef PNG_NO_PEDANTIC_WARNINGS +# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED +# define PNG_PEDANTIC_WARNINGS_SUPPORTED # endif #endif -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif - -# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4) - /* work around 64-bit gcc compiler bugs in gcc-3.x */ -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_NO_MMX_CODE +#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED + /* Support for compiler specific function attributes. These are used + * so that where compiler support is available, incorrect use of API + * functions in png.h will generate compiler warnings. Added at libpng + * version 1.2.41. Disabling these removes the warnings but may also produce + * less efficient code. + */ +# if defined(__GNUC__) +# ifndef PNG_USE_RESULT +# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # endif -# endif - -# if defined(__APPLE__) -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_NO_MMX_CODE +# ifndef PNG_NORETURN +# define PNG_NORETURN __attribute__((__noreturn__)) # endif -# endif +# if __GNUC__ >= 3 +# ifndef PNG_ALLOCATED +# define PNG_ALLOCATED __attribute__((__malloc__)) +# endif +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __attribute__((__deprecated__)) +# endif +# ifndef PNG_PRIVATE +# if 0 /* Doesn't work so we use deprecated instead*/ +# define PNG_PRIVATE \ + __attribute__((warning("This function is not exported by libpng."))) +# else +# define PNG_PRIVATE \ + __attribute__((__deprecated__)) +# endif +# endif +# if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) +# ifndef PNG_RESTRICT +# define PNG_RESTRICT __restrict +# endif +# endif /* __GNUC__ == 3.0 */ +# endif /* __GNUC__ >= 3 */ -# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh)) -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_NO_MMX_CODE +# elif defined(_MSC_VER) && (_MSC_VER >= 1300) +# ifndef PNG_USE_RESULT +# define PNG_USE_RESULT /* not supported */ +# endif +# ifndef PNG_NORETURN +# define PNG_NORETURN __declspec(noreturn) +# endif +# ifndef PNG_ALLOCATED +# if (_MSC_VER >= 1400) +# define PNG_ALLOCATED __declspec(restrict) +# endif +# endif +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __declspec(deprecated) +# endif +# ifndef PNG_PRIVATE +# define PNG_PRIVATE __declspec(deprecated) +# endif +# ifndef PNG_RESTRICT +# if (_MSC_VER >= 1400) +# define PNG_RESTRICT __restrict +# endif # endif -# endif -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_MMX_CODE_SUPPORTED -# endif +# elif defined(__WATCOMC__) +# ifndef PNG_RESTRICT +# define PNG_RESTRICT __restrict +# endif +# endif /* _MSC_VER */ +#endif /* PNG_PEDANTIC_WARNINGS */ +#ifndef PNG_DEPRECATED +# define PNG_DEPRECATED /* Use of this function is deprecated */ #endif -/* end of obsolete code to be removed from libpng-1.4.0 */ - -#if !defined(PNG_1_0_X) -#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) -# define PNG_USER_MEM_SUPPORTED +#ifndef PNG_USE_RESULT +# define PNG_USE_RESULT /* The result of this function must be checked */ #endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ -#if !defined(PNG_1_0_X) -#ifndef PNG_SET_USER_LIMITS_SUPPORTED -#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) -# define PNG_SET_USER_LIMITS_SUPPORTED +#ifndef PNG_NORETURN +# define PNG_NORETURN /* This function does not return */ #endif +#ifndef PNG_ALLOCATED +# define PNG_ALLOCATED /* The result of the function is new memory */ #endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter - * how large, set these limits to 0x7fffffffL - */ -#ifndef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 1000000L +#ifndef PNG_PRIVATE +# define PNG_PRIVATE /* This is a private libpng function */ #endif -#ifndef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 1000000L +#ifndef PNG_RESTRICT +# define PNG_RESTRICT /* The C99 "restrict" feature */ #endif - -/* These are currently experimental features, define them if you want */ - -/* very little testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +#ifndef PNG_FP_EXPORT /* A floating point API. */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FP_EXPORT(ordinal, type, name, args)\ + PNG_EXPORT(ordinal, type, name, args); +# else /* No floating point APIs */ +# define PNG_FP_EXPORT(ordinal, type, name, args) # endif #endif -*/ - -/* This is only for PowerPC big-endian and 680x0 systems */ -/* some testing */ -/* -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -# define PNG_READ_BIG_ENDIAN_SUPPORTED +#ifndef PNG_FIXED_EXPORT /* A fixed point API. */ +# ifdef PNG_FIXED_POINT_SUPPORTED +# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ + PNG_EXPORT(ordinal, type, name, args); +# else /* No fixed point APIs */ +# define PNG_FIXED_EXPORT(ordinal, type, name, args) +# endif #endif -*/ - -/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ -/* -#define PNG_NO_POINTER_INDEXING -*/ -/* These functions are turned off by default, as they will be phased out. */ -/* -#define PNG_USELESS_TESTS_SUPPORTED -#define PNG_CORRECT_PALETTE_SUPPORTED -*/ - -/* Any chunks you are not interested in, you can undef here. The - * ones that allocate memory may be expecially important (hIST, - * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info - * a bit smaller. +#ifndef PNG_BUILDING_SYMBOL_TABLE +/* Some typedefs to get us started. These should be safe on most of the common + * platforms. + * + * png_uint_32 and png_int_32 may, currently, be larger than required to hold a + * 32-bit value however this is not normally advisable. + * + * png_uint_16 and png_int_16 should always be two bytes in size - this is + * verified at library build time. + * + * png_byte must always be one byte in size. + * + * The checks below use constants from limits.h, as defined by the ISOC90 + * standard. */ - -#if defined(PNG_READ_SUPPORTED) && \ - !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_ANCILLARY_CHUNKS) -# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED +#if CHAR_BIT == 8 && UCHAR_MAX == 255 + typedef unsigned char png_byte; +#else +# error "libpng requires 8 bit bytes" #endif -#if defined(PNG_WRITE_SUPPORTED) && \ - !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) -# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED +#if INT_MIN == -32768 && INT_MAX == 32767 + typedef int png_int_16; +#elif SHRT_MIN == -32768 && SHRT_MAX == 32767 + typedef short png_int_16; +#else +# error "libpng requires a signed 16 bit type" #endif -#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_READ_TEXT -# define PNG_NO_READ_iTXt -# define PNG_NO_READ_tEXt -# define PNG_NO_READ_zTXt -#endif -#ifndef PNG_NO_READ_bKGD -# define PNG_READ_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -#endif -#ifndef PNG_NO_READ_cHRM -# define PNG_READ_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -#endif -#ifndef PNG_NO_READ_gAMA -# define PNG_READ_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -#endif -#ifndef PNG_NO_READ_hIST -# define PNG_READ_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -#endif -#ifndef PNG_NO_READ_iCCP -# define PNG_READ_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -#endif -#ifndef PNG_NO_READ_iTXt -# ifndef PNG_READ_iTXt_SUPPORTED -# define PNG_READ_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_READ_oFFs -# define PNG_READ_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -#endif -#ifndef PNG_NO_READ_pCAL -# define PNG_READ_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_sCAL -# define PNG_READ_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_pHYs -# define PNG_READ_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -#endif -#ifndef PNG_NO_READ_sBIT -# define PNG_READ_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sPLT -# define PNG_READ_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sRGB -# define PNG_READ_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -#endif -#ifndef PNG_NO_READ_tEXt -# define PNG_READ_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_tIME -# define PNG_READ_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -#endif -#ifndef PNG_NO_READ_tRNS -# define PNG_READ_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -#endif -#ifndef PNG_NO_READ_zTXt -# define PNG_READ_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -#endif -#if !defined(PNG_NO_READ_USER_CHUNKS) && \ - defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# define PNG_READ_USER_CHUNKS_SUPPORTED -# define PNG_USER_CHUNKS_SUPPORTED -# ifdef PNG_NO_READ_UNKNOWN_CHUNKS -# undef PNG_NO_READ_UNKNOWN_CHUNKS -# endif -# ifdef PNG_NO_HANDLE_AS_UNKNOWN -# undef PNG_NO_HANDLE_AS_UNKNOWN -# endif -#endif -#ifndef PNG_NO_READ_OPT_PLTE -# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ -#endif /* optional PLTE chunk in RGB and RGBA images */ -#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ - defined(PNG_READ_zTXt_SUPPORTED) -# define PNG_READ_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED +#if UINT_MAX == 65535 + typedef unsigned int png_uint_16; +#elif USHRT_MAX == 65535 + typedef unsigned short png_uint_16; +#else +# error "libpng requires an unsigned 16 bit type" #endif -#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ - -#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_WRITE_TEXT -# define PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_tEXt -# define PNG_NO_WRITE_zTXt -#endif -#ifndef PNG_NO_WRITE_bKGD -# define PNG_WRITE_bKGD_SUPPORTED -# ifndef PNG_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_cHRM -# define PNG_WRITE_cHRM_SUPPORTED -# ifndef PNG_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_gAMA -# define PNG_WRITE_gAMA_SUPPORTED -# ifndef PNG_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_hIST -# define PNG_WRITE_hIST_SUPPORTED -# ifndef PNG_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iCCP -# define PNG_WRITE_iCCP_SUPPORTED -# ifndef PNG_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iTXt -# ifndef PNG_WRITE_iTXt_SUPPORTED -# define PNG_WRITE_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_oFFs -# define PNG_WRITE_oFFs_SUPPORTED -# ifndef PNG_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pCAL -# define PNG_WRITE_pCAL_SUPPORTED -# ifndef PNG_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sCAL -# define PNG_WRITE_sCAL_SUPPORTED -# ifndef PNG_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pHYs -# define PNG_WRITE_pHYs_SUPPORTED -# ifndef PNG_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sBIT -# define PNG_WRITE_sBIT_SUPPORTED -# ifndef PNG_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sPLT -# define PNG_WRITE_sPLT_SUPPORTED -# ifndef PNG_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sRGB -# define PNG_WRITE_sRGB_SUPPORTED -# ifndef PNG_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tEXt -# define PNG_WRITE_tEXt_SUPPORTED -# ifndef PNG_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tIME -# define PNG_WRITE_tIME_SUPPORTED -# ifndef PNG_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tRNS -# define PNG_WRITE_tRNS_SUPPORTED -# ifndef PNG_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_zTXt -# define PNG_WRITE_zTXt_SUPPORTED -# ifndef PNG_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -# endif -#endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ - defined(PNG_WRITE_zTXt_SUPPORTED) -# define PNG_WRITE_TEXT_SUPPORTED -# ifndef PNG_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -# endif +#if INT_MIN < -2147483646 && INT_MAX > 2147483646 + typedef int png_int_32; +#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 + typedef long int png_int_32; +#else +# error "libpng requires a signed 32 bit (or more) type" #endif -#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ +#if UINT_MAX > 4294967294 + typedef unsigned int png_uint_32; +#elif ULONG_MAX > 4294967294 + typedef unsigned long int png_uint_32; +#else +# error "libpng requires an unsigned 32 bit (or more) type" +#endif -/* Turn this off to disable png_read_png() and - * png_write_png() and leave the row_pointers member - * out of the info structure. +/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however, + * requires an ISOC90 compiler and relies on consistent behavior of sizeof. */ -#ifndef PNG_NO_INFO_IMAGE -# define PNG_INFO_IMAGE_SUPPORTED -#endif +typedef size_t png_size_t; +typedef ptrdiff_t png_ptrdiff_t; -/* need the time information for reading tIME chunks */ -#if defined(PNG_tIME_SUPPORTED) -# if !defined(_WIN32_WCE) - /* "time.h" functions are not supported on WindowsCE */ -# include <time.h> +/* libpng needs to know the maximum value of 'size_t' and this controls the + * definition of png_alloc_size_t, below. This maximum value of size_t limits + * but does not control the maximum allocations the library makes - there is + * direct application control of this through png_set_user_limits(). + */ +#ifndef PNG_SMALL_SIZE_T + /* Compiler specific tests for systems where size_t is known to be less than + * 32 bits (some of these systems may no longer work because of the lack of + * 'far' support; see above.) + */ +# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ + (defined(_MSC_VER) && defined(MAXSEG_64K)) +# define PNG_SMALL_SIZE_T # endif #endif -/* Some typedefs to get us started. These should be safe on most of the - * common platforms. The typedefs should be at least as large as the - * numbers suggest (a png_uint_32 must be at least 32 bits long), but they - * don't have to be exactly that size. Some compilers dislike passing - * unsigned shorts as function parameters, so you may be better off using - * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may - * want to have unsigned int for png_uint_32 instead of unsigned long. +/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no + * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to + * png_alloc_size_t are not necessary; in fact, it is recommended not to use + * them at all so that the compiler can complain when something turns out to be + * problematic. + * + * Casts in the other direction (from png_alloc_size_t to png_size_t or + * png_uint_32) should be explicitly applied; however, we do not expect to + * encounter practical situations that require such conversions. + * + * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than + * 4294967295 - i.e. less than the maximum value of png_uint_32. */ - -typedef unsigned long png_uint_32; -typedef long png_int_32; -typedef unsigned short png_uint_16; -typedef short png_int_16; -typedef unsigned char png_byte; - -/* This is usually size_t. It is typedef'ed just in case you need it to - change (I'm not sure if you will or not, so I thought I'd be safe) */ -#ifdef PNG_SIZE_T - typedef PNG_SIZE_T png_size_t; -# define png_sizeof(x) png_convert_size(sizeof (x)) +#ifdef PNG_SMALL_SIZE_T + typedef png_uint_32 png_alloc_size_t; #else - typedef size_t png_size_t; -# define png_sizeof(x) sizeof (x) + typedef png_size_t png_alloc_size_t; #endif -/* The following is needed for medium model support. It cannot be in the - * PNG_INTERNAL section. Needs modification for other compilers besides - * MSC. Model independent support declares all arrays and pointers to be - * large using the far keyword. The zlib version used must also support - * model independent data. As of version zlib 1.0.4, the necessary changes - * have been made in zlib. The USE_FAR_KEYWORD define triggers other - * changes that are needed. (Tim Wegner) +/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler + * implementations of Intel CPU specific support of user-mode segmented address + * spaces, where 16-bit pointers address more than 65536 bytes of memory using + * separate 'segment' registers. The implementation requires two different + * types of pointer (only one of which includes the segment value.) + * + * If required this support is available in version 1.2 of libpng and may be + * available in versions through 1.5, although the correctness of the code has + * not been verified recently. */ -/* Separate compiler dependencies (problem here is that zlib.h always - defines FAR. (SJT) */ -#ifdef __BORLANDC__ -# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -# define LDATA 1 -# else -# define LDATA 0 -# endif - /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ -# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) -# define PNG_MAX_MALLOC_64K -# if (LDATA != 1) -# ifndef FAR -# define FAR __far -# endif -# define USE_FAR_KEYWORD -# endif /* LDATA != 1 */ - /* Possibly useful for moving data out of default segment. - * Uncomment it if you want. Could also define FARDATA as - * const if your compiler supports it. (SJT) -# define FARDATA FAR - */ -# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ -#endif /* __BORLANDC__ */ - - -/* Suggest testing for specific compiler first before testing for - * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, - * making reliance oncertain keywords suspect. (SJT) +/* Typedef for floating-point numbers that are converted to fixed-point with a + * multiple of 100,000, e.g., gamma */ - -/* MSC Medium model */ -#if defined(FAR) -# if defined(M_I86MM) -# define USE_FAR_KEYWORD -# define FARDATA FAR -# include <dos.h> -# endif -#endif - -/* SJT: default case */ -#ifndef FAR -# define FAR -#endif - -/* At this point FAR is always defined */ -#ifndef FARDATA -# define FARDATA -#endif - -/* Typedef for floating-point numbers that are converted - to fixed-point with a multiple of 100,000, e.g., int_gamma */ typedef png_int_32 png_fixed_point; /* Add typedefs for pointers */ -typedef void FAR * png_voidp; -typedef png_byte FAR * png_bytep; -typedef png_uint_32 FAR * png_uint_32p; -typedef png_int_32 FAR * png_int_32p; -typedef png_uint_16 FAR * png_uint_16p; -typedef png_int_16 FAR * png_int_16p; -typedef PNG_CONST char FAR * png_const_charp; -typedef char FAR * png_charp; -typedef png_fixed_point FAR * png_fixed_point_p; - -#ifndef PNG_NO_STDIO -#if defined(_WIN32_WCE) -typedef HANDLE png_FILE_p; -#else -typedef FILE * png_FILE_p; -#endif +typedef void * png_voidp; +typedef const void * png_const_voidp; +typedef png_byte * png_bytep; +typedef const png_byte * png_const_bytep; +typedef png_uint_32 * png_uint_32p; +typedef const png_uint_32 * png_const_uint_32p; +typedef png_int_32 * png_int_32p; +typedef const png_int_32 * png_const_int_32p; +typedef png_uint_16 * png_uint_16p; +typedef const png_uint_16 * png_const_uint_16p; +typedef png_int_16 * png_int_16p; +typedef const png_int_16 * png_const_int_16p; +typedef char * png_charp; +typedef const char * png_const_charp; +typedef png_fixed_point * png_fixed_point_p; +typedef const png_fixed_point * png_const_fixed_point_p; +typedef png_size_t * png_size_tp; +typedef const png_size_t * png_const_size_tp; + +#ifdef PNG_STDIO_SUPPORTED +typedef FILE * png_FILE_p; #endif #ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * png_doublep; +typedef double * png_doublep; +typedef const double * png_const_doublep; #endif /* Pointers to pointers; i.e. arrays */ -typedef png_byte FAR * FAR * png_bytepp; -typedef png_uint_32 FAR * FAR * png_uint_32pp; -typedef png_int_32 FAR * FAR * png_int_32pp; -typedef png_uint_16 FAR * FAR * png_uint_16pp; -typedef png_int_16 FAR * FAR * png_int_16pp; -typedef PNG_CONST char FAR * FAR * png_const_charpp; -typedef char FAR * FAR * png_charpp; -typedef png_fixed_point FAR * FAR * png_fixed_point_pp; +typedef png_byte * * png_bytepp; +typedef png_uint_32 * * png_uint_32pp; +typedef png_int_32 * * png_int_32pp; +typedef png_uint_16 * * png_uint_16pp; +typedef png_int_16 * * png_int_16pp; +typedef const char * * png_const_charpp; +typedef char * * png_charpp; +typedef png_fixed_point * * png_fixed_point_pp; #ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * FAR * png_doublepp; +typedef double * * png_doublepp; #endif /* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char FAR * FAR * FAR * png_charppp; - -#if 0 -/* SPC - Is this stuff deprecated? */ -/* It'll be removed as of libpng-1.3.0 - GR-P */ -/* libpng typedefs for types in zlib. If zlib changes - * or another compression library is used, then change these. - * Eliminates need to change all the source files. - */ -typedef charf * png_zcharp; -typedef charf * FAR * png_zcharpp; -typedef z_stream FAR * png_zstreamp; -#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ - -/* - * Define PNG_BUILD_DLL if the module being built is a Windows - * LIBPNG DLL. - * - * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. - * It is equivalent to Microsoft predefined macro _DLL that is - * automatically defined when you compile using the share - * version of the CRT (C Run-Time library) - * - * The cygwin mods make this behavior a little different: - * Define PNG_BUILD_DLL if you are building a dll for use with cygwin - * Define PNG_STATIC if you are building a static library for use with cygwin, - * -or- if you are building an application that you want to link to the - * static library. - * PNG_USE_DLL is defined by default (no user action needed) unless one of - * the other flags is defined. - */ - -#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) -# define PNG_DLL -#endif -/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. - * When building a static lib, default to no GLOBAL ARRAYS, but allow - * command-line override - */ -#if defined(__CYGWIN__) -# if !defined(PNG_STATIC) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -# else -# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# endif -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -#endif - -/* Do not use global arrays (helps with building DLL's) - * They are no longer used in libpng itself, since version 1.0.5c, - * but might be required for some pre-1.0.5c applications. - */ -#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# if defined(PNG_NO_GLOBAL_ARRAYS) || \ - (defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER) -# define PNG_USE_LOCAL_ARRAYS -# else -# define PNG_USE_GLOBAL_ARRAYS -# endif -#endif - -#if defined(__CYGWIN__) -# undef PNGAPI -# define PNGAPI __cdecl -# undef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", - * you may get warnings regarding the linkage of png_zalloc and png_zfree. - * Don't ignore those warnings; you must also reset the default calling - * convention in your compiler to match your PNGAPI, and you must build - * zlib and your applications the same way you build libpng. - */ - -#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) -# ifndef PNG_NO_MODULEDEF -# define PNG_NO_MODULEDEF -# endif -#endif - -#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) -# define PNG_IMPEXP -#endif - -#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ - (( defined(_Windows) || defined(_WINDOWS) || \ - defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) - -# ifndef PNGAPI -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) -# define PNGAPI __cdecl -# else -# define PNGAPI _cdecl -# endif -# endif - -# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ - 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) -# define PNG_IMPEXP -# endif - -# if !defined(PNG_IMPEXP) - -# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol -# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol - - /* Borland/Microsoft */ -# if defined(_MSC_VER) || defined(__BORLANDC__) -# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) -# define PNG_EXPORT PNG_EXPORT_TYPE1 -# else -# define PNG_EXPORT PNG_EXPORT_TYPE2 -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __export -# else -# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in - VC++ */ -# endif /* Exists in Borland C++ for - C++ classes (== huge) */ -# endif -# endif - -# if !defined(PNG_IMPEXP) -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __declspec(dllexport) -# else -# define PNG_IMPEXP __declspec(dllimport) -# endif -# endif -# endif /* PNG_IMPEXP */ -#else /* !(DLL || non-cygwin WINDOWS) */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# ifndef PNGAPI -# define PNGAPI _System -# endif -# else -# if 0 /* ... other platforms, with other meanings */ -# endif -# endif -#endif - -#ifndef PNGAPI -# define PNGAPI -#endif -#ifndef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -#ifdef PNG_BUILDSYMS -# ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END -# endif -# ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT -# endif -# endif -#endif - -#ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type -# endif -#endif - -/* User may want to use these so they are not in PNG_INTERNAL. Any library - * functions that are passed far data must be model independent. - */ - -#ifndef PNG_ABORT -# define PNG_ABORT() abort() -#endif - -#ifdef PNG_SETJMP_SUPPORTED -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) -#endif - -#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ -/* use this to make far-to-near assignments */ -# define CHECK 1 -# define NOCHECK 0 -# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) -# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) -# define png_snprintf _fsnprintf /* Added to v 1.2.19 */ -# define png_strcpy _fstrcpy -# define png_strncpy _fstrncpy /* Added to v 1.2.6 */ -# define png_strlen _fstrlen -# define png_memcmp _fmemcmp /* SJT: added */ -# define png_memcpy _fmemcpy -# define png_memset _fmemset -#else /* use the usual functions */ -# define CVT_PTR(ptr) (ptr) -# define CVT_PTR_NOCHECK(ptr) (ptr) -# ifndef PNG_NO_SNPRINTF -# ifdef _MSC_VER -# define png_snprintf _snprintf /* Added to v 1.2.19 */ -# define png_snprintf2 _snprintf -# define png_snprintf6 _snprintf -# else -# define png_snprintf snprintf /* Added to v 1.2.19 */ -# define png_snprintf2 snprintf -# define png_snprintf6 snprintf -# endif -# else - /* You don't have or don't want to use snprintf(). Caution: Using - * sprintf instead of snprintf exposes your application to accidental - * or malevolent buffer overflows. If you don't have snprintf() - * as a general rule you should provide one (you can get one from - * Portable OpenSSH). */ -# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1) -# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2) -# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \ - sprintf(s1,fmt,x1,x2,x3,x4,x5,x6) -# endif -# define png_strcpy strcpy -# define png_strncpy strncpy /* Added to v 1.2.6 */ -# define png_strlen strlen -# define png_memcmp memcmp /* SJT: added */ -# define png_memcpy memcpy -# define png_memset memset -#endif -/* End of memory model independent support */ - -/* Just a little check that someone hasn't tried to define something - * contradictory. - */ -#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536L -#endif +typedef char * * * png_charppp; -/* Added at libpng-1.2.8 */ -#endif /* PNG_VERSION_INFO_ONLY */ +#endif /* PNG_BUILDING_SYMBOL_TABLE */ #endif /* PNGCONF_H */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngerror.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngerror.c index e109bd843..f40cc8301 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngerror.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngerror.c @@ -1,128 +1,407 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.2.20 October 4, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file provides a location for all error handling. Users who * need special error handling are expected to write replacement functions * and use png_set_error_fn() to use those functions. See the instructions * at each function. */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + +static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr, + png_const_charp error_message)),PNG_NORETURN); + +#ifdef PNG_WARNINGS_SUPPORTED static void /* PRIVATE */ -png_default_error PNGARG((png_structp png_ptr, - png_const_charp error_message)); -#ifndef PNG_NO_WARNINGS -static void /* PRIVATE */ -png_default_warning PNGARG((png_structp png_ptr, - png_const_charp warning_message)); -#endif /* PNG_NO_WARNINGS */ +png_default_warning PNGARG((png_const_structrp png_ptr, + png_const_charp warning_message)); +#endif /* PNG_WARNINGS_SUPPORTED */ /* This function is called whenever there is a fatal error. This function * should not be changed. If there is a need to handle errors differently, * you should supply a replacement error function and use png_set_error_fn() * to replace the error function at run-time. */ -#ifndef PNG_NO_ERROR_TEXT -void PNGAPI -png_error(png_structp png_ptr, png_const_charp error_message) +#ifdef PNG_ERROR_TEXT_SUPPORTED +PNG_FUNCTION(void,PNGAPI +png_error,(png_const_structrp png_ptr, png_const_charp error_message), + PNG_NORETURN) { #ifdef PNG_ERROR_NUMBERS_SUPPORTED char msg[16]; if (png_ptr != NULL) { - if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) - { - if (*error_message == '#') - { - int offset; - for (offset=1; offset<15; offset++) - if (*(error_message+offset) == ' ') + if (png_ptr->flags& + (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) + { + if (*error_message == PNG_LITERAL_SHARP) + { + /* Strip "#nnnn " from beginning of error message. */ + int offset; + for (offset = 1; offset<15; offset++) + if (error_message[offset] == ' ') break; - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - int i; - for (i=0; i<offset-1; i++) - msg[i]=error_message[i+1]; - msg[i]='\0'; - error_message=msg; - } - else - error_message+=offset; - } - else - { - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - msg[0]='0'; - msg[1]='\0'; - error_message=msg; - } + + if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) + { + int i; + for (i = 0; i < offset - 1; i++) + msg[i] = error_message[i + 1]; + msg[i - 1] = '\0'; + error_message = msg; + } + + else + error_message += offset; + } + + else + { + if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) + { + msg[0] = '0'; + msg[1] = '\0'; + error_message = msg; + } } } } #endif if (png_ptr != NULL && png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_ptr, error_message); + (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), + error_message); /* If the custom handler doesn't exist, or if it returns, use the default handler, which will not return. */ png_default_error(png_ptr, error_message); } #else -void PNGAPI -png_err(png_structp png_ptr) +PNG_FUNCTION(void,PNGAPI +png_err,(png_const_structrp png_ptr),PNG_NORETURN) { + /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed + * erroneously as '\0', instead of the empty string "". This was + * apparently an error, introduced in libpng-1.2.20, and png_default_error + * will crash in this case. + */ if (png_ptr != NULL && png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_ptr, 0); + (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), ""); /* If the custom handler doesn't exist, or if it returns, use the default handler, which will not return. */ - png_default_error(png_ptr, 0); + png_default_error(png_ptr, ""); } -#endif /* PNG_NO_ERROR_TEXT */ +#endif /* PNG_ERROR_TEXT_SUPPORTED */ + +/* Utility to safely appends strings to a buffer. This never errors out so + * error checking is not required in the caller. + */ +size_t +png_safecat(png_charp buffer, size_t bufsize, size_t pos, + png_const_charp string) +{ + if (buffer != NULL && pos < bufsize) + { + if (string != NULL) + while (*string != '\0' && pos < bufsize-1) + buffer[pos++] = *string++; + + buffer[pos] = '\0'; + } + + return pos; +} + +#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED) +/* Utility to dump an unsigned value into a buffer, given a start pointer and + * and end pointer (which should point just *beyond* the end of the buffer!) + * Returns the pointer to the start of the formatted string. + */ +png_charp +png_format_number(png_const_charp start, png_charp end, int format, + png_alloc_size_t number) +{ + int count = 0; /* number of digits output */ + int mincount = 1; /* minimum number required */ + int output = 0; /* digit output (for the fixed point format) */ + + *--end = '\0'; + + /* This is written so that the loop always runs at least once, even with + * number zero. + */ + while (end > start && (number != 0 || count < mincount)) + { + + static const char digits[] = "0123456789ABCDEF"; + + switch (format) + { + case PNG_NUMBER_FORMAT_fixed: + /* Needs five digits (the fraction) */ + mincount = 5; + if (output || number % 10 != 0) + { + *--end = digits[number % 10]; + output = 1; + } + number /= 10; + break; -#ifndef PNG_NO_WARNINGS + case PNG_NUMBER_FORMAT_02u: + /* Expects at least 2 digits. */ + mincount = 2; + /* FALL THROUGH */ + + case PNG_NUMBER_FORMAT_u: + *--end = digits[number % 10]; + number /= 10; + break; + + case PNG_NUMBER_FORMAT_02x: + /* This format expects at least two digits */ + mincount = 2; + /* FALL THROUGH */ + + case PNG_NUMBER_FORMAT_x: + *--end = digits[number & 0xf]; + number >>= 4; + break; + + default: /* an error */ + number = 0; + break; + } + + /* Keep track of the number of digits added */ + ++count; + + /* Float a fixed number here: */ + if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start) + { + /* End of the fraction, but maybe nothing was output? In that case + * drop the decimal point. If the number is a true zero handle that + * here. + */ + if (output) + *--end = '.'; + else if (number == 0) /* and !output */ + *--end = '0'; + } + } + + return end; +} +#endif + +#ifdef PNG_WARNINGS_SUPPORTED /* This function is called whenever there is a non-fatal error. This function * should not be changed. If there is a need to handle warnings differently, * you should supply a replacement warning function and use * png_set_error_fn() to replace the warning function at run-time. */ void PNGAPI -png_warning(png_structp png_ptr, png_const_charp warning_message) +png_warning(png_const_structrp png_ptr, png_const_charp warning_message) { int offset = 0; if (png_ptr != NULL) { #ifdef PNG_ERROR_NUMBERS_SUPPORTED if (png_ptr->flags& - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) + (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) #endif - { - if (*warning_message == '#') - { - for (offset=1; offset<15; offset++) - if (*(warning_message+offset) == ' ') + { + if (*warning_message == PNG_LITERAL_SHARP) + { + for (offset = 1; offset < 15; offset++) + if (warning_message[offset] == ' ') break; - } - } - if (png_ptr != NULL && png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); + } + } + } + if (png_ptr != NULL && png_ptr->warning_fn != NULL) + (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr), + warning_message + offset); + else + png_default_warning(png_ptr, warning_message + offset); +} + +/* These functions support 'formatted' warning messages with up to + * PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter + * is introduced by @<number>, where 'number' starts at 1. This follows the + * standard established by X/Open for internationalizable error messages. + */ +void +png_warning_parameter(png_warning_parameters p, int number, + png_const_charp string) +{ + if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT) + (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string); +} + +void +png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, + png_alloc_size_t value) +{ + char buffer[PNG_NUMBER_BUFFER_SIZE]; + png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value)); +} + +void +png_warning_parameter_signed(png_warning_parameters p, int number, int format, + png_int_32 value) +{ + png_alloc_size_t u; + png_charp str; + char buffer[PNG_NUMBER_BUFFER_SIZE]; + + /* Avoid overflow by doing the negate in a png_alloc_size_t: */ + u = (png_alloc_size_t)value; + if (value < 0) + u = ~u + 1; + + str = PNG_FORMAT_NUMBER(buffer, format, u); + + if (value < 0 && str > buffer) + *--str = '-'; + + png_warning_parameter(p, number, str); +} + +void +png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p, + png_const_charp message) +{ + /* The internal buffer is just 192 bytes - enough for all our messages, + * overflow doesn't happen because this code checks! If someone figures + * out how to send us a message longer than 192 bytes, all that will + * happen is that the message will be truncated appropriately. + */ + size_t i = 0; /* Index in the msg[] buffer: */ + char msg[192]; + + /* Each iteration through the following loop writes at most one character + * to msg[i++] then returns here to validate that there is still space for + * the trailing '\0'. It may (in the case of a parameter) read more than + * one character from message[]; it must check for '\0' and continue to the + * test if it finds the end of string. + */ + while (i<(sizeof msg)-1 && *message != '\0') + { + /* '@' at end of string is now just printed (previously it was skipped); + * it is an error in the calling code to terminate the string with @. + */ + if (p != NULL && *message == '@' && message[1] != '\0') + { + int parameter_char = *++message; /* Consume the '@' */ + static const char valid_parameters[] = "123456789"; + int parameter = 0; + + /* Search for the parameter digit, the index in the string is the + * parameter to use. + */ + while (valid_parameters[parameter] != parameter_char && + valid_parameters[parameter] != '\0') + ++parameter; + + /* If the parameter digit is out of range it will just get printed. */ + if (parameter < PNG_WARNING_PARAMETER_COUNT) + { + /* Append this parameter */ + png_const_charp parm = p[parameter]; + png_const_charp pend = p[parameter] + (sizeof p[parameter]); + + /* No need to copy the trailing '\0' here, but there is no guarantee + * that parm[] has been initialized, so there is no guarantee of a + * trailing '\0': + */ + while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend) + msg[i++] = *parm++; + + /* Consume the parameter digit too: */ + ++message; + continue; + } + + /* else not a parameter and there is a character after the @ sign; just + * copy that. This is known not to be '\0' because of the test above. + */ + } + + /* At this point *message can't be '\0', even in the bad parameter case + * above where there is a lone '@' at the end of the message string. + */ + msg[i++] = *message++; + } + + /* i is always less than (sizeof msg), so: */ + msg[i] = '\0'; + + /* And this is the formatted message. It may be larger than + * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these + * are not (currently) formatted. + */ + png_warning(png_ptr, msg); +} +#endif /* PNG_WARNINGS_SUPPORTED */ + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +void PNGAPI +png_benign_error(png_const_structrp png_ptr, png_const_charp error_message) +{ + if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) + { +# ifdef PNG_READ_SUPPORTED + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && + png_ptr->chunk_name != 0) + png_chunk_warning(png_ptr, error_message); + else +# endif + png_warning(png_ptr, error_message); } + else - png_default_warning(png_ptr, warning_message+offset); + { +# ifdef PNG_READ_SUPPORTED + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && + png_ptr->chunk_name != 0) + png_chunk_error(png_ptr, error_message); + else +# endif + png_error(png_ptr, error_message); + } } -#endif /* PNG_NO_WARNINGS */ +void /* PRIVATE */ +png_app_warning(png_const_structrp png_ptr, png_const_charp error_message) +{ + if (png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) + png_warning(png_ptr, error_message); + else + png_error(png_ptr, error_message); +} + +void /* PRIVATE */ +png_app_error(png_const_structrp png_ptr, png_const_charp error_message) +{ + if (png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) + png_warning(png_ptr, error_message); + else + png_error(png_ptr, error_message); +} +#endif /* BENIGN_ERRORS */ /* These utilities are used internally to build an error message that relates * to the current chunk. The chunk name comes from png_ptr->chunk_name, @@ -131,186 +410,410 @@ png_warning(png_structp png_ptr, png_const_charp warning_message) * if the character is invalid. */ #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) -/*static PNG_CONST char png_digit[16] = { +static PNG_CONST char png_digit[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' -};*/ +}; -#if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) +#define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */ +#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED) static void /* PRIVATE */ -png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp - error_message) +png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp + error_message) { - int iout = 0, iin = 0; + png_uint_32 chunk_name = png_ptr->chunk_name; + int iout = 0, ishift = 24; - while (iin < 4) + while (ishift >= 0) { - int c = png_ptr->chunk_name[iin++]; + int c = (int)(chunk_name >> ishift) & 0xff; + + ishift -= 8; if (isnonalpha(c)) { - buffer[iout++] = '['; + buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET; buffer[iout++] = png_digit[(c & 0xf0) >> 4]; buffer[iout++] = png_digit[c & 0x0f]; - buffer[iout++] = ']'; + buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET; } + else { - buffer[iout++] = (png_byte)c; + buffer[iout++] = (char)c; } } if (error_message == NULL) - buffer[iout] = 0; + buffer[iout] = '\0'; + else { + int iin = 0; + buffer[iout++] = ':'; buffer[iout++] = ' '; - png_strncpy(buffer+iout, error_message, 63); - buffer[iout+63] = 0; + + while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0') + buffer[iout++] = error_message[iin++]; + + /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */ + buffer[iout] = '\0'; } } +#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */ -#ifdef PNG_READ_SUPPORTED -void PNGAPI -png_chunk_error(png_structp png_ptr, png_const_charp error_message) +#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) +PNG_FUNCTION(void,PNGAPI +png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message), + PNG_NORETURN) { - char msg[18+64]; + char msg[18+PNG_MAX_ERROR_TEXT]; if (png_ptr == NULL) - png_error(png_ptr, error_message); + png_error(png_ptr, error_message); + else { - png_format_buffer(png_ptr, msg, error_message); - png_error(png_ptr, msg); + png_format_buffer(png_ptr, msg, error_message); + png_error(png_ptr, msg); } } -#endif /* PNG_READ_SUPPORTED */ -#endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */ +#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */ -#ifndef PNG_NO_WARNINGS +#ifdef PNG_WARNINGS_SUPPORTED void PNGAPI -png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) +png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message) { - char msg[18+64]; + char msg[18+PNG_MAX_ERROR_TEXT]; if (png_ptr == NULL) - png_warning(png_ptr, warning_message); + png_warning(png_ptr, warning_message); + else { - png_format_buffer(png_ptr, msg, warning_message); - png_warning(png_ptr, msg); + png_format_buffer(png_ptr, msg, warning_message); + png_warning(png_ptr, msg); } } -#endif /* PNG_NO_WARNINGS */ +#endif /* PNG_WARNINGS_SUPPORTED */ +#ifdef PNG_READ_SUPPORTED +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +void PNGAPI +png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp + error_message) +{ + if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) + png_chunk_warning(png_ptr, error_message); + + else + png_chunk_error(png_ptr, error_message); +} +#endif +#endif /* PNG_READ_SUPPORTED */ + +void /* PRIVATE */ +png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error) +{ + /* This is always supported, but for just read or just write it + * unconditionally does the right thing. + */ +# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) + if (png_ptr->mode & PNG_IS_READ_STRUCT) +# endif + +# ifdef PNG_READ_SUPPORTED + { + if (error < PNG_CHUNK_ERROR) + png_chunk_warning(png_ptr, message); + + else + png_chunk_benign_error(png_ptr, message); + } +# endif + +# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) + else if (!(png_ptr->mode & PNG_IS_READ_STRUCT)) +# endif + +# ifdef PNG_WRITE_SUPPORTED + { + if (error < PNG_CHUNK_WRITE_ERROR) + png_app_warning(png_ptr, message); + + else + png_app_error(png_ptr, message); + } +# endif +} + +#ifdef PNG_ERROR_TEXT_SUPPORTED +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_FUNCTION(void, +png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN) +{ +# define fixed_message "fixed point overflow in " +# define fixed_message_ln ((sizeof fixed_message)-1) + int iin; + char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT]; + memcpy(msg, fixed_message, fixed_message_ln); + iin = 0; + if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0) + { + msg[fixed_message_ln + iin] = name[iin]; + ++iin; + } + msg[fixed_message_ln + iin] = 0; + png_error(png_ptr, msg); +} +#endif +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This API only exists if ANSI-C style error handling is used, + * otherwise it is necessary for png_default_error to be overridden. + */ +jmp_buf* PNGAPI +png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn, + size_t jmp_buf_size) +{ + /* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value + * and it must not change after that. Libpng doesn't care how big the + * buffer is, just that it doesn't change. + * + * If the buffer size is no *larger* than the size of jmp_buf when libpng is + * compiled a built in jmp_buf is returned; this preserves the pre-1.6.0 + * semantics that this call will not fail. If the size is larger, however, + * the buffer is allocated and this may fail, causing the function to return + * NULL. + */ + if (png_ptr == NULL) + return NULL; + + if (png_ptr->jmp_buf_ptr == NULL) + { + png_ptr->jmp_buf_size = 0; /* not allocated */ + + if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local)) + png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; + + else + { + png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *, + png_malloc_warn(png_ptr, jmp_buf_size)); + + if (png_ptr->jmp_buf_ptr == NULL) + return NULL; /* new NULL return on OOM */ + + png_ptr->jmp_buf_size = jmp_buf_size; + } + } + + else /* Already allocated: check the size */ + { + size_t size = png_ptr->jmp_buf_size; + + if (size == 0) + { + size = (sizeof png_ptr->jmp_buf_local); + if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local) + { + /* This is an internal error in libpng: somehow we have been left + * with a stack allocated jmp_buf when the application regained + * control. It's always possible to fix this up, but for the moment + * this is a png_error because that makes it easy to detect. + */ + png_error(png_ptr, "Libpng jmp_buf still allocated"); + /* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */ + } + } + + if (size != jmp_buf_size) + { + png_warning(png_ptr, "Application jmp_buf size changed"); + return NULL; /* caller will probably crash: no choice here */ + } + } + + /* Finally fill in the function, now we have a satisfactory buffer. It is + * valid to change the function on every call. + */ + png_ptr->longjmp_fn = longjmp_fn; + return png_ptr->jmp_buf_ptr; +} + +void /* PRIVATE */ +png_free_jmpbuf(png_structrp png_ptr) +{ + if (png_ptr != NULL) + { + jmp_buf *jb = png_ptr->jmp_buf_ptr; + + /* A size of 0 is used to indicate a local, stack, allocation of the + * pointer; used here and in png.c + */ + if (jb != NULL && png_ptr->jmp_buf_size > 0) + { + + /* This stuff is so that a failure to free the error control structure + * does not leave libpng in a state with no valid error handling: the + * free always succeeds, if there is an error it gets ignored. + */ + if (jb != &png_ptr->jmp_buf_local) + { + /* Make an internal, libpng, jmp_buf to return here */ + jmp_buf free_jmp_buf; + + if (!setjmp(free_jmp_buf)) + { + png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */ + png_ptr->jmp_buf_size = 0; /* stack allocation */ + png_ptr->longjmp_fn = longjmp; + png_free(png_ptr, jb); /* Return to setjmp on error */ + } + } + } + + /* *Always* cancel everything out: */ + png_ptr->jmp_buf_size = 0; + png_ptr->jmp_buf_ptr = NULL; + png_ptr->longjmp_fn = 0; + } +} +#endif /* This is the default error handling function. Note that replacements for * this function MUST NOT RETURN, or the program will likely crash. This * function is used by default, or if the program supplies NULL for the * error function pointer in png_set_error_fn(). */ -static void /* PRIVATE */ -png_default_error(png_structp, png_const_charp error_message) +static PNG_FUNCTION(void /* PRIVATE */, +png_default_error,(png_const_structrp png_ptr, png_const_charp error_message), + PNG_NORETURN) { -#ifndef PNG_NO_CONSOLE_IO +#ifdef PNG_CONSOLE_IO_SUPPORTED #ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*error_message == '#') + /* Check on NULL only added in 1.5.4 */ + if (error_message != NULL && *error_message == PNG_LITERAL_SHARP) { - int offset; - char error_number[16]; - for (offset=0; offset<15; offset++) - { - error_number[offset] = *(error_message+offset+1); - if (*(error_message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - error_number[offset-1]='\0'; - fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message+offset); - } - else - fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); + /* Strip "#nnnn " from beginning of error message. */ + int offset; + char error_number[16]; + for (offset = 0; offset<15; offset++) + { + error_number[offset] = error_message[offset + 1]; + if (error_message[offset] == ' ') + break; + } + + if ((offset > 1) && (offset < 15)) + { + error_number[offset - 1] = '\0'; + fprintf(stderr, "libpng error no. %s: %s", + error_number, error_message + offset + 1); + fprintf(stderr, PNG_STRING_NEWLINE); + } + + else + { + fprintf(stderr, "libpng error: %s, offset=%d", + error_message, offset); + fprintf(stderr, PNG_STRING_NEWLINE); + } } else #endif - fprintf(stderr, "libpng error: %s\n", error_message); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - if (png_ptr) { -# ifdef USE_FAR_KEYWORD - { - jmp_buf jmpbuf; - png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf)); - longjmp(jmpbuf, 1); - } -# else - longjmp(png_ptr->jmpbuf, 1); -# endif + fprintf(stderr, "libpng error: %s", error_message ? error_message : + "undefined"); + fprintf(stderr, PNG_STRING_NEWLINE); } #else - PNG_ABORT(); + PNG_UNUSED(error_message) /* Make compiler happy */ #endif -#ifdef PNG_NO_CONSOLE_IO - (void) error_message; /* make compiler happy */ + png_longjmp(png_ptr, 1); +} + +PNG_FUNCTION(void,PNGAPI +png_longjmp,(png_const_structrp, int),PNG_NORETURN) +{ +#ifdef PNG_SETJMP_SUPPORTED + if (png_ptr && png_ptr->longjmp_fn && png_ptr->jmp_buf_ptr) + png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val); #endif + + /* Here if not setjmp support or if png_ptr is null. */ + PNG_ABORT(); } -#ifndef PNG_NO_WARNINGS +#ifdef PNG_WARNINGS_SUPPORTED /* This function is called when there is a warning, but the library thinks * it can continue anyway. Replacement functions don't have to do anything * here if you don't want them to. In the default configuration, png_ptr is * not used, but it is passed in case it may be useful. */ static void /* PRIVATE */ -png_default_warning(png_structp png_ptr, png_const_charp warning_message) +png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message) { -#ifndef PNG_NO_CONSOLE_IO +#ifdef PNG_CONSOLE_IO_SUPPORTED # ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*warning_message == '#') + if (*warning_message == PNG_LITERAL_SHARP) { - int offset; - char warning_number[16]; - for (offset=0; offset<15; offset++) - { - warning_number[offset]=*(warning_message+offset+1); - if (*(warning_message+offset) == ' ') + int offset; + char warning_number[16]; + for (offset = 0; offset < 15; offset++) + { + warning_number[offset] = warning_message[offset + 1]; + if (warning_message[offset] == ' ') break; - } - if((offset > 1) && (offset < 15)) - { - warning_number[offset-1]='\0'; - fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - warning_message+offset); - } - else - fprintf(stderr, "libpng warning: %s\n", warning_message); + } + + if ((offset > 1) && (offset < 15)) + { + warning_number[offset + 1] = '\0'; + fprintf(stderr, "libpng warning no. %s: %s", + warning_number, warning_message + offset); + fprintf(stderr, PNG_STRING_NEWLINE); + } + + else + { + fprintf(stderr, "libpng warning: %s", + warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } } else # endif - fprintf(stderr, "libpng warning: %s\n", warning_message); + + { + fprintf(stderr, "libpng warning: %s", warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } #else - warning_message = warning_message; /* make compiler happy */ + PNG_UNUSED(warning_message) /* Make compiler happy */ #endif - png_ptr = png_ptr; /* make compiler happy */ + PNG_UNUSED(png_ptr) /* Make compiler happy */ } -#endif /* PNG_NO_WARNINGS */ +#endif /* PNG_WARNINGS_SUPPORTED */ /* This function is called when the application wants to use another method * of handling errors and warnings. Note that the error function MUST NOT * return to the calling routine or serious problems will occur. The return - * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) + * method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1) */ void PNGAPI -png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warning_fn) +png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warning_fn) { if (png_ptr == NULL) return; + png_ptr->error_ptr = error_ptr; png_ptr->error_fn = error_fn; +#ifdef PNG_WARNINGS_SUPPORTED png_ptr->warning_fn = warning_fn; +#else + PNG_UNUSED(warning_fn) +#endif } @@ -319,23 +822,111 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, * pointer before png_write_destroy and png_read_destroy are called. */ png_voidp PNGAPI -png_get_error_ptr(png_structp png_ptr) +png_get_error_ptr(png_const_structrp png_ptr) { if (png_ptr == NULL) return NULL; + return ((png_voidp)png_ptr->error_ptr); } #ifdef PNG_ERROR_NUMBERS_SUPPORTED void PNGAPI -png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) +png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode) +{ + if (png_ptr != NULL) + { + png_ptr->flags &= + ((~(PNG_FLAG_STRIP_ERROR_NUMBERS | + PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); + } +} +#endif + +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) + /* Currently the above both depend on SETJMP_SUPPORTED, however it would be + * possible to implement without setjmp support just so long as there is some + * way to handle the error return here: + */ +PNG_FUNCTION(void /* PRIVATE */, +png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message), + PNG_NORETURN) +{ + const png_const_structrp png_ptr = png_nonconst_ptr; + png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); + + /* An error is always logged here, overwriting anything (typically a warning) + * that is already there: + */ + if (image != NULL) + { + png_safecat(image->message, (sizeof image->message), 0, error_message); + image->warning_or_error |= PNG_IMAGE_ERROR; + + /* Retrieve the jmp_buf from within the png_control, making this work for + * C++ compilation too is pretty tricky: C++ wants a pointer to the first + * element of a jmp_buf, but C doesn't tell us the type of that. + */ + if (image->opaque != NULL && image->opaque->error_buf != NULL) + longjmp(png_control_jmp_buf(image->opaque), 1); + + /* Missing longjmp buffer, the following is to help debugging: */ + { + size_t pos = png_safecat(image->message, (sizeof image->message), 0, + "bad longjmp: "); + png_safecat(image->message, (sizeof image->message), pos, + error_message); + } + } + + /* Here on an internal programming error. */ + abort(); +} + +#ifdef PNG_WARNINGS_SUPPORTED +void /* PRIVATE */ +png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message) { - if(png_ptr != NULL) + const png_const_structrp png_ptr = png_nonconst_ptr; + png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); + + /* A warning is only logged if there is no prior warning or error. */ + if (image->warning_or_error == 0) { - png_ptr->flags &= - ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); + png_safecat(image->message, (sizeof image->message), 0, warning_message); + image->warning_or_error |= PNG_IMAGE_WARNING; } } #endif + +int /* PRIVATE */ +png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg) +{ + volatile png_imagep image = image_in; + volatile int result; + volatile png_voidp saved_error_buf; + jmp_buf safe_jmpbuf; + + /* Safely execute function(arg) with png_error returning to this function. */ + saved_error_buf = image->opaque->error_buf; + result = setjmp(safe_jmpbuf) == 0; + + if (result) + { + + image->opaque->error_buf = safe_jmpbuf; + result = function(arg); + } + + image->opaque->error_buf = saved_error_buf; + + /* And do the cleanup prior to any failure return. */ + if (!result) + png_image_free(image); + + return result; +} +#endif /* SIMPLIFIED READ/WRITE */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngget.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngget.c index 0bf989ea5..80ab055dc 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngget.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngget.c @@ -1,615 +1,833 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) png_uint_32 PNGAPI -png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) +png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 flag) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->valid & flag); - else - return(0); + + return(0); } -png_uint_32 PNGAPI -png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) +png_size_t PNGAPI +png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->rowbytes); - else - return(0); + + return(0); } -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_INFO_IMAGE_SUPPORTED png_bytepp PNGAPI -png_get_rows(png_structp png_ptr, png_infop info_ptr) +png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->row_pointers); - else - return(0); + + return(0); } #endif #ifdef PNG_EASY_ACCESS_SUPPORTED -/* easy access to info, added in libpng-0.99 */ +/* Easy access to info, added in libpng-0.99 */ png_uint_32 PNGAPI -png_get_image_width(png_structp png_ptr, png_infop info_ptr) +png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->width; - } + return (0); } png_uint_32 PNGAPI -png_get_image_height(png_structp png_ptr, png_infop info_ptr) +png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->height; - } + return (0); } png_byte PNGAPI -png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) +png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->bit_depth; - } + return (0); } png_byte PNGAPI -png_get_color_type(png_structp png_ptr, png_infop info_ptr) +png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->color_type; - } + return (0); } png_byte PNGAPI -png_get_filter_type(png_structp png_ptr, png_infop info_ptr) +png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->filter_type; - } + return (0); } png_byte PNGAPI -png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) +png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->interlace_type; - } + return (0); } png_byte PNGAPI -png_get_compression_type(png_structp png_ptr, png_infop info_ptr) +png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->compression_type; - } + return (0); } png_uint_32 PNGAPI -png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp + info_ptr) { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); +#ifdef PNG_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) + { + png_debug1(1, "in %s retrieval function", + "png_get_x_pixels_per_meter"); + + if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) + return (info_ptr->x_pixels_per_unit); + } #endif + return (0); } png_uint_32 PNGAPI -png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp + info_ptr) { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) +#ifdef PNG_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->y_pixels_per_unit); + png_debug1(1, "in %s retrieval function", + "png_get_y_pixels_per_meter"); + + if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) + return (info_ptr->y_pixels_per_unit); } -#else - return (0); #endif + return (0); } png_uint_32 PNGAPI -png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) +#ifdef PNG_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || - info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) - return (0); - else return (info_ptr->x_pixels_per_unit); + png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); + + if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && + info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) + return (info_ptr->x_pixels_per_unit); } -#else - return (0); #endif + return (0); } #ifdef PNG_FLOATING_POINT_SUPPORTED float PNGAPI -png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) - { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) +png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp + info_ptr) +{ +#ifdef PNG_READ_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); - if (info_ptr->x_pixels_per_unit == 0) - return ((float)0.0); - else + png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); + + if (info_ptr->x_pixels_per_unit != 0) return ((float)((float)info_ptr->y_pixels_per_unit - /(float)info_ptr->x_pixels_per_unit)); + /(float)info_ptr->x_pixels_per_unit)); } #else - return (0.0); + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) #endif + return ((float)0.0); } #endif -png_int_32 PNGAPI -png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) +#ifdef PNG_FIXED_POINT_SUPPORTED +png_fixed_point PNGAPI +png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, + png_const_inforp info_ptr) { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) +#ifdef PNG_READ_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) + && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 + && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX + && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->x_offset); + png_fixed_point res; + + png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed"); + + /* The following casts work because a PNG 4 byte integer only has a valid + * range of 0..2^31-1; otherwise the cast might overflow. + */ + if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1, + (png_int_32)info_ptr->x_pixels_per_unit)) + return res; } #else - return (0); + PNG_UNUSED(png_ptr) + PNG_UNUSED(info_ptr) #endif - return (0); + + return 0; } +#endif png_int_32 PNGAPI -png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) +png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) +#ifdef PNG_oFFs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->y_offset); + png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); + + if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) + return (info_ptr->x_offset); } -#else - return (0); #endif + return (0); } png_int_32 PNGAPI -png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) +png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) +#ifdef PNG_oFFs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->x_offset); + png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); + + if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) + return (info_ptr->y_offset); } -#else - return (0); #endif + return (0); } png_int_32 PNGAPI -png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) +png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) +#ifdef PNG_oFFs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->y_offset); + png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); + + if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) + return (info_ptr->x_offset); } -#else +#endif + return (0); +} + +png_int_32 PNGAPI +png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ +#ifdef PNG_oFFs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) + { + png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); + + if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) + return (info_ptr->y_offset); + } #endif + return (0); } -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) +#ifdef PNG_INCH_CONVERSIONS_SUPPORTED +static png_uint_32 +ppi_from_ppm(png_uint_32 ppm) +{ +#if 0 + /* The conversion is *(2.54/100), in binary (32 digits): + * .00000110100000001001110101001001 + */ + png_uint_32 t1001, t1101; + ppm >>= 1; /* .1 */ + t1001 = ppm + (ppm >> 3); /* .1001 */ + t1101 = t1001 + (ppm >> 1); /* .1101 */ + ppm >>= 20; /* .000000000000000000001 */ + t1101 += t1101 >> 15; /* .1101000000000001101 */ + t1001 >>= 11; /* .000000000001001 */ + t1001 += t1001 >> 12; /* .000000000001001000000001001 */ + ppm += t1001; /* .000000000001001000001001001 */ + ppm += t1101; /* .110100000001001110101001001 */ + return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ +#else + /* The argument is a PNG unsigned integer, so it is not permitted + * to be bigger than 2^31. + */ + png_fixed_point result; + if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, + 5000)) + return result; + + /* Overflow. */ + return 0; +#endif +} + png_uint_32 PNGAPI -png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) { - return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); + return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr)); } png_uint_32 PNGAPI -png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) { - return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); + return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr)); } png_uint_32 PNGAPI -png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) +{ + return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr)); +} + +#ifdef PNG_FIXED_POINT_SUPPORTED +static png_fixed_point +png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns) { - return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); + /* Convert from metres * 1,000,000 to inches * 100,000, meters to + * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127. + * Notice that this can overflow - a warning is output and 0 is + * returned. + */ + return png_muldiv_warn(png_ptr, microns, 500, 127); } +png_fixed_point PNGAPI +png_get_x_offset_inches_fixed(png_const_structrp png_ptr, + png_const_inforp info_ptr) +{ + return png_fixed_inches_from_microns(png_ptr, + png_get_x_offset_microns(png_ptr, info_ptr)); +} +#endif + +#ifdef PNG_FIXED_POINT_SUPPORTED +png_fixed_point PNGAPI +png_get_y_offset_inches_fixed(png_const_structrp png_ptr, + png_const_inforp info_ptr) +{ + return png_fixed_inches_from_microns(png_ptr, + png_get_y_offset_microns(png_ptr, info_ptr)); +} +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED float PNGAPI -png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) +png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) { - return ((float)png_get_x_offset_microns(png_ptr, info_ptr) - *.00003937); + /* To avoid the overflow do the conversion directly in floating + * point. + */ + return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937); } +#endif +#ifdef PNG_FLOATING_POINT_SUPPORTED float PNGAPI -png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) +png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) { - return ((float)png_get_y_offset_microns(png_ptr, info_ptr) - *.00003937); + /* To avoid the overflow do the conversion directly in floating + * point. + */ + return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937); } +#endif -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED png_uint_32 PNGAPI -png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) { png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function\n", "pHYs"); + png_debug1(1, "in %s retrieval function", "pHYs"); + if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; } + if (res_y != NULL) { *res_y = info_ptr->y_pixels_per_unit; retval |= PNG_INFO_pHYs; } + if (unit_type != NULL) { *unit_type = (int)info_ptr->phys_unit_type; retval |= PNG_INFO_pHYs; - if(*unit_type == 1) + + if (*unit_type == 1) { if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); } } } + return (retval); } #endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ /* png_get_channels really belongs in here, too, but it's been around longer */ #endif /* PNG_EASY_ACCESS_SUPPORTED */ + png_byte PNGAPI -png_get_channels(png_structp png_ptr, png_infop info_ptr) +png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->channels); - else - return (0); + + return (0); } -png_bytep PNGAPI -png_get_signature(png_structp png_ptr, png_infop info_ptr) +#ifdef PNG_READ_SUPPORTED +png_const_bytep PNGAPI +png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->signature); - else - return (NULL); + + return (NULL); } +#endif -#if defined(PNG_bKGD_SUPPORTED) +#ifdef PNG_bKGD_SUPPORTED png_uint_32 PNGAPI -png_get_bKGD(png_structp png_ptr, png_infop info_ptr, +png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, png_color_16p *background) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) - && background != NULL) + && background != NULL) { - png_debug1(1, "in %s retrieval function\n", "bKGD"); + png_debug1(1, "in %s retrieval function", "bKGD"); + *background = &(info_ptr->background); return (PNG_INFO_bKGD); } + return (0); } #endif -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_cHRM_SUPPORTED +/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the + * same time to correct the rgb grayscale coefficient defaults obtained from the + * cHRM chunk in 1.5.4 + */ +# ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_cHRM(png_structp png_ptr, png_infop info_ptr, - double *white_x, double *white_y, double *red_x, double *red_y, - double *green_x, double *green_y, double *blue_x, double *blue_y) +png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, + double *white_x, double *white_y, double *red_x, double *red_y, + double *green_x, double *green_y, double *blue_x, double *blue_y) { - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) + /* Quiet API change: this code used to only return the end points if a cHRM + * chunk was present, but the end points can also come from iCCP or sRGB + * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and + * the png_set_ APIs merely check that set end points are mutually + * consistent. + */ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) { - png_debug1(1, "in %s retrieval function\n", "cHRM"); + png_debug1(1, "in %s retrieval function", "cHRM"); + if (white_x != NULL) - *white_x = (double)info_ptr->x_white; + *white_x = png_float(png_ptr, + info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); if (white_y != NULL) - *white_y = (double)info_ptr->y_white; + *white_y = png_float(png_ptr, + info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); if (red_x != NULL) - *red_x = (double)info_ptr->x_red; + *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx, + "cHRM red X"); if (red_y != NULL) - *red_y = (double)info_ptr->y_red; + *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy, + "cHRM red Y"); if (green_x != NULL) - *green_x = (double)info_ptr->x_green; + *green_x = png_float(png_ptr, + info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); if (green_y != NULL) - *green_y = (double)info_ptr->y_green; + *green_y = png_float(png_ptr, + info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); if (blue_x != NULL) - *blue_x = (double)info_ptr->x_blue; + *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex, + "cHRM blue X"); if (blue_y != NULL) - *blue_y = (double)info_ptr->y_blue; + *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey, + "cHRM blue Y"); return (PNG_INFO_cHRM); } + return (0); } -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED + +png_uint_32 PNGAPI +png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, + double *red_X, double *red_Y, double *red_Z, double *green_X, + double *green_Y, double *green_Z, double *blue_X, double *blue_Y, + double *blue_Z) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) + { + png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); + + if (red_X != NULL) + *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, + "cHRM red X"); + if (red_Y != NULL) + *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, + "cHRM red Y"); + if (red_Z != NULL) + *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z, + "cHRM red Z"); + if (green_X != NULL) + *green_X = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); + if (green_Y != NULL) + *green_Y = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); + if (green_Z != NULL) + *green_Z = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); + if (blue_X != NULL) + *blue_X = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); + if (blue_Y != NULL) + *blue_Y = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); + if (blue_Z != NULL) + *blue_Z = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); + return (PNG_INFO_cHRM); + } + + return (0); +} +# endif + +# ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *int_red_X, png_fixed_point *int_red_Y, + png_fixed_point *int_red_Z, png_fixed_point *int_green_X, + png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, + png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, + png_fixed_point *int_blue_Z) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) + { + png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); + + if (int_red_X != NULL) + *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X; + if (int_red_Y != NULL) + *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y; + if (int_red_Z != NULL) + *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z; + if (int_green_X != NULL) + *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X; + if (int_green_Y != NULL) + *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y; + if (int_green_Z != NULL) + *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z; + if (int_blue_X != NULL) + *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X; + if (int_blue_Y != NULL) + *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y; + if (int_blue_Z != NULL) + *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z; + return (PNG_INFO_cHRM); + } + + return (0); +} + png_uint_32 PNGAPI -png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, - png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, - png_fixed_point *blue_x, png_fixed_point *blue_y) +png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, + png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, + png_fixed_point *blue_x, png_fixed_point *blue_y) { - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) + png_debug1(1, "in %s retrieval function", "cHRM"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) { - png_debug1(1, "in %s retrieval function\n", "cHRM"); if (white_x != NULL) - *white_x = info_ptr->int_x_white; + *white_x = info_ptr->colorspace.end_points_xy.whitex; if (white_y != NULL) - *white_y = info_ptr->int_y_white; + *white_y = info_ptr->colorspace.end_points_xy.whitey; if (red_x != NULL) - *red_x = info_ptr->int_x_red; + *red_x = info_ptr->colorspace.end_points_xy.redx; if (red_y != NULL) - *red_y = info_ptr->int_y_red; + *red_y = info_ptr->colorspace.end_points_xy.redy; if (green_x != NULL) - *green_x = info_ptr->int_x_green; + *green_x = info_ptr->colorspace.end_points_xy.greenx; if (green_y != NULL) - *green_y = info_ptr->int_y_green; + *green_y = info_ptr->colorspace.end_points_xy.greeny; if (blue_x != NULL) - *blue_x = info_ptr->int_x_blue; + *blue_x = info_ptr->colorspace.end_points_xy.bluex; if (blue_y != NULL) - *blue_y = info_ptr->int_y_blue; + *blue_y = info_ptr->colorspace.end_points_xy.bluey; return (PNG_INFO_cHRM); } + return (0); } -#endif +# endif #endif -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_gAMA_SUPPORTED +# ifdef PNG_FIXED_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) +png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *file_gamma) { - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && file_gamma != NULL) + png_debug1(1, "in %s retrieval function", "gAMA"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && + file_gamma != NULL) { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *file_gamma = (double)info_ptr->gamma; + *file_gamma = info_ptr->colorspace.gamma; return (PNG_INFO_gAMA); } + return (0); } -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED +# endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *int_file_gamma) +png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, + double *file_gamma) { - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && int_file_gamma != NULL) + png_debug1(1, "in %s retrieval function", "gAMA(float)"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) && + file_gamma != NULL) { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *int_file_gamma = info_ptr->int_gamma; + *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, + "png_get_gAMA"); return (PNG_INFO_gAMA); } + return (0); } -#endif +# endif #endif -#if defined(PNG_sRGB_SUPPORTED) +#ifdef PNG_sRGB_SUPPORTED png_uint_32 PNGAPI -png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) +png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, + int *file_srgb_intent) { + png_debug1(1, "in %s retrieval function", "sRGB"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) - && file_srgb_intent != NULL) + && file_srgb_intent != NULL) { - png_debug1(1, "in %s retrieval function\n", "sRGB"); - *file_srgb_intent = (int)info_ptr->srgb_intent; + *file_srgb_intent = info_ptr->colorspace.rendering_intent; return (PNG_INFO_sRGB); } + return (0); } #endif -#if defined(PNG_iCCP_SUPPORTED) +#ifdef PNG_iCCP_SUPPORTED png_uint_32 PNGAPI -png_get_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen) +png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, + png_charpp name, int *compression_type, + png_bytepp profile, png_uint_32 *proflen) { + png_debug1(1, "in %s retrieval function", "iCCP"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) - && name != NULL && profile != NULL && proflen != NULL) + && name != NULL && compression_type != NULL && profile != NULL && + proflen != NULL) { - png_debug1(1, "in %s retrieval function\n", "iCCP"); *name = info_ptr->iccp_name; *profile = info_ptr->iccp_profile; - /* compression_type is a dummy so the API won't have to change - if we introduce multiple compression types later. */ - *proflen = (int)info_ptr->iccp_proflen; - *compression_type = (int)info_ptr->iccp_compression; + *proflen = png_get_uint_32(info_ptr->iccp_profile); + /* This is somewhat irrelevant since the profile data returned has + * actually been uncompressed. + */ + *compression_type = PNG_COMPRESSION_TYPE_BASE; return (PNG_INFO_iCCP); } + return (0); } #endif -#if defined(PNG_sPLT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sPLT(png_structp png_ptr, png_infop info_ptr, - png_sPLT_tpp spalettes) +#ifdef PNG_sPLT_SUPPORTED +int PNGAPI +png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, + png_sPLT_tpp spalettes) { if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) { - *spalettes = info_ptr->splt_palettes; - return ((png_uint_32)info_ptr->splt_palettes_num); + *spalettes = info_ptr->splt_palettes; + return info_ptr->splt_palettes_num; } + return (0); } #endif -#if defined(PNG_hIST_SUPPORTED) +#ifdef PNG_hIST_SUPPORTED png_uint_32 PNGAPI -png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) +png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr, + png_uint_16p *hist) { + png_debug1(1, "in %s retrieval function", "hIST"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) - && hist != NULL) + && hist != NULL) { - png_debug1(1, "in %s retrieval function\n", "hIST"); *hist = info_ptr->hist; return (PNG_INFO_hIST); } + return (0); } #endif png_uint_32 PNGAPI -png_get_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *width, png_uint_32 *height, int *bit_depth, - int *color_type, int *interlace_type, int *compression_type, - int *filter_type) - +png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 *width, png_uint_32 *height, int *bit_depth, + int *color_type, int *interlace_type, int *compression_type, + int *filter_type) { - if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && - bit_depth != NULL && color_type != NULL) - { - png_debug1(1, "in %s retrieval function\n", "IHDR"); - *width = info_ptr->width; - *height = info_ptr->height; - *bit_depth = info_ptr->bit_depth; - if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) - png_error(png_ptr, "Invalid bit depth"); - *color_type = info_ptr->color_type; - if (info_ptr->color_type > 6) - png_error(png_ptr, "Invalid color type"); - if (compression_type != NULL) - *compression_type = info_ptr->compression_type; - if (filter_type != NULL) - *filter_type = info_ptr->filter_type; - if (interlace_type != NULL) - *interlace_type = info_ptr->interlace_type; + png_debug1(1, "in %s retrieval function", "IHDR"); - /* check for potential overflow of rowbytes */ - if (*width == 0 || *width > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image width"); - if (*height == 0 || *height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image height"); - if (info_ptr->width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - { - png_warning(png_ptr, - "Width too large for libpng to process image data."); - } - return (1); - } - return (0); + if (png_ptr == NULL || info_ptr == NULL || width == NULL || + height == NULL || bit_depth == NULL || color_type == NULL) + return (0); + + *width = info_ptr->width; + *height = info_ptr->height; + *bit_depth = info_ptr->bit_depth; + *color_type = info_ptr->color_type; + + if (compression_type != NULL) + *compression_type = info_ptr->compression_type; + + if (filter_type != NULL) + *filter_type = info_ptr->filter_type; + + if (interlace_type != NULL) + *interlace_type = info_ptr->interlace_type; + + /* This is redundant if we can be sure that the info_ptr values were all + * assigned in png_set_IHDR(). We do the check anyhow in case an + * application has ignored our advice not to mess with the members + * of info_ptr directly. + */ + png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, + info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, + info_ptr->compression_type, info_ptr->filter_type); + + return (1); } -#if defined(PNG_oFFs_SUPPORTED) +#ifdef PNG_oFFs_SUPPORTED png_uint_32 PNGAPI -png_get_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) +png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) { + png_debug1(1, "in %s retrieval function", "oFFs"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) - && offset_x != NULL && offset_y != NULL && unit_type != NULL) + && offset_x != NULL && offset_y != NULL && unit_type != NULL) { - png_debug1(1, "in %s retrieval function\n", "oFFs"); *offset_x = info_ptr->x_offset; *offset_y = info_ptr->y_offset; *unit_type = (int)info_ptr->offset_unit_type; return (PNG_INFO_oFFs); } + return (0); } #endif -#if defined(PNG_pCAL_SUPPORTED) +#ifdef PNG_pCAL_SUPPORTED png_uint_32 PNGAPI -png_get_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, - png_charp *units, png_charpp *params) +png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, + png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, + png_charp *units, png_charpp *params) { + png_debug1(1, "in %s retrieval function", "pCAL"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) - && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && - nparams != NULL && units != NULL && params != NULL) + && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && + nparams != NULL && units != NULL && params != NULL) { - png_debug1(1, "in %s retrieval function\n", "pCAL"); *purpose = info_ptr->pcal_purpose; *X0 = info_ptr->pcal_X0; *X1 = info_ptr->pcal_X1; @@ -619,281 +837,341 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr, *params = info_ptr->pcal_params; return (PNG_INFO_pCAL); } + return (0); } #endif -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_sCAL_SUPPORTED +# ifdef PNG_FIXED_POINT_SUPPORTED +# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ + defined(PNG_FLOATING_POINT_SUPPORTED) png_uint_32 PNGAPI -png_get_sCAL(png_structp png_ptr, png_infop info_ptr, - int *unit, double *width, double *height) +png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + int *unit, png_fixed_point *width, png_fixed_point *height) { - if (png_ptr != NULL && info_ptr != NULL && + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_pixel_width; - *height = info_ptr->scal_pixel_height; - return (PNG_INFO_sCAL); - } - return(0); + { + *unit = info_ptr->scal_unit; + /*TODO: make this work without FP support; the API is currently eliminated + * if neither floating point APIs nor internal floating point arithmetic + * are enabled. + */ + *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); + *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), + "sCAL height"); + return (PNG_INFO_sCAL); + } + + return(0); } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED +# endif /* FLOATING_ARITHMETIC */ +# endif /* FIXED_POINT */ +# ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int *unit, png_charpp width, png_charpp height) +png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, + int *unit, double *width, double *height) { - if (png_ptr != NULL && info_ptr != NULL && + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_s_width; - *height = info_ptr->scal_s_height; - return (PNG_INFO_sCAL); - } - return(0); + { + *unit = info_ptr->scal_unit; + *width = atof(info_ptr->scal_s_width); + *height = atof(info_ptr->scal_s_height); + return (PNG_INFO_sCAL); + } + + return(0); } -#endif -#endif -#endif +# endif /* FLOATING POINT */ +png_uint_32 PNGAPI +png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, + int *unit, png_charpp width, png_charpp height) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sCAL)) + { + *unit = info_ptr->scal_unit; + *width = info_ptr->scal_s_width; + *height = info_ptr->scal_s_height; + return (PNG_INFO_sCAL); + } -#if defined(PNG_pHYs_SUPPORTED) + return(0); +} +#endif /* sCAL */ + +#ifdef PNG_pHYs_SUPPORTED png_uint_32 PNGAPI -png_get_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) { png_uint_32 retval = 0; + png_debug1(1, "in %s retrieval function", "pHYs"); + if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs)) + (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function\n", "pHYs"); if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; } + if (res_y != NULL) { *res_y = info_ptr->y_pixels_per_unit; retval |= PNG_INFO_pHYs; } + if (unit_type != NULL) { *unit_type = (int)info_ptr->phys_unit_type; retval |= PNG_INFO_pHYs; } } + return (retval); } -#endif +#endif /* pHYs */ png_uint_32 PNGAPI -png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, - int *num_palette) +png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, + png_colorp *palette, int *num_palette) { + png_debug1(1, "in %s retrieval function", "PLTE"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) && palette != NULL) { - png_debug1(1, "in %s retrieval function\n", "PLTE"); *palette = info_ptr->palette; *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d\n", *num_palette); + png_debug1(3, "num_palette = %d", *num_palette); return (PNG_INFO_PLTE); } + return (0); } -#if defined(PNG_sBIT_SUPPORTED) +#ifdef PNG_sBIT_SUPPORTED png_uint_32 PNGAPI -png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) +png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, + png_color_8p *sig_bit) { + png_debug1(1, "in %s retrieval function", "sBIT"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) - && sig_bit != NULL) + && sig_bit != NULL) { - png_debug1(1, "in %s retrieval function\n", "sBIT"); *sig_bit = &(info_ptr->sig_bit); return (PNG_INFO_sBIT); } + return (0); } #endif -#if defined(PNG_TEXT_SUPPORTED) -png_uint_32 PNGAPI -png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, - int *num_text) +#ifdef PNG_TEXT_SUPPORTED +int PNGAPI +png_get_text(png_const_structrp png_ptr, png_inforp info_ptr, + png_textp *text_ptr, int *num_text) { if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) { - png_debug1(1, "in %s retrieval function\n", - (png_ptr->chunk_name[0] == '\0' ? "text" - : (png_const_charp)png_ptr->chunk_name)); + png_debug1(1, "in 0x%lx retrieval function", + (unsigned long)png_ptr->chunk_name); + if (text_ptr != NULL) *text_ptr = info_ptr->text; + if (num_text != NULL) *num_text = info_ptr->num_text; - return ((png_uint_32)info_ptr->num_text); + + return info_ptr->num_text; } + if (num_text != NULL) - *num_text = 0; + *num_text = 0; + return(0); } #endif -#if defined(PNG_tIME_SUPPORTED) +#ifdef PNG_tIME_SUPPORTED png_uint_32 PNGAPI -png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) +png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, + png_timep *mod_time) { + png_debug1(1, "in %s retrieval function", "tIME"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) && mod_time != NULL) { - png_debug1(1, "in %s retrieval function\n", "tIME"); *mod_time = &(info_ptr->mod_time); return (PNG_INFO_tIME); } + return (0); } #endif -#if defined(PNG_tRNS_SUPPORTED) +#ifdef PNG_tRNS_SUPPORTED png_uint_32 PNGAPI -png_get_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep *trans, int *num_trans, png_color_16p *trans_values) +png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, + png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) { png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { - png_debug1(1, "in %s retrieval function\n", "tRNS"); + png_debug1(1, "in %s retrieval function", "tRNS"); + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - if (trans != NULL) - { - *trans = info_ptr->trans; - retval |= PNG_INFO_tRNS; - } - if (trans_values != NULL) - *trans_values = &(info_ptr->trans_values); + if (trans_alpha != NULL) + { + *trans_alpha = info_ptr->trans_alpha; + retval |= PNG_INFO_tRNS; + } + + if (trans_color != NULL) + *trans_color = &(info_ptr->trans_color); } + else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ { - if (trans_values != NULL) - { - *trans_values = &(info_ptr->trans_values); - retval |= PNG_INFO_tRNS; - } - if(trans != NULL) - *trans = NULL; + if (trans_color != NULL) + { + *trans_color = &(info_ptr->trans_color); + retval |= PNG_INFO_tRNS; + } + + if (trans_alpha != NULL) + *trans_alpha = NULL; } - if(num_trans != NULL) + + if (num_trans != NULL) { *num_trans = info_ptr->num_trans; retval |= PNG_INFO_tRNS; } } + return (retval); } #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -png_uint_32 PNGAPI -png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, - png_unknown_chunkpp unknowns) +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +int PNGAPI +png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr, + png_unknown_chunkpp unknowns) { if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) { - *unknowns = info_ptr->unknown_chunks; - return ((png_uint_32)info_ptr->unknown_chunks_num); + *unknowns = info_ptr->unknown_chunks; + return info_ptr->unknown_chunks_num; } + return (0); } #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED png_byte PNGAPI -png_get_rgb_to_gray_status (png_structp png_ptr) +png_get_rgb_to_gray_status (png_const_structrp png_ptr) { - return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); + return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0); } #endif -#if defined(PNG_USER_CHUNKS_SUPPORTED) +#ifdef PNG_USER_CHUNKS_SUPPORTED png_voidp PNGAPI -png_get_user_chunk_ptr(png_structp png_ptr) +png_get_user_chunk_ptr(png_const_structrp png_ptr) { - return (png_ptr? png_ptr->user_chunk_ptr : NULL); + return (png_ptr ? png_ptr->user_chunk_ptr : NULL); } #endif -#ifdef PNG_WRITE_SUPPORTED -png_uint_32 PNGAPI -png_get_compression_buffer_size(png_structp png_ptr) +png_size_t PNGAPI +png_get_compression_buffer_size(png_const_structrp png_ptr) { - return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); + if (png_ptr == NULL) + return 0; + +# ifdef PNG_WRITE_SUPPORTED + if (png_ptr->mode & PNG_IS_READ_STRUCT) +# endif + { +# ifdef PNG_SEQUENTIAL_READ_SUPPORTED + return png_ptr->IDAT_read_size; +# else + return PNG_IDAT_READ_SIZE; +# endif + } + +# ifdef PNG_WRITE_SUPPORTED + else + return png_ptr->zbuffer_size; +# endif } -#endif -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifndef PNG_1_0_X -/* this function was added to libpng 1.2.0 and should exist by default */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +/* These functions were added to libpng 1.2.6 and were enabled + * by default in libpng-1.4.0 */ png_uint_32 PNGAPI -png_get_asm_flags (png_structp png_ptr) +png_get_user_width_max (png_const_structrp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ - return (png_ptr? 0L: 0L); + return (png_ptr ? png_ptr->user_width_max : 0); } -/* this function was added to libpng 1.2.0 and should exist by default */ png_uint_32 PNGAPI -png_get_asm_flagmask (int) +png_get_user_height_max (png_const_structrp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ - return 0L; + return (png_ptr ? png_ptr->user_height_max : 0); } - /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ -/* this function was added to libpng 1.2.0 */ +/* This function was added to libpng 1.4.0 */ png_uint_32 PNGAPI -png_get_mmx_flagmask (int, int *compilerID) +png_get_chunk_cache_max (png_const_structrp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ - *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ - return 0L; + return (png_ptr ? png_ptr->user_chunk_cache_max : 0); } -/* this function was added to libpng 1.2.0 */ -png_byte PNGAPI -png_get_mmx_bitdepth_threshold (png_structp png_ptr) +/* This function was added to libpng 1.4.1 */ +png_alloc_size_t PNGAPI +png_get_chunk_malloc_max (png_const_structrp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ - return (png_ptr? 0: 0); + return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); } +#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ -/* this function was added to libpng 1.2.0 */ +/* These functions were added to libpng 1.4.0 */ +#ifdef PNG_IO_STATE_SUPPORTED png_uint_32 PNGAPI -png_get_mmx_rowbytes_threshold (png_structp png_ptr) +png_get_io_state (png_const_structrp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ - return (png_ptr? 0L: 0L); + return png_ptr->io_state; } -#endif /* ?PNG_1_0_X */ -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* these functions were added to libpng 1.2.6 */ png_uint_32 PNGAPI -png_get_user_width_max (png_structp png_ptr) +png_get_io_chunk_type (png_const_structrp png_ptr) { - return (png_ptr? png_ptr->user_width_max : 0); + return png_ptr->chunk_name; } -png_uint_32 PNGAPI -png_get_user_height_max (png_structp png_ptr) +#endif /* ?PNG_IO_STATE_SUPPORTED */ + +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED +# ifdef PNG_GET_PALETTE_MAX_SUPPORTED +int PNGAPI +png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr) { - return (png_ptr? png_ptr->user_height_max : 0); -} -#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ + if (png_ptr != NULL && info_ptr != NULL) + return png_ptr->num_palette_max; + return (-1); +} +# endif +#endif #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pnginfo.h b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pnginfo.h new file mode 100644 index 000000000..898a40656 --- /dev/null +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pnginfo.h @@ -0,0 +1,260 @@ + +/* pnginfo.h - header file for PNG reference library + * + * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * Last changed in libpng 1.6.1 [March 28, 2013] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + + /* png_info is a structure that holds the information in a PNG file so + * that the application can find out the characteristics of the image. + * If you are reading the file, this structure will tell you what is + * in the PNG file. If you are writing the file, fill in the information + * you want to put into the PNG file, using png_set_*() functions, then + * call png_write_info(). + * + * The names chosen should be very close to the PNG specification, so + * consult that document for information about the meaning of each field. + * + * With libpng < 0.95, it was only possible to directly set and read the + * the values in the png_info_struct, which meant that the contents and + * order of the values had to remain fixed. With libpng 0.95 and later, + * however, there are now functions that abstract the contents of + * png_info_struct from the application, so this makes it easier to use + * libpng with dynamic libraries, and even makes it possible to use + * libraries that don't have all of the libpng ancillary chunk-handing + * functionality. In libpng-1.5.0 this was moved into a separate private + * file that is not visible to applications. + * + * The following members may have allocated storage attached that should be + * cleaned up before the structure is discarded: palette, trans, text, + * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, + * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these + * are automatically freed when the info structure is deallocated, if they were + * allocated internally by libpng. This behavior can be changed by means + * of the png_data_freer() function. + * + * More allocation details: all the chunk-reading functions that + * change these members go through the corresponding png_set_* + * functions. A function to clear these members is available: see + * png_free_data(). The png_set_* functions do not depend on being + * able to point info structure members to any of the storage they are + * passed (they make their own copies), EXCEPT that the png_set_text + * functions use the same storage passed to them in the text_ptr or + * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns + * functions do not make their own copies. + */ +#ifndef PNGINFO_H +#define PNGINFO_H + +struct png_info_def +{ + /* The following are necessary for every PNG file */ + png_uint_32 width; /* width of image in pixels (from IHDR) */ + png_uint_32 height; /* height of image in pixels (from IHDR) */ + png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ + png_size_t rowbytes; /* bytes needed to hold an untransformed row */ + png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ + png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ + png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ + png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ + png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ + /* The following three should have been named *_method not *_type */ + png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ + png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ + png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + + /* The following are set by png_set_IHDR, called from the application on + * write, but the are never actually used by the write code. + */ + png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte spare_byte; /* to align the data, and for future use */ + +#ifdef PNG_READ_SUPPORTED + /* This is never set during write */ + png_byte signature[8]; /* magic bytes read by libpng from start of file */ +#endif + + /* The rest of the data is optional. If you are reading, check the + * valid field to see if the information in these are valid. If you + * are writing, set the valid field to those chunks you want written, + * and initialize the appropriate fields below. + */ + +#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) + /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are + * defined. When COLORSPACE is switched on all the colorspace-defining + * chunks should be enabled, when GAMMA is switched on all the gamma-defining + * chunks should be enabled. If this is not done it becomes possible to read + * inconsistent PNG files and assign a probably incorrect interpretation to + * the information. (In other words, by carefully choosing which chunks to + * recognize the system configuration can select an interpretation for PNG + * files containing ambiguous data and this will result in inconsistent + * behavior between different libpng builds!) + */ + png_colorspace colorspace; +#endif + +#ifdef PNG_iCCP_SUPPORTED + /* iCCP chunk data. */ + png_charp iccp_name; /* profile name */ + png_bytep iccp_profile; /* International Color Consortium profile data */ + png_uint_32 iccp_proflen; /* ICC profile data length */ +#endif + +#ifdef PNG_TEXT_SUPPORTED + /* The tEXt, and zTXt chunks contain human-readable textual data in + * uncompressed, compressed, and optionally compressed forms, respectively. + * The data in "text" is an array of pointers to uncompressed, + * null-terminated C strings. Each chunk has a keyword that describes the + * textual data contained in that chunk. Keywords are not required to be + * unique, and the text string may be empty. Any number of text chunks may + * be in an image. + */ + int num_text; /* number of comments read or comments to write */ + int max_text; /* current size of text array */ + png_textp text; /* array of comments read or comments to write */ +#endif /* PNG_TEXT_SUPPORTED */ + +#ifdef PNG_tIME_SUPPORTED + /* The tIME chunk holds the last time the displayed image data was + * modified. See the png_time struct for the contents of this struct. + */ + png_time mod_time; +#endif + +#ifdef PNG_sBIT_SUPPORTED + /* The sBIT chunk specifies the number of significant high-order bits + * in the pixel data. Values are in the range [1, bit_depth], and are + * only specified for the channels in the pixel data. The contents of + * the low-order bits is not specified. Data is valid if + * (valid & PNG_INFO_sBIT) is non-zero. + */ + png_color_8 sig_bit; /* significant bits in color channels */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ +defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The tRNS chunk supplies transparency data for paletted images and + * other image types that don't need a full alpha channel. There are + * "num_trans" transparency values for a paletted image, stored in the + * same order as the palette colors, starting from index 0. Values + * for the data are in the range [0, 255], ranging from fully transparent + * to fully opaque, respectively. For non-paletted images, there is a + * single color specified that should be treated as fully transparent. + * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. + */ + png_bytep trans_alpha; /* alpha values for paletted image */ + png_color_16 trans_color; /* transparent color for non-palette image */ +#endif + +#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The bKGD chunk gives the suggested image background color if the + * display program does not have its own background color and the image + * is needs to composited onto a background before display. The colors + * in "background" are normally in the same color space/depth as the + * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. + */ + png_color_16 background; +#endif + +#ifdef PNG_oFFs_SUPPORTED + /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards + * and downwards from the top-left corner of the display, page, or other + * application-specific co-ordinate space. See the PNG_OFFSET_ defines + * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. + */ + png_int_32 x_offset; /* x offset on page */ + png_int_32 y_offset; /* y offset on page */ + png_byte offset_unit_type; /* offset units type */ +#endif + +#ifdef PNG_pHYs_SUPPORTED + /* The pHYs chunk gives the physical pixel density of the image for + * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ + * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. + */ + png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ + png_uint_32 y_pixels_per_unit; /* vertical pixel density */ + png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ +#endif + +#ifdef PNG_hIST_SUPPORTED + /* The hIST chunk contains the relative frequency or importance of the + * various palette entries, so that a viewer can intelligently select a + * reduced-color palette, if required. Data is an array of "num_palette" + * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) + * is non-zero. + */ + png_uint_16p hist; +#endif + +#ifdef PNG_pCAL_SUPPORTED + /* The pCAL chunk describes a transformation between the stored pixel + * values and original physical data values used to create the image. + * The integer range [0, 2^bit_depth - 1] maps to the floating-point + * range given by [pcal_X0, pcal_X1], and are further transformed by a + * (possibly non-linear) transformation function given by "pcal_type" + * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ + * defines below, and the PNG-Group's PNG extensions document for a + * complete description of the transformations and how they should be + * implemented, and for a description of the ASCII parameter strings. + * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. + */ + png_charp pcal_purpose; /* pCAL chunk description string */ + png_int_32 pcal_X0; /* minimum value */ + png_int_32 pcal_X1; /* maximum value */ + png_charp pcal_units; /* Latin-1 string giving physical units */ + png_charpp pcal_params; /* ASCII strings containing parameter values */ + png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ + png_byte pcal_nparams; /* number of parameters given in pcal_params */ +#endif + +/* New members added in libpng-1.0.6 */ + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ + +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED + /* Storage for unknown chunks that the library doesn't recognize. */ + png_unknown_chunkp unknown_chunks; + + /* The type of this field is limited by the type of + * png_struct::user_chunk_cache_max, else overflow can occur. + */ + int unknown_chunks_num; +#endif + +#ifdef PNG_sPLT_SUPPORTED + /* Data on sPLT chunks (there may be more than one). */ + png_sPLT_tp splt_palettes; + int splt_palettes_num; /* Match type returned by png_get API */ +#endif + +#ifdef PNG_sCAL_SUPPORTED + /* The sCAL chunk describes the actual physical dimensions of the + * subject matter of the graphic. The chunk contains a unit specification + * a byte value, and two ASCII strings representing floating-point + * values. The values are width and height corresponsing to one pixel + * in the image. Data values are valid if (valid & PNG_INFO_sCAL) is + * non-zero. + */ + png_byte scal_unit; /* unit of physical scale */ + png_charp scal_s_width; /* string containing height */ + png_charp scal_s_height; /* string containing width */ +#endif + +#ifdef PNG_INFO_IMAGE_SUPPORTED + /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) + non-zero */ + /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ + png_bytepp row_pointers; /* the image bits */ +#endif + +}; +#endif /* PNGINFO_H */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngmem.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngmem.c index 6aa70af4c..43e294850 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngmem.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngmem.c @@ -1,12 +1,15 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * Last changed in libpng 1.6.0 [February 14, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file provides a location for all memory allocation. Users who * need special memory handling are expected to supply replacement * functions for png_malloc() and png_free(), and to use @@ -14,569 +17,232 @@ * identify the replacement functions. */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -/* Borland DOS special memory handler */ -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* if you change this, be sure to change the one in png.h also */ - -/* Allocate memory for a png_struct. The malloc and memset can be replaced - by a single call to calloc() if this is thought to improve performance. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); -} - -/* Alternate version of png_create_struct, for use with user-defined malloc. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = png_sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = png_sizeof(png_struct); - else - return (png_get_copyright(NULL)); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); - } - else -#endif /* PNG_USER_MEM_SUPPORTED */ - struct_ptr = (png_voidp)farmalloc(size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); -} - -/* Free memory allocated by a png_create_struct() call */ +/* Free a png_struct */ void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) +png_destroy_png_struct(png_structrp png_ptr) { -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif - if (struct_ptr != NULL) + if (png_ptr != NULL) { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ - farfree (struct_ptr); + /* png_free might call png_error and may certainly call + * png_get_mem_ptr, so fake a temporary png_struct to support this. + */ + png_struct dummy_struct = *png_ptr; + memset(png_ptr, 0, (sizeof *png_ptr)); + png_free(&dummy_struct, png_ptr); + +# ifdef PNG_SETJMP_SUPPORTED + /* We may have a jmp_buf left to deallocate. */ + png_free_jmpbuf(&dummy_struct); +# endif } } /* Allocate memory. For reasonable files, size should never exceed * 64K. However, zlib may allocate more then 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does + * it not to. See zconf.h and png.h for more information. zlib does * need to allocate exactly 64K, so whatever you call here must * have the ability to do that. - * - * Borland seems to have a problem in DOS mode for exactly 64K. - * It gives you a segment with an offset of 8 (perhaps to store its - * memory stuff). zlib doesn't like this at all, so we have to - * detect and deal with it. This code should not be needed in - * Windows or OS/2 modes, and only in 16 bit mode. This code has - * been updated by Alexander Lehmann for version 0.89 to waste less - * memory. - * - * Note that we can't use png_size_t for the "size" declaration, - * since on some systems a png_size_t is a 16-bit quantity, and as a - * result, we would be truncating potentially larger memory requests - * (which should cause a fatal error) and introducing major problems. */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) +PNG_FUNCTION(png_voidp,PNGAPI +png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) { png_voidp ret; - if (png_ptr == NULL || size == 0) - return (NULL); + ret = png_malloc(png_ptr, size); -#ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - else - ret = (png_malloc_default(png_ptr, size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory!"); - return (ret); + if (ret != NULL) + memset(ret, 0, size); + + return ret; } -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) +/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of + * allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED. + * Checking and error handling must happen outside this routine; it returns NULL + * if the allocation cannot be done (for any reason.) + */ +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_malloc_base,(png_const_structrp, png_alloc_size_t size), + PNG_ALLOCATED) { - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - { - png_warning(png_ptr, "Cannot Allocate > 64K"); - ret = NULL; - } - else + /* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS + * allocators have also been removed in 1.6.0, so any 16-bit system now has + * to implement a user memory handler. This checks to be sure it isn't + * called with big numbers. + */ +#ifdef PNG_USER_MEM_SUPPORTED + PNG_UNUSED(png_ptr) #endif - - if (size != (size_t)size) - ret = NULL; - else if (size == (png_uint_32)65536L) + if (size > 0 && size <= PNG_SIZE_MAX +# ifdef PNG_MAX_MALLOC_64K + && size <= 65536U +# endif + ) { - if (png_ptr->offset_table == NULL) - { - /* try to see if we need to do any of this fancy stuff */ - ret = farmalloc(size); - if (ret == NULL || ((png_size_t)ret & 0xffff)) - { - int num_blocks; - png_uint_32 total_size; - png_bytep table; - int i; - png_byte huge * hptr; - - if (ret != NULL) - { - farfree(ret); - ret = NULL; - } - - if(png_ptr->zlib_window_bits > 14) - num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); - else - num_blocks = 1; - if (png_ptr->zlib_mem_level >= 7) - num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); - else - num_blocks++; - - total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; - - table = farmalloc(total_size); - - if (table == NULL) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of Memory."); -#endif - return (NULL); - } - - if ((png_size_t)table & 0xfff0) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, - "Farmalloc didn't return normalized pointer"); - else - png_warning(png_ptr, - "Farmalloc didn't return normalized pointer"); -#endif - return (NULL); - } - - png_ptr->offset_table = table; - png_ptr->offset_table_ptr = farmalloc(num_blocks * - png_sizeof (png_bytep)); - - if (png_ptr->offset_table_ptr == NULL) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ - else - png_warning(png_ptr, "Out Of memory."); -#endif - return (NULL); - } - - hptr = (png_byte huge *)table; - if ((png_size_t)hptr & 0xf) - { - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ - } - for (i = 0; i < num_blocks; i++) - { - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ - } - - png_ptr->offset_table_number = num_blocks; - png_ptr->offset_table_count = 0; - png_ptr->offset_table_count_free = 0; - } - } - - if (png_ptr->offset_table_count >= png_ptr->offset_table_number) - { -#ifndef PNG_USER_MEM_SUPPORTED - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ - else - png_warning(png_ptr, "Out of Memory."); -#endif - return (NULL); - } - - ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; - } - else - ret = farmalloc(size); +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr != NULL && png_ptr->malloc_fn != NULL) + return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size); -#ifndef PNG_USER_MEM_SUPPORTED - if (ret == NULL) - { - if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ else - png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ - } #endif + return malloc((size_t)size); /* checked for truncation above */ + } - return (ret); + else + return NULL; } -/* free a pointer allocated by png_malloc(). In the default - configuration, png_ptr is not used, but is passed in case it - is needed. If ptr is NULL, return without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) +/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7 + * that arises because of the checks in png_realloc_array that are repeated in + * png_malloc_array. + */ +static png_voidp +png_malloc_array_checked(png_const_structrp png_ptr, int nelements, + size_t element_size) { - if (png_ptr == NULL || ptr == NULL) - return; + png_alloc_size_t req = nelements; /* known to be > 0 */ -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); + if (req <= PNG_SIZE_MAX/element_size) + return png_malloc_base(png_ptr, req * element_size); + + /* The failure case when the request is too large */ + return NULL; } -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_malloc_array,(png_const_structrp png_ptr, int nelements, + size_t element_size),PNG_ALLOCATED) { -#endif /* PNG_USER_MEM_SUPPORTED */ + if (nelements <= 0 || element_size == 0) + png_error(png_ptr, "internal error: array alloc"); - if(png_ptr == NULL) return; + return png_malloc_array_checked(png_ptr, nelements, element_size); +} - if (png_ptr->offset_table != NULL) +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, + int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED) +{ + /* These are internal errors: */ + if (add_elements <= 0 || element_size == 0 || old_elements < 0 || + (old_array == NULL && old_elements > 0)) + png_error(png_ptr, "internal error: array realloc"); + + /* Check for overflow on the elements count (so the caller does not have to + * check.) + */ + if (add_elements <= INT_MAX - old_elements) { - int i; + png_voidp new_array = png_malloc_array_checked(png_ptr, + old_elements+add_elements, element_size); - for (i = 0; i < png_ptr->offset_table_count; i++) - { - if (ptr == png_ptr->offset_table_ptr[i]) - { - ptr = NULL; - png_ptr->offset_table_count_free++; - break; - } - } - if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) + if (new_array != NULL) { - farfree(png_ptr->offset_table); - farfree(png_ptr->offset_table_ptr); - png_ptr->offset_table = NULL; - png_ptr->offset_table_ptr = NULL; - } - } + /* Because png_malloc_array worked the size calculations below cannot + * overflow. + */ + if (old_elements > 0) + memcpy(new_array, old_array, element_size*(unsigned)old_elements); - if (ptr != NULL) - { - farfree(ptr); - } -} + memset((char*)new_array + element_size*(unsigned)old_elements, 0, + element_size*(unsigned)add_elements); -#else /* Not the Borland DOS special memory handler */ + return new_array; + } + } -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); + return NULL; /* error */ } -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +/* Various functions that have different error handling are derived from this. + * png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate + * function png_malloc_default is also provided. + */ +PNG_FUNCTION(png_voidp,PNGAPI +png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) { -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; + png_voidp ret; - if (type == PNG_STRUCT_INFO) - size = png_sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = png_sizeof(png_struct); - else - return (NULL); + if (png_ptr == NULL) + return NULL; -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); - } -#endif /* PNG_USER_MEM_SUPPORTED */ + ret = png_malloc_base(png_ptr, size); -#if defined(__TURBOC__) && !defined(__FLAT__) - struct_ptr = (png_voidp)farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - struct_ptr = (png_voidp)halloc(size,1); -# else - struct_ptr = (png_voidp)malloc(size); -# endif -#endif - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); + if (ret == NULL) + png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */ - return (struct_ptr); + return ret; } - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) +PNG_FUNCTION(png_voidp,PNGAPI +png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), + PNG_ALLOCATED PNG_DEPRECATED) { -#endif /* PNG_USER_MEM_SUPPORTED */ - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(struct_ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(struct_ptr); -# else - free(struct_ptr); -# endif -#endif - } -} + png_voidp ret; -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. */ + if (png_ptr == NULL) + return NULL; -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; + /* Passing 'NULL' here bypasses the application provided memory handler. */ + ret = png_malloc_base(NULL/*use malloc*/, size); -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr == NULL || size == 0) - return (NULL); + if (ret == NULL) + png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */ - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); - else - ret = (png_malloc_default(png_ptr, size)); - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory!"); - return (ret); + return ret; } - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ - if (png_ptr == NULL || size == 0) - return (NULL); - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) +/* This function was added at libpng version 1.2.3. The png_malloc_warn() + * function will issue a png_warning and return NULL instead of issuing a + * png_error, if it fails to allocate the requested memory. + */ +PNG_FUNCTION(png_voidp,PNGAPI +png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size), + PNG_ALLOCATED) +{ + if (png_ptr != NULL) { -#ifndef PNG_USER_MEM_SUPPORTED - if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Cannot Allocate > 64K"); - else -#endif - return NULL; - } -#endif + png_voidp ret = png_malloc_base(png_ptr, size); - /* Check for overflow */ -#if defined(__TURBOC__) && !defined(__FLAT__) - if (size != (unsigned long)size) - ret = NULL; - else - ret = farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - if (size != (unsigned long)size) - ret = NULL; - else - ret = halloc(size, 1); -# else - if (size != (size_t)size) - ret = NULL; - else - ret = malloc((size_t)size); -# endif -#endif + if (ret != NULL) + return ret; -#ifndef PNG_USER_MEM_SUPPORTED - if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory"); -#endif + png_warning(png_ptr, "Out of memory"); + } - return (ret); + return NULL; } /* Free a pointer allocated by png_malloc(). If ptr is NULL, return - without taking any action. */ + * without taking any action. + */ void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) +png_free(png_const_structrp png_ptr, png_voidp ptr) { if (png_ptr == NULL || ptr == NULL) return; #ifdef PNG_USER_MEM_SUPPORTED if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); + png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr); + + else + png_free_default(png_ptr, ptr); } -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) + +PNG_FUNCTION(void,PNGAPI +png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED) { if (png_ptr == NULL || ptr == NULL) return; - #endif /* PNG_USER_MEM_SUPPORTED */ -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(ptr); -# else free(ptr); -# endif -#endif -} - -#endif /* Not Borland DOS special memory handler */ - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* This function was added at libpng version 1.2.3. The png_malloc_warn() - * function will set up png_malloc() to issue a png_warning and return NULL - * instead of issuing a png_error, if it fails to allocate the requested - * memory. - */ -png_voidp PNGAPI -png_malloc_warn(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ptr; - png_uint_32 save_flags; - if(png_ptr == NULL) return (NULL); - - save_flags=png_ptr->flags; - png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; - ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); - png_ptr->flags=save_flags; - return(ptr); -} -#endif - -png_voidp PNGAPI -png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memcpy_check."); - - return(png_memcpy (s1, s2, size)); -} - -png_voidp PNGAPI -png_memset_check (png_structp png_ptr, png_voidp s1, int value, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memset_check."); - - return (png_memset (s1, value, size)); - } #ifdef PNG_USER_MEM_SUPPORTED @@ -584,13 +250,14 @@ png_memset_check (png_structp png_ptr, png_voidp s1, int value, * of allocating and freeing memory. */ void PNGAPI -png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr +png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { - if(png_ptr != NULL) { - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; + if (png_ptr != NULL) + { + png_ptr->mem_ptr = mem_ptr; + png_ptr->malloc_fn = malloc_fn; + png_ptr->free_fn = free_fn; } } @@ -599,10 +266,12 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr * pointer before png_write_destroy and png_read_destroy are called. */ png_voidp PNGAPI -png_get_mem_ptr(png_structp png_ptr) +png_get_mem_ptr(png_const_structrp png_ptr) { - if(png_ptr == NULL) return (NULL); - return ((png_voidp)png_ptr->mem_ptr); + if (png_ptr == NULL) + return NULL; + + return png_ptr->mem_ptr; } #endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngpread.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngpread.c index b21b8d69c..a133331ff 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngpread.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngpread.c @@ -1,19 +1,21 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.2.21 October 4, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.0 [February 14, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" #ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* push model modes */ +/* Push model modes */ #define PNG_READ_SIG_MODE 0 #define PNG_READ_CHUNK_MODE 1 #define PNG_READ_IDAT_MODE 2 @@ -25,10 +27,12 @@ #define PNG_ERROR_MODE 8 void PNGAPI -png_process_data(png_structp png_ptr, png_infop info_ptr, - png_bytep buffer, png_size_t buffer_size) +png_process_data(png_structrp png_ptr, png_inforp info_ptr, + png_bytep buffer, png_size_t buffer_size) { - if(png_ptr == NULL) return; + if (png_ptr == NULL || info_ptr == NULL) + return; + png_push_restore_buffer(png_ptr, buffer, buffer_size); while (png_ptr->buffer_size) @@ -37,13 +41,73 @@ png_process_data(png_structp png_ptr, png_infop info_ptr, } } +png_size_t PNGAPI +png_process_data_pause(png_structrp png_ptr, int save) +{ + if (png_ptr != NULL) + { + /* It's easiest for the caller if we do the save, then the caller doesn't + * have to supply the same data again: + */ + if (save) + png_push_save_buffer(png_ptr); + else + { + /* This includes any pending saved bytes: */ + png_size_t remaining = png_ptr->buffer_size; + png_ptr->buffer_size = 0; + + /* So subtract the saved buffer size, unless all the data + * is actually 'saved', in which case we just return 0 + */ + if (png_ptr->save_buffer_size < remaining) + return remaining - png_ptr->save_buffer_size; + } + } + + return 0; +} + +png_uint_32 PNGAPI +png_process_data_skip(png_structrp png_ptr) +{ + png_uint_32 remaining = 0; + + if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE && + png_ptr->skip_length > 0) + { + /* At the end of png_process_data the buffer size must be 0 (see the loop + * above) so we can detect a broken call here: + */ + if (png_ptr->buffer_size != 0) + png_error(png_ptr, + "png_process_data_skip called inside png_process_data"); + + /* If is impossible for there to be a saved buffer at this point - + * otherwise we could not be in SKIP mode. This will also happen if + * png_process_skip is called inside png_process_data (but only very + * rarely.) + */ + if (png_ptr->save_buffer_size != 0) + png_error(png_ptr, "png_process_data_skip called with saved data"); + + remaining = png_ptr->skip_length; + png_ptr->skip_length = 0; + png_ptr->process_mode = PNG_READ_CHUNK_MODE; + } + + return remaining; +} + /* What we do with the incoming data depends on what we were previously * doing before we ran out of data... */ void /* PRIVATE */ -png_process_some_data(png_structp png_ptr, png_infop info_ptr) +png_process_some_data(png_structrp png_ptr, png_inforp info_ptr) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + switch (png_ptr->process_mode) { case PNG_READ_SIG_MODE: @@ -51,42 +115,25 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr) png_push_read_sig(png_ptr, info_ptr); break; } + case PNG_READ_CHUNK_MODE: { png_push_read_chunk(png_ptr, info_ptr); break; } + case PNG_READ_IDAT_MODE: { png_push_read_IDAT(png_ptr); break; } -#if defined(PNG_READ_tEXt_SUPPORTED) - case PNG_READ_tEXt_MODE: - { - png_push_read_tEXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - case PNG_READ_zTXt_MODE: - { - png_push_read_zTXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - case PNG_READ_iTXt_MODE: - { - png_push_read_iTXt(png_ptr, info_ptr); - break; - } -#endif + case PNG_SKIP_MODE: { png_push_crc_finish(png_ptr); break; } + default: { png_ptr->buffer_size = 0; @@ -102,7 +149,7 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr) * routine. */ void /* PRIVATE */ -png_push_read_sig(png_structp png_ptr, png_infop info_ptr) +png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr) { png_size_t num_checked = png_ptr->sig_bytes, num_to_check = 8 - num_checked; @@ -113,14 +160,15 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr) } png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), - num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); + num_to_check); + png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check); if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) { if (num_checked < 4 && png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) png_error(png_ptr, "Not a PNG file"); + else png_error(png_ptr, "PNG file corrupted by ASCII conversion"); } @@ -134,65 +182,13 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr) } void /* PRIVATE */ -png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) +png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IHDR; - PNG_CONST PNG_IDAT; - PNG_CONST PNG_IEND; - PNG_CONST PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_CONST PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_CONST PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_CONST PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_CONST PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_CONST PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_CONST PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_CONST PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_CONST PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_CONST PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_CONST PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_CONST PNG_sCAL; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_CONST PNG_sRGB; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_CONST PNG_sPLT; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_CONST PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_CONST PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_CONST PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_CONST PNG_zTXt; + png_uint_32 chunk_name; +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + int keep; /* unknown handling method */ #endif -#endif /* PNG_USE_LOCAL_ARRAYS */ + /* First we make sure we have enough data for the 4 byte chunk name * and the 4 byte chunk length before proceeding with decoding the * chunk data. To fully decode each of these chunks, we also make @@ -202,6 +198,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) { png_byte chunk_length[4]; + png_byte chunk_tag[4]; if (png_ptr->buffer_size < 8) { @@ -210,61 +207,87 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) } png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); + png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_crc_read(png_ptr, chunk_tag, 4); + png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); + png_check_chunk_name(png_ptr, png_ptr->chunk_name); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; } - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + chunk_name = png_ptr->chunk_name; + + if (chunk_name == png_IDAT) + { + if (png_ptr->mode & PNG_AFTER_IDAT) + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + + /* If we reach an IDAT chunk, this means we have read all of the + * header chunks, and we can start reading the image (or if this + * is called after the image has been read - we have an error). + */ + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + + png_ptr->mode |= PNG_HAVE_IDAT; + + if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) + if (png_ptr->push_length == 0) + return; + + if (png_ptr->mode & PNG_AFTER_IDAT) + png_benign_error(png_ptr, "Too many IDATs found"); + } - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + if (chunk_name == png_IHDR) { + if (png_ptr->push_length != 13) + png_error(png_ptr, "Invalid IHDR length"); + if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); } - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + + else if (chunk_name == png_IEND) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); png_ptr->process_mode = PNG_READ_DONE_MODE; png_push_have_end(png_ptr, info_ptr); } + #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + + png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep); + + if (chunk_name == png_PLTE) png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - } } + #endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + else if (chunk_name == png_PLTE) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -273,222 +296,239 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) } png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); } - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - /* If we reach an IDAT chunk, this means we have read all of the - * header chunks, and we can start reading the image (or if this - * is called after the image has been read - we have an error). - */ - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { - if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - if (png_ptr->push_length == 0) - return; - - if (png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - } + else if (chunk_name == png_IDAT) + { png_ptr->idat_size = png_ptr->push_length; - png_ptr->mode |= PNG_HAVE_IDAT; png_ptr->process_mode = PNG_READ_IDAT_MODE; png_push_have_info(png_ptr, info_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; + png_ptr->zstream.avail_out = + (uInt) PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1; png_ptr->zstream.next_out = png_ptr->row_buf; return; } -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + +#ifdef PNG_READ_gAMA_SUPPORTED + else if (png_ptr->chunk_name == png_gAMA) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) +#ifdef PNG_READ_sBIT_SUPPORTED + else if (png_ptr->chunk_name == png_sBIT) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) +#ifdef PNG_READ_cHRM_SUPPORTED + else if (png_ptr->chunk_name == png_cHRM) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) +#ifdef PNG_READ_sRGB_SUPPORTED + else if (chunk_name == png_sRGB) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) +#ifdef PNG_READ_iCCP_SUPPORTED + else if (png_ptr->chunk_name == png_iCCP) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) +#ifdef PNG_READ_sPLT_SUPPORTED + else if (chunk_name == png_sPLT) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) +#ifdef PNG_READ_tRNS_SUPPORTED + else if (chunk_name == png_tRNS) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) +#ifdef PNG_READ_bKGD_SUPPORTED + else if (chunk_name == png_bKGD) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) +#ifdef PNG_READ_hIST_SUPPORTED + else if (chunk_name == png_hIST) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) +#ifdef PNG_READ_pHYs_SUPPORTED + else if (chunk_name == png_pHYs) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) +#ifdef PNG_READ_oFFs_SUPPORTED + else if (chunk_name == png_oFFs) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + +#ifdef PNG_READ_pCAL_SUPPORTED + else if (chunk_name == png_pCAL) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) +#ifdef PNG_READ_sCAL_SUPPORTED + else if (chunk_name == png_sCAL) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) +#ifdef PNG_READ_tIME_SUPPORTED + else if (chunk_name == png_tIME) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } + png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) +#ifdef PNG_READ_tEXt_SUPPORTED + else if (chunk_name == png_tEXt) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); + + png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) +#ifdef PNG_READ_zTXt_SUPPORTED + else if (chunk_name == png_zTXt) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); + + png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); } + #endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) +#ifdef PNG_READ_iTXt_SUPPORTED + else if (chunk_name == png_iTXt) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } - png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); + + png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); } + #endif else { @@ -497,50 +537,64 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } - png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); + png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, + PNG_HANDLE_CHUNK_AS_DEFAULT); } png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; } void /* PRIVATE */ -png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) +png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip) { png_ptr->process_mode = PNG_SKIP_MODE; png_ptr->skip_length = skip; } void /* PRIVATE */ -png_push_crc_finish(png_structp png_ptr) +png_push_crc_finish(png_structrp png_ptr) { if (png_ptr->skip_length && png_ptr->save_buffer_size) { - png_size_t save_size; + png_size_t save_size = png_ptr->save_buffer_size; + png_uint_32 skip_length = png_ptr->skip_length; + + /* We want the smaller of 'skip_length' and 'save_buffer_size', but + * they are of different types and we don't know which variable has the + * fewest bits. Carefully select the smaller and cast it to the type of + * the larger - this cannot overflow. Do not cast in the following test + * - it will break on either 16 or 64 bit platforms. + */ + if (skip_length < save_size) + save_size = (png_size_t)skip_length; - if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; else - save_size = png_ptr->save_buffer_size; + skip_length = (png_uint_32)save_size; png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - png_ptr->skip_length -= save_size; + png_ptr->skip_length -= skip_length; png_ptr->buffer_size -= save_size; png_ptr->save_buffer_size -= save_size; png_ptr->save_buffer_ptr += save_size; } if (png_ptr->skip_length && png_ptr->current_buffer_size) { - png_size_t save_size; + png_size_t save_size = png_ptr->current_buffer_size; + png_uint_32 skip_length = png_ptr->skip_length; + + /* We want the smaller of 'skip_length' and 'current_buffer_size', here, + * the same problem exists as above and the same solution. + */ + if (skip_length < save_size) + save_size = (png_size_t)skip_length; - if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; else - save_size = png_ptr->current_buffer_size; + skip_length = (png_uint_32)save_size; png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - png_ptr->skip_length -= save_size; + png_ptr->skip_length -= skip_length; png_ptr->buffer_size -= save_size; png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; @@ -558,12 +612,14 @@ png_push_crc_finish(png_structp png_ptr) } } -void PNGAPI +void PNGCBAPI png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) { png_bytep ptr; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + ptr = buffer; if (png_ptr->save_buffer_size) { @@ -571,10 +627,11 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) if (length < png_ptr->save_buffer_size) save_size = length; + else save_size = png_ptr->save_buffer_size; - png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size); + memcpy(ptr, png_ptr->save_buffer_ptr, save_size); length -= save_size; ptr += save_size; png_ptr->buffer_size -= save_size; @@ -587,10 +644,11 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) if (length < png_ptr->current_buffer_size) save_size = length; + else save_size = png_ptr->current_buffer_size; - png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size); + memcpy(ptr, png_ptr->current_buffer_ptr, save_size); png_ptr->buffer_size -= save_size; png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; @@ -598,46 +656,54 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) } void /* PRIVATE */ -png_push_save_buffer(png_structp png_ptr) +png_push_save_buffer(png_structrp png_ptr) { if (png_ptr->save_buffer_size) { if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) { - png_size_t i,istop; + png_size_t i, istop; png_bytep sp; png_bytep dp; istop = png_ptr->save_buffer_size; for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; - i < istop; i++, sp++, dp++) + i < istop; i++, sp++, dp++) { *dp = *sp; } } } if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > - png_ptr->save_buffer_max) + png_ptr->save_buffer_max) { png_size_t new_max; png_bytep old_buffer; if (png_ptr->save_buffer_size > PNG_SIZE_MAX - - (png_ptr->current_buffer_size + 256)) + (png_ptr->current_buffer_size + 256)) { - png_error(png_ptr, "Potential overflow of save_buffer"); + png_error(png_ptr, "Potential overflow of save_buffer"); } + new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; old_buffer = png_ptr->save_buffer; - png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, - (png_uint_32)new_max); - png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); + png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr, + (png_size_t)new_max); + + if (png_ptr->save_buffer == NULL) + { + png_free(png_ptr, old_buffer); + png_error(png_ptr, "Insufficient memory for save_buffer"); + } + + memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); png_free(png_ptr, old_buffer); png_ptr->save_buffer_max = new_max; } if (png_ptr->current_buffer_size) { - png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, + memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); png_ptr->save_buffer_size += png_ptr->current_buffer_size; png_ptr->current_buffer_size = 0; @@ -647,7 +713,7 @@ png_push_save_buffer(png_structp png_ptr) } void /* PRIVATE */ -png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, +png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer, png_size_t buffer_length) { png_ptr->current_buffer = buffer; @@ -657,15 +723,14 @@ png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, } void /* PRIVATE */ -png_push_read_IDAT(png_structp png_ptr) +png_push_read_IDAT(png_structrp png_ptr) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IDAT; -#endif if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) { png_byte chunk_length[4]; + png_byte chunk_tag[4]; + /* TODO: this code can be commoned up with the same code in push_read */ if (png_ptr->buffer_size < 8) { png_push_save_buffer(png_ptr); @@ -673,62 +738,73 @@ png_push_read_IDAT(png_structp png_ptr) } png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); + png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_crc_read(png_ptr, chunk_tag, 4); + png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + if (png_ptr->chunk_name != png_IDAT) { png_ptr->process_mode = PNG_READ_CHUNK_MODE; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) + + if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) png_error(png_ptr, "Not enough compressed data"); + return; } png_ptr->idat_size = png_ptr->push_length; } + if (png_ptr->idat_size && png_ptr->save_buffer_size) { - png_size_t save_size; + png_size_t save_size = png_ptr->save_buffer_size; + png_uint_32 idat_size = png_ptr->idat_size; + + /* We want the smaller of 'idat_size' and 'current_buffer_size', but they + * are of different types and we don't know which variable has the fewest + * bits. Carefully select the smaller and cast it to the type of the + * larger - this cannot overflow. Do not cast in the following test - it + * will break on either 16 or 64 bit platforms. + */ + if (idat_size < save_size) + save_size = (png_size_t)idat_size; - if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } else - save_size = png_ptr->save_buffer_size; + idat_size = (png_uint_32)save_size; png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); - png_ptr->idat_size -= save_size; + + png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); + + png_ptr->idat_size -= idat_size; png_ptr->buffer_size -= save_size; png_ptr->save_buffer_size -= save_size; png_ptr->save_buffer_ptr += save_size; } + if (png_ptr->idat_size && png_ptr->current_buffer_size) { - png_size_t save_size; + png_size_t save_size = png_ptr->current_buffer_size; + png_uint_32 idat_size = png_ptr->idat_size; + + /* We want the smaller of 'idat_size' and 'current_buffer_size', but they + * are of different types and we don't know which variable has the fewest + * bits. Carefully select the smaller and cast it to the type of the + * larger - this cannot overflow. + */ + if (idat_size < save_size) + save_size = (png_size_t)idat_size; - if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } else - save_size = png_ptr->current_buffer_size; + idat_size = (png_uint_32)save_size; png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); - png_ptr->idat_size -= save_size; + png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); + + png_ptr->idat_size -= idat_size; png_ptr->buffer_size -= save_size; png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; @@ -744,101 +820,170 @@ png_push_read_IDAT(png_structp png_ptr) png_crc_finish(png_ptr, 0); png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->zowner = 0; } } void /* PRIVATE */ -png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, +png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, png_size_t buffer_length) { - int ret; - - if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) - png_error(png_ptr, "Extra compression data"); + /* The caller checks for a non-zero buffer length. */ + if (!(buffer_length > 0) || buffer == NULL) + png_error(png_ptr, "No IDAT data (internal error)"); + /* This routine must process all the data it has been given + * before returning, calling the row callback as required to + * handle the uncompressed results. + */ png_ptr->zstream.next_in = buffer; + /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */ png_ptr->zstream.avail_in = (uInt)buffer_length; - for(;;) + + /* Keep going until the decompressed data is all processed + * or the stream marked as finished. + */ + while (png_ptr->zstream.avail_in > 0 && + !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK) + int ret; + + /* We have data for zlib, but we must check that zlib + * has someplace to put the results. It doesn't matter + * if we don't expect any results -- it may be the input + * data is just the LZ end code. + */ + if (!(png_ptr->zstream.avail_out > 0)) { - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_in) - png_error(png_ptr, "Extra compressed data"); - if (!(png_ptr->zstream.avail_out)) - { - png_push_process_row(png_ptr); - } + /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */ + png_ptr->zstream.avail_out = (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1); + + png_ptr->zstream.next_out = png_ptr->row_buf; + } + + /* Using Z_SYNC_FLUSH here means that an unterminated + * LZ stream (a stream with a missing end code) can still + * be handled, otherwise (Z_NO_FLUSH) a future zlib + * implementation might defer output and therefore + * change the current behavior (see comments in inflate.c + * for why this doesn't happen at present with zlib 1.2.5). + */ + ret = inflate(&png_ptr->zstream, Z_SYNC_FLUSH); + + /* Check for any failure before proceeding. */ + if (ret != Z_OK && ret != Z_STREAM_END) + { + /* Terminate the decompression. */ + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + png_ptr->zowner = 0; + + /* This may be a truncated stream (missing or + * damaged end code). Treat that as a warning. + */ + if (png_ptr->row_number >= png_ptr->num_rows || + png_ptr->pass > 6) + png_warning(png_ptr, "Truncated compressed data in IDAT"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - else if (ret == Z_BUF_ERROR) - break; else - png_error(png_ptr, "Decompression Error"); + png_error(png_ptr, "Decompression error in IDAT"); + + /* Skip the check on unprocessed input */ + return; } - if (!(png_ptr->zstream.avail_out)) + + /* Did inflate output any data? */ + if (png_ptr->zstream.next_out != png_ptr->row_buf) { - if (( -#if defined(PNG_READ_INTERLACING_SUPPORTED) - png_ptr->interlaced && png_ptr->pass > 6) || - (!png_ptr->interlaced && -#endif - png_ptr->row_number == png_ptr->num_rows)) + /* Is this unexpected data after the last row? + * If it is, artificially terminate the LZ output + * here. + */ + if (png_ptr->row_number >= png_ptr->num_rows || + png_ptr->pass > 6) { - if (png_ptr->zstream.avail_in) - { - png_warning(png_ptr, "Too much data in IDAT chunks"); - } - - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; + /* Extra data. */ + png_warning(png_ptr, "Extra compressed data in IDAT"); + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + png_ptr->zowner = 0; + + /* Do no more processing; skip the unprocessed + * input check below. + */ + return; } - png_push_process_row(png_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; + + /* Do we have a complete row? */ + if (png_ptr->zstream.avail_out == 0) + png_push_process_row(png_ptr); } - else - break; + + /* And check for the end of the stream. */ + if (ret == Z_STREAM_END) + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; } + + /* All the data should have been processed, if anything + * is left at this point we have bytes of IDAT data + * after the zlib end code. + */ + if (png_ptr->zstream.avail_in > 0) + png_warning(png_ptr, "Extra compression data in IDAT"); } void /* PRIVATE */ -png_push_process_row(png_structp png_ptr) +png_push_process_row(png_structrp png_ptr) { - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; + /* 1.5.6: row_info moved out of png_struct to a local here. */ + png_row_info row_info; - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); + row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */ + row_info.color_type = png_ptr->color_type; + row_info.bit_depth = png_ptr->bit_depth; + row_info.channels = png_ptr->channels; + row_info.pixel_depth = png_ptr->pixel_depth; + row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); + if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) + { + if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) + png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, + png_ptr->prev_row + 1, png_ptr->row_buf[0]); + else + png_error(png_ptr, "bad adaptive filter value"); + } - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); + /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before + * 1.5.6, while the buffer really is this big in current versions of libpng + * it may not be in the future, so this was changed just to copy the + * interlaced row count: + */ + memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); +#ifdef PNG_READ_TRANSFORMS_SUPPORTED + if (png_ptr->transformations) + png_do_read_transformations(png_ptr, &row_info); +#endif -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ + /* The transformed pixel depth should match the depth now in row_info. */ + if (png_ptr->transformed_pixel_depth == 0) + { + png_ptr->transformed_pixel_depth = row_info.pixel_depth; + if (row_info.pixel_depth > png_ptr->maximum_pixel_depth) + png_error(png_ptr, "progressive row overflow"); + } + + else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth) + png_error(png_ptr, "internal progressive row size calculation error"); + + +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); + png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, + png_ptr->transformations); switch (png_ptr->pass) { @@ -848,31 +993,36 @@ png_push_process_row(png_structp png_ptr) for (i = 0; i < 8 && png_ptr->pass == 0; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ + png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */ } - if (png_ptr->pass == 2) /* pass 1 might be empty */ + + if (png_ptr->pass == 2) /* Pass 1 might be empty */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + if (png_ptr->pass == 4 && png_ptr->height <= 4) { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + if (png_ptr->pass == 6 && png_ptr->height <= 4) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } + break; } + case 1: { int i; @@ -881,99 +1031,123 @@ png_push_process_row(png_structp png_ptr) png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 2) /* skip top 4 generated rows */ + + if (png_ptr->pass == 2) /* Skip top 4 generated rows */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + break; } + case 2: { int i; + for (i = 0; i < 4 && png_ptr->pass == 2; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } + for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 4) /* pass 3 might be empty */ + + if (png_ptr->pass == 4) /* Pass 3 might be empty */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + break; } + case 3: { int i; + for (i = 0; i < 4 && png_ptr->pass == 3; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 4) /* skip top two generated rows */ + + if (png_ptr->pass == 4) /* Skip top two generated rows */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + break; } + case 4: { int i; + for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } + for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 6) /* pass 5 might be empty */ + + if (png_ptr->pass == 6) /* Pass 5 might be empty */ { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } + break; } + case 5: { int i; + for (i = 0; i < 2 && png_ptr->pass == 5; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 6) /* skip top generated row */ + + if (png_ptr->pass == 6) /* Skip top generated row */ { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } + break; } + + default: case 6: { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); + if (png_ptr->pass != 6) break; - png_push_have_row(png_ptr, png_bytep_NULL); + + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } @@ -987,26 +1161,26 @@ png_push_process_row(png_structp png_ptr) } void /* PRIVATE */ -png_read_push_finish_row(png_structp png_ptr) +png_read_push_finish_row(png_structrp png_ptr) { -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ - PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ - PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ - PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ - PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need * it, uncomment it here and in png.h - PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; + static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; */ #endif @@ -1014,562 +1188,91 @@ png_read_push_finish_row(png_structp png_ptr) if (png_ptr->row_number < png_ptr->num_rows) return; +#ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) { png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, - png_ptr->rowbytes + 1); + memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + do { png_ptr->pass++; if ((png_ptr->pass == 1 && png_ptr->width < 5) || (png_ptr->pass == 3 && png_ptr->width < 3) || (png_ptr->pass == 5 && png_ptr->width < 2)) - png_ptr->pass++; + png_ptr->pass++; if (png_ptr->pass > 7) png_ptr->pass--; + if (png_ptr->pass >= 7) break; png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; if (png_ptr->transformations & PNG_INTERLACE) break; png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); } -} - -#if defined(PNG_READ_tEXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place tEXt"); - (void) info_ptr; /* to quiet some compiler warnings */ - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_tEXt_MODE; +#endif /* PNG_READ_INTERLACING_SUPPORTED */ } void /* PRIVATE */ -png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - if (text < key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - png_ptr->current_text = NULL; - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place zTXt"); - (void) info_ptr; /* to quiet some compiler warnings */ - } - -#ifdef PNG_MAX_MALLOC_64K - /* We can't handle zTXt chunks > 64K, since we don't have enough space - * to be able to store the uncompressed data. Actually, the threshold - * is probably around 32K, but it isn't as definite as 64K is. - */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "zTXt chunk too large to fit in memory"); - png_push_crc_skip(png_ptr, length); - return; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_zTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - png_size_t text_size, key_size; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - - key = png_ptr->current_text; - - for (text = key; *text; text++) - /* empty loop */ ; - - /* zTXt can't have zero text */ - if (text >= key + png_ptr->current_text_size) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - return; - } - - text++; - - png_ptr->zstream.next_in = (png_bytep )text; - png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - - (text - key)); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - key_size = text - key; - text_size = 0; - text = NULL; - ret = Z_STREAM_END; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) - { - if (text == NULL) - { - text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + key_size + 1)); - png_memcpy(text + key_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_memcpy(text, key, key_size); - text_size = key_size + png_ptr->zbuf_size - - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc(png_ptr, text_size + - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + 1)); - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - if (ret != Z_STREAM_END) - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else - { - break; - } - - if (ret == Z_STREAM_END) - break; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (ret != Z_STREAM_END) - { - png_ptr->current_text = NULL; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - - png_ptr->current_text = NULL; - png_free(png_ptr, key); - key = text; - text += key_size; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; -#endif - text_ptr->text = text; - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - - if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); - } -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place iTXt"); - info_ptr = info_ptr; /* to quiet some compiler warnings */ - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "iTXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_iTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) -{ - - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp key; - int comp_flag; - png_charp lang; - png_charp lang_key; - png_charp text; - int ret; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - - for (lang = key; *lang; lang++) - /* empty loop */ ; - - if (lang < key + png_ptr->current_text_size - 3) - lang++; - - comp_flag = *lang++; - lang++; /* skip comp_type, always zero */ - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - text=lang_key; - if (lang_key < key + png_ptr->current_text_size - 1) - { - for (; *text; text++) - /* empty loop */ ; - } - - if (text < key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); - text_ptr->compression = comp_flag + 2; - text_ptr->key = key; - text_ptr->lang = lang; - text_ptr->lang_key = lang_key; - text_ptr->text = text; - text_ptr->text_length = 0; - text_ptr->itxt_length = png_strlen(text); - - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_ptr->current_text = NULL; - - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to store iTXt chunk."); - } -} -#endif - -/* This function is called when we haven't found a handler for this - * chunk. If there isn't a problem with the chunk itself (ie a bad chunk - * name or a critical chunk), the chunk is (currently) silently ignored. - */ -void /* PRIVATE */ -png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - png_uint_32 skip=0; - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - - (void) info_ptr; /* to quiet some compiler warnings */ - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) - { -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - png_strncpy((png_charp)png_ptr->unknown_chunk.name, - (png_charp)png_ptr->chunk_name, 5); - png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); - png_ptr->unknown_chunk.size = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - int ret; - ret = (*(png_ptr->read_user_chunk_fn)) - (png_ptr, &png_ptr->unknown_chunk); - if (ret < 0) - png_chunk_error(png_ptr, "error in user chunk"); - if (ret == 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - png_set_unknown_chunks(png_ptr, info_ptr, - &png_ptr->unknown_chunk, 1); - } - } -#else - png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); -#endif - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } - else -#endif - skip=length; - png_push_crc_skip(png_ptr, skip); -} - -void /* PRIVATE */ -png_push_have_info(png_structp png_ptr, png_infop info_ptr) +png_push_have_info(png_structrp png_ptr, png_inforp info_ptr) { if (png_ptr->info_fn != NULL) (*(png_ptr->info_fn))(png_ptr, info_ptr); } void /* PRIVATE */ -png_push_have_end(png_structp png_ptr, png_infop info_ptr) +png_push_have_end(png_structrp png_ptr, png_inforp info_ptr) { if (png_ptr->end_fn != NULL) (*(png_ptr->end_fn))(png_ptr, info_ptr); } void /* PRIVATE */ -png_push_have_row(png_structp png_ptr, png_bytep row) +png_push_have_row(png_structrp png_ptr, png_bytep row) { if (png_ptr->row_fn != NULL) (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, (int)png_ptr->pass); } +#ifdef PNG_READ_INTERLACING_SUPPORTED void PNGAPI -png_progressive_combine_row (png_structp png_ptr, - png_bytep old_row, png_bytep new_row) +png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row, + png_const_bytep new_row) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST int FARDATA png_pass_dsp_mask[7] = - {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; -#endif - if(png_ptr == NULL) return; - if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ - png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); + if (png_ptr == NULL) + return; + + /* new_row is a flag here - if it is NULL then the app callback was called + * from an empty row (see the calls to png_struct::row_fn below), otherwise + * it must be png_ptr->row_buf+1 + */ + if (new_row != NULL) + png_combine_row(png_ptr, old_row, 1/*display*/); } +#endif /* PNG_READ_INTERLACING_SUPPORTED */ void PNGAPI -png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn) +png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + png_ptr->info_fn = info_fn; png_ptr->row_fn = row_fn; png_ptr->end_fn = end_fn; @@ -1578,9 +1281,11 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, } png_voidp PNGAPI -png_get_progressive_ptr(png_structp png_ptr) +png_get_progressive_ptr(png_const_structrp png_ptr) { - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); + return png_ptr->io_ptr; } #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngpriv.h b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngpriv.h new file mode 100644 index 000000000..8078cf184 --- /dev/null +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngpriv.h @@ -0,0 +1,1913 @@ + +/* pngpriv.h - private declarations for use inside libpng + * + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * Last changed in libpng 1.6.1 [March 28, 2013] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* The symbols declared in this file (including the functions declared + * as extern) are PRIVATE. They are not part of the libpng public + * interface, and are not recommended for use by regular applications. + * Some of them may become public in the future; others may stay private, + * change in an incompatible way, or even disappear. + * Although the libpng users are not forbidden to include this header, + * they should be well aware of the issues that may arise from doing so. + */ + +#ifndef PNGPRIV_H +#define PNGPRIV_H + +/* Feature Test Macros. The following are defined here to ensure that correctly + * implemented libraries reveal the APIs libpng needs to build and hide those + * that are not needed and potentially damaging to the compilation. + * + * Feature Test Macros must be defined before any system header is included (see + * POSIX 1003.1 2.8.2 "POSIX Symbols." + * + * These macros only have an effect if the operating system supports either + * POSIX 1003.1 or C99, or both. On other operating systems (particularly + * Windows/Visual Studio) there is no effect; the OS specific tests below are + * still required (as of 2011-05-02.) + */ +#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */ + +#ifndef PNG_VERSION_INFO_ONLY +/* Standard library headers not required by png.h: */ +# include <stdlib.h> +# include <string.h> +#endif + +#define PNGLIB_BUILD /*libpng is being built, not used*/ + +/* If HAVE_CONFIG_H is defined during the build then the build system must + * provide an appropriate "config.h" file on the include path. The header file + * must provide definitions as required below (search for "HAVE_CONFIG_H"); + * see configure.ac for more details of the requirements. The macro + * "PNG_NO_CONFIG_H" is provided for maintainers to test for dependencies on + * 'configure'; define this macro to prevent the configure build including the + * configure generated config.h. Libpng is expected to compile without *any* + * special build system support on a reasonably ANSI-C compliant system. + */ +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include <config.h> + + /* Pick up the definition of 'restrict' from config.h if it was read: */ +# define PNG_RESTRICT restrict +#endif + +/* To support symbol prefixing it is necessary to know *before* including png.h + * whether the fixed point (and maybe other) APIs are exported, because if they + * are not internal definitions may be required. This is handled below just + * before png.h is included, but load the configuration now if it is available. + */ +#ifndef PNGLCONF_H +# include "pnglibconf.h" +#endif + +/* Local renames may change non-exported API functions from png.h */ +#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H) +# include "pngprefix.h" +#endif + +#ifdef PNG_USER_CONFIG +# include "pngusr.h" + /* These should have been defined in pngusr.h */ +# ifndef PNG_USER_PRIVATEBUILD +# define PNG_USER_PRIVATEBUILD "Custom libpng build" +# endif +# ifndef PNG_USER_DLLFNAME_POSTFIX +# define PNG_USER_DLLFNAME_POSTFIX "Cb" +# endif +#endif + +/* Is this a build of a DLL where compilation of the object modules requires + * different preprocessor settings to those required for a simple library? If + * so PNG_BUILD_DLL must be set. + * + * If libpng is used inside a DLL but that DLL does not export the libpng APIs + * PNG_BUILD_DLL must not be set. To avoid the code below kicking in build a + * static library of libpng then link the DLL against that. + */ +#ifndef PNG_BUILD_DLL +# ifdef DLL_EXPORT + /* This is set by libtool when files are compiled for a DLL; libtool + * always compiles twice, even on systems where it isn't necessary. Set + * PNG_BUILD_DLL in case it is necessary: + */ +# define PNG_BUILD_DLL +# else +# ifdef _WINDLL + /* This is set by the Microsoft Visual Studio IDE in projects that + * build a DLL. It can't easily be removed from those projects (it + * isn't visible in the Visual Studio UI) so it is a fairly reliable + * indication that PNG_IMPEXP needs to be set to the DLL export + * attributes. + */ +# define PNG_BUILD_DLL +# else +# ifdef __DLL__ + /* This is set by the Borland C system when compiling for a DLL + * (as above.) + */ +# define PNG_BUILD_DLL +# else + /* Add additional compiler cases here. */ +# endif +# endif +# endif +#endif /* Setting PNG_BUILD_DLL if required */ + +/* See pngconf.h for more details: the builder of the library may set this on + * the command line to the right thing for the specific compilation system or it + * may be automagically set above (at present we know of no system where it does + * need to be set on the command line.) + * + * PNG_IMPEXP must be set here when building the library to prevent pngconf.h + * setting it to the "import" setting for a DLL build. + */ +#ifndef PNG_IMPEXP +# ifdef PNG_BUILD_DLL +# define PNG_IMPEXP PNG_DLL_EXPORT +# else + /* Not building a DLL, or the DLL doesn't require specific export + * definitions. + */ +# define PNG_IMPEXP +# endif +#endif + +/* No warnings for private or deprecated functions in the build: */ +#ifndef PNG_DEPRECATED +# define PNG_DEPRECATED +#endif +#ifndef PNG_PRIVATE +# define PNG_PRIVATE +#endif + +/* Symbol preprocessing support. + * + * To enable listing global, but internal, symbols the following macros should + * always be used to declare an extern data or function object in this file. + */ +#ifndef PNG_INTERNAL_DATA +# define PNG_INTERNAL_DATA(type, name, array) extern type name array +#endif + +#ifndef PNG_INTERNAL_FUNCTION +# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\ + extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes) +#endif + +/* If floating or fixed point APIs are disabled they may still be compiled + * internally. To handle this make sure they are declared as the appropriate + * internal extern function (otherwise the symbol prefixing stuff won't work and + * the functions will be used without definitions.) + * + * NOTE: although all the API functions are declared here they are not all + * actually built! Because the declarations are still made it is necessary to + * fake out types that they depend on. + */ +#ifndef PNG_FP_EXPORT +# ifndef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FP_EXPORT(ordinal, type, name, args)\ + PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY); +# ifndef PNG_VERSION_INFO_ONLY + typedef struct png_incomplete png_double; + typedef png_double* png_doublep; + typedef const png_double* png_const_doublep; + typedef png_double** png_doublepp; +# endif +# endif +#endif +#ifndef PNG_FIXED_EXPORT +# ifndef PNG_FIXED_POINT_SUPPORTED +# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ + PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY); +# endif +#endif + +#include "png.h" + +/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */ +#ifndef PNG_DLL_EXPORT +# define PNG_DLL_EXPORT +#endif + +/* SECURITY and SAFETY: + * + * By default libpng is built without any internal limits on image size, + * individual heap (png_malloc) allocations or the total amount of memory used. + * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used + * (unless individually overridden). These limits are believed to be fairly + * safe, but builders of secure systems should verify the values against the + * real system capabilities. + */ +#ifdef PNG_SAFE_LIMITS_SUPPORTED + /* 'safe' limits */ +# ifndef PNG_USER_WIDTH_MAX +# define PNG_USER_WIDTH_MAX 1000000 +# endif +# ifndef PNG_USER_HEIGHT_MAX +# define PNG_USER_HEIGHT_MAX 1000000 +# endif +# ifndef PNG_USER_CHUNK_CACHE_MAX +# define PNG_USER_CHUNK_CACHE_MAX 128 +# endif +# ifndef PNG_USER_CHUNK_MALLOC_MAX +# define PNG_USER_CHUNK_MALLOC_MAX 8000000 +# endif +#else + /* values for no limits */ +# ifndef PNG_USER_WIDTH_MAX +# define PNG_USER_WIDTH_MAX 0x7fffffff +# endif +# ifndef PNG_USER_HEIGHT_MAX +# define PNG_USER_HEIGHT_MAX 0x7fffffff +# endif +# ifndef PNG_USER_CHUNK_CACHE_MAX +# define PNG_USER_CHUNK_CACHE_MAX 0 +# endif +# ifndef PNG_USER_CHUNK_MALLOC_MAX +# define PNG_USER_CHUNK_MALLOC_MAX 0 +# endif +#endif + +/* Moved to pngpriv.h at libpng-1.5.0 */ +/* NOTE: some of these may have been used in external applications as + * these definitions were exposed in pngconf.h prior to 1.5. + */ + +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. + * + * zlib provides 'MAXSEG_64K' which, if defined, indicates the + * same limit and pngconf.h (already included) sets the limit + * if certain operating systems are detected. + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif + +#ifndef PNG_UNUSED +/* Unused formal parameter warnings are silenced using the following macro + * which is expected to have no bad effects on performance (optimizing + * compilers will probably remove it entirely). Note that if you replace + * it with something other than whitespace, you must include the terminating + * semicolon. + */ +# define PNG_UNUSED(param) (void)param; +#endif + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536L +#endif + +/* If warnings or errors are turned off the code is disabled or redirected here. + * From 1.5.4 functions have been added to allow very limited formatting of + * error and warning messages - this code will also be disabled here. + */ +#ifdef PNG_WARNINGS_SUPPORTED +# define PNG_WARNING_PARAMETERS(p) png_warning_parameters p; +#else +# define png_warning(s1,s2) ((void)(s1)) +# define png_chunk_warning(s1,s2) ((void)(s1)) +# define png_warning_parameter(p,number,string) ((void)0) +# define png_warning_parameter_unsigned(p,number,format,value) ((void)0) +# define png_warning_parameter_signed(p,number,format,value) ((void)0) +# define png_formatted_warning(pp,p,message) ((void)(pp)) +# define PNG_WARNING_PARAMETERS(p) +#endif +#ifndef PNG_ERROR_TEXT_SUPPORTED +# define png_error(s1,s2) png_err(s1) +# define png_chunk_error(s1,s2) png_err(s1) +# define png_fixed_error(s1,s2) png_err(s1) +#endif + +/* C allows up-casts from (void*) to any pointer and (const void*) to any + * pointer to a const object. C++ regards this as a type error and requires an + * explicit, static, cast and provides the static_cast<> rune to ensure that + * const is not cast away. + */ +#ifdef __cplusplus +# define png_voidcast(type, value) static_cast<type>(value) +# define png_constcast(type, value) const_cast<type>(value) +# define png_aligncast(type, value) \ + static_cast<type>(static_cast<void*>(value)) +# define png_aligncastconst(type, value) \ + static_cast<type>(static_cast<const void*>(value)) +#else +# define png_voidcast(type, value) (value) +# define png_constcast(type, value) ((type)(value)) +# define png_aligncast(type, value) ((void*)(value)) +# define png_aligncastconst(type, value) ((const void*)(value)) +#endif /* __cplusplus */ + +/* Some fixed point APIs are still required even if not exported because + * they get used by the corresponding floating point APIs. This magic + * deals with this: + */ +#ifdef PNG_FIXED_POINT_SUPPORTED +# define PNGFAPI PNGAPI +#else +# define PNGFAPI /* PRIVATE */ +#endif + +#ifndef PNG_VERSION_INFO_ONLY +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. + */ +#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\ + defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) + /* png.c requires the following ANSI-C constants if the conversion of + * floating point to ASCII is implemented therein: + * + * DBL_DIG Maximum number of decimal digits (can be set to any constant) + * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value) + * DBL_MAX Maximum floating point number (can be set to an arbitrary value) + */ +# include <float.h> + +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) + /* We need to check that <math.h> hasn't already been included earlier + * as it seems it doesn't agree with <fp.h>, yet we should really use + * <fp.h> if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include <fp.h> +# endif +# else +# include <math.h> +# endif +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include <m68881.h> +# endif +#endif + +/* This provides the non-ANSI (far) memory allocation routines. */ +#if defined(__TURBOC__) && defined(__MSDOS__) +# include <mem.h> +# include <alloc.h> +#endif + +#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ + defined(_WIN32) || defined(__WIN32__) +# include <windows.h> /* defines _WINDOWS_ macro */ +#endif +#endif /* PNG_VERSION_INFO_ONLY */ + +/* Moved here around 1.5.0beta36 from pngconf.h */ +/* Users may want to use these so they are not private. Any library + * functions that are passed far data must be model-independent. + */ + +/* Memory model/platform independent fns */ +#ifndef PNG_ABORT +# ifdef _WINDOWS_ +# define PNG_ABORT() ExitProcess(0) +# else +# define PNG_ABORT() abort() +# endif +#endif + +/* These macros may need to be architecture dependent. */ +#define PNG_ALIGN_NONE 0 /* do not use data alignment */ +#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */ +#ifdef offsetof +# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */ +#else +# define PNG_ALIGN_OFFSET -1 /* prevent the use of this */ +#endif +#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */ + +#ifndef PNG_ALIGN_TYPE + /* Default to using aligned access optimizations and requiring alignment to a + * multiple of the data type size. Override in a compiler specific fashion + * if necessary by inserting tests here: + */ +# define PNG_ALIGN_TYPE PNG_ALIGN_SIZE +#endif + +#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE + /* This is used because in some compiler implementations non-aligned + * structure members are supported, so the offsetof approach below fails. + * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access + * is good for performance. Do not do this unless you have tested the result + * and understand it. + */ +# define png_alignof(type) (sizeof (type)) +#else +# if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET +# define png_alignof(type) offsetof(struct{char c; type t;}, t) +# else +# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS +# define png_alignof(type) (1) +# endif + /* Else leave png_alignof undefined to prevent use thereof */ +# endif +#endif + +/* This implicitly assumes alignment is always to a power of 2. */ +#ifdef png_alignof +# define png_isaligned(ptr, type)\ + ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0) +#else +# define png_isaligned(ptr, type) 0 +#endif + +/* End of memory model/platform independent support */ +/* End of 1.5.0beta36 move from pngconf.h */ + +/* CONSTANTS and UTILITY MACROS + * These are used internally by libpng and not exposed in the API + */ + +/* Various modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. Three of these + * are defined in png.h because they need to be visible to applications + * that call png_set_unknown_chunk(). + */ +/* #define PNG_HAVE_IHDR 0x01 (defined in png.h) */ +/* #define PNG_HAVE_PLTE 0x02 (defined in png.h) */ +#define PNG_HAVE_IDAT 0x04 +/* #define PNG_AFTER_IDAT 0x08 (defined in png.h) */ +#define PNG_HAVE_IEND 0x10 + /* 0x20 (unused) */ + /* 0x40 (unused) */ + /* 0x80 (unused) */ +#define PNG_HAVE_CHUNK_HEADER 0x100 +#define PNG_WROTE_tIME 0x200 +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 +#define PNG_BACKGROUND_IS_GRAY 0x800 +#define PNG_HAVE_PNG_SIGNATURE 0x1000 +#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ + /* 0x4000 (unused) */ +#define PNG_IS_READ_STRUCT 0x8000 /* Else is a write struct */ + +/* Flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001 +#define PNG_INTERLACE 0x0002 +#define PNG_PACK 0x0004 +#define PNG_SHIFT 0x0008 +#define PNG_SWAP_BYTES 0x0010 +#define PNG_INVERT_MONO 0x0020 +#define PNG_QUANTIZE 0x0040 +#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */ +#define PNG_BACKGROUND_EXPAND 0x0100 +#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */ +#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */ +#define PNG_RGBA 0x0800 +#define PNG_EXPAND 0x1000 +#define PNG_GAMMA 0x2000 +#define PNG_GRAY_TO_RGB 0x4000 +#define PNG_FILLER 0x8000 +#define PNG_PACKSWAP 0x10000 +#define PNG_SWAP_ALPHA 0x20000 +#define PNG_STRIP_ALPHA 0x40000 +#define PNG_INVERT_ALPHA 0x80000 +#define PNG_USER_TRANSFORM 0x100000 +#define PNG_RGB_TO_GRAY_ERR 0x200000 +#define PNG_RGB_TO_GRAY_WARN 0x400000 +#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */ +#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */ +#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */ +#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */ +#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */ + /* 0x8000000 unused */ + /* 0x10000000 unused */ + /* 0x20000000 unused */ + /* 0x40000000 unused */ +/* Flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001 +#define PNG_STRUCT_INFO 0x0002 + +/* Scaling factor for filter heuristic weighting calculations */ +#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) +#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) + +/* Flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 +#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002 /* Added to libpng-1.6.0 */ + /* 0x0004 unused */ +#define PNG_FLAG_ZSTREAM_ENDED 0x0008 /* Added to libpng-1.6.0 */ + /* 0x0010 unused */ + /* 0x0020 unused */ +#define PNG_FLAG_ROW_INIT 0x0040 +#define PNG_FLAG_FILLER_AFTER 0x0080 +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 +#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */ +#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */ +#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */ +/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000 */ +/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000 */ +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000 +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000 +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000 +#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */ +#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */ +#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */ + /* 0x800000 unused */ + /* 0x1000000 unused */ + /* 0x2000000 unused */ + /* 0x4000000 unused */ + /* 0x8000000 unused */ + /* 0x10000000 unused */ + /* 0x20000000 unused */ + /* 0x40000000 unused */ + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* Save typing and make code easier to understand */ + +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255 + * by dividing by 257 *with rounding*. This macro is exact for the given range. + * See the discourse in pngrtran.c png_do_scale_16_to_8. The values in the + * macro were established by experiment (modifying the added value). The macro + * has a second variant that takes a value already scaled by 255 and divides by + * 65535 - this has a maximum error of .502. Over the range 0..65535*65535 it + * only gives off-by-one errors and only for 0.5% (1 in 200) of the values. + */ +#define PNG_DIV65535(v24) (((v24) + 32895) >> 16) +#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255) + +/* Added to libpng-1.2.6 JB */ +#define PNG_ROWBYTES(pixel_bits, width) \ + ((pixel_bits) >= 8 ? \ + ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \ + (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) ) + +/* PNG_OUT_OF_RANGE returns true if value is outside the range + * ideal-delta..ideal+delta. Each argument is evaluated twice. + * "ideal" and "delta" should be constants, normally simple + * integers, "value" a variable. Added to libpng-1.2.6 JB + */ +#define PNG_OUT_OF_RANGE(value, ideal, delta) \ + ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) + +/* Conversions between fixed and floating point, only defined if + * required (to make sure the code doesn't accidentally use float + * when it is supposedly disabled.) + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +/* The floating point conversion can't overflow, though it can and + * does lose accuracy relative to the original fixed point value. + * In practice this doesn't matter because png_fixed_point only + * stores numbers with very low precision. The png_ptr and s + * arguments are unused by default but are there in case error + * checking becomes a requirement. + */ +#define png_float(png_ptr, fixed, s) (.00001 * (fixed)) + +/* The fixed point conversion performs range checking and evaluates + * its argument multiple times, so must be used with care. The + * range checking uses the PNG specification values for a signed + * 32 bit fixed point value except that the values are deliberately + * rounded-to-zero to an integral value - 21474 (21474.83 is roughly + * (2^31-1) * 100000). 's' is a string that describes the value being + * converted. + * + * NOTE: this macro will raise a png_error if the range check fails, + * therefore it is normally only appropriate to use this on values + * that come from API calls or other sources where an out of range + * error indicates a programming error, not a data error! + * + * NOTE: by default this is off - the macro is not used - because the + * function call saves a lot of code. + */ +#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED +#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\ + ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0)) +#endif +/* else the corresponding function is defined below, inside the scope of the + * cplusplus test. + */ +#endif + +/* Constants for known chunk types. If you need to add a chunk, define the name + * here. For historical reasons these constants have the form png_<name>; i.e. + * the prefix is lower case. Please use decimal values as the parameters to + * match the ISO PNG specification and to avoid relying on the C locale + * interpretation of character values. + * + * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values + * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string + * to be generated if required. + * + * PNG_32b correctly produces a value shifted by up to 24 bits, even on + * architectures where (int) is only 16 bits. + */ +#define PNG_32b(b,s) ((png_uint_32)(b) << (s)) +#define PNG_CHUNK(b1,b2,b3,b4) \ + (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0)) + +#define png_IHDR PNG_CHUNK( 73, 72, 68, 82) +#define png_IDAT PNG_CHUNK( 73, 68, 65, 84) +#define png_IEND PNG_CHUNK( 73, 69, 78, 68) +#define png_PLTE PNG_CHUNK( 80, 76, 84, 69) +#define png_bKGD PNG_CHUNK( 98, 75, 71, 68) +#define png_cHRM PNG_CHUNK( 99, 72, 82, 77) +#define png_gAMA PNG_CHUNK(103, 65, 77, 65) +#define png_hIST PNG_CHUNK(104, 73, 83, 84) +#define png_iCCP PNG_CHUNK(105, 67, 67, 80) +#define png_iTXt PNG_CHUNK(105, 84, 88, 116) +#define png_oFFs PNG_CHUNK(111, 70, 70, 115) +#define png_pCAL PNG_CHUNK(112, 67, 65, 76) +#define png_sCAL PNG_CHUNK(115, 67, 65, 76) +#define png_pHYs PNG_CHUNK(112, 72, 89, 115) +#define png_sBIT PNG_CHUNK(115, 66, 73, 84) +#define png_sPLT PNG_CHUNK(115, 80, 76, 84) +#define png_sRGB PNG_CHUNK(115, 82, 71, 66) +#define png_sTER PNG_CHUNK(115, 84, 69, 82) +#define png_tEXt PNG_CHUNK(116, 69, 88, 116) +#define png_tIME PNG_CHUNK(116, 73, 77, 69) +#define png_tRNS PNG_CHUNK(116, 82, 78, 83) +#define png_zTXt PNG_CHUNK(122, 84, 88, 116) + +/* The following will work on (signed char*) strings, whereas the get_uint_32 + * macro will fail on top-bit-set values because of the sign extension. + */ +#define PNG_CHUNK_FROM_STRING(s)\ + PNG_CHUNK(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3]) + +/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is + * signed and the argument is a (char[]) This macro will fail miserably on + * systems where (char) is more than 8 bits. + */ +#define PNG_STRING_FROM_CHUNK(s,c)\ + (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\ + ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c))) + +/* Do the same but terminate with a null character. */ +#define PNG_CSTRING_FROM_CHUNK(s,c)\ + (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0) + +/* Test on flag values as defined in the spec (section 5.4): */ +#define PNG_CHUNK_ANCILLIARY(c) (1 & ((c) >> 29)) +#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLIARY(c)) +#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21)) +#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13)) +#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5)) + +/* Gamma values (new at libpng-1.5.4): */ +#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */ +#define PNG_GAMMA_MAC_INVERSE 65909 +#define PNG_GAMMA_sRGB_INVERSE 45455 + +/* Almost everything below is C specific; the #defines above can be used in + * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot. + */ +#ifndef PNG_VERSION_INFO_ONLY + +#include "pngstruct.h" +#include "pnginfo.h" + +/* This is used for 16 bit gamma tables -- only the top level pointers are + * const; this could be changed: + */ +typedef const png_uint_16p * png_const_uint_16pp; + +/* Added to libpng-1.5.7: sRGB conversion tables */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED +PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]); + /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value, + * 0..65535. This table gives the closest 16-bit answers (no errors). + */ +#endif + +PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]); +PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); + +#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\ + ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)) + /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB + * encoded value with maximum error 0.646365. Note that the input is not a + * 16-bit value; it has been multiplied by 255! */ +#endif /* PNG_SIMPLIFIED_READ/WRITE */ + + +/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Internal functions; these are not exported from a DLL however because they + * are used within several of the C source files they have to be C extern. + * + * All of these functions must be declared with PNG_INTERNAL_FUNCTION. + */ + +/* Zlib support */ +#define PNG_UNEXPECTED_ZLIB_RETURN (-7) +PNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret), + PNG_EMPTY); + /* Used by the zlib handling functions to ensure that z_stream::msg is always + * set before they return. + */ + +#ifdef PNG_WRITE_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr, + png_compression_bufferp *list),PNG_EMPTY); + /* Free the buffer list used by the compressed write code. */ +#endif + +#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ + !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ + (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ + defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ + (defined(PNG_sCAL_SUPPORTED) && \ + defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) +PNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr, + double fp, png_const_charp text),PNG_EMPTY); +#endif + +/* Check the user version string for compatibility, returns false if the version + * numbers aren't compatible. + */ +PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr, + png_const_charp user_png_ver),PNG_EMPTY); + +/* Internal base allocator - no messages, NULL on failure to allocate. This + * does, however, call the application provided allocator and that could call + * png_error (although that would be a bug in the application implementation.) + */ +PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr, + png_alloc_size_t size),PNG_ALLOCATED); + +#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\ + defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) +/* Internal array allocator, outputs no error or warning messages on failure, + * just returns NULL. + */ +PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr, + int nelements, size_t element_size),PNG_ALLOCATED); + +/* The same but an existing array is extended by add_elements. This function + * also memsets the new elements to 0 and copies the old elements. The old + * array is not freed or altered. + */ +PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr, + png_const_voidp array, int old_elements, int add_elements, + size_t element_size),PNG_ALLOCATED); +#endif /* text, sPLT or unknown chunks */ + +/* Magic to create a struct when there is no struct to call the user supplied + * memory allocators. Because error handling has not been set up the memory + * handlers can't safely call png_error, but this is an obscure and undocumented + * restriction so libpng has to assume that the 'free' handler, at least, might + * call png_error. + */ +PNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, + png_free_ptr free_fn),PNG_ALLOCATED); + +/* Free memory from internal libpng struct */ +PNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr), + PNG_EMPTY); + +/* Free an allocated jmp_buf (always succeeds) */ +PNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY); + +/* Function to allocate memory for zlib. PNGAPI is disallowed. */ +PNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size), + PNG_ALLOCATED); + +/* Function to free memory for zlib. PNGAPI is disallowed. */ +PNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY); + +/* Next four functions are used internally as callbacks. PNGCBAPI is required + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to + * PNGCBAPI at 1.5.0 + */ + +PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr, + png_bytep data, png_size_t length),PNG_EMPTY); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr, + png_bytep buffer, png_size_t length),PNG_EMPTY); +#endif + +PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr, + png_bytep data, png_size_t length),PNG_EMPTY); + +#ifdef PNG_WRITE_FLUSH_SUPPORTED +# ifdef PNG_STDIO_SUPPORTED +PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr), + PNG_EMPTY); +# endif +#endif + +/* Reset the CRC variable */ +PNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY); + +/* Write the "data" buffer to whatever output you are using */ +PNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr, + png_const_bytep data, png_size_t length),PNG_EMPTY); + +/* Read and check the PNG file signature */ +PNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); + +/* Read the chunk header (length + type name) */ +PNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr), + PNG_EMPTY); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data, + png_size_t length),PNG_EMPTY); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf, + png_uint_32 length),PNG_EMPTY); + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr, + png_uint_32 skip),PNG_EMPTY); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr, + png_const_bytep ptr, png_size_t length),PNG_EMPTY); + +#ifdef PNG_WRITE_FLUSH_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY); +#endif + +/* Write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, + int compression_method, int filter_method, int interlace_method),PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr, + png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr, + png_const_bytep row_data, png_alloc_size_t row_data_length, int flush), + PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY); + +#ifdef PNG_WRITE_gAMA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr, + png_fixed_point file_gamma),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_sBIT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr, + png_const_color_8p sbit, int color_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_cHRM_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr, + const png_xy *xy), PNG_EMPTY); + /* The xy value must have been previously validated */ +#endif + +#ifdef PNG_WRITE_sRGB_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr, + int intent),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_iCCP_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr, + png_const_charp name, png_const_bytep profile), PNG_EMPTY); + /* The profile must have been previously validated for correctness, the + * length comes from the first four bytes. Only the base, deflate, + * compression is supported. + */ +#endif + +#ifdef PNG_WRITE_sPLT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr, + png_const_sPLT_tp palette),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_tRNS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr, + png_const_bytep trans, png_const_color_16p values, int number, + int color_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_bKGD_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr, + png_const_color_16p values, int color_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_hIST_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr, + png_const_uint_16p hist, int num_hist),PNG_EMPTY); +#endif + +/* Chunks that have keywords */ +#ifdef PNG_WRITE_tEXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr, + png_const_charp key, png_const_charp text, png_size_t text_len),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_zTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp + key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_iTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr, + int compression, png_const_charp key, png_const_charp lang, + png_const_charp lang_key, png_const_charp text),PNG_EMPTY); +#endif + +#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */ +PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr, + png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_oFFs_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr, + png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_pCAL_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr, + png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, + png_const_charp units, png_charpp params),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_pHYs_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_tIME_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr, + png_const_timep mod_time),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_sCAL_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr, + int unit, png_const_charp width, png_const_charp height),PNG_EMPTY); +#endif + +/* Called when finished processing a row of data */ +PNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr), + PNG_EMPTY); + +/* Internal use only. Called before first row of data */ +PNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr), + PNG_EMPTY); + +/* Combine a row of data, dealing with alpha, etc. if requested. 'row' is an + * array of png_ptr->width pixels. If the image is not interlaced or this + * is the final pass this just does a memcpy, otherwise the "display" flag + * is used to determine whether to copy pixels that are not in the current pass. + * + * Because 'png_do_read_interlace' (below) replicates pixels this allows this + * function to achieve the documented 'blocky' appearance during interlaced read + * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row' + * are not changed if they are not in the current pass, when display is 0. + * + * 'display' must be 0 or 1, otherwise the memcpy will be done regardless. + * + * The API always reads from the png_struct row buffer and always assumes that + * it is full width (png_do_read_interlace has already been called.) + * + * This function is only ever used to write to row buffers provided by the + * caller of the relevant libpng API and the row must have already been + * transformed by the read transformations. + * + * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed + * bitmasks for use within the code, otherwise runtime generated masks are used. + * The default is compile time masks. + */ +#ifndef PNG_USE_COMPILE_TIME_MASKS +# define PNG_USE_COMPILE_TIME_MASKS 1 +#endif +PNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr, + png_bytep row, int display),PNG_EMPTY); + +#ifdef PNG_READ_INTERLACING_SUPPORTED +/* Expand an interlaced row: the 'row_info' describes the pass data that has + * been read in and must correspond to the pixels in 'row', the pixels are + * expanded (moved apart) in 'row' to match the final layout, when doing this + * the pixels are *replicated* to the intervening space. This is essential for + * the correct operation of png_combine_row, above. + */ +PNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED +/* Grab pixels out of a row for an interlaced pass */ +PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info, + png_bytep row, int pass),PNG_EMPTY); +#endif + +/* Unfilter a row: check the filter value before calling this, there is no point + * calling it for PNG_FILTER_VALUE_NONE. + */ +PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop + row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info, + png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); + +/* Choose the best filter to use and filter the row data */ +PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr, + png_row_infop row_info),PNG_EMPTY); + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr, + png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY); + /* Read 'avail_out' bytes of data from the IDAT stream. If the output buffer + * is NULL the function checks, instead, for the end of the stream. In this + * case a benign error will be issued if the stream end is not found or if + * extra data has to be consumed. + */ +PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr), + PNG_EMPTY); + /* This cleans up when the IDAT LZ stream does not end when the last image + * byte is read; there is still some pending input. + */ + +PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr), + PNG_EMPTY); + /* Finish a row while reading, dealing with interlacing passes, etc. */ +#endif + +/* Initialize the row buffers, etc. */ +PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY); + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* Optional call to update the users info structure */ +PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +#endif + +/* These are the functions that do the transformations */ +#ifdef PNG_READ_FILLER_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_read_filler,(png_row_infop row_info, + png_bytep row, png_uint_32 filler, png_uint_32 flags),PNG_EMPTY); +#endif + +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_read_swap_alpha,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_write_swap_alpha,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_read_invert_alpha,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_write_invert_alpha,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info, + png_bytep row, int at_start),PNG_EMPTY); +#endif + +#ifdef PNG_16BIT_SUPPORTED +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ + defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +PNG_INTERNAL_FUNCTION(int,png_do_rgb_to_gray,(png_structrp png_ptr, + png_row_infop row_info, png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_gray_to_rgb,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_READ_PACK_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_unpack,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_READ_SHIFT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_unshift,(png_row_infop row_info, + png_bytep row, png_const_color_8p sig_bits),PNG_EMPTY); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_scale_16_to_8,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_chop,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_quantize,(png_row_infop row_info, + png_bytep row, png_const_bytep palette_lookup, + png_const_bytep quantize_lookup),PNG_EMPTY); + +# ifdef PNG_CORRECT_PALETTE_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_correct_palette,(png_structrp png_ptr, + png_colorp palette, int num_palette),PNG_EMPTY); +# endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_PACK_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_pack,(png_row_infop row_info, + png_bytep row, png_uint_32 bit_depth),PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_SHIFT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_shift,(png_row_infop row_info, + png_bytep row, png_const_color_8p bit_depth),PNG_EMPTY); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_compose,(png_row_infop row_info, + png_bytep row, png_structrp png_ptr),PNG_EMPTY); +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_gamma,(png_row_infop row_info, + png_bytep row, png_structrp png_ptr),PNG_EMPTY); +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_encode_alpha,(png_row_infop row_info, + png_bytep row, png_structrp png_ptr),PNG_EMPTY); +#endif + +#ifdef PNG_READ_EXPAND_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_expand_palette,(png_row_infop row_info, + png_bytep row, png_const_colorp palette, png_const_bytep trans, + int num_trans),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_do_expand,(png_row_infop row_info, + png_bytep row, png_const_color_16p trans_color),PNG_EMPTY); +#endif + +#ifdef PNG_READ_EXPAND_16_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_expand_16,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* Decode the IHDR chunk */ +PNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); + +#ifdef PNG_READ_bKGD_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_cHRM_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_gAMA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_hIST_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_iCCP_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#ifdef PNG_READ_iTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_oFFs_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_pCAL_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_pHYs_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_sBIT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_sCAL_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_sPLT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#ifdef PNG_READ_sRGB_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_tEXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_tIME_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_tRNS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +#ifdef PNG_READ_zTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + +PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr, + png_uint_32 chunk_name),PNG_EMPTY); + +#ifdef PNG_READ_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY); + /* This is the function that gets called for unknown chunks. The 'keep' + * argument is either non-zero for a known chunk that has been set to be + * handled as unknown or zero for an unknown chunk. By default the function + * just skips the chunk or errors out if it is critical. + */ + +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED +PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling, + (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY); + /* Exactly as the API png_handle_as_unknown() except that the argument is a + * 32-bit chunk name, not a string. + */ +#endif +#endif /* PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ +#endif /* PNG_READ_SUPPORTED */ + +/* Handle the transformations for reading and writing */ +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr, + png_row_infop row_info),PNG_EMPTY); +#endif +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr, + png_row_infop row_info),PNG_EMPTY); +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr), + PNG_EMPTY); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr, + png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr, + png_bytep buffer, png_size_t buffer_length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr, + png_bytep buffer, png_size_t buffer_length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr, + png_bytep row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr), + PNG_EMPTY); +# ifdef PNG_READ_tEXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +# endif +# ifdef PNG_READ_zTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +# endif +# ifdef PNG_READ_iTXt_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr, + png_inforp info_ptr),PNG_EMPTY); +# endif + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_do_read_intrapixel,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_do_write_intrapixel,(png_row_infop row_info, + png_bytep row),PNG_EMPTY); +#endif + +/* Added at libpng version 1.6.0 */ +#ifdef PNG_GAMMA_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY); + /* Set the colorspace gamma with a value provided by the application or by + * the gAMA chunk on read. The value will override anything set by an ICC + * profile. + */ + +PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr, + png_inforp info_ptr), PNG_EMPTY); + /* Synchronize the info 'valid' flags with the colorspace */ + +PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr, + png_inforp info_ptr), PNG_EMPTY); + /* Copy the png_struct colorspace to the info_struct and call the above to + * synchronize the flags. Checks for NULL info_ptr and does nothing. + */ +#endif + +/* Added at libpng version 1.4.0 */ +#ifdef PNG_COLORSPACE_SUPPORTED +/* These internal functions are for maintaining the colorspace structure within + * a png_info or png_struct (or, indeed, both). + */ +PNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities, + (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy, + int preferred), PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints, + (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ, + int preferred), PNG_EMPTY); + +#ifdef PNG_sRGB_SUPPORTED +PNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr, + png_colorspacerp colorspace, int intent), PNG_EMPTY); + /* This does set the colorspace gAMA and cHRM values too, but doesn't set the + * flags to write them, if it returns false there was a problem and an error + * message has already been output (but the colorspace may still need to be + * synced to record the invalid flag). + */ +#endif /* sRGB */ + +#ifdef PNG_iCCP_SUPPORTED +PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_charp name, + png_uint_32 profile_length, png_const_bytep profile, int color_type), + PNG_EMPTY); + /* The 'name' is used for information only */ + +/* Routines for checking parts of an ICC profile. */ +PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_charp name, + png_uint_32 profile_length), PNG_EMPTY); +PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_charp name, + png_uint_32 profile_length, + png_const_bytep profile /* first 132 bytes only */, int color_type), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr, + png_colorspacerp colorspace, png_const_charp name, + png_uint_32 profile_length, + png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY); +#ifdef PNG_sRGB_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,( + png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_bytep profile, uLong adler), PNG_EMPTY); + /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may + * be zero to indicate that it is not available. It is used, if provided, + * as a fast check on the profile when checking to see if it is sRGB. + */ +#endif +#endif /* iCCP */ + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients, + (png_structrp png_ptr), PNG_EMPTY); + /* Set the rgb_to_gray coefficients from the colorspace Y values */ +#endif /* READ_RGB_TO_GRAY */ +#endif /* COLORSPACE */ + +/* Added at libpng version 1.4.0 */ +PNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type),PNG_EMPTY); + +/* Added at libpng version 1.5.10 */ +#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ + defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes, + (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY); +#endif + +#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) +PNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr, + png_const_charp name),PNG_NORETURN); +#endif + +/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite + * the end. Always leaves the buffer nul terminated. Never errors out (and + * there is no error code.) + */ +PNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize, + size_t pos, png_const_charp string),PNG_EMPTY); + +/* Various internal functions to handle formatted warning messages, currently + * only implemented for warnings. + */ +#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED) +/* Utility to dump an unsigned value into a buffer, given a start pointer and + * and end pointer (which should point just *beyond* the end of the buffer!) + * Returns the pointer to the start of the formatted string. This utility only + * does unsigned values. + */ +PNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start, + png_charp end, int format, png_alloc_size_t number),PNG_EMPTY); + +/* Convenience macro that takes an array: */ +#define PNG_FORMAT_NUMBER(buffer,format,number) \ + png_format_number(buffer, buffer + (sizeof buffer), format, number) + +/* Suggested size for a number buffer (enough for 64 bits and a sign!) */ +#define PNG_NUMBER_BUFFER_SIZE 24 + +/* These are the integer formats currently supported, the name is formed from + * the standard printf(3) format string. + */ +#define PNG_NUMBER_FORMAT_u 1 /* chose unsigned API! */ +#define PNG_NUMBER_FORMAT_02u 2 +#define PNG_NUMBER_FORMAT_d 1 /* chose signed API! */ +#define PNG_NUMBER_FORMAT_02d 2 +#define PNG_NUMBER_FORMAT_x 3 +#define PNG_NUMBER_FORMAT_02x 4 +#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */ +#endif + +#ifdef PNG_WARNINGS_SUPPORTED +/* New defines and members adding in libpng-1.5.4 */ +# define PNG_WARNING_PARAMETER_SIZE 32 +# define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */ + +/* An l-value of this type has to be passed to the APIs below to cache the + * values of the parameters to a formatted warning message. + */ +typedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][ + PNG_WARNING_PARAMETER_SIZE]; + +PNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p, + int number, png_const_charp string),PNG_EMPTY); + /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters, + * including the trailing '\0'. + */ +PNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned, + (png_warning_parameters p, int number, int format, png_alloc_size_t value), + PNG_EMPTY); + /* Use png_alloc_size_t because it is an unsigned type as big as any we + * need to output. Use the following for a signed value. + */ +PNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed, + (png_warning_parameters p, int number, int format, png_int_32 value), + PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr, + png_warning_parameters p, png_const_charp message),PNG_EMPTY); + /* 'message' follows the X/Open approach of using @1, @2 to insert + * parameters previously supplied using the above functions. Errors in + * specifying the parameters will simply result in garbage substitutions. + */ +#endif + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +/* Application errors (new in 1.6); use these functions (declared below) for + * errors in the parameters or order of API function calls on read. The + * 'warning' should be used for an error that can be handled completely; the + * 'error' for one which can be handled safely but which may lose application + * information or settings. + * + * By default these both result in a png_error call prior to release, while in a + * released version the 'warning' is just a warning. However if the application + * explicitly disables benign errors (explicitly permitting the code to lose + * information) they both turn into warnings. + * + * If benign errors aren't supported they end up as the corresponding base call + * (png_warning or png_error.) + */ +PNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr, + png_const_charp message),PNG_EMPTY); + /* The application provided invalid parameters to an API function or called + * an API function at the wrong time, libpng can completely recover. + */ + +PNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr, + png_const_charp message),PNG_EMPTY); + /* As above but libpng will ignore the call, or attempt some other partial + * recovery from the error. + */ +#else +# define png_app_warning(pp,s) png_warning(pp,s) +# define png_app_error(pp,s) png_error(pp,s) +#endif + +PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr, + png_const_charp message, int error),PNG_EMPTY); + /* Report a recoverable issue in chunk data. On read this is used to report + * a problem found while reading a particular chunk and the + * png_chunk_benign_error or png_chunk_warning function is used as + * appropriate. On write this is used to report an error that comes from + * data set via an application call to a png_set_ API and png_app_error or + * png_app_warning is used as appropriate. + * + * The 'error' parameter must have one of the following values: + */ +#define PNG_CHUNK_WARNING 0 /* never an error */ +#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */ +#define PNG_CHUNK_ERROR 2 /* always an error */ + +/* ASCII to FP interfaces, currently only implemented if sCAL + * support is required. + */ +#if defined(PNG_sCAL_SUPPORTED) +/* MAX_DIGITS is actually the maximum number of characters in an sCAL + * width or height, derived from the precision (number of significant + * digits - a build time settable option) and assumptions about the + * maximum ridiculous exponent. + */ +#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/) + +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr, + png_charp ascii, png_size_t size, double fp, unsigned int precision), + PNG_EMPTY); +#endif /* FLOATING_POINT */ + +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr, + png_charp ascii, png_size_t size, png_fixed_point fp),PNG_EMPTY); +#endif /* FIXED_POINT */ +#endif /* sCAL */ + +#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) +/* An internal API to validate the format of a floating point number. + * The result is the index of the next character. If the number is + * not valid it will be the index of a character in the supposed number. + * + * The format of a number is defined in the PNG extensions specification + * and this API is strictly conformant to that spec, not anyone elses! + * + * The format as a regular expression is: + * + * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)? + * + * or: + * + * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)? + * + * The complexity is that either integer or fraction must be present and the + * fraction is permitted to have no digits only if the integer is present. + * + * NOTE: The dangling E problem. + * There is a PNG valid floating point number in the following: + * + * PNG floating point numbers are not greedy. + * + * Working this out requires *TWO* character lookahead (because of the + * sign), the parser does not do this - it will fail at the 'r' - this + * doesn't matter for PNG sCAL chunk values, but it requires more care + * if the value were ever to be embedded in something more complex. Use + * ANSI-C strtod if you need the lookahead. + */ +/* State table for the parser. */ +#define PNG_FP_INTEGER 0 /* before or in integer */ +#define PNG_FP_FRACTION 1 /* before or in fraction */ +#define PNG_FP_EXPONENT 2 /* before or in exponent */ +#define PNG_FP_STATE 3 /* mask for the above */ +#define PNG_FP_SAW_SIGN 4 /* Saw +/- in current state */ +#define PNG_FP_SAW_DIGIT 8 /* Saw a digit in current state */ +#define PNG_FP_SAW_DOT 16 /* Saw a dot in current state */ +#define PNG_FP_SAW_E 32 /* Saw an E (or e) in current state */ +#define PNG_FP_SAW_ANY 60 /* Saw any of the above 4 */ + +/* These three values don't affect the parser. They are set but not used. + */ +#define PNG_FP_WAS_VALID 64 /* Preceding substring is a valid fp number */ +#define PNG_FP_NEGATIVE 128 /* A negative number, including "-0" */ +#define PNG_FP_NONZERO 256 /* A non-zero value */ +#define PNG_FP_STICKY 448 /* The above three flags */ + +/* This is available for the caller to store in 'state' if required. Do not + * call the parser after setting it (the parser sometimes clears it.) + */ +#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */ + +/* Result codes for the parser (boolean - true meants ok, false means + * not ok yet.) + */ +#define PNG_FP_MAYBE 0 /* The number may be valid in the future */ +#define PNG_FP_OK 1 /* The number is valid */ + +/* Tests on the sticky non-zero and negative flags. To pass these checks + * the state must also indicate that the whole number is valid - this is + * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this + * is equivalent to PNG_FP_OK above.) + */ +#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO) + /* NZ_MASK: the string is valid and a non-zero negative value */ +#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO) + /* Z MASK: the string is valid and a non-zero value. */ + /* PNG_FP_SAW_DIGIT: the string is valid. */ +#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT) +#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK) +#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK) + +/* The actual parser. This can be called repeatedly. It updates + * the index into the string and the state variable (which must + * be initialized to 0). It returns a result code, as above. There + * is no point calling the parser any more if it fails to advance to + * the end of the string - it is stuck on an invalid character (or + * terminated by '\0'). + * + * Note that the pointer will consume an E or even an E+ and then leave + * a 'maybe' state even though a preceding integer.fraction is valid. + * The PNG_FP_WAS_VALID flag indicates that a preceding substring was + * a valid number. It's possible to recover from this by calling + * the parser again (from the start, with state 0) but with a string + * that omits the last character (i.e. set the size to the index of + * the problem character.) This has not been tested within libpng. + */ +PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string, + png_size_t size, int *statep, png_size_tp whereami),PNG_EMPTY); + +/* This is the same but it checks a complete string and returns true + * only if it just contains a floating point number. As of 1.5.4 this + * function also returns the state at the end of parsing the number if + * it was valid (otherwise it returns 0.) This can be used for testing + * for negative or zero values using the sticky flag. + */ +PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string, + png_size_t size),PNG_EMPTY); +#endif /* pCAL || sCAL */ + +#if defined(PNG_READ_GAMMA_SUPPORTED) ||\ + defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) +/* Added at libpng version 1.5.0 */ +/* This is a utility to provide a*times/div (rounded) and indicate + * if there is an overflow. The result is a boolean - false (0) + * for overflow, true (1) if no overflow, in which case *res + * holds the result. + */ +PNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a, + png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) +/* Same deal, but issue a warning on overflow and return 0. */ +PNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn, + (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by, + png_int_32 divided_by),PNG_EMPTY); +#endif + +#ifdef PNG_GAMMA_SUPPORTED +/* Calculate a reciprocal - used for gamma values. This returns + * 0 if the argument is 0 in order to maintain an undefined value; + * there are no warnings. + */ +PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a), + PNG_EMPTY); + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* The same but gives a reciprocal of the product of two fixed point + * values. Accuracy is suitable for gamma calculations but this is + * not exact - use png_muldiv for that. Only required at present on read. + */ +PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a, + png_fixed_point b),PNG_EMPTY); +#endif + +/* Return true if the gamma value is significantly different from 1.0 */ +PNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value), + PNG_EMPTY); +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* Internal fixed point gamma correction. These APIs are called as + * required to convert single values - they don't need to be fast, + * they are not used when processing image pixel values. + * + * While the input is an 'unsigned' value it must actually be the + * correct bit value - 0..255 or 0..65535 as required. + */ +PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr, + unsigned int value, png_fixed_point gamma_value),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value, + png_fixed_point gamma_value),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value, + png_fixed_point gamma_value),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr, + int bit_depth),PNG_EMPTY); +#endif + +/* SIMPLIFIED READ/WRITE SUPPORT */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) +/* The internal structure that png_image::opaque points to. */ +typedef struct png_control +{ + png_structp png_ptr; + png_infop info_ptr; + png_voidp error_buf; /* Always a jmp_buf at present. */ + + png_const_bytep memory; /* Memory buffer. */ + png_size_t size; /* Size of the memory buffer. */ + + unsigned int for_write :1; /* Otherwise it is a read structure */ + unsigned int owned_file :1; /* We own the file in io_ptr */ +} png_control; + +/* Return the pointer to the jmp_buf from a png_control: necessary because C + * does not reveal the type of the elements of jmp_buf. + */ +#ifdef __cplusplus +# define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0]) +#else +# define png_control_jmp_buf(pc) ((pc)->error_buf) +#endif + +/* Utility to safely execute a piece of libpng code catching and logging any + * errors that might occur. Returns true on success, false on failure (either + * of the function or as a result of a png_error.) + */ +PNG_INTERNAL_FUNCTION(void,png_safe_error,(png_structp png_ptr, + png_const_charp error_message),PNG_NORETURN); + +#ifdef PNG_WARNINGS_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_safe_warning,(png_structp png_ptr, + png_const_charp warning_message),PNG_EMPTY); +#else +# define png_safe_warning 0/*dummy argument*/ +#endif + +PNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image, + int (*function)(png_voidp), png_voidp arg),PNG_EMPTY); + +/* Utility to log an error; this also cleans up the png_image; the function + * always returns 0 (false). + */ +PNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image, + png_const_charp error_message),PNG_EMPTY); + +#ifndef PNG_SIMPLIFIED_READ_SUPPORTED +/* png_image_free is used by the write code but not exported */ +PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY); +#endif /* !SIMPLIFIED_READ */ + +#endif /* SIMPLIFIED READ/WRITE */ + +#ifdef PNG_FILTER_OPTIMIZATIONS +PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, + unsigned int bpp), PNG_EMPTY); + /* This is the initialization function for hardware specific optimizations, + * one implementation (for ARM NEON machines) is contained in + * arm/filter_neon.c. It need not be defined - the generic code will be used + * if not. + */ +#endif + +/* Maintainer: Put new private prototypes here ^ */ + +//#include "pngdebug.h" + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +#endif /* PNGPRIV_H */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngread.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngread.c index cd93a0b7e..85a7d6163 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngread.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngread.c @@ -1,312 +1,85 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.2.20 September 7, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file contains routines that an application calls directly to * read a PNG file or stream. */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) +# include <errno.h> +#endif -#if defined(PNG_READ_SUPPORTED) +#ifdef PNG_READ_SUPPORTED /* Create a PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) +PNG_FUNCTION(png_structp,PNGAPI +png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED) { - -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); +#ifndef PNG_USER_MEM_SUPPORTED + png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, + error_fn, warn_fn, NULL, NULL, NULL); +#else + return png_create_read_struct_2(user_png_ver, error_ptr, error_fn, + warn_fn, NULL, NULL, NULL); } -/* Alternate create PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) +/* Alternate create PNG structure for reading, and allocate any memory + * needed. + */ +PNG_FUNCTION(png_structp,PNGAPI +png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) { + png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, + error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); #endif /* PNG_USER_MEM_SUPPORTED */ - png_structp png_ptr; - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - - int i; - - png_debug(1, "in png_create_read_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif - if (png_ptr == NULL) - return (NULL); - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, - (png_free_ptr)free_fn, (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif - - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do + if (png_ptr != NULL) { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); + png_ptr->mode = PNG_IS_READ_STRUCT; - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - png_snprintf(msg, 80, - "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - } + /* Added in libpng-1.6.0; this can be used to detect a read structure if + * required (it will be zero in a write structure.) + */ +# ifdef PNG_SEQUENTIAL_READ_SUPPORTED + png_ptr->IDAT_read_size = PNG_IDAT_READ_SIZE; +# endif - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; +# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED + png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; - default: png_error(png_ptr, "Unknown zlib error"); + /* In stable builds only warn if an application error can be completely + * handled. + */ +# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC + png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; +# endif +# endif + + /* TODO: delay this, it can be done in png_init_io (if the app doesn't + * do it itself) avoiding setting the default function if it is not + * required. + */ + png_set_read_fn(png_ptr, NULL, NULL); } - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Initialize PNG structure for reading, and allocate any memory needed. - This interface is deprecated in favour of the png_create_read_struct(), - and it will disappear as of libpng-1.3.0. */ -#undef png_read_init -void PNGAPI -png_read_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - png_snprintf(msg, 80, - "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for reading is too small."); - } - if(png_sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by application for reading is too small."); - } - png_read_init_3(&png_ptr, user_png_ver, png_struct_size); + return png_ptr; } -#endif /* PNG_1_0_X || PNG_1_2_X */ - -void PNGAPI -png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i=0; - - png_structp png_ptr=*ptr_ptr; - - if(png_ptr == NULL) return; - - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_read_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_read_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - if(png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - png_ptr = *ptr_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); -} - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. This has been * changed in v0.90 to allow reading a file that already has the magic * bytes read from the stream. You can tell libpng how many bytes have @@ -316,301 +89,294 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, * read if it is determined that this isn't a valid PNG file. */ void PNGAPI -png_read_info(png_structp png_ptr, png_infop info_ptr) +png_read_info(png_structrp png_ptr, png_inforp info_ptr) { - if(png_ptr == NULL) return; - png_debug(1, "in png_read_info\n"); - /* If we haven't checked all of the PNG signature bytes, do so now. */ - if (png_ptr->sig_bytes < 8) - { - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + int keep; +#endif - png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = 8; + png_debug(1, "in png_read_info"); - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - if (num_checked < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; - } + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* Read and check the PNG file signature. */ + png_read_sig(png_ptr, info_ptr); - for(;;) + for (;;) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IHDR; - PNG_CONST PNG_IDAT; - PNG_CONST PNG_IEND; - PNG_CONST PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_CONST PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_CONST PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_CONST PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_CONST PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_CONST PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_CONST PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_CONST PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_CONST PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_CONST PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_CONST PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_CONST PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_CONST PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_CONST PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_CONST PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_CONST PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_CONST PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_CONST PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - png_byte chunk_length[4]; - png_uint_32 length; + png_uint_32 length = png_read_chunk_header(png_ptr); + png_uint_32 chunk_name = png_ptr->chunk_name; + + /* IDAT logic needs to happen here to simplify getting the two flags + * right. + */ + if (chunk_name == png_IDAT) + { + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_chunk_error(png_ptr, "Missing IHDR before IDAT"); + + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_chunk_error(png_ptr, "Missing PLTE before IDAT"); - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); + else if (png_ptr->mode & PNG_AFTER_IDAT) + png_chunk_benign_error(png_ptr, "Too many IDATs found"); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_ptr->mode |= PNG_HAVE_IDAT; + } - png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, - length); + else if (png_ptr->mode & PNG_HAVE_IDAT) + png_ptr->mode |= PNG_AFTER_IDAT; /* This should be a binary subdivision search or a hash for * matching the chunk name rather than a linear search. */ - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + if (chunk_name == png_IHDR) png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + + else if (chunk_name == png_IEND) png_handle_IEND(png_ptr, info_ptr, length); + #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_handle_unknown(png_ptr, info_ptr, length, keep); + + if (chunk_name == png_PLTE) png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + + else if (chunk_name == png_IDAT) { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); + png_ptr->idat_size = 0; /* It has been consumed */ break; } } #endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + else if (chunk_name == png_PLTE) png_handle_PLTE(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); + else if (chunk_name == png_IDAT) + { png_ptr->idat_size = length; - png_ptr->mode |= PNG_HAVE_IDAT; break; } -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + +#ifdef PNG_READ_bKGD_SUPPORTED + else if (chunk_name == png_bKGD) png_handle_bKGD(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + +#ifdef PNG_READ_cHRM_SUPPORTED + else if (chunk_name == png_cHRM) png_handle_cHRM(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + +#ifdef PNG_READ_gAMA_SUPPORTED + else if (chunk_name == png_gAMA) png_handle_gAMA(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + +#ifdef PNG_READ_hIST_SUPPORTED + else if (chunk_name == png_hIST) png_handle_hIST(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + +#ifdef PNG_READ_oFFs_SUPPORTED + else if (chunk_name == png_oFFs) png_handle_oFFs(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + +#ifdef PNG_READ_pCAL_SUPPORTED + else if (chunk_name == png_pCAL) png_handle_pCAL(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + +#ifdef PNG_READ_sCAL_SUPPORTED + else if (chunk_name == png_sCAL) png_handle_sCAL(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + +#ifdef PNG_READ_pHYs_SUPPORTED + else if (chunk_name == png_pHYs) png_handle_pHYs(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + +#ifdef PNG_READ_sBIT_SUPPORTED + else if (chunk_name == png_sBIT) png_handle_sBIT(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + +#ifdef PNG_READ_sRGB_SUPPORTED + else if (chunk_name == png_sRGB) png_handle_sRGB(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + +#ifdef PNG_READ_iCCP_SUPPORTED + else if (chunk_name == png_iCCP) png_handle_iCCP(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + +#ifdef PNG_READ_sPLT_SUPPORTED + else if (chunk_name == png_sPLT) png_handle_sPLT(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + +#ifdef PNG_READ_tEXt_SUPPORTED + else if (chunk_name == png_tEXt) png_handle_tEXt(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + +#ifdef PNG_READ_tIME_SUPPORTED + else if (chunk_name == png_tIME) png_handle_tIME(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + +#ifdef PNG_READ_tRNS_SUPPORTED + else if (chunk_name == png_tRNS) png_handle_tRNS(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + +#ifdef PNG_READ_zTXt_SUPPORTED + else if (chunk_name == png_zTXt) png_handle_zTXt(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + +#ifdef PNG_READ_iTXt_SUPPORTED + else if (chunk_name == png_iTXt) png_handle_iTXt(png_ptr, info_ptr, length); #endif + else - png_handle_unknown(png_ptr, info_ptr, length); + png_handle_unknown(png_ptr, info_ptr, length, + PNG_HANDLE_CHUNK_AS_DEFAULT); } } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -/* optional call to update the users info_ptr structure */ +/* Optional call to update the users info_ptr structure */ void PNGAPI -png_read_update_info(png_structp png_ptr, png_infop info_ptr) +png_read_update_info(png_structrp png_ptr, png_inforp info_ptr) { - png_debug(1, "in png_read_update_info\n"); - if(png_ptr == NULL) return; - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - else - png_warning(png_ptr, - "Ignoring extra png_read_update_info() call; row buffer not reallocated"); - png_read_transform_info(png_ptr, info_ptr); + png_debug(1, "in png_read_update_info"); + + if (png_ptr != NULL) + { + if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) + { + png_read_start_row(png_ptr); + +# ifdef PNG_READ_TRANSFORMS_SUPPORTED + png_read_transform_info(png_ptr, info_ptr); +# else + PNG_UNUSED(info_ptr) +# endif + } + + /* New in 1.6.0 this avoids the bug of doing the initializations twice */ + else + png_app_error(png_ptr, + "png_read_update_info/png_start_read_image: duplicate call"); + } } -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Initialize palette, background, etc, after transformations * are set, but before any reading takes place. This allows * the user to obtain a gamma-corrected palette, for example. * If the user doesn't call this, we will do it ourselves. */ void PNGAPI -png_start_read_image(png_structp png_ptr) +png_start_read_image(png_structrp png_ptr) { - png_debug(1, "in png_start_read_image\n"); - if(png_ptr == NULL) return; - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); + png_debug(1, "in png_start_read_image"); + + if (png_ptr != NULL) + { + if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) + png_read_start_row(png_ptr); + + /* New in 1.6.0 this avoids the bug of doing the initializations twice */ + else + png_app_error(png_ptr, + "png_start_read_image/png_read_update_info: duplicate call"); + } } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED void PNGAPI -png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) +png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IDAT; - PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, - 0xff}; - PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; -#endif - int ret; - if(png_ptr == NULL) return; - png_debug2(1, "in png_read_row (row %lu, pass %d)\n", - png_ptr->row_number, png_ptr->pass); + png_row_info row_info; + + if (png_ptr == NULL) + return; + + png_debug2(1, "in png_read_row (row %lu, pass %d)", + (unsigned long)png_ptr->row_number, png_ptr->pass); + + /* png_read_start_row sets the information (in particular iwidth) for this + * interlace pass. + */ if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); + + /* 1.5.6: row_info moved out of png_struct to a local here. */ + row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */ + row_info.color_type = png_ptr->color_type; + row_info.bit_depth = png_ptr->bit_depth; + row_info.channels = png_ptr->channels; + row_info.pixel_depth = png_ptr->pixel_depth; + row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); + if (png_ptr->row_number == 0 && png_ptr->pass == 0) { - /* check for transforms that have been set but were defined out */ + /* Check for transforms that have been set but were defined out */ #if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined"); #endif + #if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined"); #endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) + +#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ + !defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined"); #endif + #if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined"); #endif + #if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined"); #endif + #if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined"); #endif + #if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined"); #endif } -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* if interlaced and we do not need a new row, combine row and return */ +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* If interlaced and we do not need a new row, combine row and return. + * Notice that the pixels we have from previous rows have been transformed + * already; we can only combine like with like (transformed or + * untransformed) and, because of the libpng API for interlaced images, this + * means we must transform before de-interlacing. + */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { switch (png_ptr->pass) @@ -619,62 +385,68 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) if (png_ptr->row_number & 0x07) { if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); + png_combine_row(png_ptr, dsp_row, 1/*display*/); png_read_finish_row(png_ptr); return; } break; + case 1: if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) { if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); + png_combine_row(png_ptr, dsp_row, 1/*display*/); + png_read_finish_row(png_ptr); return; } break; + case 2: if ((png_ptr->row_number & 0x07) != 4) { if (dsp_row != NULL && (png_ptr->row_number & 4)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); + png_combine_row(png_ptr, dsp_row, 1/*display*/); + png_read_finish_row(png_ptr); return; } break; + case 3: if ((png_ptr->row_number & 3) || png_ptr->width < 3) { if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); + png_combine_row(png_ptr, dsp_row, 1/*display*/); + png_read_finish_row(png_ptr); return; } break; + case 4: if ((png_ptr->row_number & 3) != 2) { if (dsp_row != NULL && (png_ptr->row_number & 2)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); + png_combine_row(png_ptr, dsp_row, 1/*display*/); + png_read_finish_row(png_ptr); return; } break; + case 5: if ((png_ptr->row_number & 1) || png_ptr->width < 2) { if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); + png_combine_row(png_ptr, dsp_row, 1/*display*/); + png_read_finish_row(png_ptr); return; } break; + + default: case 6: if (!(png_ptr->row_number & 1)) { @@ -689,114 +461,85 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) if (!(png_ptr->mode & PNG_HAVE_IDAT)) png_error(png_ptr, "Invalid attempt to read row data"); - png_ptr->zstream.next_out = png_ptr->row_buf; - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - do - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; + /* Fill the row with IDAT data: */ + png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1); - png_crc_finish(png_ptr, 0); + if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) + { + if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) + png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, + png_ptr->prev_row + 1, png_ptr->row_buf[0]); + else + png_error(png_ptr, "bad adaptive filter value"); + } - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); + /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before + * 1.5.6, while the buffer really is this big in current versions of libpng + * it may not be in the future, so this was changed just to copy the + * interlaced count: + */ + memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, - (png_size_t)png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_error(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression error"); - - } while (png_ptr->zstream.avail_out); - - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - if(png_ptr->row_buf[0]) - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) +#ifdef PNG_MNG_FEATURES_SUPPORTED + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) { /* Intrapixel differencing */ - png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1); } #endif - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); +#ifdef PNG_READ_TRANSFORMS_SUPPORTED + if (png_ptr->transformations) + png_do_read_transformations(png_ptr, &row_info); +#endif + + /* The transformed pixel depth should match the depth now in row_info. */ + if (png_ptr->transformed_pixel_depth == 0) + { + png_ptr->transformed_pixel_depth = row_info.pixel_depth; + if (row_info.pixel_depth > png_ptr->maximum_pixel_depth) + png_error(png_ptr, "sequential row overflow"); + } + + else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth) + png_error(png_ptr, "internal sequential row size calculation error"); -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); + png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, + png_ptr->transformations); if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); + png_combine_row(png_ptr, dsp_row, 1/*display*/); + if (row != NULL) - png_combine_row(png_ptr, row, - png_pass_mask[png_ptr->pass]); + png_combine_row(png_ptr, row, 0/*row*/); } + else #endif { if (row != NULL) - png_combine_row(png_ptr, row, 0xff); + png_combine_row(png_ptr, row, -1/*ignored*/); + if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 0xff); + png_combine_row(png_ptr, dsp_row, -1/*ignored*/); } png_read_finish_row(png_ptr); if (png_ptr->read_row_fn != NULL) (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); + } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read one or more rows of image data. If the image is interlaced, * and png_set_interlace_handling() has been called, the rows need to * contain the contents of the rows from the previous pass. If the @@ -822,15 +565,18 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) */ void PNGAPI -png_read_rows(png_structp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows) +png_read_rows(png_structrp png_ptr, png_bytepp row, + png_bytepp display_row, png_uint_32 num_rows) { png_uint_32 i; png_bytepp rp; png_bytepp dp; - png_debug(1, "in png_read_rows\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_read_rows"); + + if (png_ptr == NULL) + return; + rp = row; dp = display_row; if (rp != NULL && dp != NULL) @@ -841,24 +587,26 @@ png_read_rows(png_structp png_ptr, png_bytepp row, png_read_row(png_ptr, rptr, dptr); } - else if(rp != NULL) + + else if (rp != NULL) for (i = 0; i < num_rows; i++) { png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, png_bytep_NULL); + png_read_row(png_ptr, rptr, NULL); rp++; } - else if(dp != NULL) + + else if (dp != NULL) for (i = 0; i < num_rows; i++) { png_bytep dptr = *dp; - png_read_row(png_ptr, png_bytep_NULL, dptr); + png_read_row(png_ptr, NULL, dptr); dp++; } } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the entire image. If the image has an alpha channel or a tRNS * chunk, and you have called png_handle_alpha()[*], you will need to * initialize the image to the current image that PNG will be overlaying. @@ -872,487 +620,363 @@ png_read_rows(png_structp png_ptr, png_bytepp row, * [*] png_handle_alpha() does not exist yet, as of this version of libpng */ void PNGAPI -png_read_image(png_structp png_ptr, png_bytepp image) +png_read_image(png_structrp png_ptr, png_bytepp image) { - png_uint_32 i,image_height; + png_uint_32 i, image_height; int pass, j; png_bytepp rp; - png_debug(1, "in png_read_image\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_read_image"); + + if (png_ptr == NULL) + return; #ifdef PNG_READ_INTERLACING_SUPPORTED - pass = png_set_interlace_handling(png_ptr); + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + { + pass = png_set_interlace_handling(png_ptr); + /* And make sure transforms are initialized. */ + png_start_read_image(png_ptr); + } + else + { + if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE)) + { + /* Caller called png_start_read_image or png_read_update_info without + * first turning on the PNG_INTERLACE transform. We can fix this here, + * but the caller should do it! + */ + png_warning(png_ptr, "Interlace handling should be turned on when " + "using png_read_image"); + /* Make sure this is set correctly */ + png_ptr->num_rows = png_ptr->height; + } + + /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in + * the above error case. + */ + pass = png_set_interlace_handling(png_ptr); + } #else if (png_ptr->interlaced) png_error(png_ptr, - "Cannot read interlaced image -- interlace handler disabled."); + "Cannot read interlaced image -- interlace handler disabled"); + pass = 1; #endif - image_height=png_ptr->height; - png_ptr->num_rows = image_height; /* Make sure this is set correctly */ for (j = 0; j < pass; j++) { rp = image; for (i = 0; i < image_height; i++) { - png_read_row(png_ptr, *rp, png_bytep_NULL); + png_read_row(png_ptr, *rp, NULL); rp++; } } } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the end of the PNG file. Will not read past the end of the * file, will verify the end is accurate, and will read any comments * or time information at the end of the file, if info is not NULL. */ void PNGAPI -png_read_end(png_structp png_ptr, png_infop info_ptr) +png_read_end(png_structrp png_ptr, png_inforp info_ptr) { - png_byte chunk_length[4]; - png_uint_32 length; +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + int keep; +#endif - png_debug(1, "in png_read_end\n"); - if(png_ptr == NULL) return; - png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ + png_debug(1, "in png_read_end"); - do - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IHDR; - PNG_CONST PNG_IDAT; - PNG_CONST PNG_IEND; - PNG_CONST PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_CONST PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_CONST PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_CONST PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_CONST PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_CONST PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_CONST PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_CONST PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_CONST PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_CONST PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_CONST PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_CONST PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_CONST PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_CONST PNG_sRGB; + if (png_ptr == NULL) + return; + + /* If png_read_end is called in the middle of reading the rows there may + * still be pending IDAT data and an owned zstream. Deal with this here. + */ +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + if (!png_chunk_unknown_handling(png_ptr, png_IDAT)) #endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_CONST PNG_tEXt; + png_read_finish_IDAT(png_ptr); + +#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Report invalid palette index; added at libng-1.5.10 */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + png_ptr->num_palette_max > png_ptr->num_palette) + png_benign_error(png_ptr, "Read palette index exceeding num_palette"); #endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_CONST PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_CONST PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_CONST PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); + do + { + png_uint_32 length = png_read_chunk_header(png_ptr); + png_uint_32 chunk_name = png_ptr->chunk_name; - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + if (chunk_name == png_IHDR) png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + + else if (chunk_name == png_IEND) png_handle_IEND(png_ptr, info_ptr, length); + #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + if (chunk_name == png_IDAT) { if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); + png_benign_error(png_ptr, "Too many IDATs found"); } - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_handle_unknown(png_ptr, info_ptr, length, keep); + if (chunk_name == png_PLTE) png_ptr->mode |= PNG_HAVE_PLTE; } #endif - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + + else if (chunk_name == png_IDAT) { /* Zero length IDATs are legal after the last IDAT has been * read, but not after other chunks have been read. */ if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); + png_benign_error(png_ptr, "Too many IDATs found"); + png_crc_finish(png_ptr, length); } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + else if (chunk_name == png_PLTE) png_handle_PLTE(png_ptr, info_ptr, length); -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + +#ifdef PNG_READ_bKGD_SUPPORTED + else if (chunk_name == png_bKGD) png_handle_bKGD(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + +#ifdef PNG_READ_cHRM_SUPPORTED + else if (chunk_name == png_cHRM) png_handle_cHRM(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + +#ifdef PNG_READ_gAMA_SUPPORTED + else if (chunk_name == png_gAMA) png_handle_gAMA(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + +#ifdef PNG_READ_hIST_SUPPORTED + else if (chunk_name == png_hIST) png_handle_hIST(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + +#ifdef PNG_READ_oFFs_SUPPORTED + else if (chunk_name == png_oFFs) png_handle_oFFs(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + +#ifdef PNG_READ_pCAL_SUPPORTED + else if (chunk_name == png_pCAL) png_handle_pCAL(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + +#ifdef PNG_READ_sCAL_SUPPORTED + else if (chunk_name == png_sCAL) png_handle_sCAL(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + +#ifdef PNG_READ_pHYs_SUPPORTED + else if (chunk_name == png_pHYs) png_handle_pHYs(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + +#ifdef PNG_READ_sBIT_SUPPORTED + else if (chunk_name == png_sBIT) png_handle_sBIT(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + +#ifdef PNG_READ_sRGB_SUPPORTED + else if (chunk_name == png_sRGB) png_handle_sRGB(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + +#ifdef PNG_READ_iCCP_SUPPORTED + else if (chunk_name == png_iCCP) png_handle_iCCP(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + +#ifdef PNG_READ_sPLT_SUPPORTED + else if (chunk_name == png_sPLT) png_handle_sPLT(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + +#ifdef PNG_READ_tEXt_SUPPORTED + else if (chunk_name == png_tEXt) png_handle_tEXt(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + +#ifdef PNG_READ_tIME_SUPPORTED + else if (chunk_name == png_tIME) png_handle_tIME(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + +#ifdef PNG_READ_tRNS_SUPPORTED + else if (chunk_name == png_tRNS) png_handle_tRNS(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + +#ifdef PNG_READ_zTXt_SUPPORTED + else if (chunk_name == png_zTXt) png_handle_zTXt(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + +#ifdef PNG_READ_iTXt_SUPPORTED + else if (chunk_name == png_iTXt) png_handle_iTXt(png_ptr, info_ptr, length); #endif + else - png_handle_unknown(png_ptr, info_ptr, length); + png_handle_unknown(png_ptr, info_ptr, length, + PNG_HANDLE_CHUNK_AS_DEFAULT); } while (!(png_ptr->mode & PNG_HAVE_IEND)); } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -/* free all memory used by the read */ -void PNGAPI -png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, - png_infopp end_info_ptr_ptr) +/* Free all memory used in the read struct */ +static void +png_read_destroy(png_structrp png_ptr) { - png_structp png_ptr = NULL; - png_infop info_ptr = NULL, end_info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; - png_voidp mem_ptr; -#endif + png_debug(1, "in png_read_destroy"); - png_debug(1, "in png_destroy_read_struct\n"); - if (png_ptr_ptr != NULL) - png_ptr = *png_ptr_ptr; - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (end_info_ptr_ptr != NULL) - end_info_ptr = *end_info_ptr_ptr; - -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - - png_read_destroy(png_ptr, info_ptr, end_info_ptr); - - if (info_ptr != NULL) - { -#if defined(PNG_TEXT_SUPPORTED) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (end_info_ptr != NULL) - { -#if defined(PNG_READ_TEXT_SUPPORTED) - png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); +#ifdef PNG_READ_GAMMA_SUPPORTED + png_destroy_gamma_table(png_ptr); #endif -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)end_info_ptr); -#endif - *end_info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - -/* free all memory used by the read (old method) */ -void /* PRIVATE */ -png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_read_destroy\n"); - if (info_ptr != NULL) - png_info_destroy(png_ptr, info_ptr); - - if (end_info_ptr != NULL) - png_info_destroy(png_ptr, end_info_ptr); - png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->prev_row); -#if defined(PNG_READ_DITHER_SUPPORTED) + png_free(png_ptr, png_ptr->big_prev_row); + png_free(png_ptr, png_ptr->read_buffer); + +#ifdef PNG_READ_QUANTIZE_SUPPORTED png_free(png_ptr, png_ptr->palette_lookup); - png_free(png_ptr, png_ptr->dither_index); -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_table); + png_free(png_ptr, png_ptr->quantize_index); #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_from_1); - png_free(png_ptr, png_ptr->gamma_to_1); -#endif -#ifdef PNG_FREE_ME_SUPPORTED + if (png_ptr->free_me & PNG_FREE_PLTE) png_zfree(png_ptr, png_ptr->palette); png_ptr->free_me &= ~PNG_FREE_PLTE; -#else - if (png_ptr->flags & PNG_FLAG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif + #if defined(PNG_tRNS_SUPPORTED) || \ defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED if (png_ptr->free_me & PNG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); + png_free(png_ptr, png_ptr->trans_alpha); png_ptr->free_me &= ~PNG_FREE_TRNS; -#else - if (png_ptr->flags & PNG_FLAG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif -#endif -#if defined(PNG_READ_hIST_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->free_me &= ~PNG_FREE_HIST; -#else - if (png_ptr->flags & PNG_FLAG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->gamma_16_table != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_table[i]); - } - png_free(png_ptr, png_ptr->gamma_16_table); - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_from_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_from_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_from_1); - } - if (png_ptr->gamma_16_to_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_to_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_to_1); - } -#endif -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); #endif inflateEnd(&png_ptr->zstream); + #ifdef PNG_PROGRESSIVE_READ_SUPPORTED png_free(png_ptr, png_ptr->save_buffer); #endif -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -#ifdef PNG_TEXT_SUPPORTED - png_free(png_ptr, png_ptr->current_text); -#endif /* PNG_TEXT_SUPPORTED */ -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - - /* Save the important info out of the png_struct, in case it is - * being used again. - */ -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); +#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) &&\ + defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + png_free(png_ptr, png_ptr->unknown_chunk.data); #endif - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + png_free(png_ptr, png_ptr->chunk_list); #endif - png_memset(png_ptr, 0, png_sizeof (png_struct)); + /* NOTE: the 'setjmp' buffer may still be allocated and the memory and error + * callbacks are still set at this point. They are required to complete the + * destruction of the png_struct itself. + */ +} - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif +/* Free all memory used by the read */ +void PNGAPI +png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, + png_infopp end_info_ptr_ptr) +{ + png_structrp png_ptr = NULL; -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif + png_debug(1, "in png_destroy_read_struct"); + + if (png_ptr_ptr != NULL) + png_ptr = *png_ptr_ptr; + + if (png_ptr == NULL) + return; + /* libpng 1.6.0: use the API to destroy info structs to ensure consistent + * behavior. Prior to 1.6.0 libpng did extra 'info' destruction in this API. + * The extra was, apparently, unnecessary yet this hides memory leak bugs. + */ + png_destroy_info_struct(png_ptr, end_info_ptr_ptr); + png_destroy_info_struct(png_ptr, info_ptr_ptr); + + *png_ptr_ptr = NULL; + png_read_destroy(png_ptr); + png_destroy_png_struct(png_ptr); } void PNGAPI -png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) +png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + png_ptr->read_row_fn = read_row_fn; } -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +#ifdef PNG_INFO_IMAGE_SUPPORTED void PNGAPI -png_read_png(png_structp png_ptr, png_infop info_ptr, +png_read_png(png_structrp png_ptr, png_inforp info_ptr, int transforms, voidp params) { int row; - if(png_ptr == NULL) return; -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency - */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif + if (png_ptr == NULL || info_ptr == NULL) + return; /* png_read_info() gives us all of the information from the * PNG file before the first IDAT (image data chunk). */ png_read_info(png_ptr, info_ptr); - if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) - png_error(png_ptr,"Image is too high to process with png_read_png()"); + if (info_ptr->height > PNG_UINT_32_MAX/(sizeof (png_bytep))) + png_error(png_ptr, "Image is too high to process with png_read_png()"); /* -------------- image transformations start here ------------------- */ -#if defined(PNG_READ_16_TO_8_SUPPORTED) - /* tell libpng to strip 16 bit/color files down to 8 bits per color +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + /* Tell libpng to strip 16-bit/color files down to 8 bits per color. + */ + if (transforms & PNG_TRANSFORM_SCALE_16) + { + /* Added at libpng-1.5.4. "strip_16" produces the same result that it + * did in earlier versions, while "scale_16" is now more accurate. + */ + png_set_scale_16(png_ptr); + } +#endif + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + /* If both SCALE and STRIP are required pngrtran will effectively cancel the + * latter by doing SCALE first. This is ok and allows apps not to check for + * which is supported to get the right answer. */ if (transforms & PNG_TRANSFORM_STRIP_16) - png_set_strip_16(png_ptr); + png_set_strip_16(png_ptr); #endif -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED /* Strip alpha bytes from the input data without combining with * the background (not recommended). */ if (transforms & PNG_TRANSFORM_STRIP_ALPHA) - png_set_strip_alpha(png_ptr); + png_set_strip_alpha(png_ptr); #endif #if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) @@ -1360,41 +984,41 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, * byte into separate bytes (useful for paletted and grayscale images). */ if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); + png_set_packing(png_ptr); #endif -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED /* Change the order of packed pixels to least significant bit first * (not useful if you are using png_set_packing). */ if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); + png_set_packswap(png_ptr); #endif -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED /* Expand paletted colors into true RGB triplets * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel * Expand paletted or RGB images with transparency to full alpha * channels so the data will be available as RGBA quartets. */ if (transforms & PNG_TRANSFORM_EXPAND) - if ((png_ptr->bit_depth < 8) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || - (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) + if ((png_ptr->bit_depth < 8) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || + (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) png_set_expand(png_ptr); #endif - /* We don't handle background color or gamma transformation or dithering. + /* We don't handle background color or gamma transformation or quantizing. */ -#if defined(PNG_READ_INVERT_SUPPORTED) - /* invert monochrome files to have 0 as white and 1 as black +#ifdef PNG_READ_INVERT_SUPPORTED + /* Invert monochrome files to have 0 as white and 1 as black */ if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); + png_set_invert_mono(png_ptr); #endif -#if defined(PNG_READ_SHIFT_SUPPORTED) +#ifdef PNG_READ_SHIFT_SUPPORTED /* If you want to shift the pixel values from the range [0,255] or * [0,65535] to the original [0,7] or [0,31], or whatever range the * colors were originally in: @@ -1409,29 +1033,51 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, } #endif -#if defined(PNG_READ_BGR_SUPPORTED) - /* flip the RGB pixels to BGR (or RGBA to BGRA) - */ +#ifdef PNG_READ_BGR_SUPPORTED + /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); + png_set_bgr(png_ptr); #endif -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) - */ +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED + /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); + png_set_swap_alpha(png_ptr); #endif -#if defined(PNG_READ_SWAP_SUPPORTED) - /* swap bytes of 16 bit files to least significant byte first - */ +#ifdef PNG_READ_SWAP_SUPPORTED + /* Swap bytes of 16-bit files to least significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); + png_set_swap(png_ptr); +#endif + +/* Added at libpng-1.2.41 */ +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED + /* Invert the alpha channel from opacity to transparency */ + if (transforms & PNG_TRANSFORM_INVERT_ALPHA) + png_set_invert_alpha(png_ptr); +#endif + +/* Added at libpng-1.2.41 */ +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + /* Expand grayscale image to RGB */ + if (transforms & PNG_TRANSFORM_GRAY_TO_RGB) + png_set_gray_to_rgb(png_ptr); +#endif + +/* Added at libpng-1.5.4 */ +#ifdef PNG_READ_EXPAND_16_SUPPORTED + if (transforms & PNG_TRANSFORM_EXPAND_16) + png_set_expand_16(png_ptr); #endif /* We don't handle adding filler bytes */ + /* We use png_read_image and rely on that for interlace handling, but we also + * call png_read_update_info therefore must turn on interlace handling now: + */ + (void)png_set_interlace_handling(png_ptr); + /* Optional call to gamma correct and add the background to the palette * and update info structure. REQUIRED if you are expecting libpng to * update the palette for you (i.e., you selected such a transform above). @@ -1440,33 +1086,2915 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, /* -------------- image transformations end here ------------------- */ -#ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); -#endif - if(info_ptr->row_pointers == NULL) + if (info_ptr->row_pointers == NULL) { + png_uint_32 iptr; + info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, - info_ptr->height * png_sizeof(png_bytep)); -#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->height * (sizeof (png_bytep))); + for (iptr=0; iptr<info_ptr->height; iptr++) + info_ptr->row_pointers[iptr] = NULL; + info_ptr->free_me |= PNG_FREE_ROWS; -#endif + for (row = 0; row < (int)info_ptr->height; row++) - { info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - } } png_read_image(png_ptr, info_ptr->row_pointers); info_ptr->valid |= PNG_INFO_IDAT; - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ + /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); - (void) transforms; /* quiet compiler warnings */ - (void) params; + PNG_UNUSED(transforms) /* Quiet compiler warnings */ + PNG_UNUSED(params) } #endif /* PNG_INFO_IMAGE_SUPPORTED */ -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED +/* SIMPLIFIED READ + * + * This code currently relies on the sequential reader, though it could easily + * be made to work with the progressive one. + */ +/* Arguments to png_image_finish_read: */ + +/* Encoding of PNG data (used by the color-map code) */ +/* TODO: change these, dang, ANSI-C reserves the 'E' namespace. */ +# define E_NOTSET 0 /* File encoding not yet known */ +# define E_sRGB 1 /* 8-bit encoded to sRGB gamma */ +# define E_LINEAR 2 /* 16-bit linear: not encoded, NOT pre-multiplied! */ +# define E_FILE 3 /* 8-bit encoded to file gamma, not sRGB or linear */ +# define E_LINEAR8 4 /* 8-bit linear: only from a file value */ + +/* Color-map processing: after libpng has run on the PNG image further + * processing may be needed to conver the data to color-map indicies. + */ +#define PNG_CMAP_NONE 0 +#define PNG_CMAP_GA 1 /* Process GA data to a color-map with alpha */ +#define PNG_CMAP_TRANS 2 /* Process GA data to a background index */ +#define PNG_CMAP_RGB 3 /* Process RGB data */ +#define PNG_CMAP_RGB_ALPHA 4 /* Process RGBA data */ + +/* The following document where the background is for each processing case. */ +#define PNG_CMAP_NONE_BACKGROUND 256 +#define PNG_CMAP_GA_BACKGROUND 231 +#define PNG_CMAP_TRANS_BACKGROUND 254 +#define PNG_CMAP_RGB_BACKGROUND 256 +#define PNG_CMAP_RGB_ALPHA_BACKGROUND 216 + +typedef struct +{ + /* Arguments: */ + png_imagep image; + png_voidp buffer; + png_int_32 row_stride; + png_voidp colormap; + png_const_colorp background; + /* Local variables: */ + png_voidp local_row; + png_voidp first_row; + ptrdiff_t row_bytes; /* step between rows */ + int file_encoding; /* E_ values above */ + png_fixed_point gamma_to_linear; /* For E_FILE, reciprocal of gamma */ + int colormap_processing; /* PNG_CMAP_ values above */ +} png_image_read_control; + +/* Do all the *safe* initialization - 'safe' means that png_error won't be + * called, so setting up the jmp_buf is not required. This means that anything + * called from here must *not* call png_malloc - it has to call png_malloc_warn + * instead so that control is returned safely back to this routine. + */ +static int +png_image_read_init(png_imagep image) +{ + if (image->opaque == NULL) + { + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, image, + png_safe_error, png_safe_warning); + + /* And set the rest of the structure to NULL to ensure that the various + * fields are consistent. + */ + memset(image, 0, (sizeof *image)); + image->version = PNG_IMAGE_VERSION; + + if (png_ptr != NULL) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (info_ptr != NULL) + { + png_controlp control = png_voidcast(png_controlp, + png_malloc_warn(png_ptr, (sizeof *control))); + + if (control != NULL) + { + memset(control, 0, (sizeof *control)); + + control->png_ptr = png_ptr; + control->info_ptr = info_ptr; + control->for_write = 0; + + image->opaque = control; + return 1; + } + + /* Error clean up */ + png_destroy_info_struct(png_ptr, &info_ptr); + } + + png_destroy_read_struct(&png_ptr, NULL, NULL); + } + + return png_image_error(image, "png_image_read: out of memory"); + } + + return png_image_error(image, "png_image_read: opaque pointer not NULL"); +} + +/* Utility to find the base format of a PNG file from a png_struct. */ +static png_uint_32 +png_image_format(png_structrp png_ptr) +{ + png_uint_32 format = 0; + + if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + format |= PNG_FORMAT_FLAG_COLOR; + + if (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) + format |= PNG_FORMAT_FLAG_ALPHA; + + /* Use png_ptr here, not info_ptr, because by examination png_handle_tRNS + * sets the png_struct fields; that's all we are interested in here. The + * precise interaction with an app call to png_set_tRNS and PNG file reading + * is unclear. + */ + else if (png_ptr->num_trans > 0) + format |= PNG_FORMAT_FLAG_ALPHA; + + if (png_ptr->bit_depth == 16) + format |= PNG_FORMAT_FLAG_LINEAR; + + if (png_ptr->color_type & PNG_COLOR_MASK_PALETTE) + format |= PNG_FORMAT_FLAG_COLORMAP; + + return format; +} + +/* Is the given gamma significantly different from sRGB? The test is the same + * one used in pngrtran.c when deciding whether to do gamma correction. The + * arithmetic optimizes the division by using the fact that the inverse of the + * file sRGB gamma is 2.2 + */ +static int +png_gamma_not_sRGB(png_fixed_point g) +{ + if (g < PNG_FP_1) + { + /* An uninitialized gamma is assumed to be sRGB for the simplified API. */ + if (g == 0) + return 0; + + return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */); + } + + return 1; +} + +/* Do the main body of a 'png_image_begin_read' function; read the PNG file + * header and fill in all the information. This is executed in a safe context, + * unlike the init routine above. + */ +static int +png_image_read_header(png_voidp argument) +{ + png_imagep image = png_voidcast(png_imagep, argument); + png_structrp png_ptr = image->opaque->png_ptr; + png_inforp info_ptr = image->opaque->info_ptr; + + png_set_benign_errors(png_ptr, 1/*warn*/); + png_read_info(png_ptr, info_ptr); + + /* Do this the fast way; just read directly out of png_struct. */ + image->width = png_ptr->width; + image->height = png_ptr->height; + + { + png_uint_32 format = png_image_format(png_ptr); + + image->format = format; + +#ifdef PNG_COLORSPACE_SUPPORTED + /* Does the colorspace match sRGB? If there is no color endpoint + * (colorant) information assume yes, otherwise require the + * 'ENDPOINTS_MATCHE_sRGB' colorspace flag to have been set. If the + * colorspace has been determined to be invalid ignore it. + */ + if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags + & (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB| + PNG_COLORSPACE_INVALID)) == PNG_COLORSPACE_HAVE_ENDPOINTS)) + image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB; +#endif + } + + /* We need the maximum number of entries regardless of the format the + * application sets here. + */ + { + png_uint_32 cmap_entries; + + switch (png_ptr->color_type) + { + case PNG_COLOR_TYPE_GRAY: + cmap_entries = 1U << png_ptr->bit_depth; + break; + + case PNG_COLOR_TYPE_PALETTE: + cmap_entries = png_ptr->num_palette; + break; + + default: + cmap_entries = 256; + break; + } + + if (cmap_entries > 256) + cmap_entries = 256; + + image->colormap_entries = cmap_entries; + } + + return 1; +} + +#ifdef PNG_STDIO_SUPPORTED +int PNGAPI +png_image_begin_read_from_stdio(png_imagep image, FILE* file) +{ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (file != NULL) + { + if (png_image_read_init(image)) + { + /* This is slightly evil, but png_init_io doesn't do anything other + * than this and we haven't changed the standard IO functions so + * this saves a 'safe' function. + */ + image->opaque->png_ptr->io_ptr = file; + return png_safe_execute(image, png_image_read_header, image); + } + } + + else + return png_image_error(image, + "png_image_begin_read_from_stdio: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION"); + + return 0; +} + +int PNGAPI +png_image_begin_read_from_file(png_imagep image, const char *file_name) +{ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (file_name != NULL) + { + FILE *fp = fopen(file_name, "rb"); + + if (fp != NULL) + { + if (png_image_read_init(image)) + { + image->opaque->png_ptr->io_ptr = fp; + image->opaque->owned_file = 1; + return png_safe_execute(image, png_image_read_header, image); + } + + /* Clean up: just the opened file. */ + (void)fclose(fp); + } + + else + return png_image_error(image, strerror(errno)); + } + + else + return png_image_error(image, + "png_image_begin_read_from_file: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION"); + + return 0; +} +#endif /* PNG_STDIO_SUPPORTED */ + +static void PNGCBAPI +png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need) +{ + if (png_ptr != NULL) + { + png_imagep image = png_voidcast(png_imagep, png_ptr->io_ptr); + if (image != NULL) + { + png_controlp cp = image->opaque; + if (cp != NULL) + { + png_const_bytep memory = cp->memory; + png_size_t size = cp->size; + + if (memory != NULL && size >= need) + { + memcpy(out, memory, need); + cp->memory = memory + need; + cp->size = size - need; + return; + } + + png_error(png_ptr, "read beyond end of data"); + } + } + + png_error(png_ptr, "invalid memory read"); + } +} + +int PNGAPI png_image_begin_read_from_memory(png_imagep image, + png_const_voidp memory, png_size_t size) +{ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (memory != NULL && size > 0) + { + if (png_image_read_init(image)) + { + /* Now set the IO functions to read from the memory buffer and + * store it into io_ptr. Again do this in-place to avoid calling a + * libpng function that requires error handling. + */ + image->opaque->memory = png_voidcast(png_const_bytep, memory); + image->opaque->size = size; + image->opaque->png_ptr->io_ptr = image; + image->opaque->png_ptr->read_data_fn = png_image_memory_read; + + return png_safe_execute(image, png_image_read_header, image); + } + } + + else + return png_image_error(image, + "png_image_begin_read_from_memory: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION"); + + return 0; +} + +/* Utility function to skip chunks that are not used by the simplified image + * read functions and an appropriate macro to call it. + */ +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +static void +png_image_skip_unused_chunks(png_structrp png_ptr) +{ + /* Prepare the reader to ignore all recognized chunks whose data will not + * be used, i.e., all chunks recognized by libpng except for those + * involved in basic image reading: + * + * IHDR, PLTE, IDAT, IEND + * + * Or image data handling: + * + * tRNS, bKGD, gAMA, cHRM, sRGB, iCCP and sBIT. + * + * This provides a small performance improvement and eliminates any + * potential vulnerability to security problems in the unused chunks. + */ + { + static PNG_CONST png_byte chunks_to_process[] = { + 98, 75, 71, 68, '\0', /* bKGD */ + 99, 72, 82, 77, '\0', /* cHRM */ + 103, 65, 77, 65, '\0', /* gAMA */ + 105, 67, 67, 80, '\0', /* iCCP */ + 115, 66, 73, 84, '\0', /* sBIT */ + 115, 82, 71, 66, '\0', /* sRGB */ + }; + + /* Ignore unknown chunks and all other chunks except for the + * IHDR, PLTE, tRNS, IDAT, and IEND chunks. + */ + png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER, + NULL, -1); + + /* But do not ignore image data handling chunks */ + png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT, + chunks_to_process, (sizeof chunks_to_process)/5); + } +} + +# define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p) +#else +# define PNG_SKIP_CHUNKS(p) ((void)0) +#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */ + +/* The following macro gives the exact rounded answer for all values in the + * range 0..255 (it actually divides by 51.2, but the rounding still generates + * the correct numbers 0..5 + */ +#define PNG_DIV51(v8) (((v8) * 5 + 130) >> 8) + +/* Utility functions to make particular color-maps */ +static void +set_file_encoding(png_image_read_control *display) +{ + png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma; + if (png_gamma_significant(g)) + { + if (png_gamma_not_sRGB(g)) + { + display->file_encoding = E_FILE; + display->gamma_to_linear = png_reciprocal(g); + } + + else + display->file_encoding = E_sRGB; + } + + else + display->file_encoding = E_LINEAR8; +} + +static unsigned int +decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) +{ + if (encoding == E_FILE) /* double check */ + encoding = display->file_encoding; + + if (encoding == E_NOTSET) /* must be the file encoding */ + { + set_file_encoding(display); + encoding = display->file_encoding; + } + + switch (encoding) + { + case E_FILE: + value = png_gamma_16bit_correct(value*257, display->gamma_to_linear); + break; + + case E_sRGB: + value = png_sRGB_table[value]; + break; + + case E_LINEAR: + break; + + case E_LINEAR8: + value *= 257; + break; + + default: + png_error(display->image->opaque->png_ptr, + "unexpected encoding (internal error)"); + break; + } + + return value; +} + +static png_uint_32 +png_colormap_compose(png_image_read_control *display, + png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha, + png_uint_32 background, int encoding) +{ + /* The file value is composed on the background, the background has the given + * encoding and so does the result, the file is encoded with E_FILE and the + * file and alpha are 8-bit values. The (output) encoding will always be + * E_LINEAR or E_sRGB. + */ + png_uint_32 f = decode_gamma(display, foreground, foreground_encoding); + png_uint_32 b = decode_gamma(display, background, encoding); + + /* The alpha is always an 8-bit value (it comes from the palette), the value + * scaled by 255 is what PNG_sRGB_FROM_LINEAR requires. + */ + f = f * alpha + b * (255-alpha); + + if (encoding == E_LINEAR) + { + /* Scale to 65535; divide by 255, approximately (in fact this is extremely + * accurate, it divides by 255.00000005937181414556, with no overflow.) + */ + f *= 257; /* Now scaled by 65535 */ + f += f >> 16; + f = (f+32768) >> 16; + } + + else /* E_sRGB */ + f = PNG_sRGB_FROM_LINEAR(f); + + return f; +} + +/* NOTE: E_LINEAR values to this routine must be 16-bit, but E_FILE values must + * be 8-bit. + */ +static void +png_create_colormap_entry(png_image_read_control *display, + png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue, + png_uint_32 alpha, int encoding) +{ + png_imagep image = display->image; + const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) ? + E_LINEAR : E_sRGB; + const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && + (red != green || green != blue); + + if (ip > 255) + png_error(image->opaque->png_ptr, "color-map index out of range"); + + /* Update the cache with whether the file gamma is significantly different + * from sRGB. + */ + if (encoding == E_FILE) + { + if (display->file_encoding == E_NOTSET) + set_file_encoding(display); + + /* Note that the cached value may be E_FILE too, but if it is then the + * gamma_to_linear member has been set. + */ + encoding = display->file_encoding; + } + + if (encoding == E_FILE) + { + png_fixed_point g = display->gamma_to_linear; + + red = png_gamma_16bit_correct(red*257, g); + green = png_gamma_16bit_correct(green*257, g); + blue = png_gamma_16bit_correct(blue*257, g); + + if (convert_to_Y || output_encoding == E_LINEAR) + { + alpha *= 257; + encoding = E_LINEAR; + } + + else + { + red = PNG_sRGB_FROM_LINEAR(red * 255); + green = PNG_sRGB_FROM_LINEAR(green * 255); + blue = PNG_sRGB_FROM_LINEAR(blue * 255); + encoding = E_sRGB; + } + } + + else if (encoding == E_LINEAR8) + { + /* This encoding occurs quite frequently in test cases because PngSuite + * includes a gAMA 1.0 chunk with most images. + */ + red *= 257; + green *= 257; + blue *= 257; + alpha *= 257; + encoding = E_LINEAR; + } + + else if (encoding == E_sRGB && (convert_to_Y || output_encoding == E_LINEAR)) + { + /* The values are 8-bit sRGB values, but must be converted to 16-bit + * linear. + */ + red = png_sRGB_table[red]; + green = png_sRGB_table[green]; + blue = png_sRGB_table[blue]; + alpha *= 257; + encoding = E_LINEAR; + } + + /* This is set if the color isn't gray but the output is. */ + if (encoding == E_LINEAR) + { + if (convert_to_Y) + { + /* NOTE: these values are copied from png_do_rgb_to_gray */ + png_uint_32 y = (png_uint_32)6968 * red + (png_uint_32)23434 * green + + (png_uint_32)2366 * blue; + + if (output_encoding == E_LINEAR) + y = (y + 16384) >> 15; + + else + { + /* y is scaled by 32768, we need it scaled by 255: */ + y = (y + 128) >> 8; + y *= 255; + y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7); + encoding = E_sRGB; + } + + blue = red = green = y; + } + + else if (output_encoding == E_sRGB) + { + red = PNG_sRGB_FROM_LINEAR(red * 255); + green = PNG_sRGB_FROM_LINEAR(green * 255); + blue = PNG_sRGB_FROM_LINEAR(blue * 255); + alpha = PNG_DIV257(alpha); + encoding = E_sRGB; + } + } + + if (encoding != output_encoding) + png_error(image->opaque->png_ptr, "bad encoding (internal error)"); + + /* Store the value. */ + { +# ifdef PNG_FORMAT_BGR_SUPPORTED + const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 && + (image->format & PNG_FORMAT_FLAG_ALPHA) != 0; +# else +# define afirst 0 +# endif +# ifdef PNG_FORMAT_BGR_SUPPORTED + const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) ? 2 : 0; +# else +# define bgr 0 +# endif + + if (output_encoding == E_LINEAR) + { + png_uint_16p entry = png_voidcast(png_uint_16p, display->colormap); + + entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format); + + /* The linear 16-bit values must be pre-multiplied by the alpha channel + * value, if less than 65535 (this is, effectively, composite on black + * if the alpha channel is removed.) + */ + switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format)) + { + case 4: + entry[afirst ? 0 : 3] = (png_uint_16)alpha; + /* FALL THROUGH */ + + case 3: + if (alpha < 65535) + { + if (alpha > 0) + { + blue = (blue * alpha + 32767U)/65535U; + green = (green * alpha + 32767U)/65535U; + red = (red * alpha + 32767U)/65535U; + } + + else + red = green = blue = 0; + } + entry[afirst + (2 ^ bgr)] = (png_uint_16)blue; + entry[afirst + 1] = (png_uint_16)green; + entry[afirst + bgr] = (png_uint_16)red; + break; + + case 2: + entry[1 ^ afirst] = (png_uint_16)alpha; + /* FALL THROUGH */ + + case 1: + if (alpha < 65535) + { + if (alpha > 0) + green = (green * alpha + 32767U)/65535U; + + else + green = 0; + } + entry[afirst] = (png_uint_16)green; + break; + + default: + break; + } + } + + else /* output encoding is E_sRGB */ + { + png_bytep entry = png_voidcast(png_bytep, display->colormap); + + entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format); + + switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format)) + { + case 4: + entry[afirst ? 0 : 3] = (png_byte)alpha; + case 3: + entry[afirst + (2 ^ bgr)] = (png_byte)blue; + entry[afirst + 1] = (png_byte)green; + entry[afirst + bgr] = (png_byte)red; + break; + + case 2: + entry[1 ^ afirst] = (png_byte)alpha; + case 1: + entry[afirst] = (png_byte)green; + break; + + default: + break; + } + } + +# ifdef afirst +# undef afirst +# endif +# ifdef bgr +# undef bgr +# endif + } +} + +static int +make_gray_file_colormap(png_image_read_control *display) +{ + unsigned int i; + + for (i=0; i<256; ++i) + png_create_colormap_entry(display, i, i, i, i, 255, E_FILE); + + return i; +} + +static int +make_gray_colormap(png_image_read_control *display) +{ + unsigned int i; + + for (i=0; i<256; ++i) + png_create_colormap_entry(display, i, i, i, i, 255, E_sRGB); + + return i; +} +#define PNG_GRAY_COLORMAP_ENTRIES 256 + +static int +make_ga_colormap(png_image_read_control *display) +{ + unsigned int i, a; + + /* Alpha is retained, the output will be a color-map with entries + * selected by six levels of alpha. One transparent entry, 6 gray + * levels for all the intermediate alpha values, leaving 230 entries + * for the opaque grays. The color-map entries are the six values + * [0..5]*51, the GA processing uses PNG_DIV51(value) to find the + * relevant entry. + * + * if (alpha > 229) // opaque + * { + * // The 231 entries are selected to make the math below work: + * base = 0; + * entry = (231 * gray + 128) >> 8; + * } + * else if (alpha < 26) // transparent + * { + * base = 231; + * entry = 0; + * } + * else // partially opaque + * { + * base = 226 + 6 * PNG_DIV51(alpha); + * entry = PNG_DIV51(gray); + * } + */ + i = 0; + while (i < 231) + { + unsigned int gray = (i * 256 + 115) / 231; + png_create_colormap_entry(display, i++, gray, gray, gray, 255, E_sRGB); + } + + /* 255 is used here for the component values for consistency with the code + * that undoes premultiplication in pngwrite.c. + */ + png_create_colormap_entry(display, i++, 255, 255, 255, 0, E_sRGB); + + for (a=1; a<5; ++a) + { + unsigned int g; + + for (g=0; g<6; ++g) + png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51, + E_sRGB); + } + + return i; +} + +#define PNG_GA_COLORMAP_ENTRIES 256 + +static int +make_rgb_colormap(png_image_read_control *display) +{ + unsigned int i, r; + + /* Build a 6x6x6 opaque RGB cube */ + for (i=r=0; r<6; ++r) + { + unsigned int g; + + for (g=0; g<6; ++g) + { + unsigned int b; + + for (b=0; b<6; ++b) + png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255, + E_sRGB); + } + } + + return i; +} + +#define PNG_RGB_COLORMAP_ENTRIES 216 + +/* Return a palette index to the above palette given three 8-bit sRGB values. */ +#define PNG_RGB_INDEX(r,g,b) \ + ((png_byte)(6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b))) + +static int +png_image_read_colormap(png_voidp argument) +{ + png_image_read_control *display = + png_voidcast(png_image_read_control*, argument); + const png_imagep image = display->image; + + const png_structrp png_ptr = image->opaque->png_ptr; + const png_uint_32 output_format = image->format; + const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) ? + E_LINEAR : E_sRGB; + + unsigned int cmap_entries; + unsigned int output_processing; /* Output processing option */ + unsigned int data_encoding = E_NOTSET; /* Encoding libpng must produce */ + + /* Background information; the background color and the index of this color + * in the color-map if it exists (else 256). + */ + unsigned int background_index = 256; + png_uint_32 back_r, back_g, back_b; + + /* Flags to accumulate things that need to be done to the input. */ + int expand_tRNS = 0; + + /* Exclude the NYI feature of compositing onto a color-mapped buffer; it is + * very difficult to do, the results look awful, and it is difficult to see + * what possible use it is because the application can't control the + * color-map. + */ + if (((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0 || + png_ptr->num_trans > 0) /* alpha in input */ && + ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) /* no alpha in output */) + { + if (output_encoding == E_LINEAR) /* compose on black */ + back_b = back_g = back_r = 0; + + else if (display->background == NULL /* no way to remove it */) + png_error(png_ptr, + "a background color must be supplied to remove alpha/transparency"); + + /* Get a copy of the background color (this avoids repeating the checks + * below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the + * output format. + */ + else + { + back_g = display->background->green; + if (output_format & PNG_FORMAT_FLAG_COLOR) + { + back_r = display->background->red; + back_b = display->background->blue; + } + else + back_b = back_r = back_g; + } + } + + else if (output_encoding == E_LINEAR) + back_b = back_r = back_g = 65535; + + else + back_b = back_r = back_g = 255; + + /* Default the input file gamma if required - this is necessary because + * libpng assumes that if no gamma information is present the data is in the + * output format, but the simplified API deduces the gamma from the input + * format. + */ + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0) + { + /* Do this directly, not using the png_colorspace functions, to ensure + * that it happens even if the colorspace is invalid (though probably if + * it is the setting will be ignored) Note that the same thing can be + * achieved at the application interface with png_set_gAMA. + */ + if (png_ptr->bit_depth == 16 && + (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) + png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR; + + else + png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE; + + png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; + } + + /* Decide what to do based on the PNG color type of the input data. The + * utility function png_create_colormap_entry deals with most aspects of the + * output transformations; this code works out how to produce bytes of + * color-map entries from the original format. + */ + switch (png_ptr->color_type) + { + case PNG_COLOR_TYPE_GRAY: + if (png_ptr->bit_depth <= 8) + { + /* There at most 256 colors in the output, regardless of + * transparency. + */ + unsigned int step, i, val, trans = 256/*ignore*/, back_alpha = 0; + + cmap_entries = 1U << png_ptr->bit_depth; + if (cmap_entries > image->colormap_entries) + png_error(png_ptr, "gray[8] color-map: too few entries"); + + step = 255 / (cmap_entries - 1); + output_processing = PNG_CMAP_NONE; + + /* If there is a tRNS chunk then this either selects a transparent + * value or, if the output has no alpha, the background color. + */ + if (png_ptr->num_trans > 0) + { + trans = png_ptr->trans_color.gray; + + if ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) + back_alpha = output_encoding == E_LINEAR ? 65535 : 255; + } + + /* png_create_colormap_entry just takes an RGBA and writes the + * corresponding color-map entry using the format from 'image', + * including the required conversion to sRGB or linear as + * appropriate. The input values are always either sRGB (if the + * gamma correction flag is 0) or 0..255 scaled file encoded values + * (if the function must gamma correct them). + */ + for (i=val=0; i<cmap_entries; ++i, val += step) + { + /* 'i' is a file value. While this will result in duplicated + * entries for 8-bit non-sRGB encoded files it is necessary to + * have non-gamma corrected values to do tRNS handling. + */ + if (i != trans) + png_create_colormap_entry(display, i, val, val, val, 255, + E_FILE/*8-bit with file gamma*/); + + /* Else this entry is transparent. The colors don't matter if + * there is an alpha channel (back_alpha == 0), but it does no + * harm to pass them in; the values are not set above so this + * passes in white. + * + * NOTE: this preserves the full precision of the application + * supplied background color when it is used. + */ + else + png_create_colormap_entry(display, i, back_r, back_g, back_b, + back_alpha, output_encoding); + } + + /* We need libpng to preserve the original encoding. */ + data_encoding = E_FILE; + + /* The rows from libpng, while technically gray values, are now also + * color-map indicies; however, they may need to be expanded to 1 + * byte per pixel. This is what png_set_packing does (i.e., it + * unpacks the bit values into bytes.) + */ + if (png_ptr->bit_depth < 8) + png_set_packing(png_ptr); + } + + else /* bit depth is 16 */ + { + /* The 16-bit input values can be converted directly to 8-bit gamma + * encoded values; however, if a tRNS chunk is present 257 color-map + * entries are required. This means that the extra entry requires + * special processing; add an alpha channel, sacrifice gray level + * 254 and convert transparent (alpha==0) entries to that. + * + * Use libpng to chop the data to 8 bits. Convert it to sRGB at the + * same time to minimize quality loss. If a tRNS chunk is present + * this means libpng must handle it too; otherwise it is impossible + * to do the exact match on the 16-bit value. + * + * If the output has no alpha channel *and* the background color is + * gray then it is possible to let libpng handle the substitution by + * ensuring that the corresponding gray level matches the background + * color exactly. + */ + data_encoding = E_sRGB; + + if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "gray[16] color-map: too few entries"); + + cmap_entries = make_gray_colormap(display); + + if (png_ptr->num_trans > 0) + { + unsigned int back_alpha; + + if (output_format & PNG_FORMAT_FLAG_ALPHA) + back_alpha = 0; + + else + { + if (back_r == back_g && back_g == back_b) + { + /* Background is gray; no special processing will be + * required. + */ + png_color_16 c; + png_uint_32 gray = back_g; + + if (output_encoding == E_LINEAR) + { + gray = PNG_sRGB_FROM_LINEAR(gray * 255); + + /* And make sure the corresponding palette entry + * matches. + */ + png_create_colormap_entry(display, gray, back_g, back_g, + back_g, 65535, E_LINEAR); + } + + /* The background passed to libpng, however, must be the + * sRGB value. + */ + c.index = 0; /*unused*/ + c.gray = c.red = c.green = c.blue = (png_uint_16)gray; + + /* NOTE: does this work without expanding tRNS to alpha? + * It should be the color->gray case below apparently + * doesn't. + */ + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + + output_processing = PNG_CMAP_NONE; + break; + } + + back_alpha = output_encoding == E_LINEAR ? 65535 : 255; + } + + /* output_processing means that the libpng-processed row will be + * 8-bit GA and it has to be processing to single byte color-map + * values. Entry 254 is replaced by either a completely + * transparent entry or by the background color at full + * precision (and the background color is not a simple gray leve + * in this case.) + */ + expand_tRNS = 1; + output_processing = PNG_CMAP_TRANS; + background_index = 254; + + /* And set (overwrite) color-map entry 254 to the actual + * background color at full precision. + */ + png_create_colormap_entry(display, 254, back_r, back_g, back_b, + back_alpha, output_encoding); + } + + else + output_processing = PNG_CMAP_NONE; + } + break; + + case PNG_COLOR_TYPE_GRAY_ALPHA: + /* 8-bit or 16-bit PNG with two channels - gray and alpha. A minimum + * of 65536 combinations. If, however, the alpha channel is to be + * removed there are only 256 possibilities if the background is gray. + * (Otherwise there is a subset of the 65536 possibilities defined by + * the triangle between black, white and the background color.) + * + * Reduce 16-bit files to 8-bit and sRGB encode the result. No need to + * worry about tRNS matching - tRNS is ignored if there is an alpha + * channel. + */ + data_encoding = E_sRGB; + + if (output_format & PNG_FORMAT_FLAG_ALPHA) + { + if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "gray+alpha color-map: too few entries"); + + cmap_entries = make_ga_colormap(display); + + background_index = PNG_CMAP_GA_BACKGROUND; + output_processing = PNG_CMAP_GA; + } + + else /* alpha is removed */ + { + /* Alpha must be removed as the PNG data is processed when the + * background is a color because the G and A channels are + * independent and the vector addition (non-parallel vectors) is a + * 2-D problem. + * + * This can be reduced to the same algorithm as above by making a + * colormap containing gray levels (for the opaque grays), a + * background entry (for a transparent pixel) and a set of four six + * level color values, one set for each intermediate alpha value. + * See the comments in make_ga_colormap for how this works in the + * per-pixel processing. + * + * If the background is gray, however, we only need a 256 entry gray + * level color map. It is sufficient to make the entry generated + * for the background color be exactly the color specified. + */ + if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0 || + (back_r == back_g && back_g == back_b)) + { + /* Background is gray; no special processing will be required. */ + png_color_16 c; + png_uint_32 gray = back_g; + + if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "gray-alpha color-map: too few entries"); + + cmap_entries = make_gray_colormap(display); + + if (output_encoding == E_LINEAR) + { + gray = PNG_sRGB_FROM_LINEAR(gray * 255); + + /* And make sure the corresponding palette entry matches. */ + png_create_colormap_entry(display, gray, back_g, back_g, + back_g, 65535, E_LINEAR); + } + + /* The background passed to libpng, however, must be the sRGB + * value. + */ + c.index = 0; /*unused*/ + c.gray = c.red = c.green = c.blue = (png_uint_16)gray; + + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + + output_processing = PNG_CMAP_NONE; + } + + else + { + png_uint_32 i, a; + + /* This is the same as png_make_ga_colormap, above, except that + * the entries are all opaque. + */ + if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "ga-alpha color-map: too few entries"); + + i = 0; + while (i < 231) + { + png_uint_32 gray = (i * 256 + 115) / 231; + png_create_colormap_entry(display, i++, gray, gray, gray, + 255, E_sRGB); + } + + /* NOTE: this preserves the full precision of the application + * background color. + */ + background_index = i; + png_create_colormap_entry(display, i++, back_r, back_g, back_b, + output_encoding == E_LINEAR ? 65535U : 255U, output_encoding); + + /* For non-opaque input composite on the sRGB background - this + * requires inverting the encoding for each component. The input + * is still converted to the sRGB encoding because this is a + * reasonable approximate to the logarithmic curve of human + * visual sensitivity, at least over the narrow range which PNG + * represents. Consequently 'G' is always sRGB encoded, while + * 'A' is linear. We need the linear background colors. + */ + if (output_encoding == E_sRGB) /* else already linear */ + { + /* This may produce a value not exactly matching the + * background, but that's ok because these numbers are only + * used when alpha != 0 + */ + back_r = png_sRGB_table[back_r]; + back_g = png_sRGB_table[back_g]; + back_b = png_sRGB_table[back_b]; + } + + for (a=1; a<5; ++a) + { + unsigned int g; + + /* PNG_sRGB_FROM_LINEAR expects a 16-bit linear value scaled + * by an 8-bit alpha value (0..255). + */ + png_uint_32 alpha = 51 * a; + png_uint_32 back_rx = (255-alpha) * back_r; + png_uint_32 back_gx = (255-alpha) * back_g; + png_uint_32 back_bx = (255-alpha) * back_b; + + for (g=0; g<6; ++g) + { + png_uint_32 gray = png_sRGB_table[g*51] * alpha; + + png_create_colormap_entry(display, i++, + PNG_sRGB_FROM_LINEAR(gray + back_rx), + PNG_sRGB_FROM_LINEAR(gray + back_gx), + PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, E_sRGB); + } + } + + cmap_entries = i; + output_processing = PNG_CMAP_GA; + } + } + break; + + case PNG_COLOR_TYPE_RGB: + case PNG_COLOR_TYPE_RGB_ALPHA: + /* Exclude the case where the output is gray; we can always handle this + * with the cases above. + */ + if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0) + { + /* The color-map will be grayscale, so we may as well convert the + * input RGB values to a simple grayscale and use the grayscale + * code above. + * + * NOTE: calling this apparently damages the recognition of the + * transparent color in background color handling; call + * png_set_tRNS_to_alpha before png_set_background_fixed. + */ + png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1, + -1); + data_encoding = E_sRGB; + + /* The output will now be one or two 8-bit gray or gray+alpha + * channels. The more complex case arises when the input has alpha. + */ + if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + png_ptr->num_trans > 0) && + (output_format & PNG_FORMAT_FLAG_ALPHA) != 0) + { + /* Both input and output have an alpha channel, so no background + * processing is required; just map the GA bytes to the right + * color-map entry. + */ + expand_tRNS = 1; + + if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "rgb[ga] color-map: too few entries"); + + cmap_entries = make_ga_colormap(display); + background_index = PNG_CMAP_GA_BACKGROUND; + output_processing = PNG_CMAP_GA; + } + + else + { + /* Either the input or the output has no alpha channel, so there + * will be no non-opaque pixels in the color-map; it will just be + * grayscale. + */ + if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "rgb[gray] color-map: too few entries"); + + /* Ideally this code would use libpng to do the gamma correction, + * but if an input alpha channel is to be removed we will hit the + * libpng bug in gamma+compose+rgb-to-gray (the double gamma + * correction bug). Fix this by dropping the gamma correction in + * this case and doing it in the palette; this will result in + * duplicate palette entries, but that's better than the + * alternative of double gamma correction. + */ + if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + png_ptr->num_trans > 0) && + png_gamma_not_sRGB(png_ptr->colorspace.gamma)) + { + cmap_entries = make_gray_file_colormap(display); + data_encoding = E_FILE; + } + + else + cmap_entries = make_gray_colormap(display); + + /* But if the input has alpha or transparency it must be removed + */ + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + png_ptr->num_trans > 0) + { + png_color_16 c; + png_uint_32 gray = back_g; + + /* We need to ensure that the application background exists in + * the colormap and that completely transparent pixels map to + * it. Achieve this simply by ensuring that the entry + * selected for the background really is the background color. + */ + if (data_encoding == E_FILE) /* from the fixup above */ + { + /* The app supplied a gray which is in output_encoding, we + * need to convert it to a value of the input (E_FILE) + * encoding then set this palette entry to the required + * output encoding. + */ + if (output_encoding == E_sRGB) + gray = png_sRGB_table[gray]; /* now E_LINEAR */ + + gray = PNG_DIV257(png_gamma_16bit_correct(gray, + png_ptr->colorspace.gamma)); /* now E_FILE */ + + /* And make sure the corresponding palette entry contains + * exactly the required sRGB value. + */ + png_create_colormap_entry(display, gray, back_g, back_g, + back_g, 0/*unused*/, output_encoding); + } + + else if (output_encoding == E_LINEAR) + { + gray = PNG_sRGB_FROM_LINEAR(gray * 255); + + /* And make sure the corresponding palette entry matches. + */ + png_create_colormap_entry(display, gray, back_g, back_g, + back_g, 0/*unused*/, E_LINEAR); + } + + /* The background passed to libpng, however, must be the + * output (normally sRGB) value. + */ + c.index = 0; /*unused*/ + c.gray = c.red = c.green = c.blue = (png_uint_16)gray; + + /* NOTE: the following is apparently a bug in libpng. Without + * it the transparent color recognition in + * png_set_background_fixed seems to go wrong. + */ + expand_tRNS = 1; + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + } + + output_processing = PNG_CMAP_NONE; + } + } + + else /* output is color */ + { + /* We could use png_quantize here so long as there is no transparent + * color or alpha; png_quantize ignores alpha. Easier overall just + * to do it once and using PNG_DIV51 on the 6x6x6 reduced RGB cube. + * Consequently we always want libpng to produce sRGB data. + */ + data_encoding = E_sRGB; + + /* Is there any transparency or alpha? */ + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + png_ptr->num_trans > 0) + { + /* Is there alpha in the output too? If so all four channels are + * processed into a special RGB cube with alpha support. + */ + if (output_format & PNG_FORMAT_FLAG_ALPHA) + { + png_uint_32 r; + + if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) + png_error(png_ptr, "rgb+alpha color-map: too few entries"); + + cmap_entries = make_rgb_colormap(display); + + /* Add a transparent entry. */ + png_create_colormap_entry(display, cmap_entries, 255, 255, + 255, 0, E_sRGB); + + /* This is stored as the background index for the processing + * algorithm. + */ + background_index = cmap_entries++; + + /* Add 27 r,g,b entries each with alpha 0.5. */ + for (r=0; r<256; r = (r << 1) | 0x7f) + { + png_uint_32 g; + + for (g=0; g<256; g = (g << 1) | 0x7f) + { + png_uint_32 b; + + /* This generates components with the values 0, 127 and + * 255 + */ + for (b=0; b<256; b = (b << 1) | 0x7f) + png_create_colormap_entry(display, cmap_entries++, + r, g, b, 128, E_sRGB); + } + } + + expand_tRNS = 1; + output_processing = PNG_CMAP_RGB_ALPHA; + } + + else + { + /* Alpha/transparency must be removed. The background must + * exist in the color map (achieved by setting adding it after + * the 666 color-map). If the standard processing code will + * pick up this entry automatically that's all that is + * required; libpng can be called to do the background + * processing. + */ + unsigned int sample_size = + PNG_IMAGE_SAMPLE_SIZE(output_format); + png_uint_32 r, g, b; /* sRGB background */ + + if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) + png_error(png_ptr, "rgb-alpha color-map: too few entries"); + + cmap_entries = make_rgb_colormap(display); + + png_create_colormap_entry(display, cmap_entries, back_r, + back_g, back_b, 0/*unused*/, output_encoding); + + if (output_encoding == E_LINEAR) + { + r = PNG_sRGB_FROM_LINEAR(back_r * 255); + g = PNG_sRGB_FROM_LINEAR(back_g * 255); + b = PNG_sRGB_FROM_LINEAR(back_b * 255); + } + + else + { + r = back_r; + g = back_g; + b = back_g; + } + + /* Compare the newly-created color-map entry with the one the + * PNG_CMAP_RGB algorithm will use. If the two entries don't + * match, add the new one and set this as the background + * index. + */ + if (memcmp((png_const_bytep)display->colormap + + sample_size * cmap_entries, + (png_const_bytep)display->colormap + + sample_size * PNG_RGB_INDEX(r,g,b), + sample_size) != 0) + { + /* The background color must be added. */ + background_index = cmap_entries++; + + /* Add 27 r,g,b entries each with created by composing with + * the background at alpha 0.5. + */ + for (r=0; r<256; r = (r << 1) | 0x7f) + { + for (g=0; g<256; g = (g << 1) | 0x7f) + { + /* This generates components with the values 0, 127 + * and 255 + */ + for (b=0; b<256; b = (b << 1) | 0x7f) + png_create_colormap_entry(display, cmap_entries++, + png_colormap_compose(display, r, E_sRGB, 128, + back_r, output_encoding), + png_colormap_compose(display, g, E_sRGB, 128, + back_g, output_encoding), + png_colormap_compose(display, b, E_sRGB, 128, + back_b, output_encoding), + 0/*unused*/, output_encoding); + } + } + + expand_tRNS = 1; + output_processing = PNG_CMAP_RGB_ALPHA; + } + + else /* background color is in the standard color-map */ + { + png_color_16 c; + + c.index = 0; /*unused*/ + c.red = (png_uint_16)back_r; + c.gray = c.green = (png_uint_16)back_g; + c.blue = (png_uint_16)back_b; + + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + + output_processing = PNG_CMAP_RGB; + } + } + } + + else /* no alpha or transparency in the input */ + { + /* Alpha in the output is irrelevant, simply map the opaque input + * pixels to the 6x6x6 color-map. + */ + if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries) + png_error(png_ptr, "rgb color-map: too few entries"); + + cmap_entries = make_rgb_colormap(display); + output_processing = PNG_CMAP_RGB; + } + } + break; + + case PNG_COLOR_TYPE_PALETTE: + /* It's already got a color-map. It may be necessary to eliminate the + * tRNS entries though. + */ + { + unsigned int num_trans = png_ptr->num_trans; + png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL; + png_const_colorp colormap = png_ptr->palette; + const int do_background = trans != NULL && + (output_format & PNG_FORMAT_FLAG_ALPHA) == 0; + unsigned int i; + + /* Just in case: */ + if (trans == NULL) + num_trans = 0; + + output_processing = PNG_CMAP_NONE; + data_encoding = E_FILE; /* Don't change from color-map indicies */ + cmap_entries = png_ptr->num_palette; + if (cmap_entries > 256) + cmap_entries = 256; + + if (cmap_entries > image->colormap_entries) + png_error(png_ptr, "palette color-map: too few entries"); + + for (i=0; i < cmap_entries; ++i) + { + if (do_background && i < num_trans && trans[i] < 255) + { + if (trans[i] == 0) + png_create_colormap_entry(display, i, back_r, back_g, + back_b, 0, output_encoding); + + else + { + /* Must compose the PNG file color in the color-map entry + * on the sRGB color in 'back'. + */ + png_create_colormap_entry(display, i, + png_colormap_compose(display, colormap[i].red, E_FILE, + trans[i], back_r, output_encoding), + png_colormap_compose(display, colormap[i].green, E_FILE, + trans[i], back_g, output_encoding), + png_colormap_compose(display, colormap[i].blue, E_FILE, + trans[i], back_b, output_encoding), + output_encoding == E_LINEAR ? trans[i] * 257U : + trans[i], + output_encoding); + } + } + + else + png_create_colormap_entry(display, i, colormap[i].red, + colormap[i].green, colormap[i].blue, + i < num_trans ? trans[i] : 255U, E_FILE/*8-bit*/); + } + + /* The PNG data may have indicies packed in fewer than 8 bits, it + * must be expanded if so. + */ + if (png_ptr->bit_depth < 8) + png_set_packing(png_ptr); + } + break; + + default: + png_error(png_ptr, "invalid PNG color type"); + /*NOT REACHED*/ + break; + } + + /* Now deal with the output processing */ + if (expand_tRNS && png_ptr->num_trans > 0 && + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0) + png_set_tRNS_to_alpha(png_ptr); + + switch (data_encoding) + { + default: + png_error(png_ptr, "bad data option (internal error)"); + break; + + case E_sRGB: + /* Change to 8-bit sRGB */ + png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB); + /* FALL THROUGH */ + + case E_FILE: + if (png_ptr->bit_depth > 8) + png_set_scale_16(png_ptr); + break; + } + + if (cmap_entries > 256 || cmap_entries > image->colormap_entries) + png_error(png_ptr, "color map overflow (BAD internal error)"); + + image->colormap_entries = cmap_entries; + + /* Double check using the recorded background index */ + switch (output_processing) + { + case PNG_CMAP_NONE: + if (background_index != PNG_CMAP_NONE_BACKGROUND) + goto bad_background; + break; + + case PNG_CMAP_GA: + if (background_index != PNG_CMAP_GA_BACKGROUND) + goto bad_background; + break; + + case PNG_CMAP_TRANS: + if (background_index >= cmap_entries || + background_index != PNG_CMAP_TRANS_BACKGROUND) + goto bad_background; + break; + + case PNG_CMAP_RGB: + if (background_index != PNG_CMAP_RGB_BACKGROUND) + goto bad_background; + break; + + case PNG_CMAP_RGB_ALPHA: + if (background_index != PNG_CMAP_RGB_ALPHA_BACKGROUND) + goto bad_background; + break; + + default: + png_error(png_ptr, "bad processing option (internal error)"); + + bad_background: + png_error(png_ptr, "bad background index (internal error)"); + } + + display->colormap_processing = output_processing; + + return 1/*ok*/; +} + +/* The final part of the color-map read called from png_image_finish_read. */ +static int +png_image_read_and_map(png_voidp argument) +{ + png_image_read_control *display = png_voidcast(png_image_read_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + int passes; + + /* Called when the libpng data must be transformed into the color-mapped + * form. There is a local row buffer in display->local and this routine must + * do the interlace handling. + */ + switch (png_ptr->interlaced) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + passes = 0; + png_error(png_ptr, "unknown interlace type"); + } + + { + png_uint_32 height = image->height; + png_uint_32 width = image->width; + int proc = display->colormap_processing; + png_bytep first_row = png_voidcast(png_bytep, display->first_row); + ptrdiff_t step_row = display->row_bytes; + int pass; + + for (pass = 0; pass < passes; ++pass) + { + unsigned int startx, stepx, stepy; + png_uint_32 y; + + if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) + { + /* The row may be empty for a short image: */ + if (PNG_PASS_COLS(width, pass) == 0) + continue; + + startx = PNG_PASS_START_COL(pass); + stepx = PNG_PASS_COL_OFFSET(pass); + y = PNG_PASS_START_ROW(pass); + stepy = PNG_PASS_ROW_OFFSET(pass); + } + + else + { + y = 0; + startx = 0; + stepx = stepy = 1; + } + + for (; y<height; y += stepy) + { + png_bytep inrow = png_voidcast(png_bytep, display->local_row); + png_bytep outrow = first_row + y * step_row; + png_const_bytep end_row = outrow + width; + + /* Read read the libpng data into the temporary buffer. */ + png_read_row(png_ptr, inrow, NULL); + + /* Now process the row according to the processing option, note + * that the caller verifies that the format of the libpng output + * data is as required. + */ + outrow += startx; + switch (proc) + { + case PNG_CMAP_GA: + for (; outrow < end_row; outrow += stepx) + { + /* The data is always in the PNG order */ + unsigned int gray = *inrow++; + unsigned int alpha = *inrow++; + unsigned int entry; + + /* NOTE: this code is copied as a comment in + * make_ga_colormap above. Please update the + * comment if you change this code! + */ + if (alpha > 229) /* opaque */ + { + entry = (231 * gray + 128) >> 8; + } + else if (alpha < 26) /* transparent */ + { + entry = 231; + } + else /* partially opaque */ + { + entry = 226 + 6 * PNG_DIV51(alpha) + PNG_DIV51(gray); + } + + *outrow = (png_byte)entry; + } + break; + + case PNG_CMAP_TRANS: + for (; outrow < end_row; outrow += stepx) + { + png_byte gray = *inrow++; + png_byte alpha = *inrow++; + + if (alpha == 0) + *outrow = PNG_CMAP_TRANS_BACKGROUND; + + else if (gray != PNG_CMAP_TRANS_BACKGROUND) + *outrow = gray; + + else + *outrow = (png_byte)(PNG_CMAP_TRANS_BACKGROUND+1); + } + break; + + case PNG_CMAP_RGB: + for (; outrow < end_row; outrow += stepx) + { + *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], inrow[2]); + inrow += 3; + } + break; + + case PNG_CMAP_RGB_ALPHA: + for (; outrow < end_row; outrow += stepx) + { + unsigned int alpha = inrow[3]; + + /* Because the alpha entries only hold alpha==0.5 values + * split the processing at alpha==0.25 (64) and 0.75 + * (196). + */ + + if (alpha >= 196) + *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], + inrow[2]); + + else if (alpha < 64) + *outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND; + + else + { + /* Likewise there are three entries for each of r, g + * and b. We could select the entry by popcount on + * the top two bits on those architectures that + * support it, this is what the code below does, + * crudely. + */ + unsigned int back_i = PNG_CMAP_RGB_ALPHA_BACKGROUND+1; + + /* Here are how the values map: + * + * 0x00 .. 0x3f -> 0 + * 0x40 .. 0xbf -> 1 + * 0xc0 .. 0xff -> 2 + * + * So, as above with the explicit alpha checks, the + * breakpoints are at 64 and 196. + */ + if (inrow[0] & 0x80) back_i += 9; /* red */ + if (inrow[0] & 0x40) back_i += 9; + if (inrow[0] & 0x80) back_i += 3; /* green */ + if (inrow[0] & 0x40) back_i += 3; + if (inrow[0] & 0x80) back_i += 1; /* blue */ + if (inrow[0] & 0x40) back_i += 1; + + *outrow = (png_byte)back_i; + } + + inrow += 4; + } + break; + + default: + break; + } + } + } + } + + return 1; +} + +static int +png_image_read_colormapped(png_voidp argument) +{ + png_image_read_control *display = png_voidcast(png_image_read_control*, + argument); + png_imagep image = display->image; + png_controlp control = image->opaque; + png_structrp png_ptr = control->png_ptr; + png_inforp info_ptr = control->info_ptr; + + int passes = 0; /* As a flag */ + + PNG_SKIP_CHUNKS(png_ptr); + + /* Update the 'info' structure and make sure the result is as required; first + * make sure to turn on the interlace handling if it will be required + * (because it can't be turned on *after* the call to png_read_update_info!) + */ + if (display->colormap_processing == PNG_CMAP_NONE) + passes = png_set_interlace_handling(png_ptr); + + png_read_update_info(png_ptr, info_ptr); + + /* The expected output can be deduced from the colormap_processing option. */ + switch (display->colormap_processing) + { + case PNG_CMAP_NONE: + /* Output must be one channel and one byte per pixel, the output + * encoding can be anything. + */ + if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE || + info_ptr->color_type == PNG_COLOR_TYPE_GRAY) && + info_ptr->bit_depth == 8) + break; + + goto bad_output; + + case PNG_CMAP_TRANS: + case PNG_CMAP_GA: + /* Output must be two channels and the 'G' one must be sRGB, the latter + * can be checked with an exact number because it should have been set + * to this number above! + */ + if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && + info_ptr->bit_depth == 8 && + png_ptr->screen_gamma == PNG_GAMMA_sRGB && + image->colormap_entries == 256) + break; + + goto bad_output; + + case PNG_CMAP_RGB: + /* Output must be 8-bit sRGB encoded RGB */ + if (info_ptr->color_type == PNG_COLOR_TYPE_RGB && + info_ptr->bit_depth == 8 && + png_ptr->screen_gamma == PNG_GAMMA_sRGB && + image->colormap_entries == 216) + break; + + goto bad_output; + + case PNG_CMAP_RGB_ALPHA: + /* Output must be 8-bit sRGB encoded RGBA */ + if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA && + info_ptr->bit_depth == 8 && + png_ptr->screen_gamma == PNG_GAMMA_sRGB && + image->colormap_entries == 244 /* 216 + 1 + 27 */) + break; + + /* goto bad_output; */ + /* FALL THROUGH */ + + default: + bad_output: + png_error(png_ptr, "bad color-map processing (internal error)"); + } + + /* Now read the rows. Do this here if it is possible to read directly into + * the output buffer, otherwise allocate a local row buffer of the maximum + * size libpng requires and call the relevant processing routine safely. + */ + { + png_voidp first_row = display->buffer; + ptrdiff_t row_bytes = display->row_stride; + + /* The following expression is designed to work correctly whether it gives + * a signed or an unsigned result. + */ + if (row_bytes < 0) + { + char *ptr = png_voidcast(char*, first_row); + ptr += (image->height-1) * (-row_bytes); + first_row = png_voidcast(png_voidp, ptr); + } + + display->first_row = first_row; + display->row_bytes = row_bytes; + } + + if (passes == 0) + { + int result; + png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); + + display->local_row = row; + result = png_safe_execute(image, png_image_read_and_map, display); + display->local_row = NULL; + png_free(png_ptr, row); + + return result; + } + + else + { + png_alloc_size_t row_bytes = display->row_bytes; + + while (--passes >= 0) + { + png_uint_32 y = image->height; + png_bytep row = png_voidcast(png_bytep, display->first_row); + + while (y-- > 0) + { + png_read_row(png_ptr, row, NULL); + row += row_bytes; + } + } + + return 1; + } +} + +/* Just the row reading part of png_image_read. */ +static int +png_image_read_composite(png_voidp argument) +{ + png_image_read_control *display = png_voidcast(png_image_read_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + int passes; + + switch (png_ptr->interlaced) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + passes = 0; + png_error(png_ptr, "unknown interlace type"); + } + + { + png_uint_32 height = image->height; + png_uint_32 width = image->width; + ptrdiff_t step_row = display->row_bytes; + unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; + int pass; + + for (pass = 0; pass < passes; ++pass) + { + unsigned int startx, stepx, stepy; + png_uint_32 y; + + if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) + { + /* The row may be empty for a short image: */ + if (PNG_PASS_COLS(width, pass) == 0) + continue; + + startx = PNG_PASS_START_COL(pass) * channels; + stepx = PNG_PASS_COL_OFFSET(pass) * channels; + y = PNG_PASS_START_ROW(pass); + stepy = PNG_PASS_ROW_OFFSET(pass); + } + + else + { + y = 0; + startx = 0; + stepx = channels; + stepy = 1; + } + + for (; y<height; y += stepy) + { + png_bytep inrow = png_voidcast(png_bytep, display->local_row); + png_bytep outrow; + png_const_bytep end_row; + + /* Read the row, which is packed: */ + png_read_row(png_ptr, inrow, NULL); + + outrow = png_voidcast(png_bytep, display->first_row); + outrow += y * step_row; + end_row = outrow + width * channels; + + /* Now do the composition on each pixel in this row. */ + outrow += startx; + for (; outrow < end_row; outrow += stepx) + { + png_byte alpha = inrow[channels]; + + if (alpha > 0) /* else no change to the output */ + { + unsigned int c; + + for (c=0; c<channels; ++c) + { + png_uint_32 component = inrow[c]; + + if (alpha < 255) /* else just use component */ + { + /* This is PNG_OPTIMIZED_ALPHA, the component value + * is a linear 8-bit value. Combine this with the + * current outrow[c] value which is sRGB encoded. + * Arithmetic here is 16-bits to preserve the output + * values correctly. + */ + component *= 257*255; /* =65535 */ + component += (255-alpha)*png_sRGB_table[outrow[c]]; + + /* So 'component' is scaled by 255*65535 and is + * therefore appropriate for the sRGB to linear + * conversion table. + */ + component = PNG_sRGB_FROM_LINEAR(component); + } + + outrow[c] = (png_byte)component; + } + } + + inrow += channels+1; /* components and alpha channel */ + } + } + } + } + + return 1; +} + +/* The do_local_background case; called when all the following transforms are to + * be done: + * + * PNG_RGB_TO_GRAY + * PNG_COMPOSITE + * PNG_GAMMA + * + * This is a work-round for the fact that both the PNG_RGB_TO_GRAY and + * PNG_COMPOSITE code performs gamma correction, so we get double gamma + * correction. The fix-up is to prevent the PNG_COMPOSITE operation happening + * inside libpng, so this routine sees an 8 or 16-bit gray+alpha row and handles + * the removal or pre-multiplication of the alpha channel. + */ +static int +png_image_read_background(png_voidp argument) +{ + png_image_read_control *display = png_voidcast(png_image_read_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + png_inforp info_ptr = image->opaque->info_ptr; + png_uint_32 height = image->height; + png_uint_32 width = image->width; + int pass, passes; + + /* Double check the convoluted logic below. We expect to get here with + * libpng doing rgb to gray and gamma correction but background processing + * left to the png_image_read_background function. The rows libpng produce + * might be 8 or 16-bit but should always have two channels; gray plus alpha. + */ + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) + png_error(png_ptr, "lost rgb to gray"); + + if ((png_ptr->transformations & PNG_COMPOSE) != 0) + png_error(png_ptr, "unexpected compose"); + + if (png_get_channels(png_ptr, info_ptr) != 2) + png_error(png_ptr, "lost/gained channels"); + + /* Expect the 8-bit case to always remove the alpha channel */ + if ((image->format & PNG_FORMAT_FLAG_LINEAR) == 0 && + (image->format & PNG_FORMAT_FLAG_ALPHA) != 0) + png_error(png_ptr, "unexpected 8-bit transformation"); + + switch (png_ptr->interlaced) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + passes = 0; + png_error(png_ptr, "unknown interlace type"); + } + + switch (png_get_bit_depth(png_ptr, info_ptr)) + { + default: + png_error(png_ptr, "unexpected bit depth"); + break; + + case 8: + /* 8-bit sRGB gray values with an alpha channel; the alpha channel is + * to be removed by composing on a backgroundi: either the row if + * display->background is NULL or display->background->green if not. + * Unlike the code above ALPHA_OPTIMIZED has *not* been done. + */ + { + png_bytep first_row = png_voidcast(png_bytep, display->first_row); + ptrdiff_t step_row = display->row_bytes; + + for (pass = 0; pass < passes; ++pass) + { + png_bytep row = png_voidcast(png_bytep, + display->first_row); + unsigned int startx, stepx, stepy; + png_uint_32 y; + + if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) + { + /* The row may be empty for a short image: */ + if (PNG_PASS_COLS(width, pass) == 0) + continue; + + startx = PNG_PASS_START_COL(pass); + stepx = PNG_PASS_COL_OFFSET(pass); + y = PNG_PASS_START_ROW(pass); + stepy = PNG_PASS_ROW_OFFSET(pass); + } + + else + { + y = 0; + startx = 0; + stepx = stepy = 1; + } + + if (display->background == NULL) + { + for (; y<height; y += stepy) + { + png_bytep inrow = png_voidcast(png_bytep, + display->local_row); + png_bytep outrow = first_row + y * step_row; + png_const_bytep end_row = outrow + width; + + /* Read the row, which is packed: */ + png_read_row(png_ptr, inrow, NULL); + + /* Now do the composition on each pixel in this row. */ + outrow += startx; + for (; outrow < end_row; outrow += stepx) + { + png_byte alpha = inrow[1]; + + if (alpha > 0) /* else no change to the output */ + { + png_uint_32 component = inrow[0]; + + if (alpha < 255) /* else just use component */ + { + /* Since PNG_OPTIMIZED_ALPHA was not set it is + * necessary to invert the sRGB transfer + * function and multiply the alpha out. + */ + component = png_sRGB_table[component] * alpha; + component += png_sRGB_table[outrow[0]] * + (255-alpha); + component = PNG_sRGB_FROM_LINEAR(component); + } + + outrow[0] = (png_byte)component; + } + + inrow += 2; /* gray and alpha channel */ + } + } + } + + else /* constant background value */ + { + png_byte background8 = display->background->green; + png_uint_16 background = png_sRGB_table[background8]; + + for (; y<height; y += stepy) + { + png_bytep inrow = png_voidcast(png_bytep, + display->local_row); + png_bytep outrow = first_row + y * step_row; + png_const_bytep end_row = outrow + width; + + /* Read the row, which is packed: */ + png_read_row(png_ptr, inrow, NULL); + + /* Now do the composition on each pixel in this row. */ + outrow += startx; + for (; outrow < end_row; outrow += stepx) + { + png_byte alpha = inrow[1]; + + if (alpha > 0) /* else use background */ + { + png_uint_32 component = inrow[0]; + + if (alpha < 255) /* else just use component */ + { + component = png_sRGB_table[component] * alpha; + component += background * (255-alpha); + component = PNG_sRGB_FROM_LINEAR(component); + } + + outrow[0] = (png_byte)component; + } + + else + outrow[0] = background8; + + inrow += 2; /* gray and alpha channel */ + } + + row += display->row_bytes; + } + } + } + } + break; + + case 16: + /* 16-bit linear with pre-multiplied alpha; the pre-multiplication must + * still be done and, maybe, the alpha channel removed. This code also + * handles the alpha-first option. + */ + { + png_uint_16p first_row = png_voidcast(png_uint_16p, + display->first_row); + /* The division by two is safe because the caller passed in a + * stride which was multiplied by 2 (below) to get row_bytes. + */ + ptrdiff_t step_row = display->row_bytes / 2; + int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0; + unsigned int outchannels = 1+preserve_alpha; + int swap_alpha = 0; + + if (preserve_alpha && (image->format & PNG_FORMAT_FLAG_AFIRST)) + swap_alpha = 1; + + for (pass = 0; pass < passes; ++pass) + { + unsigned int startx, stepx, stepy; + png_uint_32 y; + + /* The 'x' start and step are adjusted to output components here. + */ + if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) + { + /* The row may be empty for a short image: */ + if (PNG_PASS_COLS(width, pass) == 0) + continue; + + startx = PNG_PASS_START_COL(pass) * outchannels; + stepx = PNG_PASS_COL_OFFSET(pass) * outchannels; + y = PNG_PASS_START_ROW(pass); + stepy = PNG_PASS_ROW_OFFSET(pass); + } + + else + { + y = 0; + startx = 0; + stepx = outchannels; + stepy = 1; + } + + for (; y<height; y += stepy) + { + png_const_uint_16p inrow; + png_uint_16p outrow = first_row + y*step_row; + png_uint_16p end_row = outrow + width * outchannels; + + /* Read the row, which is packed: */ + png_read_row(png_ptr, png_voidcast(png_bytep, + display->local_row), NULL); + inrow = png_voidcast(png_const_uint_16p, display->local_row); + + /* Now do the pre-multiplication on each pixel in this row. + */ + outrow += startx; + for (; outrow < end_row; outrow += stepx) + { + png_uint_32 component = inrow[0]; + png_uint_16 alpha = inrow[1]; + + if (alpha > 0) /* else 0 */ + { + if (alpha < 65535) /* else just use component */ + { + component *= alpha; + component += 32767; + component /= 65535; + } + } + + else + component = 0; + + outrow[swap_alpha] = (png_uint_16)component; + if (preserve_alpha) + outrow[1 ^ swap_alpha] = alpha; + + inrow += 2; /* components and alpha channel */ + } + } + } + } + break; + } + + return 1; +} + +/* The guts of png_image_finish_read as a png_safe_execute callback. */ +static int +png_image_read_direct(png_voidp argument) +{ + png_image_read_control *display = png_voidcast(png_image_read_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + png_inforp info_ptr = image->opaque->info_ptr; + + png_uint_32 format = image->format; + int linear = (format & PNG_FORMAT_FLAG_LINEAR) != 0; + int do_local_compose = 0; + int do_local_background = 0; /* to avoid double gamma correction bug */ + int passes = 0; + + /* Add transforms to ensure the correct output format is produced then check + * that the required implementation support is there. Always expand; always + * need 8 bits minimum, no palette and expanded tRNS. + */ + png_set_expand(png_ptr); + + /* Now check the format to see if it was modified. */ + { + png_uint_32 base_format = png_image_format(png_ptr) & + ~PNG_FORMAT_FLAG_COLORMAP /* removed by png_set_expand */; + png_uint_32 change = format ^ base_format; + png_fixed_point output_gamma; + int mode; /* alpha mode */ + + /* Do this first so that we have a record if rgb to gray is happening. */ + if (change & PNG_FORMAT_FLAG_COLOR) + { + /* gray<->color transformation required. */ + if (format & PNG_FORMAT_FLAG_COLOR) + png_set_gray_to_rgb(png_ptr); + + else + { + /* libpng can't do both rgb to gray and + * background/pre-multiplication if there is also significant gamma + * correction, because both operations require linear colors and + * the code only supports one transform doing the gamma correction. + * Handle this by doing the pre-multiplication or background + * operation in this code, if necessary. + * + * TODO: fix this by rewriting pngrtran.c (!) + * + * For the moment (given that fixing this in pngrtran.c is an + * enormous change) 'do_local_background' is used to indicate that + * the problem exists. + */ + if (base_format & PNG_FORMAT_FLAG_ALPHA) + do_local_background = 1/*maybe*/; + + png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, + PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT); + } + + change &= ~PNG_FORMAT_FLAG_COLOR; + } + + /* Set the gamma appropriately, linear for 16-bit input, sRGB otherwise. + */ + { + png_fixed_point input_gamma_default; + + if ((base_format & PNG_FORMAT_FLAG_LINEAR) && + (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) + input_gamma_default = PNG_GAMMA_LINEAR; + else + input_gamma_default = PNG_DEFAULT_sRGB; + + /* Call png_set_alpha_mode to set the default for the input gamma; the + * output gamma is set by a second call below. + */ + png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, input_gamma_default); + } + + if (linear) + { + /* If there *is* an alpha channel in the input it must be multiplied + * out; use PNG_ALPHA_STANDARD, otherwise just use PNG_ALPHA_PNG. + */ + if (base_format & PNG_FORMAT_FLAG_ALPHA) + mode = PNG_ALPHA_STANDARD; /* associated alpha */ + + else + mode = PNG_ALPHA_PNG; + + output_gamma = PNG_GAMMA_LINEAR; + } + + else + { + mode = PNG_ALPHA_PNG; + output_gamma = PNG_DEFAULT_sRGB; + } + + /* If 'do_local_background' is set check for the presence of gamma + * correction; this is part of the work-round for the libpng bug + * described above. + * + * TODO: fix libpng and remove this. + */ + if (do_local_background) + { + png_fixed_point gtest; + + /* This is 'png_gamma_threshold' from pngrtran.c; the test used for + * gamma correction, the screen gamma hasn't been set on png_struct + * yet; it's set below. png_struct::gamma, however, is set to the + * final value. + */ + if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma, + PNG_FP_1) && !png_gamma_significant(gtest)) + do_local_background = 0; + + else if (mode == PNG_ALPHA_STANDARD) + { + do_local_background = 2/*required*/; + mode = PNG_ALPHA_PNG; /* prevent libpng doing it */ + } + + /* else leave as 1 for the checks below */ + } + + /* If the bit-depth changes then handle that here. */ + if (change & PNG_FORMAT_FLAG_LINEAR) + { + if (linear /*16-bit output*/) + png_set_expand_16(png_ptr); + + else /* 8-bit output */ + png_set_scale_16(png_ptr); + + change &= ~PNG_FORMAT_FLAG_LINEAR; + } + + /* Now the background/alpha channel changes. */ + if (change & PNG_FORMAT_FLAG_ALPHA) + { + /* Removing an alpha channel requires composition for the 8-bit + * formats; for the 16-bit it is already done, above, by the + * pre-multiplication and the channel just needs to be stripped. + */ + if (base_format & PNG_FORMAT_FLAG_ALPHA) + { + /* If RGB->gray is happening the alpha channel must be left and the + * operation completed locally. + * + * TODO: fix libpng and remove this. + */ + if (do_local_background) + do_local_background = 2/*required*/; + + /* 16-bit output: just remove the channel */ + else if (linear) /* compose on black (well, pre-multiply) */ + png_set_strip_alpha(png_ptr); + + /* 8-bit output: do an appropriate compose */ + else if (display->background != NULL) + { + png_color_16 c; + + c.index = 0; /*unused*/ + c.red = display->background->red; + c.green = display->background->green; + c.blue = display->background->blue; + c.gray = display->background->green; + + /* This is always an 8-bit sRGB value, using the 'green' channel + * for gray is much better than calculating the luminance here; + * we can get off-by-one errors in that calculation relative to + * the app expectations and that will show up in transparent + * pixels. + */ + png_set_background_fixed(png_ptr, &c, + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); + } + + else /* compose on row: implemented below. */ + { + do_local_compose = 1; + /* This leaves the alpha channel in the output, so it has to be + * removed by the code below. Set the encoding to the 'OPTIMIZE' + * one so the code only has to hack on the pixels that require + * composition. + */ + mode = PNG_ALPHA_OPTIMIZED; + } + } + + else /* output needs an alpha channel */ + { + /* This is tricky because it happens before the swap operation has + * been accomplished; however, the swap does *not* swap the added + * alpha channel (weird API), so it must be added in the correct + * place. + */ + png_uint_32 filler; /* opaque filler */ + int where; + + if (linear) + filler = 65535; + + else + filler = 255; + +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + { + where = PNG_FILLER_BEFORE; + change &= ~PNG_FORMAT_FLAG_AFIRST; + } + + else +# endif + where = PNG_FILLER_AFTER; + + png_set_add_alpha(png_ptr, filler, where); + } + + /* This stops the (irrelevant) call to swap_alpha below. */ + change &= ~PNG_FORMAT_FLAG_ALPHA; + } + + /* Now set the alpha mode correctly; this is always done, even if there is + * no alpha channel in either the input or the output because it correctly + * sets the output gamma. + */ + png_set_alpha_mode_fixed(png_ptr, mode, output_gamma); + +# ifdef PNG_FORMAT_BGR_SUPPORTED + if (change & PNG_FORMAT_FLAG_BGR) + { + /* Check only the output format; PNG is never BGR; don't do this if + * the output is gray, but fix up the 'format' value in that case. + */ + if (format & PNG_FORMAT_FLAG_COLOR) + png_set_bgr(png_ptr); + + else + format &= ~PNG_FORMAT_FLAG_BGR; + + change &= ~PNG_FORMAT_FLAG_BGR; + } +# endif + +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (change & PNG_FORMAT_FLAG_AFIRST) + { + /* Only relevant if there is an alpha channel - it's particularly + * important to handle this correctly because do_local_compose may + * be set above and then libpng will keep the alpha channel for this + * code to remove. + */ + if (format & PNG_FORMAT_FLAG_ALPHA) + { + /* Disable this if doing a local background, + * TODO: remove this when local background is no longer required. + */ + if (do_local_background != 2) + png_set_swap_alpha(png_ptr); + } + + else + format &= ~PNG_FORMAT_FLAG_AFIRST; + + change &= ~PNG_FORMAT_FLAG_AFIRST; + } +# endif + + /* If the *output* is 16-bit then we need to check for a byte-swap on this + * architecture. + */ + if (linear) + { + PNG_CONST png_uint_16 le = 0x0001; + + if (*(png_const_bytep)&le) + png_set_swap(png_ptr); + } + + /* If change is not now 0 some transformation is missing - error out. */ + if (change) + png_error(png_ptr, "png_read_image: unsupported transformation"); + } + + PNG_SKIP_CHUNKS(png_ptr); + + /* Update the 'info' structure and make sure the result is as required; first + * make sure to turn on the interlace handling if it will be required + * (because it can't be turned on *after* the call to png_read_update_info!) + * + * TODO: remove the do_local_background fixup below. + */ + if (!do_local_compose && do_local_background != 2) + passes = png_set_interlace_handling(png_ptr); + + png_read_update_info(png_ptr, info_ptr); + + { + png_uint_32 info_format = 0; + + if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) + info_format |= PNG_FORMAT_FLAG_COLOR; + + if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) + { + /* do_local_compose removes this channel below. */ + if (!do_local_compose) + { + /* do_local_background does the same if required. */ + if (do_local_background != 2 || + (format & PNG_FORMAT_FLAG_ALPHA) != 0) + info_format |= PNG_FORMAT_FLAG_ALPHA; + } + } + + else if (do_local_compose) /* internal error */ + png_error(png_ptr, "png_image_read: alpha channel lost"); + + if (info_ptr->bit_depth == 16) + info_format |= PNG_FORMAT_FLAG_LINEAR; + +# ifdef PNG_FORMAT_BGR_SUPPORTED + if (png_ptr->transformations & PNG_BGR) + info_format |= PNG_FORMAT_FLAG_BGR; +# endif + +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (do_local_background == 2) + { + if (format & PNG_FORMAT_FLAG_AFIRST) + info_format |= PNG_FORMAT_FLAG_AFIRST; + } + + if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0 || + ((png_ptr->transformations & PNG_ADD_ALPHA) != 0 && + (png_ptr->flags & PNG_FLAG_FILLER_AFTER) == 0)) + { + if (do_local_background == 2) + png_error(png_ptr, "unexpected alpha swap transformation"); + + info_format |= PNG_FORMAT_FLAG_AFIRST; + } +# endif + + /* This is actually an internal error. */ + if (info_format != format) + png_error(png_ptr, "png_read_image: invalid transformations"); + } + + /* Now read the rows. If do_local_compose is set then it is necessary to use + * a local row buffer. The output will be GA, RGBA or BGRA and must be + * converted to G, RGB or BGR as appropriate. The 'local_row' member of the + * display acts as a flag. + */ + { + png_voidp first_row = display->buffer; + ptrdiff_t row_bytes = display->row_stride; + + if (linear) + row_bytes *= 2; + + /* The following expression is designed to work correctly whether it gives + * a signed or an unsigned result. + */ + if (row_bytes < 0) + { + char *ptr = png_voidcast(char*, first_row); + ptr += (image->height-1) * (-row_bytes); + first_row = png_voidcast(png_voidp, ptr); + } + + display->first_row = first_row; + display->row_bytes = row_bytes; + } + + if (do_local_compose) + { + int result; + png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); + + display->local_row = row; + result = png_safe_execute(image, png_image_read_composite, display); + display->local_row = NULL; + png_free(png_ptr, row); + + return result; + } + + else if (do_local_background == 2) + { + int result; + png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); + + display->local_row = row; + result = png_safe_execute(image, png_image_read_background, display); + display->local_row = NULL; + png_free(png_ptr, row); + + return result; + } + + else + { + png_alloc_size_t row_bytes = display->row_bytes; + + while (--passes >= 0) + { + png_uint_32 y = image->height; + png_bytep row = png_voidcast(png_bytep, display->first_row); + + while (y-- > 0) + { + png_read_row(png_ptr, row, NULL); + row += row_bytes; + } + } + + return 1; + } +} + +int PNGAPI +png_image_finish_read(png_imagep image, png_const_colorp background, + void *buffer, png_int_32 row_stride, void *colormap) +{ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + png_uint_32 check; + + if (row_stride == 0) + row_stride = PNG_IMAGE_ROW_STRIDE(*image); + + if (row_stride < 0) + check = -row_stride; + + else + check = row_stride; + + if (image->opaque != NULL && buffer != NULL && + check >= PNG_IMAGE_ROW_STRIDE(*image)) + { + if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 || + (image->colormap_entries > 0 && colormap != NULL)) + { + int result; + png_image_read_control display; + + memset(&display, 0, (sizeof display)); + display.image = image; + display.buffer = buffer; + display.row_stride = row_stride; + display.colormap = colormap; + display.background = background; + display.local_row = NULL; + + /* Choose the correct 'end' routine; for the color-map case all the + * setup has already been done. + */ + if (image->format & PNG_FORMAT_FLAG_COLORMAP) + result = + png_safe_execute(image, png_image_read_colormap, &display) && + png_safe_execute(image, png_image_read_colormapped, &display); + + else + result = + png_safe_execute(image, png_image_read_direct, &display); + + png_image_free(image); + return result; + } + + else + return png_image_error(image, + "png_image_finish_read[color-map]: no color-map"); + } + + else + return png_image_error(image, + "png_image_finish_read: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_finish_read: damaged PNG_IMAGE_VERSION"); + + return 0; +} + +#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ #endif /* PNG_READ_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrio.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrio.c index 22756832d..2b9c10320 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrio.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrio.c @@ -1,12 +1,15 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * Last changed in libpng 1.6.0 [February 14, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file provides a location for all input. Users who need * special handling are expected to write a function that has the same * arguments as this and performs a similar function, but that possibly @@ -15,135 +18,84 @@ * libpng use it at run time with png_set_read_fn(...). */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" -#if defined(PNG_READ_SUPPORTED) +#ifdef PNG_READ_SUPPORTED /* Read the data from whatever input you are using. The default routine - reads from a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered reads. This should never be asked - to read more then 64K on a 16 bit machine. */ + * reads from a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered reads. This should never be asked + * to read more then 64K on a 16 bit machine. + */ void /* PRIVATE */ -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length) { - png_debug1(4,"reading %d bytes\n", (int)length); + png_debug1(4, "reading %d bytes", (int)length); + if (png_ptr->read_data_fn != NULL) (*(png_ptr->read_data_fn))(png_ptr, data, length); + else png_error(png_ptr, "Call to NULL read function"); } -#if !defined(PNG_NO_STDIO) +#ifdef PNG_STDIO_SUPPORTED /* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI + * not reading from a standard C stream, you should create a replacement + * read_data function and use it at run time with png_set_read_fn(), rather + * than changing the library. + */ +void PNGCBAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + /* fread() returns 0 on error, so it is OK to store this in a png_size_t * instead of an int, which is what fread() actually returns. */ -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = (png_size_t)fread(data, (png_size_t)1, length, - (png_FILE_p)png_ptr->io_ptr); -#endif + check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr)); if (check != length) png_error(png_ptr, "Read Error"); } -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void PNGAPI -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - if(png_ptr == NULL) return; - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fread(n_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) - err = 0; -#else - err = fread(buf, (png_size_t)1, read, io_ptr); -#endif - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if ((png_uint_32)check != (png_uint_32)length) - png_error(png_ptr, "read Error"); -} -#endif #endif /* This function allows the application to supply a new input function - for libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png input data structure - io_ptr - pointer to user supplied structure containing info about - the input functions. May be NULL. - read_data_fn - pointer to a new input function that takes as its - arguments a pointer to a png_struct, a pointer to - a location where input data can be stored, and a 32-bit - unsigned int that is the number of bytes to be read. - To exit and output any fatal error messages the new write - function should call png_error(png_ptr, "Error msg"). */ + * for libpng if standard C streams aren't being used. + * + * This function takes as its arguments: + * + * png_ptr - pointer to a png input data structure + * + * io_ptr - pointer to user supplied structure containing info about + * the input functions. May be NULL. + * + * read_data_fn - pointer to a new input function that takes as its + * arguments a pointer to a png_struct, a pointer to + * a location where input data can be stored, and a 32-bit + * unsigned int that is the number of bytes to be read. + * To exit and output any fatal error messages the new write + * function should call png_error(png_ptr, "Error msg"). + * May be NULL, in which case libpng's default function will + * be used. + */ void PNGAPI -png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, +png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + png_ptr->io_ptr = io_ptr; -#if !defined(PNG_NO_STDIO) +#ifdef PNG_STDIO_SUPPORTED if (read_data_fn != NULL) png_ptr->read_data_fn = read_data_fn; + else png_ptr->read_data_fn = png_default_read_data; #else @@ -155,12 +107,11 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, { png_ptr->write_data_fn = NULL; png_warning(png_ptr, - "It's an error to set both read_data_fn and write_data_fn in the "); - png_warning(png_ptr, - "same structure. Resetting write_data_fn to NULL."); + "Can't set both read_data_fn and write_data_fn in the" + " same structure"); } -#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#ifdef PNG_WRITE_FLUSH_SUPPORTED png_ptr->output_flush_fn = NULL; #endif } diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrtran.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrtran.c index b02b1d160..034b9c309 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrtran.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrtran.c @@ -1,70 +1,86 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.2.21 [October 4, 2007] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file contains functions optionally called by an application * in order to tell libpng how to handle data when reading a PNG. * Transformations that are used in both reading and writing are * in pngtrans.c. */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" -#if defined(PNG_READ_SUPPORTED) +#ifdef PNG_READ_SUPPORTED /* Set the action on getting a CRC error for an ancillary or critical chunk. */ void PNGAPI -png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) +png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action) { - png_debug(1, "in png_set_crc_action\n"); + png_debug(1, "in png_set_crc_action"); + + if (png_ptr == NULL) + return; + /* Tell libpng how we react to CRC errors in critical chunks */ - if(png_ptr == NULL) return; switch (crit_action) { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ + case PNG_CRC_NO_CHANGE: /* Leave setting as is */ break; - case PNG_CRC_WARN_USE: /* warn/use data */ + + case PNG_CRC_WARN_USE: /* Warn/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ + + case PNG_CRC_QUIET_USE: /* Quiet/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | PNG_FLAG_CRC_CRITICAL_IGNORE; break; - case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ - png_warning(png_ptr, "Can't discard critical data on CRC error."); - case PNG_CRC_ERROR_QUIT: /* error/quit */ + + case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */ + png_warning(png_ptr, + "Can't discard critical data on CRC error"); + case PNG_CRC_ERROR_QUIT: /* Error/quit */ + case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; break; } + /* Tell libpng how we react to CRC errors in ancillary chunks */ switch (ancil_action) { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ + case PNG_CRC_NO_CHANGE: /* Leave setting as is */ break; - case PNG_CRC_WARN_USE: /* warn/use data */ + + case PNG_CRC_WARN_USE: /* Warn/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ + + case PNG_CRC_QUIET_USE: /* Quiet/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN; break; - case PNG_CRC_ERROR_QUIT: /* error/quit */ + + case PNG_CRC_ERROR_QUIT: /* Error/quit */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; break; - case PNG_CRC_WARN_DISCARD: /* warn/discard data */ + + case PNG_CRC_WARN_DISCARD: /* Warn/discard data */ + case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; @@ -72,88 +88,344 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) } } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -/* handle alpha and tRNS via a background color */ -void PNGAPI -png_set_background(png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma) +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* Is it OK to set a transformation now? Only if png_start_read_image or + * png_read_update_info have not been called. It is not necessary for the IHDR + * to have been read in all cases, the parameter allows for this check too. + */ +static int +png_rtran_ok(png_structrp png_ptr, int need_IHDR) { - png_debug(1, "in png_set_background\n"); - if(png_ptr == NULL) return; + if (png_ptr != NULL) + { + if (png_ptr->flags & PNG_FLAG_ROW_INIT) + png_app_error(png_ptr, + "invalid after png_start_read_image or png_read_update_info"); + + else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_app_error(png_ptr, "invalid before the PNG header has been read"); + + else + { + /* Turn on failure to initialize correctly for all transforms. */ + png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED; + + return 1; /* Ok */ + } + } + + return 0; /* no png_error possible! */ +} +#endif + +#ifdef PNG_READ_BACKGROUND_SUPPORTED +/* Handle alpha and tRNS via a background color */ +void PNGFAPI +png_set_background_fixed(png_structrp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, png_fixed_point background_gamma) +{ + png_debug(1, "in png_set_background_fixed"); + + if (!png_rtran_ok(png_ptr, 0) || background_color == NULL) + return; + if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) { png_warning(png_ptr, "Application must supply a known background gamma"); return; } - png_ptr->transformations |= PNG_BACKGROUND; - png_memcpy(&(png_ptr->background), background_color, - png_sizeof(png_color_16)); - png_ptr->background_gamma = (float)background_gamma; + png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA; + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + + png_ptr->background = *background_color; + png_ptr->background_gamma = background_gamma; png_ptr->background_gamma_type = (png_byte)(background_gamma_code); - png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); + if (need_expand) + png_ptr->transformations |= PNG_BACKGROUND_EXPAND; + else + png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_background(png_structrp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma) +{ + png_set_background_fixed(png_ptr, background_color, background_gamma_code, + need_expand, png_fixed(png_ptr, background_gamma, "png_set_background")); +} +# endif /* FLOATING_POINT */ +#endif /* READ_BACKGROUND */ + +/* Scale 16-bit depth files to 8-bit depth. If both of these are set then the + * one that pngrtran does first (scale) happens. This is necessary to allow the + * TRANSFORM and API behavior to be somewhat consistent, and it's simpler. + */ +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED +void PNGAPI +png_set_scale_16(png_structrp png_ptr) +{ + png_debug(1, "in png_set_scale_16"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + + png_ptr->transformations |= PNG_SCALE_16_TO_8; } #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip 16 bit depth files to 8 bit depth */ +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED +/* Chop 16-bit depth files to 8-bit depth */ void PNGAPI -png_set_strip_16(png_structp png_ptr) +png_set_strip_16(png_structrp png_ptr) { - png_debug(1, "in png_set_strip_16\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_strip_16"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + png_ptr->transformations |= PNG_16_TO_8; } #endif -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +void PNGAPI +png_set_strip_alpha(png_structrp png_ptr) +{ + png_debug(1, "in png_set_strip_alpha"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + + png_ptr->transformations |= PNG_STRIP_ALPHA; +} +#endif + +#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED) +static png_fixed_point +translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, + int is_screen) +{ + /* Check for flag values. The main reason for having the old Mac value as a + * flag is that it is pretty near impossible to work out what the correct + * value is from Apple documentation - a working Mac system is needed to + * discover the value! + */ + if (output_gamma == PNG_DEFAULT_sRGB || + output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB) + { + /* If there is no sRGB support this just sets the gamma to the standard + * sRGB value. (This is a side effect of using this function!) + */ +# ifdef PNG_READ_sRGB_SUPPORTED + png_ptr->flags |= PNG_FLAG_ASSUME_sRGB; +# endif + if (is_screen) + output_gamma = PNG_GAMMA_sRGB; + else + output_gamma = PNG_GAMMA_sRGB_INVERSE; + } + + else if (output_gamma == PNG_GAMMA_MAC_18 || + output_gamma == PNG_FP_1 / PNG_GAMMA_MAC_18) + { + if (is_screen) + output_gamma = PNG_GAMMA_MAC_OLD; + else + output_gamma = PNG_GAMMA_MAC_INVERSE; + } + + return output_gamma; +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +static png_fixed_point +convert_gamma_value(png_structrp png_ptr, double output_gamma) +{ + /* The following silently ignores cases where fixed point (times 100,000) + * gamma values are passed to the floating point API. This is safe and it + * means the fixed point constants work just fine with the floating point + * API. The alternative would just lead to undetected errors and spurious + * bug reports. Negative values fail inside the _fixed API unless they + * correspond to the flag values. + */ + if (output_gamma > 0 && output_gamma < 128) + output_gamma *= PNG_FP_1; + + /* This preserves -1 and -2 exactly: */ + output_gamma = floor(output_gamma + .5); + + if (output_gamma > PNG_FP_MAX || output_gamma < PNG_FP_MIN) + png_fixed_error(png_ptr, "gamma value"); + + return (png_fixed_point)output_gamma; +} +# endif +#endif /* READ_ALPHA_MODE || READ_GAMMA */ + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED +void PNGFAPI +png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, + png_fixed_point output_gamma) +{ + int compose = 0; + png_fixed_point file_gamma; + + png_debug(1, "in png_set_alpha_mode"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + + output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/); + + /* Validate the value to ensure it is in a reasonable range. The value + * is expected to be 1 or greater, but this range test allows for some + * viewing correction values. The intent is to weed out users of this API + * who use the inverse of the gamma value accidentally! Since some of these + * values are reasonable this may have to be changed. + */ + if (output_gamma < 70000 || output_gamma > 300000) + png_error(png_ptr, "output gamma out of expected range"); + + /* The default file gamma is the inverse of the output gamma; the output + * gamma may be changed below so get the file value first: + */ + file_gamma = png_reciprocal(output_gamma); + + /* There are really 8 possibilities here, composed of any combination + * of: + * + * premultiply the color channels + * do not encode non-opaque pixels + * encode the alpha as well as the color channels + * + * The differences disappear if the input/output ('screen') gamma is 1.0, + * because then the encoding is a no-op and there is only the choice of + * premultiplying the color channels or not. + * + * png_set_alpha_mode and png_set_background interact because both use + * png_compose to do the work. Calling both is only useful when + * png_set_alpha_mode is used to set the default mode - PNG_ALPHA_PNG - along + * with a default gamma value. Otherwise PNG_COMPOSE must not be set. + */ + switch (mode) + { + case PNG_ALPHA_PNG: /* default: png standard */ + /* No compose, but it may be set by png_set_background! */ + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + break; + + case PNG_ALPHA_ASSOCIATED: /* color channels premultiplied */ + compose = 1; + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + /* The output is linear: */ + output_gamma = PNG_FP_1; + break; + + case PNG_ALPHA_OPTIMIZED: /* associated, non-opaque pixels linear */ + compose = 1; + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA; + /* output_gamma records the encoding of opaque pixels! */ + break; + + case PNG_ALPHA_BROKEN: /* associated, non-linear, alpha encoded */ + compose = 1; + png_ptr->transformations |= PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + break; + + default: + png_error(png_ptr, "invalid alpha mode"); + } + + /* Only set the default gamma if the file gamma has not been set (this has + * the side effect that the gamma in a second call to png_set_alpha_mode will + * be ignored.) + */ + if (png_ptr->colorspace.gamma == 0) + { + png_ptr->colorspace.gamma = file_gamma; + png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; + } + + /* But always set the output gamma: */ + png_ptr->screen_gamma = output_gamma; + + /* Finally, if pre-multiplying, set the background fields to achieve the + * desired result. + */ + if (compose) + { + /* And obtain alpha pre-multiplication by composing on black: */ + memset(&png_ptr->background, 0, (sizeof png_ptr->background)); + png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */ + png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE; + png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; + + if (png_ptr->transformations & PNG_COMPOSE) + png_error(png_ptr, + "conflicting calls to set alpha mode and background"); + + png_ptr->transformations |= PNG_COMPOSE; + } +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI -png_set_strip_alpha(png_structp png_ptr) +png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma) { - png_debug(1, "in png_set_strip_alpha\n"); - if(png_ptr == NULL) return; - png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; + png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr, + output_gamma)); } +# endif #endif -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Dither file to 8 bit. Supply a palette, the current number +#ifdef PNG_READ_QUANTIZE_SUPPORTED +/* Dither file to 8-bit. Supply a palette, the current number * of elements in the palette, the maximum number of elements * allowed, and a histogram if possible. If the current number * of colors is greater then the maximum number, the palette will be - * modified to fit in the maximum number. "full_dither" indicates - * whether we need a dithering cube set up for RGB images, or if we + * modified to fit in the maximum number. "full_quantize" indicates + * whether we need a quantizing cube set up for RGB images, or if we * simply are reducing the number of colors in a paletted image. */ typedef struct png_dsort_struct { - struct png_dsort_struct FAR * next; + struct png_dsort_struct * next; png_byte left; png_byte right; } png_dsort; -typedef png_dsort FAR * png_dsortp; -typedef png_dsort FAR * FAR * png_dsortpp; +typedef png_dsort * png_dsortp; +typedef png_dsort * * png_dsortpp; void PNGAPI -png_set_dither(png_structp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_uint_16p histogram, - int full_dither) +png_set_quantize(png_structrp png_ptr, png_colorp palette, + int num_palette, int maximum_colors, png_const_uint_16p histogram, + int full_quantize) { - png_debug(1, "in png_set_dither\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_DITHER; + png_debug(1, "in png_set_quantize"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + + png_ptr->transformations |= PNG_QUANTIZE; - if (!full_dither) + if (!full_quantize) { int i; - png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); + png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * (sizeof (png_byte)))); for (i = 0; i < num_palette; i++) - png_ptr->dither_index[i] = (png_byte)i; + png_ptr->quantize_index[i] = (png_byte)i; } if (num_palette > maximum_colors) @@ -161,61 +433,66 @@ png_set_dither(png_structp png_ptr, png_colorp palette, if (histogram != NULL) { /* This is easy enough, just throw out the least used colors. - Perhaps not the best solution, but good enough. */ + * Perhaps not the best solution, but good enough. + */ int i; - /* initialize an array to sort colors */ - png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); + /* Initialize an array to sort colors */ + png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * (sizeof (png_byte)))); - /* initialize the dither_sort array */ + /* Initialize the quantize_sort array */ for (i = 0; i < num_palette; i++) - png_ptr->dither_sort[i] = (png_byte)i; + png_ptr->quantize_sort[i] = (png_byte)i; /* Find the least used palette entries by starting a - bubble sort, and running it until we have sorted - out enough colors. Note that we don't care about - sorting all the colors, just finding which are - least used. */ + * bubble sort, and running it until we have sorted + * out enough colors. Note that we don't care about + * sorting all the colors, just finding which are + * least used. + */ for (i = num_palette - 1; i >= maximum_colors; i--) { - int done; /* to stop early if the list is pre-sorted */ + int done; /* To stop early if the list is pre-sorted */ int j; done = 1; for (j = 0; j < i; j++) { - if (histogram[png_ptr->dither_sort[j]] - < histogram[png_ptr->dither_sort[j + 1]]) + if (histogram[png_ptr->quantize_sort[j]] + < histogram[png_ptr->quantize_sort[j + 1]]) { png_byte t; - t = png_ptr->dither_sort[j]; - png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; - png_ptr->dither_sort[j + 1] = t; + t = png_ptr->quantize_sort[j]; + png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1]; + png_ptr->quantize_sort[j + 1] = t; done = 0; } } + if (done) break; } - /* swap the palette around, and set up a table, if necessary */ - if (full_dither) + /* Swap the palette around, and set up a table, if necessary */ + if (full_quantize) { int j = num_palette; - /* put all the useful colors within the max, but don't - move the others */ + /* Put all the useful colors within the max, but don't + * move the others. + */ for (i = 0; i < maximum_colors; i++) { - if ((int)png_ptr->dither_sort[i] >= maximum_colors) + if ((int)png_ptr->quantize_sort[i] >= maximum_colors) { do j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); + while ((int)png_ptr->quantize_sort[j] >= maximum_colors); + palette[i] = palette[j]; } } @@ -224,37 +501,38 @@ png_set_dither(png_structp png_ptr, png_colorp palette, { int j = num_palette; - /* move all the used colors inside the max limit, and - develop a translation table */ + /* Move all the used colors inside the max limit, and + * develop a translation table. + */ for (i = 0; i < maximum_colors; i++) { - /* only move the colors we need to */ - if ((int)png_ptr->dither_sort[i] >= maximum_colors) + /* Only move the colors we need to */ + if ((int)png_ptr->quantize_sort[i] >= maximum_colors) { png_color tmp_color; do j--; - while ((int)png_ptr->dither_sort[j] >= maximum_colors); + while ((int)png_ptr->quantize_sort[j] >= maximum_colors); tmp_color = palette[j]; palette[j] = palette[i]; palette[i] = tmp_color; - /* indicate where the color went */ - png_ptr->dither_index[j] = (png_byte)i; - png_ptr->dither_index[i] = (png_byte)j; + /* Indicate where the color went */ + png_ptr->quantize_index[j] = (png_byte)i; + png_ptr->quantize_index[i] = (png_byte)j; } } - /* find closest color for those colors we are not using */ + /* Find closest color for those colors we are not using */ for (i = 0; i < num_palette; i++) { - if ((int)png_ptr->dither_index[i] >= maximum_colors) + if ((int)png_ptr->quantize_index[i] >= maximum_colors) { int min_d, k, min_k, d_index; - /* find the closest color to one we threw out */ - d_index = png_ptr->dither_index[i]; + /* Find the closest color to one we threw out */ + d_index = png_ptr->quantize_index[i]; min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); for (k = 1, min_k = 0; k < maximum_colors; k++) { @@ -268,61 +546,58 @@ png_set_dither(png_structp png_ptr, png_colorp palette, min_k = k; } } - /* point to closest color */ - png_ptr->dither_index[i] = (png_byte)min_k; + /* Point to closest color */ + png_ptr->quantize_index[i] = (png_byte)min_k; } } } - png_free(png_ptr, png_ptr->dither_sort); - png_ptr->dither_sort=NULL; + png_free(png_ptr, png_ptr->quantize_sort); + png_ptr->quantize_sort = NULL; } else { /* This is much harder to do simply (and quickly). Perhaps - we need to go through a median cut routine, but those - don't always behave themselves with only a few colors - as input. So we will just find the closest two colors, - and throw out one of them (chosen somewhat randomly). - [We don't understand this at all, so if someone wants to - work on improving it, be our guest - AED, GRP] - */ + * we need to go through a median cut routine, but those + * don't always behave themselves with only a few colors + * as input. So we will just find the closest two colors, + * and throw out one of them (chosen somewhat randomly). + * [We don't understand this at all, so if someone wants to + * work on improving it, be our guest - AED, GRP] + */ int i; int max_d; int num_new_palette; png_dsortp t; png_dsortpp hash; - t=NULL; + t = NULL; - /* initialize palette index arrays */ + /* Initialize palette index arrays */ png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); + (png_uint_32)(num_palette * (sizeof (png_byte)))); png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); + (png_uint_32)(num_palette * (sizeof (png_byte)))); - /* initialize the sort array */ + /* Initialize the sort array */ for (i = 0; i < num_palette; i++) { png_ptr->index_to_palette[i] = (png_byte)i; png_ptr->palette_to_index[i] = (png_byte)i; } - hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * - png_sizeof (png_dsortp))); - for (i = 0; i < 769; i++) - hash[i] = NULL; -/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */ + hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 * + (sizeof (png_dsortp)))); num_new_palette = num_palette; - /* initial wild guess at how far apart the farthest pixel - pair we will be eliminating will be. Larger - numbers mean more areas will be allocated, Smaller - numbers run the risk of not saving enough data, and - having to do this all over again. - - I have not done extensive checking on this number. - */ + /* Initial wild guess at how far apart the farthest pixel + * pair we will be eliminating will be. Larger + * numbers mean more areas will be allocated, Smaller + * numbers run the risk of not saving enough data, and + * having to do this all over again. + * + * I have not done extensive checking on this number. + */ max_d = 96; while (num_new_palette > maximum_colors) @@ -341,9 +616,11 @@ png_set_dither(png_structp png_ptr, png_colorp palette, { t = (png_dsortp)png_malloc_warn(png_ptr, - (png_uint_32)(png_sizeof(png_dsort))); + (png_uint_32)(sizeof (png_dsort))); + if (t == NULL) break; + t->next = hash[d]; t->left = (png_byte)i; t->right = (png_byte)j; @@ -364,9 +641,9 @@ png_set_dither(png_structp png_ptr, png_colorp palette, for (p = hash[i]; p; p = p->next) { if ((int)png_ptr->index_to_palette[p->left] - < num_new_palette && - (int)png_ptr->index_to_palette[p->right] - < num_new_palette) + < num_new_palette && + (int)png_ptr->index_to_palette[p->right] + < num_new_palette) { int j, next_j; @@ -383,31 +660,36 @@ png_set_dither(png_structp png_ptr, png_colorp palette, num_new_palette--; palette[png_ptr->index_to_palette[j]] - = palette[num_new_palette]; - if (!full_dither) + = palette[num_new_palette]; + if (!full_quantize) { int k; for (k = 0; k < num_palette; k++) { - if (png_ptr->dither_index[k] == - png_ptr->index_to_palette[j]) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[next_j]; - if ((int)png_ptr->dither_index[k] == - num_new_palette) - png_ptr->dither_index[k] = - png_ptr->index_to_palette[j]; + if (png_ptr->quantize_index[k] == + png_ptr->index_to_palette[j]) + png_ptr->quantize_index[k] = + png_ptr->index_to_palette[next_j]; + + if ((int)png_ptr->quantize_index[k] == + num_new_palette) + png_ptr->quantize_index[k] = + png_ptr->index_to_palette[j]; } } png_ptr->index_to_palette[png_ptr->palette_to_index - [num_new_palette]] = png_ptr->index_to_palette[j]; + [num_new_palette]] = png_ptr->index_to_palette[j]; + png_ptr->palette_to_index[png_ptr->index_to_palette[j]] - = png_ptr->palette_to_index[num_new_palette]; + = png_ptr->palette_to_index[num_new_palette]; - png_ptr->index_to_palette[j] = (png_byte)num_new_palette; - png_ptr->palette_to_index[num_new_palette] = (png_byte)j; + png_ptr->index_to_palette[j] = + (png_byte)num_new_palette; + + png_ptr->palette_to_index[num_new_palette] = + (png_byte)j; } if (num_new_palette <= maximum_colors) break; @@ -436,8 +718,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette, png_free(png_ptr, hash); png_free(png_ptr, png_ptr->palette_to_index); png_free(png_ptr, png_ptr->index_to_palette); - png_ptr->palette_to_index=NULL; - png_ptr->index_to_palette=NULL; + png_ptr->palette_to_index = NULL; + png_ptr->index_to_palette = NULL; } num_palette = maximum_colors; } @@ -447,40 +729,38 @@ png_set_dither(png_structp png_ptr, png_colorp palette, } png_ptr->num_palette = (png_uint_16)num_palette; - if (full_dither) + if (full_quantize) { int i; png_bytep distance; - int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + - PNG_DITHER_BLUE_BITS; - int num_red = (1 << PNG_DITHER_RED_BITS); - int num_green = (1 << PNG_DITHER_GREEN_BITS); - int num_blue = (1 << PNG_DITHER_BLUE_BITS); + int total_bits = PNG_QUANTIZE_RED_BITS + PNG_QUANTIZE_GREEN_BITS + + PNG_QUANTIZE_BLUE_BITS; + int num_red = (1 << PNG_QUANTIZE_RED_BITS); + int num_green = (1 << PNG_QUANTIZE_GREEN_BITS); + int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS); png_size_t num_entries = ((png_size_t)1 << total_bits); - png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, - (png_uint_32)(num_entries * png_sizeof (png_byte))); - - png_memset(png_ptr->palette_lookup, 0, num_entries * - png_sizeof (png_byte)); + png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr, + (png_uint_32)(num_entries * (sizeof (png_byte)))); distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * - png_sizeof(png_byte))); + (sizeof (png_byte)))); - png_memset(distance, 0xff, num_entries * png_sizeof(png_byte)); + memset(distance, 0xff, num_entries * (sizeof (png_byte))); for (i = 0; i < num_palette; i++) { int ir, ig, ib; - int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); - int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); - int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); + int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS)); + int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS)); + int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS)); for (ir = 0; ir < num_red; ir++) { /* int dr = abs(ir - r); */ int dr = ((ir > r) ? ir - r : r - ir); - int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); + int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS + + PNG_QUANTIZE_GREEN_BITS)); for (ig = 0; ig < num_green; ig++) { @@ -488,7 +768,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette, int dg = ((ig > g) ? ig - g : g - ig); int dt = dr + dg; int dm = ((dr > dg) ? dr : dg); - int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); + int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS); for (ib = 0; ib < num_blue; ib++) { @@ -511,46 +791,72 @@ png_set_dither(png_structp png_ptr, png_colorp palette, png_free(png_ptr, distance); } } -#endif +#endif /* PNG_READ_QUANTIZE_SUPPORTED */ -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) -/* Transform the image from the file_gamma to the screen_gamma. We - * only do transformations on images where the file_gamma and screen_gamma - * are not close reciprocals, otherwise it slows things down slightly, and - * also needlessly introduces small errors. - * - * We will turn off gamma transformation later if no semitransparent entries - * are present in the tRNS array for palette images. We can't do it here - * because we don't necessarily have the tRNS chunk yet. - */ +#ifdef PNG_READ_GAMMA_SUPPORTED +void PNGFAPI +png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, + png_fixed_point file_gamma) +{ + png_debug(1, "in png_set_gamma_fixed"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + + /* New in libpng-1.5.4 - reserve particular negative values as flags. */ + scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/); + file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/); + + /* Checking the gamma values for being >0 was added in 1.5.4 along with the + * premultiplied alpha support; this actually hides an undocumented feature + * of the previous implementation which allowed gamma processing to be + * disabled in background handling. There is no evidence (so far) that this + * was being used; however, png_set_background itself accepted and must still + * accept '0' for the gamma value it takes, because it isn't always used. + * + * Since this is an API change (albeit a very minor one that removes an + * undocumented API feature) the following checks were only enabled in + * libpng-1.6.0. + */ + if (file_gamma <= 0) + png_error(png_ptr, "invalid file gamma in png_set_gamma"); + + if (scrn_gamma <= 0) + png_error(png_ptr, "invalid screen gamma in png_set_gamma"); + + /* Set the gamma values unconditionally - this overrides the value in the PNG + * file if a gAMA chunk was present. png_set_alpha_mode provides a + * different, easier, way to default the file gamma. + */ + png_ptr->colorspace.gamma = file_gamma; + png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; + png_ptr->screen_gamma = scrn_gamma; +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI -png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) +png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma) { - png_debug(1, "in png_set_gamma\n"); - if(png_ptr == NULL) return; - if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) - png_ptr->transformations |= PNG_GAMMA; - png_ptr->gamma = (float)file_gamma; - png_ptr->screen_gamma = (float)scrn_gamma; + png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma), + convert_gamma_value(png_ptr, file_gamma)); } -#endif +# endif /* FLOATING_POINT_SUPPORTED */ +#endif /* READ_GAMMA */ -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED /* Expand paletted images to RGB, expand grayscale images of * less than 8-bit depth to 8-bit depth, and expand tRNS chunks * to alpha channels. */ void PNGAPI -png_set_expand(png_structp png_ptr) +png_set_expand(png_structrp png_ptr) { - png_debug(1, "in png_set_expand\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_expand"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -#ifdef PNG_WARN_UNINITIALIZED_ROW - png_ptr->flags &= ~PNG_FLAG_ROW_INIT; -#endif } /* GRR 19990627: the following three functions currently are identical @@ -566,318 +872,725 @@ png_set_expand(png_structp png_ptr) * More to the point, these functions make it obvious what libpng will be * doing, whereas "expand" can (and does) mean any number of things. * - * GRP 20060307: In libpng-1.4.0, png_set_gray_1_2_4_to_8() was modified - * to expand only the sample depth but not to expand the tRNS to alpha. + * GRP 20060307: In libpng-1.2.9, png_set_gray_1_2_4_to_8() was modified + * to expand only the sample depth but not to expand the tRNS to alpha + * and its name was changed to png_set_expand_gray_1_2_4_to_8(). */ /* Expand paletted images to RGB. */ void PNGAPI -png_set_palette_to_rgb(png_structp png_ptr) +png_set_palette_to_rgb(png_structrp png_ptr) { - png_debug(1, "in png_set_palette_to_rgb\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_palette_to_rgb"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -#ifdef PNG_WARN_UNINITIALIZED_ROW - png_ptr->flags &= !(PNG_FLAG_ROW_INIT); - png_ptr->flags &= ~PNG_FLAG_ROW_INIT; -#endif } -#if !defined(PNG_1_0_X) /* Expand grayscale images of less than 8-bit depth to 8 bits. */ void PNGAPI -png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) +png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr) { - png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_expand_gray_1_2_4_to_8"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + png_ptr->transformations |= PNG_EXPAND; -#ifdef PNG_WARN_UNINITIALIZED_ROW - png_ptr->flags &= ~PNG_FLAG_ROW_INIT; -#endif } -#endif -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -/* Deprecated as of libpng-1.2.9 */ +/* Expand tRNS chunks to alpha channels. */ void PNGAPI -png_set_gray_1_2_4_to_8(png_structp png_ptr) +png_set_tRNS_to_alpha(png_structrp png_ptr) { - png_debug(1, "in png_set_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif + png_debug(1, "in png_set_tRNS_to_alpha"); + if (!png_rtran_ok(png_ptr, 0)) + return; -/* Expand tRNS chunks to alpha channels. */ -void PNGAPI -png_set_tRNS_to_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_tRNS_to_alpha\n"); png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -#ifdef PNG_WARN_UNINITIALIZED_ROW - png_ptr->flags &= ~PNG_FLAG_ROW_INIT; -#endif } #endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_EXPAND_16_SUPPORTED +/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise + * it may not work correctly.) + */ void PNGAPI -png_set_gray_to_rgb(png_structp png_ptr) +png_set_expand_16(png_structrp png_ptr) { - png_debug(1, "in png_set_gray_to_rgb\n"); - png_ptr->transformations |= PNG_GRAY_TO_RGB; -#ifdef PNG_WARN_UNINITIALIZED_ROW - png_ptr->flags &= ~PNG_FLAG_ROW_INIT; -#endif + png_debug(1, "in png_set_expand_16"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + + png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS); } #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) -/* Convert a RGB image to a grayscale of the same width. This allows us, - * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. - */ - +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED void PNGAPI -png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, - double green) +png_set_gray_to_rgb(png_structrp png_ptr) { - int red_fixed = (int)((float)red*100000.0 + 0.5); - int green_fixed = (int)((float)green*100000.0 + 0.5); - if(png_ptr == NULL) return; - png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); + png_debug(1, "in png_set_gray_to_rgb"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + + /* Because rgb must be 8 bits or more: */ + png_set_expand_gray_1_2_4_to_8(png_ptr); + png_ptr->transformations |= PNG_GRAY_TO_RGB; } #endif -void PNGAPI -png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, - png_fixed_point red, png_fixed_point green) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +void PNGFAPI +png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, + png_fixed_point red, png_fixed_point green) { - png_debug(1, "in png_set_rgb_to_gray\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_rgb_to_gray"); + + /* Need the IHDR here because of the check on color_type below. */ + /* TODO: fix this */ + if (!png_rtran_ok(png_ptr, 1)) + return; + switch(error_action) { - case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; - break; - case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; - break; - case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; + case PNG_ERROR_ACTION_NONE: + png_ptr->transformations |= PNG_RGB_TO_GRAY; + break; + + case PNG_ERROR_ACTION_WARN: + png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; + break; + + case PNG_ERROR_ACTION_ERROR: + png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; + break; + + default: + png_error(png_ptr, "invalid error action to rgb_to_gray"); + break; } + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED png_ptr->transformations |= PNG_EXPAND; #else { - png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); - png_ptr->transformations &= ~PNG_RGB_TO_GRAY; + /* Make this an error in 1.6 because otherwise the application may assume + * that it just worked and get a memory overwrite. + */ + png_error(png_ptr, + "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED"); + + /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */ } #endif { - png_uint_16 red_int, green_int; - if(red < 0 || green < 0) - { - red_int = 6968; /* .212671 * 32768 + .5 */ - green_int = 23434; /* .715160 * 32768 + .5 */ - } - else if(red + green < 100000L) + if (red >= 0 && green >= 0 && red + green <= PNG_FP_1) { - red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); - green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); + png_uint_16 red_int, green_int; + + /* NOTE: this calculation does not round, but this behavior is retained + * for consistency, the inaccuracy is very small. The code here always + * overwrites the coefficients, regardless of whether they have been + * defaulted or set already. + */ + red_int = (png_uint_16)(((png_uint_32)red*32768)/100000); + green_int = (png_uint_16)(((png_uint_32)green*32768)/100000); + + png_ptr->rgb_to_gray_red_coeff = red_int; + png_ptr->rgb_to_gray_green_coeff = green_int; + png_ptr->rgb_to_gray_coefficients_set = 1; } + else { - png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); - red_int = 6968; - green_int = 23434; + if (red >= 0 && green >= 0) + png_app_warning(png_ptr, + "ignoring out of range rgb_to_gray coefficients"); + + /* Use the defaults, from the cHRM chunk if set, else the historical + * values which are close to the sRGB/HDTV/ITU-Rec 709 values. See + * png_do_rgb_to_gray for more discussion of the values. In this case + * the coefficients are not marked as 'set' and are not overwritten if + * something has already provided a default. + */ + if (png_ptr->rgb_to_gray_red_coeff == 0 && + png_ptr->rgb_to_gray_green_coeff == 0) + { + png_ptr->rgb_to_gray_red_coeff = 6968; + png_ptr->rgb_to_gray_green_coeff = 23434; + /* png_ptr->rgb_to_gray_blue_coeff = 2366; */ + } } - png_ptr->rgb_to_gray_red_coeff = red_int; - png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); } } -#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +/* Convert a RGB image to a grayscale of the same width. This allows us, + * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. + */ + +void PNGAPI +png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red, + double green) +{ + png_set_rgb_to_gray_fixed(png_ptr, error_action, + png_fixed(png_ptr, red, "rgb to gray red coefficient"), + png_fixed(png_ptr, green, "rgb to gray green coefficient")); +} +#endif /* FLOATING POINT */ + +#endif /* RGB_TO_GRAY */ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) void PNGAPI -png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - read_user_transform_fn) +png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr + read_user_transform_fn) { - png_debug(1, "in png_set_read_user_transform_fn\n"); - if(png_ptr == NULL) return; -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_debug(1, "in png_set_read_user_transform_fn"); + + if (!png_rtran_ok(png_ptr, 0)) + return; + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->read_user_transform_fn = read_user_transform_fn; #endif -#ifdef PNG_LEGACY_SUPPORTED - if(read_user_transform_fn) - png_warning(png_ptr, - "This version of libpng does not support user transforms"); -#endif } #endif -/* Initialize everything needed for the read. This includes modifying - * the palette. +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +#ifdef PNG_READ_GAMMA_SUPPORTED +/* In the case of gamma transformations only do transformations on images where + * the [file] gamma and screen_gamma are not close reciprocals, otherwise it + * slows things down slightly, and also needlessly introduces small errors. */ -void /* PRIVATE */ -png_init_read_transformations(png_structp png_ptr) +static int /* PRIVATE */ +png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma) { - png_debug(1, "in png_init_read_transformations\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if(png_ptr != NULL) -#endif - { -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ - || defined(PNG_READ_GAMMA_SUPPORTED) - int color_type = png_ptr->color_type; + /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma + * correction as a difference of the overall transform from 1.0 + * + * We want to compare the threshold with s*f - 1, if we get + * overflow here it is because of wacky gamma values so we + * turn on processing anyway. + */ + png_fixed_point gtest; + return !png_muldiv(>est, screen_gamma, file_gamma, PNG_FP_1) || + png_gamma_significant(gtest); +} #endif -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Initialize everything needed for the read. This includes modifying + * the palette. + */ -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* Detect gray background and attempt to enable optimization - * for gray --> RGB case */ - /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or - * RGB_ALPHA (in which case need_expand is superfluous anyway), the - * background color might actually be gray yet not be flagged as such. - * This is not a problem for the current code, which uses - * PNG_BACKGROUND_IS_GRAY only to decide when to do the - * png_do_gray_to_rgb() transformation. +/*For the moment 'png_init_palette_transformations' and + * 'png_init_rgb_transformations' only do some flag canceling optimizations. + * The intent is that these two routines should have palette or rgb operations + * extracted from 'png_init_read_transformations'. + */ +static void /* PRIVATE */ +png_init_palette_transformations(png_structrp png_ptr) +{ + /* Called to handle the (input) palette case. In png_do_read_transformations + * the first step is to expand the palette if requested, so this code must + * take care to only make changes that are invariant with respect to the + * palette expansion, or only do them if there is no expansion. + * + * STRIP_ALPHA has already been handled in the caller (by setting num_trans + * to 0.) */ - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - !(color_type & PNG_COLOR_MASK_COLOR)) + int input_has_alpha = 0; + int input_has_transparency = 0; + + if (png_ptr->num_trans > 0) { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - } else if ((png_ptr->transformations & PNG_BACKGROUND) && - !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_GRAY_TO_RGB) && - png_ptr->background.red == png_ptr->background.green && - png_ptr->background.red == png_ptr->background.blue) + int i; + + /* Ignore if all the entries are opaque (unlikely!) */ + for (i=0; i<png_ptr->num_trans; ++i) + if (png_ptr->trans_alpha[i] == 255) + continue; + else if (png_ptr->trans_alpha[i] == 0) + input_has_transparency = 1; + else + input_has_alpha = 1; + } + + /* If no alpha we can optimize. */ + if (!input_has_alpha) { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - png_ptr->background.gray = png_ptr->background.red; + /* Any alpha means background and associative alpha processing is + * required, however if the alpha is 0 or 1 throughout OPTIIMIZE_ALPHA + * and ENCODE_ALPHA are irrelevant. + */ + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + + if (!input_has_transparency) + png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); } -#endif +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) + /* png_set_background handling - deals with the complexity of whether the + * background color is in the file format or the screen format in the case + * where an 'expand' will happen. + */ + + /* The following code cannot be entered in the alpha pre-multiplication case + * because PNG_BACKGROUND_EXPAND is cancelled below. + */ if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && (png_ptr->transformations & PNG_EXPAND)) { - if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ - { - /* expand background and tRNS chunks */ - switch (png_ptr->bit_depth) - { - case 1: - png_ptr->background.gray *= (png_uint_16)0xff; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0xff; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 2: - png_ptr->background.gray *= (png_uint_16)0x55; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0x55; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 4: - png_ptr->background.gray *= (png_uint_16)0x11; - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) - { - png_ptr->trans_values.gray *= (png_uint_16)0x11; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; - } - break; - case 8: - case 16: - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - break; - } - } - else if (color_type == PNG_COLOR_TYPE_PALETTE) { png_ptr->background.red = - png_ptr->palette[png_ptr->background.index].red; + png_ptr->palette[png_ptr->background.index].red; png_ptr->background.green = - png_ptr->palette[png_ptr->background.index].green; + png_ptr->palette[png_ptr->background.index].green; png_ptr->background.blue = - png_ptr->palette[png_ptr->background.index].blue; + png_ptr->palette[png_ptr->background.index].blue; -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_INVERT_ALPHA) { -#if defined(PNG_READ_EXPAND_SUPPORTED) if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) -#endif { - /* invert the alpha channel (in tRNS) unless the pixels are - going to be expanded, in which case leave it for later */ - int i,istop; - istop=(int)png_ptr->num_trans; + /* Invert the alpha channel (in tRNS) unless the pixels are + * going to be expanded, in which case leave it for later + */ + int i, istop = png_ptr->num_trans; + for (i=0; i<istop; i++) - png_ptr->trans[i] = (png_byte)(255 - png_ptr->trans[i]); + png_ptr->trans_alpha[i] = (png_byte)(255 - + png_ptr->trans_alpha[i]); } } -#endif +#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */ + } + } /* background expand and (therefore) no alpha association. */ +#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */ +} +static void /* PRIVATE */ +png_init_rgb_transformations(png_structrp png_ptr) +{ + /* Added to libpng-1.5.4: check the color type to determine whether there + * is any alpha or transparency in the image and simply cancel the + * background and alpha mode stuff if there isn't. + */ + int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0; + int input_has_transparency = png_ptr->num_trans > 0; + + /* If no alpha we can optimize. */ + if (!input_has_alpha) + { + /* Any alpha means background and associative alpha processing is + * required, however if the alpha is 0 or 1 throughout OPTIIMIZE_ALPHA + * and ENCODE_ALPHA are irrelevant. + */ +# ifdef PNG_READ_ALPHA_MODE_SUPPORTED + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; +# endif + + if (!input_has_transparency) + png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); + } + +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) + /* png_set_background handling - deals with the complexity of whether the + * background color is in the file format or the screen format in the case + * where an 'expand' will happen. + */ + + /* The following code cannot be entered in the alpha pre-multiplication case + * because PNG_BACKGROUND_EXPAND is cancelled below. + */ + if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && + (png_ptr->transformations & PNG_EXPAND) && + !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) + /* i.e., GRAY or GRAY_ALPHA */ + { + { + /* Expand background and tRNS chunks */ + int gray = png_ptr->background.gray; + int trans_gray = png_ptr->trans_color.gray; + + switch (png_ptr->bit_depth) + { + case 1: + gray *= 0xff; + trans_gray *= 0xff; + break; + + case 2: + gray *= 0x55; + trans_gray *= 0x55; + break; + + case 4: + gray *= 0x11; + trans_gray *= 0x11; + break; + + default: + + case 8: + /* FALL THROUGH (Already 8 bits) */ + + case 16: + /* Already a full 16 bits */ + break; + } + + png_ptr->background.red = png_ptr->background.green = + png_ptr->background.blue = (png_uint_16)gray; + + if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) + { + png_ptr->trans_color.red = png_ptr->trans_color.green = + png_ptr->trans_color.blue = (png_uint_16)trans_gray; + } } + } /* background expand and (therefore) no alpha association. */ +#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */ +} + +void /* PRIVATE */ +png_init_read_transformations(png_structrp png_ptr) +{ + png_debug(1, "in png_init_read_transformations"); + + /* This internal function is called from png_read_start_row in pngrutil.c + * and it is called before the 'rowbytes' calculation is done, so the code + * in here can change or update the transformations flags. + * + * First do updates that do not depend on the details of the PNG image data + * being processed. + */ + +#ifdef PNG_READ_GAMMA_SUPPORTED + /* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds + * png_set_alpha_mode and this is another source for a default file gamma so + * the test needs to be performed later - here. In addition prior to 1.5.4 + * the tests were repeated for the PALETTE color type here - this is no + * longer necessary (and doesn't seem to have been necessary before.) + */ + { + /* The following temporary indicates if overall gamma correction is + * required. + */ + int gamma_correction = 0; + + if (png_ptr->colorspace.gamma != 0) /* has been set */ + { + if (png_ptr->screen_gamma != 0) /* screen set too */ + gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma, + png_ptr->screen_gamma); + + else + /* Assume the output matches the input; a long time default behavior + * of libpng, although the standard has nothing to say about this. + */ + png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma); + } + + else if (png_ptr->screen_gamma != 0) + /* The converse - assume the file matches the screen, note that this + * perhaps undesireable default can (from 1.5.4) be changed by calling + * png_set_alpha_mode (even if the alpha handling mode isn't required + * or isn't changed from the default.) + */ + png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma); + + else /* neither are set */ + /* Just in case the following prevents any processing - file and screen + * are both assumed to be linear and there is no way to introduce a + * third gamma value other than png_set_background with 'UNIQUE', and, + * prior to 1.5.4 + */ + png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1; + + /* We have a gamma value now. */ + png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; + + /* Now turn the gamma transformation on or off as appropriate. Notice + * that PNG_GAMMA just refers to the file->screen correction. Alpha + * composition may independently cause gamma correction because it needs + * linear data (e.g. if the file has a gAMA chunk but the screen gamma + * hasn't been specified.) In any case this flag may get turned off in + * the code immediately below if the transform can be handled outside the + * row loop. + */ + if (gamma_correction) + png_ptr->transformations |= PNG_GAMMA; + + else + png_ptr->transformations &= ~PNG_GAMMA; } #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - png_ptr->background_1 = png_ptr->background; + /* Certain transformations have the effect of preventing other + * transformations that happen afterward in png_do_read_transformations, + * resolve the interdependencies here. From the code of + * png_do_read_transformations the order is: + * + * 1) PNG_EXPAND (including PNG_EXPAND_tRNS) + * 2) PNG_STRIP_ALPHA (if no compose) + * 3) PNG_RGB_TO_GRAY + * 4) PNG_GRAY_TO_RGB iff !PNG_BACKGROUND_IS_GRAY + * 5) PNG_COMPOSE + * 6) PNG_GAMMA + * 7) PNG_STRIP_ALPHA (if compose) + * 8) PNG_ENCODE_ALPHA + * 9) PNG_SCALE_16_TO_8 + * 10) PNG_16_TO_8 + * 11) PNG_QUANTIZE (converts to palette) + * 12) PNG_EXPAND_16 + * 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY + * 14) PNG_INVERT_MONO + * 15) PNG_SHIFT + * 16) PNG_PACK + * 17) PNG_BGR + * 18) PNG_PACKSWAP + * 19) PNG_FILLER (includes PNG_ADD_ALPHA) + * 20) PNG_INVERT_ALPHA + * 21) PNG_SWAP_ALPHA + * 22) PNG_SWAP_BYTES + * 23) PNG_USER_TRANSFORM [must be last] + */ +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_STRIP_ALPHA) && + !(png_ptr->transformations & PNG_COMPOSE)) + { + /* Stripping the alpha channel happens immediately after the 'expand' + * transformations, before all other transformation, so it cancels out + * the alpha handling. It has the side effect negating the effect of + * PNG_EXPAND_tRNS too: + */ + png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA | + PNG_EXPAND_tRNS); + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + + /* Kill the tRNS chunk itself too. Prior to 1.5.4 this did not happen + * so transparency information would remain just so long as it wasn't + * expanded. This produces unexpected API changes if the set of things + * that do PNG_EXPAND_tRNS changes (perfectly possible given the + * documentation - which says ask for what you want, accept what you + * get.) This makes the behavior consistent from 1.5.4: + */ + png_ptr->num_trans = 0; + } +#endif /* STRIP_ALPHA supported, no COMPOSE */ + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + /* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA + * settings will have no effect. + */ + if (!png_gamma_significant(png_ptr->screen_gamma)) + { + png_ptr->transformations &= ~PNG_ENCODE_ALPHA; + png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; + } +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + /* Make sure the coefficients for the rgb to gray conversion are set + * appropriately. + */ + if (png_ptr->transformations & PNG_RGB_TO_GRAY) + png_colorspace_set_rgb_coefficients(png_ptr); #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) - && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) - < PNG_GAMMA_THRESHOLD)) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) + /* Detect gray background and attempt to enable optimization for + * gray --> RGB case. + * + * Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or + * RGB_ALPHA (in which case need_expand is superfluous anyway), the + * background color might actually be gray yet not be flagged as such. + * This is not a problem for the current code, which uses + * PNG_BACKGROUND_IS_GRAY only to decide when to do the + * png_do_gray_to_rgb() transformation. + * + * TODO: this code needs to be revised to avoid the complexity and + * interdependencies. The color type of the background should be recorded in + * png_set_background, along with the bit depth, then the code has a record + * of exactly what color space the background is currently in. + */ + if (png_ptr->transformations & PNG_BACKGROUND_EXPAND) + { + /* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if + * the file was grayscale the background value is gray. + */ + if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) + png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; + } + + else if (png_ptr->transformations & PNG_COMPOSE) { - int i,k; - k=0; - for (i=0; i<png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) - k=1; /* partial transparency is present */ - } - if (k == 0) - png_ptr->transformations &= (~PNG_GAMMA); + /* PNG_COMPOSE: png_set_background was called with need_expand false, + * so the color is in the color space of the output or png_set_alpha_mode + * was called and the color is black. Ignore RGB_TO_GRAY because that + * happens before GRAY_TO_RGB. + */ + if (png_ptr->transformations & PNG_GRAY_TO_RGB) + { + if (png_ptr->background.red == png_ptr->background.green && + png_ptr->background.red == png_ptr->background.blue) + { + png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; + png_ptr->background.gray = png_ptr->background.red; + } + } + } +#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */ +#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */ + + /* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations + * can be performed directly on the palette, and some (such as rgb to gray) + * can be optimized inside the palette. This is particularly true of the + * composite (background and alpha) stuff, which can be pretty much all done + * in the palette even if the result is expanded to RGB or gray afterward. + * + * NOTE: this is Not Yet Implemented, the code behaves as in 1.5.1 and + * earlier and the palette stuff is actually handled on the first row. This + * leads to the reported bug that the palette returned by png_get_PLTE is not + * updated. + */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + png_init_palette_transformations(png_ptr); + + else + png_init_rgb_transformations(png_ptr); + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + defined(PNG_READ_EXPAND_16_SUPPORTED) + if ((png_ptr->transformations & PNG_EXPAND_16) && + (png_ptr->transformations & PNG_COMPOSE) && + !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && + png_ptr->bit_depth != 16) + { + /* TODO: fix this. Because the expand_16 operation is after the compose + * handling the background color must be 8, not 16, bits deep, but the + * application will supply a 16-bit value so reduce it here. + * + * The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at + * present, so that case is ok (until do_expand_16 is moved.) + * + * NOTE: this discards the low 16 bits of the user supplied background + * color, but until expand_16 works properly there is no choice! + */ +# define CHOP(x) (x)=((png_uint_16)PNG_DIV257(x)) + CHOP(png_ptr->background.red); + CHOP(png_ptr->background.green); + CHOP(png_ptr->background.blue); + CHOP(png_ptr->background.gray); +# undef CHOP } +#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */ + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + (defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \ + defined(PNG_READ_STRIP_16_TO_8_SUPPORTED)) + if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) && + (png_ptr->transformations & PNG_COMPOSE) && + !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && + png_ptr->bit_depth == 16) + { + /* On the other hand, if a 16-bit file is to be reduced to 8-bits per + * component this will also happen after PNG_COMPOSE and so the background + * color must be pre-expanded here. + * + * TODO: fix this too. + */ + png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257); + png_ptr->background.green = + (png_uint_16)(png_ptr->background.green * 257); + png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257); + png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257); + } +#endif + + /* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the + * background support (see the comments in scripts/pnglibconf.dfa), this + * allows pre-multiplication of the alpha channel to be implemented as + * compositing on black. This is probably sub-optimal and has been done in + * 1.5.4 betas simply to enable external critique and testing (i.e. to + * implement the new API quickly, without lots of internal changes.) + */ - if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && - png_ptr->gamma != 0.0) +#ifdef PNG_READ_GAMMA_SUPPORTED +# ifdef PNG_READ_BACKGROUND_SUPPORTED + /* Includes ALPHA_MODE */ + png_ptr->background_1 = png_ptr->background; +# endif + + /* This needs to change - in the palette image case a whole set of tables are + * built when it would be quicker to just calculate the correct value for + * each palette entry directly. Also, the test is too tricky - why check + * PNG_RGB_TO_GRAY if PNG_GAMMA is not set? The answer seems to be that + * PNG_GAMMA is cancelled even if the gamma is known? The test excludes the + * PNG_COMPOSE case, so apparently if there is no *overall* gamma correction + * the gamma tables will not be built even if composition is required on a + * gamma encoded value. + * + * In 1.5.4 this is addressed below by an additional check on the individual + * file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the + * tables. + */ + if ((png_ptr->transformations & PNG_GAMMA) + || ((png_ptr->transformations & PNG_RGB_TO_GRAY) + && (png_gamma_significant(png_ptr->colorspace.gamma) || + png_gamma_significant(png_ptr->screen_gamma))) + || ((png_ptr->transformations & PNG_COMPOSE) + && (png_gamma_significant(png_ptr->colorspace.gamma) + || png_gamma_significant(png_ptr->screen_gamma) +# ifdef PNG_READ_BACKGROUND_SUPPORTED + || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE + && png_gamma_significant(png_ptr->background_gamma)) +# endif + )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) + && png_gamma_significant(png_ptr->screen_gamma)) + ) { - png_build_gamma_table(png_ptr); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) + png_build_gamma_table(png_ptr, png_ptr->bit_depth); + +#ifdef PNG_READ_BACKGROUND_SUPPORTED + if (png_ptr->transformations & PNG_COMPOSE) { - if (color_type == PNG_COLOR_TYPE_PALETTE) + /* Issue a warning about this combination: because RGB_TO_GRAY is + * optimized to do the gamma transform if present yet do_background has + * to do the same thing if both options are set a + * double-gamma-correction happens. This is true in all versions of + * libpng to date. + */ + if (png_ptr->transformations & PNG_RGB_TO_GRAY) + png_warning(png_ptr, + "libpng does not support gamma+background+rgb_to_gray"); + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - /* could skip if no transparency and - */ + /* We don't get to here unless there is a tRNS chunk with non-opaque + * entries - see the checking code at the start of this function. + */ png_color back, back_1; png_colorp palette = png_ptr->palette; int num_palette = png_ptr->num_palette; int i; if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) { + back.red = png_ptr->gamma_table[png_ptr->background.red]; back.green = png_ptr->gamma_table[png_ptr->background.green]; back.blue = png_ptr->gamma_table[png_ptr->background.blue]; @@ -888,73 +1601,90 @@ png_init_read_transformations(png_structp png_ptr) } else { - double g, gs; + png_fixed_point g, gs; switch (png_ptr->background_gamma_type) { case PNG_BACKGROUND_GAMMA_SCREEN: g = (png_ptr->screen_gamma); - gs = 1.0; + gs = PNG_FP_1; break; + case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + g = png_reciprocal(png_ptr->colorspace.gamma); + gs = png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma); break; + case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); + g = png_reciprocal(png_ptr->background_gamma); + gs = png_reciprocal2(png_ptr->background_gamma, + png_ptr->screen_gamma); break; default: - g = 1.0; /* back_1 */ - gs = 1.0; /* back */ + g = PNG_FP_1; /* back_1 */ + gs = PNG_FP_1; /* back */ + break; } - if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) + if (png_gamma_significant(gs)) + { + back.red = png_gamma_8bit_correct(png_ptr->background.red, + gs); + back.green = png_gamma_8bit_correct(png_ptr->background.green, + gs); + back.blue = png_gamma_8bit_correct(png_ptr->background.blue, + gs); + } + + else { back.red = (png_byte)png_ptr->background.red; back.green = (png_byte)png_ptr->background.green; back.blue = (png_byte)png_ptr->background.blue; } - else + + if (png_gamma_significant(g)) { - back.red = (png_byte)(pow( - (double)png_ptr->background.red/255, gs) * 255.0 + .5); - back.green = (png_byte)(pow( - (double)png_ptr->background.green/255, gs) * 255.0 + .5); - back.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, gs) * 255.0 + .5); + back_1.red = png_gamma_8bit_correct(png_ptr->background.red, + g); + back_1.green = png_gamma_8bit_correct( + png_ptr->background.green, g); + back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue, + g); } - back_1.red = (png_byte)(pow( - (double)png_ptr->background.red/255, g) * 255.0 + .5); - back_1.green = (png_byte)(pow( - (double)png_ptr->background.green/255, g) * 255.0 + .5); - back_1.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, g) * 255.0 + .5); + else + { + back_1.red = (png_byte)png_ptr->background.red; + back_1.green = (png_byte)png_ptr->background.green; + back_1.blue = (png_byte)png_ptr->background.blue; + } } + for (i = 0; i < num_palette; i++) { - if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) + if (i < (int)png_ptr->num_trans && + png_ptr->trans_alpha[i] != 0xff) { - if (png_ptr->trans[i] == 0) + if (png_ptr->trans_alpha[i] == 0) { palette[i] = back; } - else /* if (png_ptr->trans[i] != 0xff) */ + else /* if (png_ptr->trans_alpha[i] != 0xff) */ { png_byte v, w; v = png_ptr->gamma_to_1[palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); + png_composite(w, v, png_ptr->trans_alpha[i], back_1.red); palette[i].red = png_ptr->gamma_from_1[w]; v = png_ptr->gamma_to_1[palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); + png_composite(w, v, png_ptr->trans_alpha[i], back_1.green); palette[i].green = png_ptr->gamma_from_1[w]; v = png_ptr->gamma_to_1[palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); + png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue); palette[i].blue = png_ptr->gamma_from_1[w]; } } @@ -965,90 +1695,140 @@ png_init_read_transformations(png_structp png_ptr) palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } } - } + + /* Prevent the transformations being done again. + * + * NOTE: this is highly dubious; it removes the transformations in + * place. This seems inconsistent with the general treatment of the + * transformations elsewhere. + */ + png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA); + } /* color_type == PNG_COLOR_TYPE_PALETTE */ + /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ - else - /* color_type != PNG_COLOR_TYPE_PALETTE */ + else /* color_type != PNG_COLOR_TYPE_PALETTE */ { - double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); - double g = 1.0; - double gs = 1.0; + int gs_sig, g_sig; + png_fixed_point g = PNG_FP_1; /* Correction to linear */ + png_fixed_point gs = PNG_FP_1; /* Correction to screen */ switch (png_ptr->background_gamma_type) { case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; + g = png_ptr->screen_gamma; + /* gs = PNG_FP_1; */ break; + case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + g = png_reciprocal(png_ptr->colorspace.gamma); + gs = png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma); break; + case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); + g = png_reciprocal(png_ptr->background_gamma); + gs = png_reciprocal2(png_ptr->background_gamma, + png_ptr->screen_gamma); break; + + default: + png_error(png_ptr, "invalid background gamma type"); } - png_ptr->background_1.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, g) * m + .5); - png_ptr->background.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, gs) * m + .5); + g_sig = png_gamma_significant(g); + gs_sig = png_gamma_significant(gs); + + if (g_sig) + png_ptr->background_1.gray = png_gamma_correct(png_ptr, + png_ptr->background.gray, g); + + if (gs_sig) + png_ptr->background.gray = png_gamma_correct(png_ptr, + png_ptr->background.gray, gs); if ((png_ptr->background.red != png_ptr->background.green) || (png_ptr->background.red != png_ptr->background.blue) || (png_ptr->background.red != png_ptr->background.gray)) { /* RGB or RGBA with color background */ - png_ptr->background_1.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, g) * m + .5); - png_ptr->background_1.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, g) * m + .5); - png_ptr->background_1.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, g) * m + .5); - png_ptr->background.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, gs) * m + .5); - png_ptr->background.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, gs) * m + .5); - png_ptr->background.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, gs) * m + .5); + if (g_sig) + { + png_ptr->background_1.red = png_gamma_correct(png_ptr, + png_ptr->background.red, g); + + png_ptr->background_1.green = png_gamma_correct(png_ptr, + png_ptr->background.green, g); + + png_ptr->background_1.blue = png_gamma_correct(png_ptr, + png_ptr->background.blue, g); + } + + if (gs_sig) + { + png_ptr->background.red = png_gamma_correct(png_ptr, + png_ptr->background.red, gs); + + png_ptr->background.green = png_gamma_correct(png_ptr, + png_ptr->background.green, gs); + + png_ptr->background.blue = png_gamma_correct(png_ptr, + png_ptr->background.blue, gs); + } } + else { /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ png_ptr->background_1.red = png_ptr->background_1.green - = png_ptr->background_1.blue = png_ptr->background_1.gray; + = png_ptr->background_1.blue = png_ptr->background_1.gray; + png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; + = png_ptr->background.blue = png_ptr->background.gray; } - } - } + + /* The background is now in screen gamma: */ + png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN; + } /* color_type != PNG_COLOR_TYPE_PALETTE */ + }/* png_ptr->transformations & PNG_BACKGROUND */ + else - /* transformation does not include PNG_BACKGROUND */ + /* Transformation does not include PNG_BACKGROUND */ #endif /* PNG_READ_BACKGROUND_SUPPORTED */ - if (color_type == PNG_COLOR_TYPE_PALETTE) + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + /* RGB_TO_GRAY needs to have non-gamma-corrected values! */ + && ((png_ptr->transformations & PNG_EXPAND) == 0 || + (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) +#endif + ) { png_colorp palette = png_ptr->palette; int num_palette = png_ptr->num_palette; int i; + /* NOTE: there are other transformations that should probably be in + * here too. + */ for (i = 0; i < num_palette; i++) { palette[i].red = png_ptr->gamma_table[palette[i].red]; palette[i].green = png_ptr->gamma_table[palette[i].green]; palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } - } + + /* Done the gamma correction. */ + png_ptr->transformations &= ~PNG_GAMMA; + } /* color_type == PALETTE && !PNG_BACKGROUND transformation */ } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED else #endif -#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - /* No GAMMA transformation */ - if ((png_ptr->transformations & PNG_BACKGROUND) && - (color_type == PNG_COLOR_TYPE_PALETTE)) +#endif /* PNG_READ_GAMMA_SUPPORTED */ + +#ifdef PNG_READ_BACKGROUND_SUPPORTED + /* No GAMMA transformation (see the hanging else 4 lines above) */ + if ((png_ptr->transformations & PNG_COMPOSE) && + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) { int i; int istop = (int)png_ptr->num_trans; @@ -1061,54 +1841,71 @@ png_init_read_transformations(png_structp png_ptr) for (i = 0; i < istop; i++) { - if (png_ptr->trans[i] == 0) + if (png_ptr->trans_alpha[i] == 0) { palette[i] = back; } - else if (png_ptr->trans[i] != 0xff) + + else if (png_ptr->trans_alpha[i] != 0xff) { /* The png_composite() macro is defined in png.h */ png_composite(palette[i].red, palette[i].red, - png_ptr->trans[i], back.red); + png_ptr->trans_alpha[i], back.red); + png_composite(palette[i].green, palette[i].green, - png_ptr->trans[i], back.green); + png_ptr->trans_alpha[i], back.green); + png_composite(palette[i].blue, palette[i].blue, - png_ptr->trans[i], back.blue); + png_ptr->trans_alpha[i], back.blue); } } + + png_ptr->transformations &= ~PNG_COMPOSE; } #endif /* PNG_READ_BACKGROUND_SUPPORTED */ -#if defined(PNG_READ_SHIFT_SUPPORTED) +#ifdef PNG_READ_SHIFT_SUPPORTED if ((png_ptr->transformations & PNG_SHIFT) && - (color_type == PNG_COLOR_TYPE_PALETTE)) + !(png_ptr->transformations & PNG_EXPAND) && + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) { - png_uint_16 i; - png_uint_16 istop = png_ptr->num_palette; - int sr = 8 - png_ptr->sig_bit.red; - int sg = 8 - png_ptr->sig_bit.green; - int sb = 8 - png_ptr->sig_bit.blue; - - if (sr < 0 || sr > 8) - sr = 0; - if (sg < 0 || sg > 8) - sg = 0; - if (sb < 0 || sb > 8) - sb = 0; - for (i = 0; i < istop; i++) + int i; + int istop = png_ptr->num_palette; + int shift = 8 - png_ptr->sig_bit.red; + + png_ptr->transformations &= ~PNG_SHIFT; + + /* significant bits can be in the range 1 to 7 for a meaninful result, if + * the number of significant bits is 0 then no shift is done (this is an + * error condition which is silently ignored.) + */ + if (shift > 0 && shift < 8) for (i=0; i<istop; ++i) { - png_ptr->palette[i].red >>= sr; - png_ptr->palette[i].green >>= sg; - png_ptr->palette[i].blue >>= sb; + int component = png_ptr->palette[i].red; + + component >>= shift; + png_ptr->palette[i].red = (png_byte)component; + } + + shift = 8 - png_ptr->sig_bit.green; + if (shift > 0 && shift < 8) for (i=0; i<istop; ++i) + { + int component = png_ptr->palette[i].green; + + component >>= shift; + png_ptr->palette[i].green = (png_byte)component; + } + + shift = 8 - png_ptr->sig_bit.blue; + if (shift > 0 && shift < 8) for (i=0; i<istop; ++i) + { + int component = png_ptr->palette[i].blue; + + component >>= shift; + png_ptr->palette[i].blue = (png_byte)component; } } #endif /* PNG_READ_SHIFT_SUPPORTED */ - } -#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ - && !defined(PNG_READ_BACKGROUND_SUPPORTED) - if(png_ptr) - return; -#endif } /* Modify the info structure to reflect the transformations. The @@ -1116,18 +1913,25 @@ png_init_read_transformations(png_structp png_ptr) * assuming the transformations result in valid PNG data. */ void /* PRIVATE */ -png_read_transform_info(png_structp png_ptr, png_infop info_ptr) +png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) { - png_debug(1, "in png_read_transform_info\n"); -#if defined(PNG_READ_EXPAND_SUPPORTED) + png_debug(1, "in png_read_transform_info"); + +#ifdef PNG_READ_EXPAND_SUPPORTED if (png_ptr->transformations & PNG_EXPAND) { if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) + /* This check must match what actually happens in + * png_do_expand_palette; if it ever checks the tRNS chunk to see if + * it is all opaque we must do the same (at present it does not.) + */ + if (png_ptr->num_trans > 0) info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; + else info_ptr->color_type = PNG_COLOR_TYPE_RGB; + info_ptr->bit_depth = 8; info_ptr->num_trans = 0; } @@ -1136,118 +1940,174 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) if (png_ptr->num_trans) { if (png_ptr->transformations & PNG_EXPAND_tRNS) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; - else - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; } if (info_ptr->bit_depth < 8) info_ptr->bit_depth = 8; + info_ptr->num_trans = 0; } } #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; - info_ptr->num_trans = 0; +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) + /* The following is almost certainly wrong unless the background value is in + * the screen space! + */ + if (png_ptr->transformations & PNG_COMPOSE) info_ptr->background = png_ptr->background; - } #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = png_ptr->gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = png_ptr->int_gamma; -#endif - } +#ifdef PNG_READ_GAMMA_SUPPORTED + /* The following used to be conditional on PNG_GAMMA (prior to 1.5.4), + * however it seems that the code in png_init_read_transformations, which has + * been called before this from png_read_update_info->png_read_start_row + * sometimes does the gamma transform and cancels the flag. + * + * TODO: this looks wrong; the info_ptr should end up with a gamma equal to + * the screen_gamma value. The following probably results in weirdness if + * the info_ptr is used by the app after the rows have been read. + */ + info_ptr->colorspace.gamma = png_ptr->colorspace.gamma; #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) - info_ptr->bit_depth = 8; -#endif + if (info_ptr->bit_depth == 16) + { +# ifdef PNG_READ_16BIT_SUPPORTED +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + if (png_ptr->transformations & PNG_SCALE_16_TO_8) + info_ptr->bit_depth = 8; +# endif + +# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + if (png_ptr->transformations & PNG_16_TO_8) + info_ptr->bit_depth = 8; +# endif -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +# else + /* No 16 bit support: force chopping 16-bit input down to 8, in this case + * the app program can chose if both APIs are available by setting the + * correct scaling to use. + */ +# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + /* For compatibility with previous versions use the strip method by + * default. This code works because if PNG_SCALE_16_TO_8 is already + * set the code below will do that in preference to the chop. + */ + png_ptr->transformations |= PNG_16_TO_8; + info_ptr->bit_depth = 8; +# else + +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_ptr->transformations |= PNG_SCALE_16_TO_8; + info_ptr->bit_depth = 8; +# else + + CONFIGURATION ERROR: you must enable at least one 16 to 8 method +# endif +# endif +#endif /* !READ_16BIT_SUPPORTED */ + } + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED if (png_ptr->transformations & PNG_GRAY_TO_RGB) - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; + info_ptr->color_type = (png_byte)(info_ptr->color_type | + PNG_COLOR_MASK_COLOR); #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED if (png_ptr->transformations & PNG_RGB_TO_GRAY) - info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; + info_ptr->color_type = (png_byte)(info_ptr->color_type & + ~PNG_COLOR_MASK_COLOR); #endif -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) +#ifdef PNG_READ_QUANTIZE_SUPPORTED + if (png_ptr->transformations & PNG_QUANTIZE) { if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && - png_ptr->palette_lookup && info_ptr->bit_depth == 8) + (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && + png_ptr->palette_lookup && info_ptr->bit_depth == 8) { info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; } } #endif -#if defined(PNG_READ_PACK_SUPPORTED) +#ifdef PNG_READ_EXPAND_16_SUPPORTED + if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 && + info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) + { + info_ptr->bit_depth = 16; + } +#endif + +#ifdef PNG_READ_PACK_SUPPORTED if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) info_ptr->bit_depth = 8; #endif if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) info_ptr->channels = 1; + else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) info_ptr->channels = 3; + else info_ptr->channels = 1; -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + if (png_ptr->transformations & PNG_STRIP_ALPHA) + { + info_ptr->color_type = (png_byte)(info_ptr->color_type & + ~PNG_COLOR_MASK_ALPHA); + info_ptr->num_trans = 0; + } #endif if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) info_ptr->channels++; -#if defined(PNG_READ_FILLER_SUPPORTED) +#ifdef PNG_READ_FILLER_SUPPORTED /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ if ((png_ptr->transformations & PNG_FILLER) && ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) { info_ptr->channels++; - /* if adding a true alpha channel not just filler */ -#if !defined(PNG_1_0_X) + /* If adding a true alpha channel not just filler */ if (png_ptr->transformations & PNG_ADD_ALPHA) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; -#endif + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; } #endif #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(info_ptr->bit_depth < png_ptr->user_transform_depth) + if (png_ptr->transformations & PNG_USER_TRANSFORM) + { + if (info_ptr->bit_depth < png_ptr->user_transform_depth) info_ptr->bit_depth = png_ptr->user_transform_depth; - if(info_ptr->channels < png_ptr->user_transform_channels) + + if (info_ptr->channels < png_ptr->user_transform_channels) info_ptr->channels = png_ptr->user_transform_channels; - } + } #endif info_ptr->pixel_depth = (png_byte)(info_ptr->channels * - info_ptr->bit_depth); + info_ptr->bit_depth); - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width); + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width); -#if !defined(PNG_READ_EXPAND_SUPPORTED) - if(png_ptr) + /* Adding in 1.5.4: cache the above value in png_struct so that we can later + * check in png_rowbytes that the user buffer won't get overwritten. Note + * that the field is not always set - if png_read_update_info isn't called + * the application has to either not do any transforms or get the calculation + * right itself. + */ + png_ptr->info_rowbytes = info_ptr->rowbytes; + +#ifndef PNG_READ_EXPAND_SUPPORTED + if (png_ptr) return; #endif } @@ -1257,245 +2117,299 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED) * decide how it fits in with the other transformations here. */ void /* PRIVATE */ -png_do_read_transformations(png_structp png_ptr) +png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) { - png_debug(1, "in png_do_read_transformations\n"); + png_debug(1, "in png_do_read_transformations"); + if (png_ptr->row_buf == NULL) { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - - png_snprintf2(msg, 50, - "NULL row buffer for row %ld, pass %d", png_ptr->row_number, - png_ptr->pass); - png_error(png_ptr, msg); -#else + /* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this + * error is incredibly rare and incredibly easy to debug without this + * information. + */ png_error(png_ptr, "NULL row buffer"); -#endif } -#ifdef PNG_WARN_UNINITIALIZED_ROW - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - /* Application has failed to call either png_read_start_image() - * or png_read_update_info() after setting transforms that expand - * pixels. This check added to libpng-1.2.19 */ -#if (PNG_WARN_UNINITIALIZED_ROW==1) + + /* The following is debugging; prior to 1.5.4 the code was never compiled in; + * in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro + * PNG_WARN_UNINITIALIZED_ROW removed. In 1.6 the new flag is set only for + * all transformations, however in practice the ROW_INIT always gets done on + * demand, if necessary. + */ + if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 && + !(png_ptr->flags & PNG_FLAG_ROW_INIT)) + { + /* Application has failed to call either png_read_start_image() or + * png_read_update_info() after setting transforms that expand pixels. + * This check added to libpng-1.2.19 (but not enabled until 1.5.4). + */ png_error(png_ptr, "Uninitialized row"); -#else - png_warning(png_ptr, "Uninitialized row"); -#endif -#endif + } -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED if (png_ptr->transformations & PNG_EXPAND) { - if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) + if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) { - png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette, png_ptr->trans, png_ptr->num_trans); + png_do_expand_palette(row_info, png_ptr->row_buf + 1, + png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans); } + else { if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values)); + png_do_expand(row_info, png_ptr->row_buf + 1, + &(png_ptr->trans_color)); + else - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - NULL); + png_do_expand(row_info, png_ptr->row_buf + 1, + NULL); } } #endif -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)); +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_STRIP_ALPHA) && + !(png_ptr->transformations & PNG_COMPOSE) && + (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) + png_do_strip_channel(row_info, png_ptr->row_buf + 1, + 0 /* at_start == false, because SWAP_ALPHA happens later */); #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED if (png_ptr->transformations & PNG_RGB_TO_GRAY) { int rgb_error = - png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); - if(rgb_error) + png_do_rgb_to_gray(png_ptr, row_info, + png_ptr->row_buf + 1); + + if (rgb_error) { png_ptr->rgb_to_gray_status=1; - if((png_ptr->transformations & PNG_RGB_TO_GRAY) == + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == PNG_RGB_TO_GRAY_WARN) png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - if((png_ptr->transformations & PNG_RGB_TO_GRAY) == + + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == PNG_RGB_TO_GRAY_ERR) png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); } } #endif -/* -From Andreas Dilger e-mail to png-implement, 26 March 1998: - - In most cases, the "simple transparency" should be done prior to doing - gray-to-RGB, or you will have to test 3x as many bytes to check if a - pixel is transparent. You would also need to make sure that the - transparency information is upgraded to RGB. - - To summarize, the current flow is: - - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - with background "in place" if transparent, - convert to RGB if necessary - - Gray + alpha -> composite with gray background and remove alpha bytes, - convert to RGB if necessary - - To support RGB backgrounds for gray images we need: - - Gray + simple transparency -> convert to RGB + simple transparency, compare - 3 or 6 bytes and composite with background - "in place" if transparent (3x compare/pixel - compared to doing composite with gray bkgrnd) - - Gray + alpha -> convert to RGB + alpha, composite with background and - remove alpha bytes (3x float operations/pixel - compared with composite on gray background) - - Greg's change will do this. The reason it wasn't done before is for - performance, as this increases the per-pixel operations. If we would check - in advance if the background was gray or RGB, and position the gray-to-RGB - transform appropriately, then it would save a lot of work/time. +/* From Andreas Dilger e-mail to png-implement, 26 March 1998: + * + * In most cases, the "simple transparency" should be done prior to doing + * gray-to-RGB, or you will have to test 3x as many bytes to check if a + * pixel is transparent. You would also need to make sure that the + * transparency information is upgraded to RGB. + * + * To summarize, the current flow is: + * - Gray + simple transparency -> compare 1 or 2 gray bytes and composite + * with background "in place" if transparent, + * convert to RGB if necessary + * - Gray + alpha -> composite with gray background and remove alpha bytes, + * convert to RGB if necessary + * + * To support RGB backgrounds for gray images we need: + * - Gray + simple transparency -> convert to RGB + simple transparency, + * compare 3 or 6 bytes and composite with + * background "in place" if transparent + * (3x compare/pixel compared to doing + * composite with gray bkgrnd) + * - Gray + alpha -> convert to RGB + alpha, composite with background and + * remove alpha bytes (3x float + * operations/pixel compared with composite + * on gray background) + * + * Greg's change will do this. The reason it wasn't done before is for + * performance, as this increases the per-pixel operations. If we would check + * in advance if the background was gray or RGB, and position the gray-to-RGB + * transform appropriately, then it would save a lot of work/time. */ -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons */ +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + /* If gray -> RGB, do so now only if background is non-gray; else do later + * for performance reasons + */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if ((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0 ) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) - png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values), &(png_ptr->background) -#if defined(PNG_READ_GAMMA_SUPPORTED) - , &(png_ptr->background_1), - png_ptr->gamma_table, png_ptr->gamma_from_1, - png_ptr->gamma_to_1, png_ptr->gamma_16_table, - png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, - png_ptr->gamma_shift -#endif -); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) + if (png_ptr->transformations & PNG_COMPOSE) + png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr); #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if ((png_ptr->transformations & PNG_GAMMA) && -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - !((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + /* Because RGB_TO_GRAY does the gamma transform. */ + !(png_ptr->transformations & PNG_RGB_TO_GRAY) && #endif - (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) - png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->gamma_table, png_ptr->gamma_16_table, - png_ptr->gamma_shift); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) + /* Because PNG_COMPOSE does the gamma transform if there is something to + * do (if there is an alpha channel or transparency.) + */ + !((png_ptr->transformations & PNG_COMPOSE) && + ((png_ptr->num_trans != 0) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && +#endif + /* Because png_init_read_transformations transforms the palette, unless + * RGB_TO_GRAY will do the transform. + */ + (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) + png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr); #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + if ((png_ptr->transformations & PNG_STRIP_ALPHA) && + (png_ptr->transformations & PNG_COMPOSE) && + (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || + row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) + png_do_strip_channel(row_info, png_ptr->row_buf + 1, + 0 /* at_start == false, because SWAP_ALPHA happens later */); +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + if ((png_ptr->transformations & PNG_ENCODE_ALPHA) && + (row_info->color_type & PNG_COLOR_MASK_ALPHA)) + png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr); +#endif + +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + if (png_ptr->transformations & PNG_SCALE_16_TO_8) + png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + /* There is no harm in doing both of these because only one has any effect, + * by putting the 'scale' option first if the app asks for scale (either by + * calling the API or in a TRANSFORM flag) this is what happens. + */ if (png_ptr->transformations & PNG_16_TO_8) - png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_chop(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) +#ifdef PNG_READ_QUANTIZE_SUPPORTED + if (png_ptr->transformations & PNG_QUANTIZE) { - png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette_lookup, png_ptr->dither_index); - if(png_ptr->row_info.rowbytes == (png_uint_32)0) - png_error(png_ptr, "png_do_dither returned rowbytes=0"); + png_do_quantize(row_info, png_ptr->row_buf + 1, + png_ptr->palette_lookup, png_ptr->quantize_index); + + if (row_info->rowbytes == 0) + png_error(png_ptr, "png_do_quantize returned rowbytes=0"); } +#endif /* PNG_READ_QUANTIZE_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_16_SUPPORTED + /* Do the expansion now, after all the arithmetic has been done. Notice + * that previous transformations can handle the PNG_EXPAND_16 flag if this + * is efficient (particularly true in the case of gamma correction, where + * better accuracy results faster!) + */ + if (png_ptr->transformations & PNG_EXPAND_16) + png_do_expand_16(row_info, png_ptr->row_buf + 1); +#endif + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + /* NOTE: moved here in 1.5.4 (from much later in this list.) */ + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && + (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) + png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_INVERT_SUPPORTED) +#ifdef PNG_READ_INVERT_SUPPORTED if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_invert(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_SHIFT_SUPPORTED) +#ifdef PNG_READ_SHIFT_SUPPORTED if (png_ptr->transformations & PNG_SHIFT) - png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); + png_do_unshift(row_info, png_ptr->row_buf + 1, + &(png_ptr->shift)); #endif -#if defined(PNG_READ_PACK_SUPPORTED) +#ifdef PNG_READ_PACK_SUPPORTED if (png_ptr->transformations & PNG_PACK) - png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_unpack(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); +#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Added at libpng-1.5.10 */ + if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && + png_ptr->num_palette_max >= 0) + png_do_check_palette_indexes(png_ptr, row_info); #endif -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); +#ifdef PNG_READ_BGR_SUPPORTED + if (png_ptr->transformations & PNG_BGR) + png_do_bgr(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if we did not do so above */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); +#ifdef PNG_READ_PACKSWAP_SUPPORTED + if (png_ptr->transformations & PNG_PACKSWAP) + png_do_packswap(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_FILLER_SUPPORTED) +#ifdef PNG_READ_FILLER_SUPPORTED if (png_ptr->transformations & PNG_FILLER) - png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->filler, png_ptr->flags); + png_do_read_filler(row_info, png_ptr->row_buf + 1, + (png_uint_32)png_ptr->filler, png_ptr->flags); #endif -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_SWAP_SUPPORTED) +#ifdef PNG_READ_16BIT_SUPPORTED +#ifdef PNG_READ_SWAP_SUPPORTED if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_swap(row_info, png_ptr->row_buf + 1); +#endif #endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED if (png_ptr->transformations & PNG_USER_TRANSFORM) { - if(png_ptr->read_user_transform_fn != NULL) - (*(png_ptr->read_user_transform_fn)) /* user read transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->user_transform_depth) - png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; - if(png_ptr->user_transform_channels) - png_ptr->row_info.channels = png_ptr->user_transform_channels; + if (png_ptr->read_user_transform_fn != NULL) + (*(png_ptr->read_user_transform_fn)) /* User read transform function */ + (png_ptr, /* png_ptr */ + row_info, /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_size_t rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED + if (png_ptr->user_transform_depth) + row_info->bit_depth = png_ptr->user_transform_depth; + + if (png_ptr->user_transform_channels) + row_info->channels = png_ptr->user_transform_channels; #endif - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); + row_info->pixel_depth = (png_byte)(row_info->bit_depth * + row_info->channels); + + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width); } #endif - } -#if defined(PNG_READ_PACK_SUPPORTED) +#ifdef PNG_READ_PACK_SUPPORTED /* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, * without changing the actual values. Thus, if you had a row with * a bit depth of 1, you would end up with bytes that only contained @@ -1505,12 +2419,9 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998: void /* PRIVATE */ png_do_unpack(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_unpack\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth < 8) -#else + png_debug(1, "in png_do_unpack"); + if (row_info->bit_depth < 8) -#endif { png_uint_32 i; png_uint_32 row_width=row_info->width; @@ -1525,11 +2436,13 @@ png_do_unpack(png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x01); + if (shift == 7) { shift = 0; sp--; } + else shift++; @@ -1537,6 +2450,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } break; } + case 2: { @@ -1546,11 +2460,13 @@ png_do_unpack(png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x03); + if (shift == 6) { shift = 0; sp--; } + else shift += 2; @@ -1558,6 +2474,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } break; } + case 4: { png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); @@ -1566,11 +2483,13 @@ png_do_unpack(png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x0f); + if (shift == 4) { shift = 0; sp--; } + else shift = 4; @@ -1578,6 +2497,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } break; } + + default: + break; } row_info->bit_depth = 8; row_info->pixel_depth = (png_byte)(8 * row_info->channels); @@ -1586,164 +2508,229 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } #endif -#if defined(PNG_READ_SHIFT_SUPPORTED) +#ifdef PNG_READ_SHIFT_SUPPORTED /* Reverse the effects of png_do_shift. This routine merely shifts the * pixels back to their significant bits values. Thus, if you have * a row of bit depth 8, but only 5 are significant, this will shift * the values back to 0 through 31. */ void /* PRIVATE */ -png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) +png_do_unshift(png_row_infop row_info, png_bytep row, + png_const_color_8p sig_bits) { - png_debug(1, "in png_do_unshift\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && sig_bits != NULL && -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) + int color_type; + + png_debug(1, "in png_do_unshift"); + + /* The palette case has already been handled in the _init routine. */ + color_type = row_info->color_type; + + if (color_type != PNG_COLOR_TYPE_PALETTE) { int shift[4]; int channels = 0; - int c; - png_uint_16 value = 0; - png_uint_32 row_width = row_info->width; + int bit_depth = row_info->bit_depth; - if (row_info->color_type & PNG_COLOR_MASK_COLOR) + if (color_type & PNG_COLOR_MASK_COLOR) { - shift[channels++] = row_info->bit_depth - sig_bits->red; - shift[channels++] = row_info->bit_depth - sig_bits->green; - shift[channels++] = row_info->bit_depth - sig_bits->blue; + shift[channels++] = bit_depth - sig_bits->red; + shift[channels++] = bit_depth - sig_bits->green; + shift[channels++] = bit_depth - sig_bits->blue; } + else { - shift[channels++] = row_info->bit_depth - sig_bits->gray; + shift[channels++] = bit_depth - sig_bits->gray; } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) + + if (color_type & PNG_COLOR_MASK_ALPHA) { - shift[channels++] = row_info->bit_depth - sig_bits->alpha; + shift[channels++] = bit_depth - sig_bits->alpha; } - for (c = 0; c < channels; c++) { - if (shift[c] <= 0) - shift[c] = 0; - else - value = 1; - } + int c, have_shift; - if (!value) - return; + for (c = have_shift = 0; c < channels; ++c) + { + /* A shift of more than the bit depth is an error condition but it + * gets ignored here. + */ + if (shift[c] <= 0 || shift[c] >= bit_depth) + shift[c] = 0; - switch (row_info->bit_depth) + else + have_shift = 1; + } + + if (!have_shift) + return; + } + + switch (bit_depth) { + default: + /* Must be 1bpp gray: should not be here! */ + /* NOTREACHED */ + break; + case 2: + /* Must be 2bpp gray */ + /* assert(channels == 1 && shift[0] == 1) */ { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; + png_bytep bp = row; + png_bytep bp_end = bp + row_info->rowbytes; - for (bp = row, i = 0; i < istop; i++) + while (bp < bp_end) { - *bp >>= 1; - *bp++ &= 0x55; + int b = (*bp >> 1) & 0x55; + *bp++ = (png_byte)b; } break; } + case 4: + /* Must be 4bpp gray */ + /* assert(channels == 1) */ { png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | - (png_byte)((int)0xf >> shift[0])); + png_bytep bp_end = bp + row_info->rowbytes; + int gray_shift = shift[0]; + int mask = 0xf >> gray_shift; + + mask |= mask << 4; - for (i = 0; i < istop; i++) + while (bp < bp_end) { - *bp >>= shift[0]; - *bp++ &= mask; + int b = (*bp >> gray_shift) & mask; + *bp++ = (png_byte)b; } break; } + case 8: + /* Single byte components, G, GA, RGB, RGBA */ { png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_width * channels; + png_bytep bp_end = bp + row_info->rowbytes; + int channel = 0; - for (i = 0; i < istop; i++) + while (bp < bp_end) { - *bp++ >>= shift[i%channels]; + int b = *bp >> shift[channel]; + if (++channel >= channels) + channel = 0; + *bp++ = (png_byte)b; } break; } + +#ifdef PNG_READ_16BIT_SUPPORTED case 16: + /* Double byte components, G, GA, RGB, RGBA */ { png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_width; + png_bytep bp_end = bp + row_info->rowbytes; + int channel = 0; - for (i = 0; i < istop; i++) + while (bp < bp_end) { - value = (png_uint_16)((*bp << 8) + *(bp + 1)); - value >>= shift[i%channels]; + int value = (bp[0] << 8) + bp[1]; + + value >>= shift[channel]; + if (++channel >= channels) + channel = 0; *bp++ = (png_byte)(value >> 8); *bp++ = (png_byte)(value & 0xff); } break; } +#endif } } } #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* chop rows of bit depth 16 down to 8 */ +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED +/* Scale rows of bit depth 16 down to 8 accurately */ void /* PRIVATE */ -png_do_chop(png_row_infop row_info, png_bytep row) +png_do_scale_16_to_8(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_chop\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth == 16) -#else + png_debug(1, "in png_do_scale_16_to_8"); + if (row_info->bit_depth == 16) -#endif { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - png_uint_32 istop = row_info->width * row_info->channels; + png_bytep sp = row; /* source */ + png_bytep dp = row; /* destination */ + png_bytep ep = sp + row_info->rowbytes; /* end+1 */ - for (i = 0; i<istop; i++, sp += 2, dp++) + while (sp < ep) { -#if defined(PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED) - /* This does a more accurate scaling of the 16-bit color - * value, rather than a simple low-byte truncation. - * - * What the ideal calculation should be: - * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) * 255 + 127) / (png_uint_32)65535L; - * - * GRR: no, I think this is what it really should be: - * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) + 128L) / (png_uint_32)257L; - * - * GRR: here's the exact calculation with shifts: - * temp = (((png_uint_32)(*sp) << 8) | (png_uint_32)(*(sp + 1))) + 128L; - * *dp = (temp - (temp >> 8)) >> 8; - * - * Approximate calculation with shift/add instead of multiply/divide: - * *dp = ((((png_uint_32)(*sp) << 8) | - * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; - * - * What we actually do to avoid extra shifting and conversion: - */ + /* The input is an array of 16 bit components, these must be scaled to + * 8 bits each. For a 16 bit value V the required value (from the PNG + * specification) is: + * + * (V * 255) / 65535 + * + * This reduces to round(V / 257), or floor((V + 128.5)/257) + * + * Represent V as the two byte value vhi.vlo. Make a guess that the + * result is the top byte of V, vhi, then the correction to this value + * is: + * + * error = floor(((V-vhi.vhi) + 128.5) / 257) + * = floor(((vlo-vhi) + 128.5) / 257) + * + * This can be approximated using integer arithmetic (and a signed + * shift): + * + * error = (vlo-vhi+128) >> 8; + * + * The approximate differs from the exact answer only when (vlo-vhi) is + * 128; it then gives a correction of +1 when the exact correction is + * 0. This gives 128 errors. The exact answer (correct for all 16 bit + * input values) is: + * + * error = (vlo-vhi+128)*65535 >> 24; + * + * An alternative arithmetic calculation which also gives no errors is: + * + * (V * 255 + 32895) >> 16 + */ + + png_int_32 tmp = *sp++; /* must be signed! */ + tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24; + *dp++ = (png_byte)tmp; + } - *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); -#else - /* Simply discard the low order byte */ - *dp = *sp; + row_info->bit_depth = 8; + row_info->pixel_depth = (png_byte)(8 * row_info->channels); + row_info->rowbytes = row_info->width * row_info->channels; + } +} #endif + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED +void /* PRIVATE */ +/* Simply discard the low byte. This was the default behavior prior + * to libpng-1.5.4. + */ +png_do_chop(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_chop"); + + if (row_info->bit_depth == 16) + { + png_bytep sp = row; /* source */ + png_bytep dp = row; /* destination */ + png_bytep ep = sp + row_info->rowbytes; /* end+1 */ + + while (sp < ep) + { + *dp++ = *sp; + sp += 2; /* skip low byte */ } + row_info->bit_depth = 8; row_info->pixel_depth = (png_byte)(8 * row_info->channels); row_info->rowbytes = row_info->width * row_info->channels; @@ -1751,14 +2738,12 @@ png_do_chop(png_row_infop row_info, png_bytep row) } #endif -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED void /* PRIVATE */ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif + png_debug(1, "in png_do_read_swap_alpha"); + { png_uint_32 row_width = row_info->width; if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) @@ -1780,6 +2765,8 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) *(--dp) = save; } } + +#ifdef PNG_READ_16BIT_SUPPORTED /* This converts from RRGGBBAA to AARRGGBB */ else { @@ -1802,7 +2789,9 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) *(--dp) = save[1]; } } +#endif } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { /* This converts from GA to AG */ @@ -1820,6 +2809,8 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) *(--dp) = save; } } + +#ifdef PNG_READ_16BIT_SUPPORTED /* This converts from GGAA to AAGG */ else { @@ -1838,133 +2829,137 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) *(--dp) = save[1]; } } +#endif } } } #endif -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED void /* PRIVATE */ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif + png_uint_32 row_width; + png_debug(1, "in png_do_read_invert_alpha"); + + row_width = row_info->width; + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + if (row_info->bit_depth == 8) { /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: */ - sp-=3; - dp=sp; - } + sp-=3; + dp=sp; } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; + } - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); +#ifdef PNG_READ_16BIT_SUPPORTED + /* This inverts the alpha channel in RRGGBBAA */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); + +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: */ - sp-=6; - dp=sp; - } + sp-=6; + dp=sp; } } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) +#endif + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (row_info->bit_depth == 8) { /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = *(--sp); - } + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = *(--sp); } + } + +#ifdef PNG_READ_16BIT_SUPPORTED + else + { /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); /* - *(--dp) = *(--sp); - *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); */ - sp-=2; - dp=sp; - } + sp-=2; + dp=sp; } } +#endif } } #endif -#if defined(PNG_READ_FILLER_SUPPORTED) +#ifdef PNG_READ_FILLER_SUPPORTED /* Add filler channel if we have RGB color */ void /* PRIVATE */ png_do_read_filler(png_row_infop row_info, png_bytep row, - png_uint_32 filler, png_uint_32 flags) + png_uint_32 filler, png_uint_32 flags) { png_uint_32 i; png_uint_32 row_width = row_info->width; +#ifdef PNG_READ_16BIT_SUPPORTED png_byte hi_filler = (png_byte)((filler>>8) & 0xff); +#endif png_byte lo_filler = (png_byte)(filler & 0xff); - png_debug(1, "in png_do_read_filler\n"); + png_debug(1, "in png_do_read_filler"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif row_info->color_type == PNG_COLOR_TYPE_GRAY) { - if(row_info->bit_depth == 8) + if (row_info->bit_depth == 8) { - /* This changes the data from G to GX */ if (flags & PNG_FLAG_FILLER_AFTER) { + /* This changes the data from G to GX */ png_bytep sp = row + (png_size_t)row_width; png_bytep dp = sp + (png_size_t)row_width; for (i = 1; i < row_width; i++) @@ -1977,9 +2972,10 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->pixel_depth = 16; row_info->rowbytes = row_width * 2; } - /* This changes the data from G to XG */ + else { + /* This changes the data from G to XG */ png_bytep sp = row + (png_size_t)row_width; png_bytep dp = sp + (png_size_t)row_width; for (i = 0; i < row_width; i++) @@ -1992,11 +2988,13 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->rowbytes = row_width * 2; } } - else if(row_info->bit_depth == 16) + +#ifdef PNG_READ_16BIT_SUPPORTED + else if (row_info->bit_depth == 16) { - /* This changes the data from GG to GGXX */ if (flags & PNG_FLAG_FILLER_AFTER) { + /* This changes the data from GG to GGXX */ png_bytep sp = row + (png_size_t)row_width * 2; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 1; i < row_width; i++) @@ -2012,9 +3010,10 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } - /* This changes the data from GG to XXGG */ + else { + /* This changes the data from GG to XXGG */ png_bytep sp = row + (png_size_t)row_width * 2; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) @@ -2029,14 +3028,15 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->rowbytes = row_width * 4; } } +#endif } /* COLOR_TYPE == GRAY */ else if (row_info->color_type == PNG_COLOR_TYPE_RGB) { - if(row_info->bit_depth == 8) + if (row_info->bit_depth == 8) { - /* This changes the data from RGB to RGBX */ if (flags & PNG_FLAG_FILLER_AFTER) { + /* This changes the data from RGB to RGBX */ png_bytep sp = row + (png_size_t)row_width * 3; png_bytep dp = sp + (png_size_t)row_width; for (i = 1; i < row_width; i++) @@ -2051,9 +3051,10 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } - /* This changes the data from RGB to XRGB */ + else { + /* This changes the data from RGB to XRGB */ png_bytep sp = row + (png_size_t)row_width * 3; png_bytep dp = sp + (png_size_t)row_width; for (i = 0; i < row_width; i++) @@ -2068,11 +3069,13 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->rowbytes = row_width * 4; } } - else if(row_info->bit_depth == 16) + +#ifdef PNG_READ_16BIT_SUPPORTED + else if (row_info->bit_depth == 16) { - /* This changes the data from RRGGBB to RRGGBBXX */ if (flags & PNG_FLAG_FILLER_AFTER) { + /* This changes the data from RRGGBB to RRGGBBXX */ png_bytep sp = row + (png_size_t)row_width * 6; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 1; i < row_width; i++) @@ -2092,9 +3095,10 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->pixel_depth = 64; row_info->rowbytes = row_width * 8; } - /* This changes the data from RRGGBB to XXRRGGBB */ + else { + /* This changes the data from RRGGBB to XXRRGGBB */ png_bytep sp = row + (png_size_t)row_width * 6; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) @@ -2108,34 +3112,35 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, *(--dp) = hi_filler; *(--dp) = lo_filler; } + row_info->channels = 4; row_info->pixel_depth = 64; row_info->rowbytes = row_width * 8; } } +#endif } /* COLOR_TYPE == RGB */ } #endif -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* expand grayscale files to RGB, with or without alpha */ +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +/* Expand grayscale files to RGB, with or without alpha */ void /* PRIVATE */ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) { png_uint_32 i; png_uint_32 row_width = row_info->width; - png_debug(1, "in png_do_gray_to_rgb\n"); + png_debug(1, "in png_do_gray_to_rgb"); + if (row_info->bit_depth >= 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - !(row_info->color_type & PNG_COLOR_MASK_COLOR)) + !(row_info->color_type & PNG_COLOR_MASK_COLOR)) { if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { if (row_info->bit_depth == 8) { + /* This changes G to RGB */ png_bytep sp = row + (png_size_t)row_width - 1; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) @@ -2145,8 +3150,10 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) *(dp--) = *(sp--); } } + else { + /* This changes GG to RRGGBB */ png_bytep sp = row + (png_size_t)row_width * 2 - 1; png_bytep dp = sp + (png_size_t)row_width * 4; for (i = 0; i < row_width; i++) @@ -2160,10 +3167,12 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) } } } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { if (row_info->bit_depth == 8) { + /* This changes GA to RGBA */ png_bytep sp = row + (png_size_t)row_width * 2 - 1; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) @@ -2174,8 +3183,10 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) *(dp--) = *(sp--); } } + else { + /* This changes GGAA to RRGGBBAA */ png_bytep sp = row + (png_size_t)row_width * 4 - 1; png_bytep dp = sp + (png_size_t)row_width * 4; for (i = 0; i < row_width; i++) @@ -2191,273 +3202,269 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) } } } - row_info->channels += (png_byte)2; + row_info->channels = (png_byte)(row_info->channels + 2); row_info->color_type |= PNG_COLOR_MASK_COLOR; row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } } #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* reduce RGB files to grayscale, with or without alpha - * using the equation given in Poynton's ColorFAQ at - * <http://www.inforamp.net/~poynton/> - * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +/* Reduce RGB files to grayscale, with or without alpha + * using the equation given in Poynton's ColorFAQ of 1998-01-04 at + * <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008 but + * versions dated 1998 through November 2002 have been archived at + * http://web.archive.org/web/20000816232553/http://www.inforamp.net/ + * ~poynton/notes/colour_and_gamma/ColorFAQ.txt ) + * Charles Poynton poynton at poynton.com * * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B * - * We approximate this with + * which can be expressed with integers as + * + * Y = (6969 * R + 23434 * G + 2365 * B)/32768 + * + * Poynton's current link (as of January 2003 through July 2011): + * <http://www.poynton.com/notes/colour_and_gamma/> + * has changed the numbers slightly: * - * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B + * Y = 0.2126*R + 0.7152*G + 0.0722*B * * which can be expressed with integers as * - * Y = (6969 * R + 23434 * G + 2365 * B)/32768 + * Y = (6966 * R + 23436 * G + 2366 * B)/32768 + * + * Historically, however, libpng uses numbers derived from the ITU-R Rec 709 + * end point chromaticities and the D65 white point. Depending on the + * precision used for the D65 white point this produces a variety of different + * numbers, however if the four decimal place value used in ITU-R Rec 709 is + * used (0.3127,0.3290) the Y calculation would be: + * + * Y = (6968 * R + 23435 * G + 2366 * B)/32768 + * + * While this is correct the rounding results in an overflow for white, because + * the sum of the rounded coefficients is 32769, not 32768. Consequently + * libpng uses, instead, the closest non-overflowing approximation: * - * The calculation is to be done in a linear colorspace. + * Y = (6968 * R + 23434 * G + 2366 * B)/32768 * - * Other integer coefficents can be used via png_set_rgb_to_gray(). + * Starting with libpng-1.5.5, if the image being converted has a cHRM chunk + * (including an sRGB chunk) then the chromaticities are used to calculate the + * coefficients. See the chunk handling in pngrutil.c for more information. + * + * In all cases the calculation is to be done in a linear colorspace. If no + * gamma information is available to correct the encoding of the original RGB + * values this results in an implicit assumption that the original PNG RGB + * values were linear. + * + * Other integer coefficents can be used via png_set_rgb_to_gray(). Because + * the API takes just red and green coefficients the blue coefficient is + * calculated to make the sum 32768. This will result in different rounding + * to that used above. */ int /* PRIVATE */ -png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) +png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) { - png_uint_32 i; - - png_uint_32 row_width = row_info->width; int rgb_error = 0; - png_debug(1, "in png_do_rgb_to_gray\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) + png_debug(1, "in png_do_rgb_to_gray"); + + if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) && + (row_info->color_type & PNG_COLOR_MASK_COLOR)) { - png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; - png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; - png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; + PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; + PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; + PNG_CONST png_uint_32 bc = 32768 - rc - gc; + PNG_CONST png_uint_32 row_width = row_info->width; + PNG_CONST int have_alpha = + (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0; - if (row_info->color_type == PNG_COLOR_TYPE_RGB) + if (row_info->bit_depth == 8) { - if (row_info->bit_depth == 8) +#ifdef PNG_READ_GAMMA_SUPPORTED + /* Notice that gamma to/from 1 are not necessarily inverses (if + * there is an overall gamma correction). Prior to 1.5.5 this code + * checked the linearized values for equality; this doesn't match + * the documentation, the original values must be checked. + */ + if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1[ - (rc*red+gc*green+bc*blue)>>15]; - } - else - *(dp++) = *(sp-1); - } - } - else -#endif + for (i = 0; i < row_width; i++) { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); - } - else - *(dp++) = *(sp-1); - } - } - } + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); - else /* RGB bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) + if (red != green || red != blue) { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 - + bc*blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } + red = png_ptr->gamma_to_1[red]; + green = png_ptr->gamma_to_1[green]; + blue = png_ptr->gamma_to_1[blue]; - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); + rgb_error |= 1; + *(dp++) = png_ptr->gamma_from_1[ + (rc*red + gc*green + bc*blue + 16384)>>15]; } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + else + { + /* If there is no overall correction the table will not be + * set. + */ + if (png_ptr->gamma_table != NULL) + red = png_ptr->gamma_table[red]; - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); + *(dp++) = red; } + + if (have_alpha) + *(dp++) = *(sp++); } } - } - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1 - [(rc*red + gc*green + bc*blue)>>15]; - *(dp++) = *(sp++); /* alpha */ - } - } - else + else #endif + { + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + + for (i = 0; i < row_width; i++) { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); + + if (red != green || red != blue) { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = *(sp++); /* alpha */ + rgb_error |= 1; + /* NOTE: this is the historical approach which simply + * truncates the results. + */ + *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); } + + else + *(dp++) = red; + + if (have_alpha) + *(dp++) = *(sp++); } } - else /* RGBA bit_depth == 16 */ + } + + else /* RGB bit_depth == 16 */ + { +#ifdef PNG_READ_GAMMA_SUPPORTED + if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL) { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + + for (i = 0; i < row_width; i++) { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; + png_uint_16 red, green, blue, w; - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; + green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; + + if (red == green && red == blue) + { + if (png_ptr->gamma_16_table != NULL) + w = png_ptr->gamma_16_table[(red&0xff) + >> png_ptr->gamma_shift][red>>8]; - if(red == green && red == blue) - w = red; else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc * red_1 - + gc * green_1 + bc * blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } + w = red; + } + + else + { + png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) + >> png_ptr->gamma_shift][red>>8]; + png_uint_16 green_1 = + png_ptr->gamma_16_to_1[(green&0xff) >> + png_ptr->gamma_shift][green>>8]; + png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) + >> png_ptr->gamma_shift][blue>>8]; + png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 + + bc*blue_1 + 16384)>>15); + w = png_ptr->gamma_16_from_1[(gray16&0xff) >> + png_ptr->gamma_shift][gray16 >> 8]; + rgb_error |= 1; + } + + *(dp++) = (png_byte)((w>>8) & 0xff); + *(dp++) = (png_byte)(w & 0xff); - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - *(dp++) = *(sp++); /* alpha */ + if (have_alpha) + { + *(dp++) = *(sp++); *(dp++) = *(sp++); } } - else + } + else #endif + { + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + + for (i = 0; i < row_width; i++) { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) + png_uint_16 red, green, blue, gray16; + + red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; + green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; + + if (red != green || red != blue) + rgb_error |= 1; + + /* From 1.5.5 in the 16 bit case do the accurate conversion even + * in the 'fast' case - this is because this is where the code + * ends up when handling linear 16 bit data. + */ + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >> + 15); + *(dp++) = (png_byte)((gray16>>8) & 0xff); + *(dp++) = (png_byte)(gray16 & 0xff); + + if (have_alpha) { - png_uint_16 red, green, blue, gray16; - red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - *(dp++) = *(sp++); /* alpha */ + *(dp++) = *(sp++); *(dp++) = *(sp++); } } } } - row_info->channels -= (png_byte)2; - row_info->color_type &= ~PNG_COLOR_MASK_COLOR; + + row_info->channels = (png_byte)(row_info->channels - 2); + row_info->color_type = (png_byte)(row_info->color_type & + ~PNG_COLOR_MASK_COLOR); row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->bit_depth); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } return rgb_error; } #endif +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ +#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED /* Build a grayscale palette. Palette is assumed to be 1 << bit_depth * large of png_color. This lets grayscale images be treated as * paletted. Most useful for gamma correction and simplification - * of code. + * of code. This API is not used internally. */ void PNGAPI png_build_grayscale_palette(int bit_depth, png_colorp palette) @@ -2467,7 +3474,8 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette) int i; int v; - png_debug(1, "in png_do_build_grayscale_palette\n"); + png_debug(1, "in png_do_build_grayscale_palette"); + if (palette == NULL) return; @@ -2477,18 +3485,22 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette) num_palette = 2; color_inc = 0xff; break; + case 2: num_palette = 4; color_inc = 0x55; break; + case 4: num_palette = 16; color_inc = 0x11; break; + case 8: num_palette = 256; color_inc = 1; break; + default: num_palette = 0; color_inc = 0; @@ -2502,217 +3514,37 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette) palette[i].blue = (png_byte)v; } } - -/* This function is currently unused. Do we really need it? */ -#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) -void /* PRIVATE */ -png_correct_palette(png_structp png_ptr, png_colorp palette, - int num_palette) -{ - png_debug(1, "in png_correct_palette\n"); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) - { - png_color back, back_1; - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g; - - g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || - fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = png_ptr->background.red; - back.green = png_ptr->background.green; - back.blue = png_ptr->background.blue; - } - else - { - back.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - g = 1.0 / png_ptr->background_gamma; - - back_1.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back_1.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back_1.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_uint_32 i; - - for (i = 0; i < (png_uint_32)num_palette; i++) - { - if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - png_byte v, w; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - else - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (palette[i].red == (png_byte)png_ptr->trans_values.gray) - { - palette[i] = back; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - } - else -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else #endif -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_color back; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < (int)png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i].red = back.red; - palette[i].green = back.green; - palette[i].blue = back.blue; - } - else if (png_ptr->trans[i] != 0xff) - { - png_composite(palette[i].red, png_ptr->palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, png_ptr->palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, png_ptr->palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } - else /* assume grayscale palette (what else could it be?) */ - { - int i; - for (i = 0; i < num_palette; i++) - { - if (i == (png_byte)png_ptr->trans_values.gray) - { - palette[i].red = (png_byte)png_ptr->background.red; - palette[i].green = (png_byte)png_ptr->background.green; - palette[i].blue = (png_byte)png_ptr->background.blue; - } - } - } - } -#endif -} -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) /* Replace any alpha or transparency with the supplied background color. * "background" is already in the screen gamma, while "background_1" is * at a gamma of 1.0. Paletted files have already been taken care of. */ void /* PRIVATE */ -png_do_background(png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background -#if defined(PNG_READ_GAMMA_SUPPORTED) - , png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift -#endif - ) +png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) { - png_bytep sp, dp; +#ifdef PNG_READ_GAMMA_SUPPORTED + png_const_bytep gamma_table = png_ptr->gamma_table; + png_const_bytep gamma_from_1 = png_ptr->gamma_from_1; + png_const_bytep gamma_to_1 = png_ptr->gamma_to_1; + png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table; + png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1; + png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1; + int gamma_shift = png_ptr->gamma_shift; + int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0; +#endif + + png_bytep sp; png_uint_32 i; - png_uint_32 row_width=row_info->width; + png_uint_32 row_width = row_info->width; int shift; - png_debug(1, "in png_do_background\n"); - if (background != NULL && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || - (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) + png_debug(1, "in png_do_compose"); + { switch (row_info->color_type) { @@ -2727,24 +3559,28 @@ png_do_background(png_row_infop row_info, png_bytep row, for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x01) - == trans_values->gray) + == png_ptr->trans_color.gray) { - *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); + unsigned int tmp = *sp & (0x7f7f >> (7 - shift)); + tmp |= png_ptr->background.gray << shift; + *sp = (png_byte)(tmp & 0xff); } + if (!shift) { shift = 7; sp++; } + else shift--; } break; } + case 2: { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_table != NULL) { sp = row; @@ -2752,28 +3588,34 @@ png_do_background(png_row_infop row_info, png_bytep row, for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) + == png_ptr->trans_color.gray) { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); + unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); + tmp |= png_ptr->background.gray << shift; + *sp = (png_byte)(tmp & 0xff); } + else { - png_byte p = (png_byte)((*sp >> shift) & 0x03); - png_byte g = (png_byte)((gamma_table [p | (p << 2) | - (p << 4) | (p << 6)] >> 6) & 0x03); - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); + unsigned int p = (*sp >> shift) & 0x03; + unsigned int g = (gamma_table [p | (p << 2) | + (p << 4) | (p << 6)] >> 6) & 0x03; + unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); + tmp |= g << shift; + *sp = (png_byte)(tmp & 0xff); } + if (!shift) { shift = 6; sp++; } + else shift -= 2; } } + else #endif { @@ -2782,25 +3624,29 @@ png_do_background(png_row_infop row_info, png_bytep row, for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) + == png_ptr->trans_color.gray) { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); + unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); + tmp |= png_ptr->background.gray << shift; + *sp = (png_byte)(tmp & 0xff); } + if (!shift) { shift = 6; sp++; } + else shift -= 2; } } break; } + case 4: { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_table != NULL) { sp = row; @@ -2808,28 +3654,34 @@ png_do_background(png_row_infop row_info, png_bytep row, for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) + == png_ptr->trans_color.gray) { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); + unsigned int tmp = *sp & (0xf0f >> (4 - shift)); + tmp |= png_ptr->background.gray << shift; + *sp = (png_byte)(tmp & 0xff); } + else { - png_byte p = (png_byte)((*sp >> shift) & 0x0f); - png_byte g = (png_byte)((gamma_table[p | - (p << 4)] >> 4) & 0x0f); - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); + unsigned int p = (*sp >> shift) & 0x0f; + unsigned int g = (gamma_table[p | (p << 4)] >> 4) & + 0x0f; + unsigned int tmp = *sp & (0xf0f >> (4 - shift)); + tmp |= g << shift; + *sp = (png_byte)(tmp & 0xff); } + if (!shift) { shift = 4; sp++; } + else shift -= 4; } } + else #endif { @@ -2838,38 +3690,39 @@ png_do_background(png_row_infop row_info, png_bytep row, for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) + == png_ptr->trans_color.gray) { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); + unsigned int tmp = *sp & (0xf0f >> (4 - shift)); + tmp |= png_ptr->background.gray << shift; + *sp = (png_byte)(tmp & 0xff); } + if (!shift) { shift = 4; sp++; } + else shift -= 4; } } break; } + case 8: { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_table != NULL) { sp = row; for (i = 0; i < row_width; i++, sp++) { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } + if (*sp == png_ptr->trans_color.gray) + *sp = (png_byte)png_ptr->background.gray; + else - { *sp = gamma_table[*sp]; - } } } else @@ -2878,17 +3731,16 @@ png_do_background(png_row_infop row_info, png_bytep row, sp = row; for (i = 0; i < row_width; i++, sp++) { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } + if (*sp == png_ptr->trans_color.gray) + *sp = (png_byte)png_ptr->background.gray; } } break; } + case 16: { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_16 != NULL) { sp = row; @@ -2897,12 +3749,16 @@ png_do_background(png_row_infop row_info, png_bytep row, png_uint_16 v; v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) + + if (v == png_ptr->trans_color.gray) { - /* background is already in screen gamma */ - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); + /* Background is already in screen gamma */ + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray + & 0xff); } + else { v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; @@ -2920,36 +3776,44 @@ png_do_background(png_row_infop row_info, png_bytep row, png_uint_16 v; v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) + + if (v == png_ptr->trans_color.gray) { - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray + & 0xff); } } } break; } + + default: + break; } break; } + case PNG_COLOR_TYPE_RGB: { if (row_info->bit_depth == 8) { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_table != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 3) { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) + if (*sp == png_ptr->trans_color.red && + *(sp + 1) == png_ptr->trans_color.green && + *(sp + 2) == png_ptr->trans_color.blue) { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; + *sp = (png_byte)png_ptr->background.red; + *(sp + 1) = (png_byte)png_ptr->background.green; + *(sp + 2) = (png_byte)png_ptr->background.blue; } + else { *sp = gamma_table[*sp]; @@ -2964,108 +3828,131 @@ png_do_background(png_row_infop row_info, png_bytep row, sp = row; for (i = 0; i < row_width; i++, sp += 3) { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) + if (*sp == png_ptr->trans_color.red && + *(sp + 1) == png_ptr->trans_color.green && + *(sp + 2) == png_ptr->trans_color.blue) { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; + *sp = (png_byte)png_ptr->background.red; + *(sp + 1) = (png_byte)png_ptr->background.green; + *(sp + 2) = (png_byte)png_ptr->background.blue; } } } } else /* if (row_info->bit_depth == 16) */ { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_16 != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 6) { png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) + + png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + + png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + + *(sp + 5)); + + if (r == png_ptr->trans_color.red && + g == png_ptr->trans_color.green && + b == png_ptr->trans_color.blue) { - /* background is already in screen gamma */ - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); + /* Background is already in screen gamma */ + *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); + *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); } + else { png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; *(sp + 2) = (png_byte)((v >> 8) & 0xff); *(sp + 3) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; *(sp + 4) = (png_byte)((v >> 8) & 0xff); *(sp + 5) = (png_byte)(v & 0xff); } } } + else #endif { sp = row; for (i = 0; i < row_width; i++, sp += 6) { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + + png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) + png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + + *(sp + 5)); + + if (r == png_ptr->trans_color.red && + g == png_ptr->trans_color.green && + b == png_ptr->trans_color.blue) { - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); + *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); + *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); } } } } break; } + case PNG_COLOR_TYPE_GRAY_ALPHA: { if (row_info->bit_depth == 8) { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_to_1 != NULL && gamma_from_1 != NULL && gamma_table != NULL) { sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) + for (i = 0; i < row_width; i++, sp += 2) { png_uint_16 a = *(sp + 1); if (a == 0xff) - { - *dp = gamma_table[*sp]; - } + *sp = gamma_table[*sp]; + else if (a == 0) { - /* background is already in screen gamma */ - *dp = (png_byte)background->gray; + /* Background is already in screen gamma */ + *sp = (png_byte)png_ptr->background.gray; } + else { png_byte v, w; v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->gray); - *dp = gamma_from_1[w]; + png_composite(w, v, a, png_ptr->background_1.gray); + if (!optimize) + w = gamma_from_1[w]; + *sp = w; } } } @@ -3073,151 +3960,139 @@ png_do_background(png_row_infop row_info, png_bytep row, #endif { sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) + for (i = 0; i < row_width; i++, sp += 2) { png_byte a = *(sp + 1); - if (a == 0xff) - { - *dp = *sp; - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) - { - *dp = (png_byte)background->gray; - } - else - { - png_composite(*dp, *sp, a, background_1->gray); - } -#else - *dp = (png_byte)background->gray; -#endif + if (a == 0) + *sp = (png_byte)png_ptr->background.gray; + + else if (a < 0xff) + png_composite(*sp, *sp, a, png_ptr->background.gray); } } } else /* if (png_ptr->bit_depth == 16) */ { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_16 != NULL && gamma_16_from_1 != NULL && gamma_16_to_1 != NULL) { sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) + for (i = 0; i < row_width; i++, sp += 4) { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); if (a == (png_uint_16)0xffff) { png_uint_16 v; v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); } -#if defined(PNG_READ_GAMMA_SUPPORTED) + else if (a == 0) -#else - else -#endif { - /* background is already in screen gamma */ - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); + /* Background is already in screen gamma */ + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); } -#if defined(PNG_READ_GAMMA_SUPPORTED) + else { png_uint_16 g, v, w; g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(v, g, a, background_1->gray); - w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; - *dp = (png_byte)((w >> 8) & 0xff); - *(dp + 1) = (png_byte)(w & 0xff); + png_composite_16(v, g, a, png_ptr->background_1.gray); + if (optimize) + w = v; + else + w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; + *sp = (png_byte)((w >> 8) & 0xff); + *(sp + 1) = (png_byte)(w & 0xff); } -#endif } } else #endif { sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) + for (i = 0; i < row_width; i++, sp += 4) { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 2); - } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else if (a == 0) -#else - else -#endif + png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + + if (a == 0) { - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); + *sp = (png_byte)((png_ptr->background.gray >> 8) + & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); } -#if defined(PNG_READ_GAMMA_SUPPORTED) - else + + else if (a < 0xffff) { png_uint_16 g, v; g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_composite_16(v, g, a, background_1->gray); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); + png_composite_16(v, g, a, png_ptr->background.gray); + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); } -#endif } } } break; } + case PNG_COLOR_TYPE_RGB_ALPHA: { if (row_info->bit_depth == 8) { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_to_1 != NULL && gamma_from_1 != NULL && gamma_table != NULL) { sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) + for (i = 0; i < row_width; i++, sp += 4) { png_byte a = *(sp + 3); if (a == 0xff) { - *dp = gamma_table[*sp]; - *(dp + 1) = gamma_table[*(sp + 1)]; - *(dp + 2) = gamma_table[*(sp + 2)]; + *sp = gamma_table[*sp]; + *(sp + 1) = gamma_table[*(sp + 1)]; + *(sp + 2) = gamma_table[*(sp + 2)]; } + else if (a == 0) { - /* background is already in screen gamma */ - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; + /* Background is already in screen gamma */ + *sp = (png_byte)png_ptr->background.red; + *(sp + 1) = (png_byte)png_ptr->background.green; + *(sp + 2) = (png_byte)png_ptr->background.blue; } + else { png_byte v, w; v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->red); - *dp = gamma_from_1[w]; + png_composite(w, v, a, png_ptr->background_1.red); + if (!optimize) w = gamma_from_1[w]; + *sp = w; + v = gamma_to_1[*(sp + 1)]; - png_composite(w, v, a, background_1->green); - *(dp + 1) = gamma_from_1[w]; + png_composite(w, v, a, png_ptr->background_1.green); + if (!optimize) w = gamma_from_1[w]; + *(sp + 1) = w; + v = gamma_to_1[*(sp + 2)]; - png_composite(w, v, a, background_1->blue); - *(dp + 2) = gamma_from_1[w]; + png_composite(w, v, a, png_ptr->background_1.blue); + if (!optimize) w = gamma_from_1[w]; + *(sp + 2) = w; } } } @@ -3225,115 +4100,129 @@ png_do_background(png_row_infop row_info, png_bytep row, #endif { sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) + for (i = 0; i < row_width; i++, sp += 4) { png_byte a = *(sp + 3); - if (a == 0xff) - { - *dp = *sp; - *(dp + 1) = *(sp + 1); - *(dp + 2) = *(sp + 2); - } - else if (a == 0) + if (a == 0) { - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; + *sp = (png_byte)png_ptr->background.red; + *(sp + 1) = (png_byte)png_ptr->background.green; + *(sp + 2) = (png_byte)png_ptr->background.blue; } - else + + else if (a < 0xff) { - png_composite(*dp, *sp, a, background->red); - png_composite(*(dp + 1), *(sp + 1), a, - background->green); - png_composite(*(dp + 2), *(sp + 2), a, - background->blue); + png_composite(*sp, *sp, a, png_ptr->background.red); + + png_composite(*(sp + 1), *(sp + 1), a, + png_ptr->background.green); + + png_composite(*(sp + 2), *(sp + 2), a, + png_ptr->background.blue); } } } } else /* if (row_info->bit_depth == 16) */ { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_16 != NULL && gamma_16_from_1 != NULL && gamma_16_to_1 != NULL) { sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) + for (i = 0; i < row_width; i++, sp += 8) { png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) << 8) + (png_uint_16)(*(sp + 7))); + if (a == (png_uint_16)0xffff) { png_uint_16 v; v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); + *(sp + 2) = (png_byte)((v >> 8) & 0xff); + *(sp + 3) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); + *(sp + 4) = (png_byte)((v >> 8) & 0xff); + *(sp + 5) = (png_byte)(v & 0xff); } + else if (a == 0) { - /* background is already in screen gamma */ - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); + /* Background is already in screen gamma */ + *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); + *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); } + else { - png_uint_16 v, w, x; + png_uint_16 v, w; v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(w, v, a, background_1->red); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *dp = (png_byte)((x >> 8) & 0xff); - *(dp + 1) = (png_byte)(x & 0xff); + png_composite_16(w, v, a, png_ptr->background_1.red); + if (!optimize) + w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> + 8]; + *sp = (png_byte)((w >> 8) & 0xff); + *(sp + 1) = (png_byte)(w & 0xff); + v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; - png_composite_16(w, v, a, background_1->green); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *(dp + 2) = (png_byte)((x >> 8) & 0xff); - *(dp + 3) = (png_byte)(x & 0xff); + png_composite_16(w, v, a, png_ptr->background_1.green); + if (!optimize) + w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> + 8]; + + *(sp + 2) = (png_byte)((w >> 8) & 0xff); + *(sp + 3) = (png_byte)(w & 0xff); + v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; - png_composite_16(w, v, a, background_1->blue); - x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; - *(dp + 4) = (png_byte)((x >> 8) & 0xff); - *(dp + 5) = (png_byte)(x & 0xff); + png_composite_16(w, v, a, png_ptr->background_1.blue); + if (!optimize) + w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> + 8]; + + *(sp + 4) = (png_byte)((w >> 8) & 0xff); + *(sp + 5) = (png_byte)(w & 0xff); } } } + else #endif { sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) + for (i = 0; i < row_width; i++, sp += 8) { png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 6); - } - else if (a == 0) + << 8) + (png_uint_16)(*(sp + 7))); + + if (a == 0) { - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); + *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); + *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); + *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) + & 0xff); + *(sp + 3) = (png_byte)(png_ptr->background.green + & 0xff); + *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) + & 0xff); + *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); } - else + + else if (a < 0xffff) { png_uint_16 v; @@ -3343,130 +4232,133 @@ png_do_background(png_row_infop row_info, png_bytep row, png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + *(sp + 5)); - png_composite_16(v, r, a, background->red); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - png_composite_16(v, g, a, background->green); - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - png_composite_16(v, b, a, background->blue); - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); + png_composite_16(v, r, a, png_ptr->background.red); + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + + png_composite_16(v, g, a, png_ptr->background.green); + *(sp + 2) = (png_byte)((v >> 8) & 0xff); + *(sp + 3) = (png_byte)(v & 0xff); + + png_composite_16(v, b, a, png_ptr->background.blue); + *(sp + 4) = (png_byte)((v >> 8) & 0xff); + *(sp + 5) = (png_byte)(v & 0xff); } } } } break; } - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - row_info->channels--; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + default: + break; } } } -#endif +#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_READ_ALPHA_MODE_SUPPORTED */ -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED /* Gamma correct the image, avoiding the alpha channel. Make sure * you do this after you deal with the transparency issue on grayscale * or RGB images. If your bit depth is 8, use gamma_table, if it * is 16, use gamma_16_table and gamma_shift. Build these with * build_gamma_table(). */ - -// (Note: the reason I've pulled this block of code out of png_do_gamma and into its own function -// is because the android NDK compiler was crashing when it tried to compile it) -static void doGamma_RGB (png_uint_32 row_width, png_row_infop row_info, png_bytep row, png_bytep gamma_table, png_uint_16pp gamma_16_table, int gamma_shift) -{ - if (row_info->bit_depth == 8) - { - png_bytep sp = row; - for (png_uint_32 i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - png_bytep sp = row; - for (png_uint_32 i = 0; i < row_width; i++) - { - png_uint_16 v; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } -} - void /* PRIVATE */ -png_do_gamma(png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift) +png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) { + png_const_bytep gamma_table = png_ptr->gamma_table; + png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table; + int gamma_shift = png_ptr->gamma_shift; + png_bytep sp; - const png_uint_32 row_width=row_info->width; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_gamma"); - png_debug(1, "in png_do_gamma\n"); if (((row_info->bit_depth <= 8 && gamma_table != NULL) || - (row_info->bit_depth == 16 && gamma_16_table != NULL))) + (row_info->bit_depth == 16 && gamma_16_table != NULL))) { switch (row_info->color_type) { - case PNG_COLOR_TYPE_RGB: - doGamma_RGB (row_width, row_info, row, gamma_table, gamma_16_table, gamma_shift); - break; + case PNG_COLOR_TYPE_RGB: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + } + } + + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + } + } + break; + } - case PNG_COLOR_TYPE_RGB_ALPHA: + case PNG_COLOR_TYPE_RGB_ALPHA: { if (row_info->bit_depth == 8) { sp = row; - for (png_uint_32 i = 0; i < row_width; i++) + for (i = 0; i < row_width; i++) { *sp = gamma_table[*sp]; sp++; + *sp = gamma_table[*sp]; sp++; + *sp = gamma_table[*sp]; sp++; + sp++; } } + else /* if (row_info->bit_depth == 16) */ { sp = row; - for (png_uint_32 i = 0; i < row_width; i++) + for (i = 0; i < row_width; i++) { png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); @@ -3475,21 +4367,23 @@ png_do_gamma(png_row_infop row_info, png_bytep row, } break; } + case PNG_COLOR_TYPE_GRAY_ALPHA: { if (row_info->bit_depth == 8) { sp = row; - for (png_uint_32 i = 0; i < row_width; i++) + for (i = 0; i < row_width; i++) { *sp = gamma_table[*sp]; sp += 2; } } + else /* if (row_info->bit_depth == 16) */ { sp = row; - for (png_uint_32 i = 0; i < row_width; i++) + for (i = 0; i < row_width; i++) { png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); @@ -3499,12 +4393,13 @@ png_do_gamma(png_row_infop row_info, png_bytep row, } break; } + case PNG_COLOR_TYPE_GRAY: { if (row_info->bit_depth == 2) { sp = row; - for (png_uint_32 i = 0; i < row_width; i += 4) + for (i = 0; i < row_width; i += 4) { int a = *sp & 0xc0; int b = *sp & 0x30; @@ -3512,39 +4407,42 @@ png_do_gamma(png_row_infop row_info, png_bytep row, int d = *sp & 0x03; *sp = (png_byte)( - ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| - ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| - ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| - ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); + ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| + ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| + ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| + ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); sp++; } } + if (row_info->bit_depth == 4) { sp = row; - for (png_uint_32 i = 0; i < row_width; i += 2) + for (i = 0; i < row_width; i += 2) { int msb = *sp & 0xf0; int lsb = *sp & 0x0f; *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) - | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); + | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); sp++; } } + else if (row_info->bit_depth == 8) { sp = row; - for (png_uint_32 i = 0; i < row_width; i++) + for (i = 0; i < row_width; i++) { *sp = gamma_table[*sp]; sp++; } } + else if (row_info->bit_depth == 16) { sp = row; - for (png_uint_32 i = 0; i < row_width; i++) + for (i = 0; i < row_width; i++) { png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); @@ -3554,30 +4452,97 @@ png_do_gamma(png_row_infop row_info, png_bytep row, } break; } + + default: + break; + } + } +} +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED +/* Encode the alpha channel to the output gamma (the input channel is always + * linear.) Called only with color types that have an alpha channel. Needs the + * from_1 tables. + */ +void /* PRIVATE */ +png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) +{ + png_uint_32 row_width = row_info->width; + + png_debug(1, "in png_do_encode_alpha"); + + if (row_info->color_type & PNG_COLOR_MASK_ALPHA) + { + if (row_info->bit_depth == 8) + { + PNG_CONST png_bytep table = png_ptr->gamma_from_1; + + if (table != NULL) + { + PNG_CONST int step = + (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2; + + /* The alpha channel is the last component: */ + row += step - 1; + + for (; row_width > 0; --row_width, row += step) + *row = table[*row]; + + return; + } + } + + else if (row_info->bit_depth == 16) + { + PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1; + PNG_CONST int gamma_shift = png_ptr->gamma_shift; + + if (table != NULL) + { + PNG_CONST int step = + (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4; + + /* The alpha channel is the last component: */ + row += step - 2; + + for (; row_width > 0; --row_width, row += step) + { + png_uint_16 v; + + v = table[*(row + 1) >> gamma_shift][*row]; + *row = (png_byte)((v >> 8) & 0xff); + *(row + 1) = (png_byte)(v & 0xff); + } + + return; + } } } + + /* Only get to here if called with a weird row_info; no harm has been done, + * so just issue a warning. + */ + png_warning(png_ptr, "png_do_encode_alpha: unexpected call"); } #endif -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED /* Expands a palette row to an RGB or RGBA row depending * upon whether you supply trans and num_trans. */ void /* PRIVATE */ png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_colorp palette, png_bytep trans, int num_trans) + png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) { int shift, value; png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_expand_palette\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_PALETTE) + png_debug(1, "in png_do_expand_palette"); + + if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) { if (row_info->bit_depth < 8) { @@ -3592,13 +4557,16 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, { if ((*sp >> shift) & 0x01) *dp = 1; + else *dp = 0; + if (shift == 7) { shift = 0; sp--; } + else shift++; @@ -3606,6 +4574,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, } break; } + case 2: { sp = row + (png_size_t)((row_width - 1) >> 2); @@ -3620,6 +4589,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, shift = 0; sp--; } + else shift += 2; @@ -3627,6 +4597,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, } break; } + case 4: { sp = row + (png_size_t)((row_width - 1) >> 1); @@ -3641,6 +4612,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, shift = 0; sp--; } + else shift += 4; @@ -3648,16 +4620,19 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, } break; } + + default: + break; } row_info->bit_depth = 8; row_info->pixel_depth = 8; row_info->rowbytes = row_width; } - switch (row_info->bit_depth) + + if (row_info->bit_depth == 8) { - case 8: { - if (trans != NULL) + if (num_trans > 0) { sp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)(row_width << 2) - 1; @@ -3666,8 +4641,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, { if ((int)(*sp) >= num_trans) *dp-- = 0xff; + else - *dp-- = trans[*sp]; + *dp-- = trans_alpha[*sp]; + *dp-- = palette[*sp].blue; *dp-- = palette[*sp].green; *dp-- = palette[*sp].red; @@ -3679,6 +4656,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, row_info->color_type = 6; row_info->channels = 4; } + else { sp = row + (png_size_t)row_width - 1; @@ -3691,13 +4669,13 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, *dp-- = palette[*sp].red; sp--; } + row_info->bit_depth = 8; row_info->pixel_depth = 24; row_info->rowbytes = row_width * 3; row_info->color_type = 2; row_info->channels = 3; } - break; } } } @@ -3708,21 +4686,19 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, */ void /* PRIVATE */ png_do_expand(png_row_infop row_info, png_bytep row, - png_color_16p trans_value) + png_const_color_16p trans_color) { int shift, value; png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_expand\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif + png_debug(1, "in png_do_expand"); + { if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { - png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); + unsigned int gray = trans_color ? trans_color->gray : 0; if (row_info->bit_depth < 8) { @@ -3730,7 +4706,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, { case 1: { - gray = (png_uint_16)((gray&0x01)*0xff); + gray = (gray & 0x01) * 0xff; sp = row + (png_size_t)((row_width - 1) >> 3); dp = row + (png_size_t)row_width - 1; shift = 7 - (int)((row_width + 7) & 0x07); @@ -3738,13 +4714,16 @@ png_do_expand(png_row_infop row_info, png_bytep row, { if ((*sp >> shift) & 0x01) *dp = 0xff; + else *dp = 0; + if (shift == 7) { shift = 0; sp--; } + else shift++; @@ -3752,9 +4731,10 @@ png_do_expand(png_row_infop row_info, png_bytep row, } break; } + case 2: { - gray = (png_uint_16)((gray&0x03)*0x55); + gray = (gray & 0x03) * 0x55; sp = row + (png_size_t)((row_width - 1) >> 2); dp = row + (png_size_t)row_width - 1; shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); @@ -3768,6 +4748,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, shift = 0; sp--; } + else shift += 2; @@ -3775,9 +4756,10 @@ png_do_expand(png_row_infop row_info, png_bytep row, } break; } + case 4: { - gray = (png_uint_16)((gray&0x0f)*0x11); + gray = (gray & 0x0f) * 0x11; sp = row + (png_size_t)((row_width - 1) >> 1); dp = row + (png_size_t)row_width - 1; shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); @@ -3790,6 +4772,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, shift = 0; sp--; } + else shift = 4; @@ -3797,50 +4780,61 @@ png_do_expand(png_row_infop row_info, png_bytep row, } break; } + + default: + break; } + row_info->bit_depth = 8; row_info->pixel_depth = 8; row_info->rowbytes = row_width; } - if (trans_value != NULL) + if (trans_color != NULL) { if (row_info->bit_depth == 8) { gray = gray & 0xff; sp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)(row_width << 1) - 1; + for (i = 0; i < row_width; i++) { if (*sp == gray) *dp-- = 0; + else *dp-- = 0xff; + *dp-- = *sp--; } } + else if (row_info->bit_depth == 16) { - png_byte gray_high = (gray >> 8) & 0xff; - png_byte gray_low = gray & 0xff; + unsigned int gray_high = (gray >> 8) & 0xff; + unsigned int gray_low = gray & 0xff; sp = row + row_info->rowbytes - 1; dp = row + (row_info->rowbytes << 1) - 1; for (i = 0; i < row_width; i++) { - if (*(sp-1) == gray_high && *(sp) == gray_low) + if (*(sp - 1) == gray_high && *(sp) == gray_low) { *dp-- = 0; *dp-- = 0; } + else { *dp-- = 0xff; *dp-- = 0xff; } + *dp-- = *sp--; *dp-- = *sp--; } } + row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; row_info->channels = 2; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); @@ -3848,21 +4842,23 @@ png_do_expand(png_row_infop row_info, png_bytep row, row_width); } } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) + else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color) { if (row_info->bit_depth == 8) { - png_byte red = trans_value->red & 0xff; - png_byte green = trans_value->green & 0xff; - png_byte blue = trans_value->blue & 0xff; + png_byte red = (png_byte)(trans_color->red & 0xff); + png_byte green = (png_byte)(trans_color->green & 0xff); + png_byte blue = (png_byte)(trans_color->blue & 0xff); sp = row + (png_size_t)row_info->rowbytes - 1; dp = row + (png_size_t)(row_width << 2) - 1; for (i = 0; i < row_width; i++) { if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue) *dp-- = 0; + else *dp-- = 0xff; + *dp-- = *sp--; *dp-- = *sp--; *dp-- = *sp--; @@ -3870,31 +4866,33 @@ png_do_expand(png_row_infop row_info, png_bytep row, } else if (row_info->bit_depth == 16) { - png_byte red_high = (trans_value->red >> 8) & 0xff; - png_byte green_high = (trans_value->green >> 8) & 0xff; - png_byte blue_high = (trans_value->blue >> 8) & 0xff; - png_byte red_low = trans_value->red & 0xff; - png_byte green_low = trans_value->green & 0xff; - png_byte blue_low = trans_value->blue & 0xff; + png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff); + png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff); + png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff); + png_byte red_low = (png_byte)(trans_color->red & 0xff); + png_byte green_low = (png_byte)(trans_color->green & 0xff); + png_byte blue_low = (png_byte)(trans_color->blue & 0xff); sp = row + row_info->rowbytes - 1; dp = row + (png_size_t)(row_width << 3) - 1; for (i = 0; i < row_width; i++) { if (*(sp - 5) == red_high && - *(sp - 4) == red_low && - *(sp - 3) == green_high && - *(sp - 2) == green_low && - *(sp - 1) == blue_high && - *(sp ) == blue_low) + *(sp - 4) == red_low && + *(sp - 3) == green_high && + *(sp - 2) == green_low && + *(sp - 1) == blue_high && + *(sp ) == blue_low) { *dp-- = 0; *dp-- = 0; } + else { *dp-- = 0xff; *dp-- = 0xff; } + *dp-- = *sp--; *dp-- = *sp--; *dp-- = *sp--; @@ -3906,28 +4904,57 @@ png_do_expand(png_row_infop row_info, png_bytep row, row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; row_info->channels = 4; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } } } #endif -#if defined(PNG_READ_DITHER_SUPPORTED) +#ifdef PNG_READ_EXPAND_16_SUPPORTED +/* If the bit depth is 8 and the color type is not a palette type expand the + * whole row to 16 bits. Has no effect otherwise. + */ +void /* PRIVATE */ +png_do_expand_16(png_row_infop row_info, png_bytep row) +{ + if (row_info->bit_depth == 8 && + row_info->color_type != PNG_COLOR_TYPE_PALETTE) + { + /* The row have a sequence of bytes containing [0..255] and we need + * to turn it into another row containing [0..65535], to do this we + * calculate: + * + * (input / 255) * 65535 + * + * Which happens to be exactly input * 257 and this can be achieved + * simply by byte replication in place (copying backwards). + */ + png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */ + png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */ + while (dp > sp) + dp[-2] = dp[-1] = *--sp, dp -= 2; + + row_info->rowbytes *= 2; + row_info->bit_depth = 16; + row_info->pixel_depth = (png_byte)(row_info->channels * 16); + } +} +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED void /* PRIVATE */ -png_do_dither(png_row_infop row_info, png_bytep row, - png_bytep palette_lookup, png_bytep dither_lookup) +png_do_quantize(png_row_infop row_info, png_bytep row, + png_const_bytep palette_lookup, png_const_bytep quantize_lookup) { png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_dither\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif + png_debug(1, "in png_do_quantize"); + + if (row_info->bit_depth == 8) { - if (row_info->color_type == PNG_COLOR_TYPE_RGB && - palette_lookup && row_info->bit_depth == 8) + if (row_info->color_type == PNG_COLOR_TYPE_RGB && palette_lookup) { int r, g, b, p; sp = row; @@ -3938,31 +4965,33 @@ png_do_dither(png_row_infop row_info, png_bytep row, g = *sp++; b = *sp++; - /* this looks real messy, but the compiler will reduce - it down to a reasonable formula. For example, with - 5 bits per color, we get: - p = (((r >> 3) & 0x1f) << 10) | - (((g >> 3) & 0x1f) << 5) | - ((b >> 3) & 0x1f); - */ - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); + /* This looks real messy, but the compiler will reduce + * it down to a reasonable formula. For example, with + * 5 bits per color, we get: + * p = (((r >> 3) & 0x1f) << 10) | + * (((g >> 3) & 0x1f) << 5) | + * ((b >> 3) & 0x1f); + */ + p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) & + ((1 << PNG_QUANTIZE_RED_BITS) - 1)) << + (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) | + (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) & + ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) << + (PNG_QUANTIZE_BLUE_BITS)) | + ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) & + ((1 << PNG_QUANTIZE_BLUE_BITS) - 1)); *dp++ = palette_lookup[p]; } + row_info->color_type = PNG_COLOR_TYPE_PALETTE; row_info->channels = 1; row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - palette_lookup != NULL && row_info->bit_depth == 8) + palette_lookup != NULL) { int r, g, b, p; sp = row; @@ -3974,270 +5003,52 @@ png_do_dither(png_row_infop row_info, png_bytep row, b = *sp++; sp++; - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); + p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) & + ((1 << PNG_QUANTIZE_RED_BITS) - 1)) << + (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) | + (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) & + ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) << + (PNG_QUANTIZE_BLUE_BITS)) | + ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) & + ((1 << PNG_QUANTIZE_BLUE_BITS) - 1)); *dp++ = palette_lookup[p]; } + row_info->color_type = PNG_COLOR_TYPE_PALETTE; row_info->channels = 1; row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } + else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - dither_lookup && row_info->bit_depth == 8) + quantize_lookup) { sp = row; + for (i = 0; i < row_width; i++, sp++) { - *sp = dither_lookup[*sp]; + *sp = quantize_lookup[*sp]; } } } } -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -#if defined(PNG_READ_GAMMA_SUPPORTED) -static PNG_CONST int png_gamma_shift[] = - {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00}; - -/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit - * tables, we don't make a full table if we are reducing to 8-bit in - * the future. Note also how the gamma_16 tables are segmented so that - * we don't need to allocate > 64K chunks for a full 16-bit table. - */ -void /* PRIVATE */ -png_build_gamma_table(png_structp png_ptr) -{ - png_debug(1, "in png_build_gamma_table\n"); - - if (png_ptr->bit_depth <= 8) - { - int i; - double g; - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - - - png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } - else - { - double g; - int i, j, shift, num; - int sig_bit; - png_uint_32 ig; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit = (int)png_ptr->sig_bit.red; - if ((int)png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - if ((int)png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - { - sig_bit = (int)png_ptr->sig_bit.gray; - } - - if (sig_bit > 0) - shift = 16 - sig_bit; - else - shift = 0; - - if (png_ptr->transformations & PNG_16_TO_8) - { - if (shift < (16 - PNG_MAX_GAMMA_8)) - shift = (16 - PNG_MAX_GAMMA_8); - } - - if (shift > 8) - shift = 8; - if (shift < 0) - shift = 0; - - png_ptr->gamma_shift = (png_byte)shift; - - num = (1 << (8 - shift)); - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); - - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) - { - double fin, fout; - png_uint_32 last, max; - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - } - - g = 1.0 / g; - last = 0; - for (i = 0; i < 256; i++) - { - fout = ((double)i + 0.5) / 256.0; - fin = pow(fout, g); - max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); - while (last <= max) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)( - (png_uint_16)i | ((png_uint_16)i << 8)); - last++; - } - } - while (last < ((png_uint_32)num << 8)) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)65535L; - last++; - } - } - else - { - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_table[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p ))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_to_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); +#endif /* PNG_READ_QUANTIZE_SUPPORTED */ +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_from_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } -} -#endif -/* To do: install integer version of png_build_gamma_table here */ -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ +#ifdef PNG_MNG_FEATURES_SUPPORTED +/* Undoes intrapixel differencing */ void /* PRIVATE */ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_intrapixel\n"); + png_debug(1, "in png_do_read_intrapixel"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; + if (row_info->bit_depth == 8) { png_bytep rp; @@ -4245,15 +5056,17 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 3; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 4; + else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); - *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); + *(rp) = (png_byte)((256 + *rp + *(rp + 1)) & 0xff); + *(rp+2) = (png_byte)((256 + *(rp + 2) + *(rp + 1)) & 0xff); } } else if (row_info->bit_depth == 16) @@ -4263,22 +5076,24 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 6; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 8; + else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); - png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); - png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0+s1+65536L) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp+1) = (png_byte)(red & 0xff); - *(rp+4) = (png_byte)((blue >> 8) & 0xff); - *(rp+5) = (png_byte)(blue & 0xff); + png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); + png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); + png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); + png_uint_32 red = (s0 + s1 + 65536) & 0xffff; + png_uint_32 blue = (s2 + s1 + 65536) & 0xffff; + *(rp ) = (png_byte)((red >> 8) & 0xff); + *(rp + 1) = (png_byte)(red & 0xff); + *(rp + 4) = (png_byte)((blue >> 8) & 0xff); + *(rp + 5) = (png_byte)(blue & 0xff); } } } diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrutil.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrutil.c index b6440ae0d..6f94f51fd 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrutil.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngrutil.c @@ -1,138 +1,239 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.2.21 [October 4, 2007] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file contains routines that are only called from within * libpng itself during the course of reading an image. */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" -#if defined(PNG_READ_SUPPORTED) +#ifdef PNG_READ_SUPPORTED -#if defined(_WIN32_WCE) && (_WIN32_WCE<0x500) -# define WIN32_WCE_OLD -#endif +#define png_strtod(p,a,b) strtod(a,b) -#ifdef PNG_FLOATING_POINT_SUPPORTED -# if defined(WIN32_WCE_OLD) -/* strtod() function is not supported on WindowsCE */ -__inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr) +png_uint_32 PNGAPI +png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf) { - double result = 0; - int len; - wchar_t *str, *end; + png_uint_32 uval = png_get_uint_32(buf); - len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); - str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t)); - if ( NULL != str ) - { - MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); - result = wcstod(str, &end); - len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); - *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); - png_free(png_ptr, str); - } - return result; + if (uval > PNG_UINT_31_MAX) + png_error(png_ptr, "PNG unsigned integer out of range"); + + return (uval); } -# else -# define png_strtod(p,a,b) strtod(a,b) -# endif -#endif -png_uint_32 PNGAPI -png_get_uint_31(png_structp png_ptr, png_bytep buf) +#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED) +/* The following is a variation on the above for use with the fixed + * point values used for gAMA and cHRM. Instead of png_error it + * issues a warning and returns (-1) - an invalid value because both + * gAMA and cHRM use *unsigned* integers for fixed point values. + */ +#define PNG_FIXED_ERROR (-1) + +static png_fixed_point /* PRIVATE */ +png_get_fixed_point(png_structrp png_ptr, png_const_bytep buf) { - png_uint_32 i = png_get_uint_32(buf); - if (i > PNG_UINT_31_MAX) - png_error(png_ptr, "PNG unsigned integer out of range."); - return (i); + png_uint_32 uval = png_get_uint_32(buf); + + if (uval <= PNG_UINT_31_MAX) + return (png_fixed_point)uval; /* known to be in range */ + + /* The caller can turn off the warning by passing NULL. */ + if (png_ptr != NULL) + png_warning(png_ptr, "PNG fixed point integer out of range"); + + return PNG_FIXED_ERROR; } -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED +#endif + +#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED +/* NOTE: the read macros will obscure these definitions, so that if + * PNG_USE_READ_MACROS is set the library will not use them internally, + * but the APIs will still be available externally. + * + * The parentheses around "PNGAPI function_name" in the following three + * functions are necessary because they allow the macros to co-exist with + * these (unused but exported) functions. + */ + /* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ -png_uint_32 PNGAPI -png_get_uint_32(png_bytep buf) +png_uint_32 (PNGAPI +png_get_uint_32)(png_const_bytep buf) { - png_uint_32 i = ((png_uint_32)(*buf) << 24) + - ((png_uint_32)(*(buf + 1)) << 16) + - ((png_uint_32)(*(buf + 2)) << 8) + - (png_uint_32)(*(buf + 3)); + png_uint_32 uval = + ((png_uint_32)(*(buf )) << 24) + + ((png_uint_32)(*(buf + 1)) << 16) + + ((png_uint_32)(*(buf + 2)) << 8) + + ((png_uint_32)(*(buf + 3)) ) ; - return (i); + return uval; } /* Grab a signed 32-bit integer from a buffer in big-endian format. The - * data is stored in the PNG file in two's complement format, and it is - * assumed that the machine format for signed integers is the same. */ -png_int_32 PNGAPI -png_get_int_32(png_bytep buf) + * data is stored in the PNG file in two's complement format and there + * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore + * the following code does a two's complement to native conversion. + */ +png_int_32 (PNGAPI +png_get_int_32)(png_const_bytep buf) { - png_int_32 i = ((png_int_32)(*buf) << 24) + - ((png_int_32)(*(buf + 1)) << 16) + - ((png_int_32)(*(buf + 2)) << 8) + - (png_int_32)(*(buf + 3)); + png_uint_32 uval = png_get_uint_32(buf); + if ((uval & 0x80000000) == 0) /* non-negative */ + return uval; - return (i); + uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */ + return -(png_int_32)uval; } /* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ -png_uint_16 PNGAPI -png_get_uint_16(png_bytep buf) +png_uint_16 (PNGAPI +png_get_uint_16)(png_const_bytep buf) +{ + /* ANSI-C requires an int value to accomodate at least 16 bits so this + * works and allows the compiler not to worry about possible narrowing + * on 32 bit systems. (Pre-ANSI systems did not make integers smaller + * than 16 bits either.) + */ + unsigned int val = + ((unsigned int)(*buf) << 8) + + ((unsigned int)(*(buf + 1))); + + return (png_uint_16)val; +} + +#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */ + +/* Read and check the PNG file signature */ +void /* PRIVATE */ +png_read_sig(png_structrp png_ptr, png_inforp info_ptr) +{ + png_size_t num_checked, num_to_check; + + /* Exit if the user application does not expect a signature. */ + if (png_ptr->sig_bytes >= 8) + return; + + num_checked = png_ptr->sig_bytes; + num_to_check = 8 - num_checked; + +#ifdef PNG_IO_STATE_SUPPORTED + png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE; +#endif + + /* The signature must be serialized in a single I/O call. */ + png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); + png_ptr->sig_bytes = 8; + + if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) + { + if (num_checked < 4 && + png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) + png_error(png_ptr, "Not a PNG file"); + else + png_error(png_ptr, "PNG file corrupted by ASCII conversion"); + } + if (num_checked < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; +} + +/* Read the chunk header (length + type name). + * Put the type name into png_ptr->chunk_name, and return the length. + */ +png_uint_32 /* PRIVATE */ +png_read_chunk_header(png_structrp png_ptr) { - png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + - (png_uint_16)(*(buf + 1))); + png_byte buf[8]; + png_uint_32 length; + +#ifdef PNG_IO_STATE_SUPPORTED + png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR; +#endif + + /* Read the length and the chunk name. + * This must be performed in a single I/O call. + */ + png_read_data(png_ptr, buf, 8); + length = png_get_uint_31(png_ptr, buf); + + /* Put the chunk name into png_ptr->chunk_name. */ + png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4); + + png_debug2(0, "Reading %lx chunk, length = %lu", + (unsigned long)png_ptr->chunk_name, (unsigned long)length); + + /* Reset the crc and run it over the chunk name. */ + png_reset_crc(png_ptr); + png_calculate_crc(png_ptr, buf + 4, 4); + + /* Check to see if chunk name is valid. */ + png_check_chunk_name(png_ptr, png_ptr->chunk_name); + +#ifdef PNG_IO_STATE_SUPPORTED + png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA; +#endif - return (i); + return length; } -#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ /* Read data, and (optionally) run it through the CRC. */ void /* PRIVATE */ -png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) +png_crc_read(png_structrp png_ptr, png_bytep buf, png_uint_32 length) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + png_read_data(png_ptr, buf, length); png_calculate_crc(png_ptr, buf, length); } /* Optionally skip data and then check the CRC. Depending on whether we - are reading a ancillary or critical chunk, and how the program has set - things up, we may calculate the CRC on the data and print a message. - Returns '1' if there was a CRC error, '0' otherwise. */ + * are reading an ancillary or critical chunk, and how the program has set + * things up, we may calculate the CRC on the data and print a message. + * Returns '1' if there was a CRC error, '0' otherwise. + */ int /* PRIVATE */ -png_crc_finish(png_structp png_ptr, png_uint_32 skip) +png_crc_finish(png_structrp png_ptr, png_uint_32 skip) { - png_size_t i; - png_size_t istop = png_ptr->zbuf_size; - - for (i = (png_size_t)skip; i > istop; i -= istop) + /* The size of the local buffer for inflate is a good guess as to a + * reasonable size to use for buffering reads from the application. + */ + while (skip > 0) { - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - } - if (i) - { - png_crc_read(png_ptr, png_ptr->zbuf, i); + png_uint_32 len; + png_byte tmpbuf[PNG_INFLATE_BUF_SIZE]; + + len = (sizeof tmpbuf); + if (len > skip) + len = skip; + skip -= len; + + png_crc_read(png_ptr, tmpbuf, len); } if (png_crc_error(png_ptr)) { - if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ - !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || - (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ - (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) + if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name) ? + !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) : + (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE)) { png_chunk_warning(png_ptr, "CRC error"); } + else { - png_chunk_error(png_ptr, "CRC error"); + png_chunk_benign_error(png_ptr, "CRC error"); + return (0); } + return (1); } @@ -140,26 +241,33 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip) } /* Compare the CRC stored in the PNG file with that calculated by libpng from - the data it has read thus far. */ + * the data it has read thus far. + */ int /* PRIVATE */ -png_crc_error(png_structp png_ptr) +png_crc_error(png_structrp png_ptr) { png_byte crc_bytes[4]; png_uint_32 crc; int need_crc = 1; - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ + if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name)) { if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) need_crc = 0; } - else /* critical */ + + else /* critical */ { if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) need_crc = 0; } +#ifdef PNG_IO_STATE_SUPPORTED + png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC; +#endif + + /* The chunk CRC must be serialized in a single I/O call. */ png_read_data(png_ptr, crc_bytes, 4); if (need_crc) @@ -167,199 +275,527 @@ png_crc_error(png_structp png_ptr) crc = png_get_uint_32(crc_bytes); return ((int)(crc != png_ptr->crc)); } + else return (0); } -#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ - defined(PNG_READ_iCCP_SUPPORTED) +/* Manage the read buffer; this simply reallocates the buffer if it is not small + * enough (or if it is not allocated). The routine returns a pointer to the + * buffer; if an error occurs and 'warn' is set the routine returns NULL, else + * it will call png_error (via png_malloc) on failure. (warn == 2 means + * 'silent'). + */ +static png_bytep +png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn) +{ + png_bytep buffer = png_ptr->read_buffer; + + if (buffer != NULL && new_size > png_ptr->read_buffer_size) + { + png_ptr->read_buffer = NULL; + png_ptr->read_buffer = NULL; + png_ptr->read_buffer_size = 0; + png_free(png_ptr, buffer); + buffer = NULL; + } + + if (buffer == NULL) + { + buffer = png_voidcast(png_bytep, png_malloc_base(png_ptr, new_size)); + + if (buffer != NULL) + { + png_ptr->read_buffer = buffer; + png_ptr->read_buffer_size = new_size; + } + + else if (warn < 2) /* else silent */ + { +#ifdef PNG_WARNINGS_SUPPORTED + if (warn) + png_chunk_warning(png_ptr, "insufficient memory to read chunk"); + else +#endif + { +#ifdef PNG_ERROR_TEXT_SUPPORTED + png_chunk_error(png_ptr, "insufficient memory to read chunk"); +#endif + } + } + } + + return buffer; +} + +/* png_inflate_claim: claim the zstream for some nefarious purpose that involves + * decompression. Returns Z_OK on success, else a zlib error code. It checks + * the owner but, in final release builds, just issues a warning if some other + * chunk apparently owns the stream. Prior to release it does a png_error. + */ +static int +png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits) +{ + if (png_ptr->zowner != 0) + { + char msg[64]; + + PNG_STRING_FROM_CHUNK(msg, png_ptr->zowner); + /* So the message that results is "<chunk> using zstream"; this is an + * internal error, but is very useful for debugging. i18n requirements + * are minimal. + */ + (void)png_safecat(msg, (sizeof msg), 4, " using zstream"); +# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC + png_chunk_warning(png_ptr, msg); + png_ptr->zowner = 0; +# else + png_chunk_error(png_ptr, msg); +# endif + } + + /* Implementation note: unlike 'png_deflate_claim' this internal function + * does not take the size of the data as an argument. Some efficiency could + * be gained by using this when it is known *if* the zlib stream itself does + * not record the number; however, this is an illusion: the original writer + * of the PNG may have selected a lower window size, and we really must + * follow that because, for systems with with limited capabilities, we + * would otherwise reject the application's attempts to use a smaller window + * size (zlib doesn't have an interface to say "this or lower"!). + * + * inflateReset2 was added to zlib 1.2.4; before this the window could not be + * reset, therefore it is necessary to always allocate the maximum window + * size with earlier zlibs just in case later compressed chunks need it. + */ + { + int ret; /* zlib return code */ + + /* Set this for safety, just in case the previous owner left pointers to + * memory allocations. + */ + png_ptr->zstream.next_in = NULL; + png_ptr->zstream.avail_in = 0; + png_ptr->zstream.next_out = NULL; + png_ptr->zstream.avail_out = 0; + + if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) + { +# if ZLIB_VERNUM < 0x1240 + PNG_UNUSED(window_bits) + ret = inflateReset(&png_ptr->zstream); +# else + ret = inflateReset2(&png_ptr->zstream, window_bits); +# endif + } + + else + { +# if ZLIB_VERNUM < 0x1240 + ret = inflateInit(&png_ptr->zstream); +# else + ret = inflateInit2(&png_ptr->zstream, window_bits); +# endif + + if (ret == Z_OK) + png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; + } + + if (ret == Z_OK) + png_ptr->zowner = owner; + + else + png_zstream_error(png_ptr, ret); + + return ret; + } +} + +#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED +/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to + * allow the caller to do multiple calls if required. If the 'finish' flag is + * set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must + * be returned or there has been a problem, otherwise Z_SYNC_FLUSH is used and + * Z_OK or Z_STREAM_END will be returned on success. + * + * The input and output sizes are updated to the actual amounts of data consumed + * or written, not the amount available (as in a z_stream). The data pointers + * are not changed, so the next input is (data+input_size) and the next + * available output is (output+output_size). + */ +static int +png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish, + /* INPUT: */ png_const_bytep input, png_uint_32p input_size_ptr, + /* OUTPUT: */ png_bytep output, png_alloc_size_t *output_size_ptr) +{ + if (png_ptr->zowner == owner) /* Else not claimed */ + { + int ret; + png_alloc_size_t avail_out = *output_size_ptr; + png_uint_32 avail_in = *input_size_ptr; + + /* zlib can't necessarily handle more than 65535 bytes at once (i.e. it + * can't even necessarily handle 65536 bytes) because the type uInt is + * "16 bits or more". Consequently it is necessary to chunk the input to + * zlib. This code uses ZLIB_IO_MAX, from pngpriv.h, as the maximum (the + * maximum value that can be stored in a uInt.) It is possible to set + * ZLIB_IO_MAX to a lower value in pngpriv.h and this may sometimes have + * a performance advantage, because it reduces the amount of data accessed + * at each step and that may give the OS more time to page it in. + */ + png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input); + /* avail_in and avail_out are set below from 'size' */ + png_ptr->zstream.avail_in = 0; + png_ptr->zstream.avail_out = 0; + + /* Read directly into the output if it is available (this is set to + * a local buffer below if output is NULL). + */ + if (output != NULL) + png_ptr->zstream.next_out = output; + + do + { + uInt avail; + Byte local_buffer[PNG_INFLATE_BUF_SIZE]; + + /* zlib INPUT BUFFER */ + /* The setting of 'avail_in' used to be outside the loop; by setting it + * inside it is possible to chunk the input to zlib and simply rely on + * zlib to advance the 'next_in' pointer. This allows arbitrary + * amounts of data to be passed through zlib at the unavoidable cost of + * requiring a window save (memcpy of up to 32768 output bytes) + * every ZLIB_IO_MAX input bytes. + */ + avail_in += png_ptr->zstream.avail_in; /* not consumed last time */ + + avail = ZLIB_IO_MAX; + + if (avail_in < avail) + avail = (uInt)avail_in; /* safe: < than ZLIB_IO_MAX */ + + avail_in -= avail; + png_ptr->zstream.avail_in = avail; + + /* zlib OUTPUT BUFFER */ + avail_out += png_ptr->zstream.avail_out; /* not written last time */ + + avail = ZLIB_IO_MAX; /* maximum zlib can process */ + + if (output == NULL) + { + /* Reset the output buffer each time round if output is NULL and + * make available the full buffer, up to 'remaining_space' + */ + png_ptr->zstream.next_out = local_buffer; + if ((sizeof local_buffer) < avail) + avail = (sizeof local_buffer); + } + + if (avail_out < avail) + avail = (uInt)avail_out; /* safe: < ZLIB_IO_MAX */ + + png_ptr->zstream.avail_out = avail; + avail_out -= avail; + + /* zlib inflate call */ + /* In fact 'avail_out' may be 0 at this point, that happens at the end + * of the read when the final LZ end code was not passed at the end of + * the previous chunk of input data. Tell zlib if we have reached the + * end of the output buffer. + */ + ret = inflate(&png_ptr->zstream, avail_out > 0 ? Z_NO_FLUSH : + (finish ? Z_FINISH : Z_SYNC_FLUSH)); + } while (ret == Z_OK); + + /* For safety kill the local buffer pointer now */ + if (output == NULL) + png_ptr->zstream.next_out = NULL; + + /* Claw back the 'size' and 'remaining_space' byte counts. */ + avail_in += png_ptr->zstream.avail_in; + avail_out += png_ptr->zstream.avail_out; + + /* Update the input and output sizes; the updated values are the amount + * consumed or written, effectively the inverse of what zlib uses. + */ + if (avail_out > 0) + *output_size_ptr -= avail_out; + + if (avail_in > 0) + *input_size_ptr -= avail_in; + + /* Ensure png_ptr->zstream.msg is set (even in the success case!) */ + png_zstream_error(png_ptr, ret); + return ret; + } + + else + { + /* This is a bad internal error. The recovery assigns to the zstream msg + * pointer, which is not owned by the caller, but this is safe; it's only + * used on errors! + */ + png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed"); + return Z_STREAM_ERROR; + } +} + /* - * Decompress trailing data in a chunk. The assumption is that chunkdata + * Decompress trailing data in a chunk. The assumption is that read_buffer * points at an allocated area holding the contents of a chunk with a * trailing compressed part. What we get back is an allocated area * holding the original prefix part and an uncompressed version of the * trailing part (the malloc area passed in is freed). */ -png_charp /* PRIVATE */ -png_decompress_chunk(png_structp png_ptr, int comp_type, - png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_size, png_size_t *newlength) +static int +png_decompress_chunk(png_structrp png_ptr, + png_uint_32 chunklength, png_uint_32 prefix_size, + png_alloc_size_t *newlength /* must be initialized to the maximum! */, + int terminate /*add a '\0' to the end of the uncompressed data*/) { - static PNG_CONST char msg[] = "Error decoding compressed text"; - png_charp text; - png_size_t text_size; + /* TODO: implement different limits for different types of chunk. + * + * The caller supplies *newlength set to the maximum length of the + * uncompressed data, but this routine allocates space for the prefix and + * maybe a '\0' terminator too. We have to assume that 'prefix_size' is + * limited only by the maximum chunk size. + */ + png_alloc_size_t limit = PNG_SIZE_MAX; + +# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED + if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < limit) + limit = png_ptr->user_chunk_malloc_max; +# elif PNG_USER_CHUNK_MALLOC_MAX > 0 + if (PNG_USER_CHUNK_MALLOC_MAX < limit) + limit = PNG_USER_CHUNK_MALLOC_MAX; +# endif - if (comp_type == PNG_COMPRESSION_TYPE_BASE) + if (limit >= prefix_size + (terminate != 0)) { - int ret = Z_OK; - png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); - png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + int ret; - text_size = 0; - text = NULL; + limit -= prefix_size + (terminate != 0); - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_warning(png_ptr, png_ptr->zstream.msg); - else - png_warning(png_ptr, msg); - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; + if (limit < *newlength) + *newlength = limit; - if (text == NULL) - { - text_size = prefix_size + png_sizeof(msg) + 1; - text = (png_charp)png_malloc_warn(png_ptr, text_size); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk"); - } - png_memcpy(text, chunkdata, prefix_size); - } + /* Now try to claim the stream; the 'warn' setting causes zlib to be told + * to use the maximum window size during inflate; this hides errors in the + * deflate header window bits value which is used if '0' is passed. In + * fact this only has an effect with zlib versions 1.2.4 and later - see + * the comments in png_inflate_claim above. + */ + ret = png_inflate_claim(png_ptr, png_ptr->chunk_name, + png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN ? 15 : 0); - text[text_size - 1] = 0x00; + if (ret == Z_OK) + { + png_uint_32 lzsize = chunklength - prefix_size; - /* Copy what we can of the error message into the text chunk */ - text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); - text_size = png_sizeof(msg) > text_size ? text_size : - png_sizeof(msg); - png_memcpy(text + prefix_size, msg, text_size + 1); - break; - } - if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) + ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, + /* input: */ png_ptr->read_buffer + prefix_size, &lzsize, + /* output: */ NULL, newlength); + + if (ret == Z_STREAM_END) { - if (text == NULL) - { - text_size = prefix_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out; - text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); - if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk."); - } - png_memcpy(text + prefix_size, png_ptr->zbuf, - text_size - prefix_size); - png_memcpy(text, chunkdata, prefix_size); - *(text + text_size) = 0x00; - } - else + /* Use 'inflateReset' here, not 'inflateReset2' because this + * preserves the previously decided window size (otherwise it would + * be necessary to store the previous window size.) In practice + * this doesn't matter anyway, because png_inflate will call inflate + * with Z_FINISH in almost all cases, so the window will not be + * maintained. + */ + if (inflateReset(&png_ptr->zstream) == Z_OK) { - png_charp tmp; + /* Because of the limit checks above we know that the new, + * expanded, size will fit in a size_t (let alone an + * png_alloc_size_t). Use png_malloc_base here to avoid an + * extra OOM message. + */ + png_alloc_size_t new_size = *newlength; + png_alloc_size_t buffer_size = prefix_size + new_size + + (terminate != 0); + png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr, + buffer_size)); + + if (text != NULL) + { + ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, + png_ptr->read_buffer + prefix_size, &lzsize, + text + prefix_size, newlength); + + if (ret == Z_STREAM_END) + { + if (new_size == *newlength) + { + if (terminate) + text[prefix_size + *newlength] = 0; + + if (prefix_size > 0) + memcpy(text, png_ptr->read_buffer, prefix_size); + + { + png_bytep old_ptr = png_ptr->read_buffer; + + png_ptr->read_buffer = text; + png_ptr->read_buffer_size = buffer_size; + text = old_ptr; /* freed below */ + } + } + + else + { + /* The size changed on the second read, there can be no + * guarantee that anything is correct at this point. + * The 'msg' pointer has been set to "unexpected end of + * LZ stream", which is fine, but return an error code + * that the caller won't accept. + */ + ret = PNG_UNEXPECTED_ZLIB_RETURN; + } + } + + else if (ret == Z_OK) + ret = PNG_UNEXPECTED_ZLIB_RETURN; /* for safety */ + + /* Free the text pointer (this is the old read_buffer on + * success) + */ + png_free(png_ptr, text); - tmp = text; - text = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(text_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); - if (text == NULL) + /* This really is very benign, but it's still an error because + * the extra space may otherwise be used as a Trojan Horse. + */ + if (ret == Z_STREAM_END && + chunklength - prefix_size != lzsize) + png_chunk_benign_error(png_ptr, "extra compressed data"); + } + + else { - png_free(png_ptr, tmp); - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk.."); + /* Out of memory allocating the buffer */ + ret = Z_MEM_ERROR; + png_zstream_error(png_ptr, Z_MEM_ERROR); } - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = 0x00; } - if (ret == Z_STREAM_END) - break; + else { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + /* inflateReset failed, store the error message */ + png_zstream_error(png_ptr, ret); + + if (ret == Z_STREAM_END) + ret = PNG_UNEXPECTED_ZLIB_RETURN; } } + + else if (ret == Z_OK) + ret = PNG_UNEXPECTED_ZLIB_RETURN; + + /* Release the claimed stream */ + png_ptr->zowner = 0; } - if (ret != Z_STREAM_END) + + else /* the claim failed */ if (ret == Z_STREAM_END) /* impossible! */ + ret = PNG_UNEXPECTED_ZLIB_RETURN; + + return ret; + } + + else + { + /* Application/configuration limits exceeded */ + png_zstream_error(png_ptr, Z_MEM_ERROR); + return Z_MEM_ERROR; + } +} +#endif /* PNG_READ_COMPRESSED_TEXT_SUPPORTED */ + +#ifdef PNG_READ_iCCP_SUPPORTED +/* Perform a partial read and decompress, producing 'avail_out' bytes and + * reading from the current chunk as required. + */ +static int +png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, + png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, + int finish) +{ + if (png_ptr->zowner == png_ptr->chunk_name) + { + int ret; + + /* next_in and avail_in must have been initialized by the caller. */ + png_ptr->zstream.next_out = next_out; + png_ptr->zstream.avail_out = 0; /* set in the loop */ + + do { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[52]; - - if (ret == Z_BUF_ERROR) - png_snprintf(umsg, 52, - "Buffer error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else if (ret == Z_DATA_ERROR) - png_snprintf(umsg, 52, - "Data error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else - png_snprintf(umsg, 52, - "Incomplete compressed datastream in %s chunk", - png_ptr->chunk_name); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, - "Incomplete compressed datastream in chunk other than IDAT"); -#endif - text_size=prefix_size; - if (text == NULL) + if (png_ptr->zstream.avail_in == 0) { - text = (png_charp)png_malloc_warn(png_ptr, text_size+1); - if (text == NULL) - { - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory for text."); - } - png_memcpy(text, chunkdata, prefix_size); + if (read_size > *chunk_bytes) + read_size = (uInt)*chunk_bytes; + *chunk_bytes -= read_size; + + if (read_size > 0) + png_crc_read(png_ptr, read_buffer, read_size); + + png_ptr->zstream.next_in = read_buffer; + png_ptr->zstream.avail_in = read_size; } - *(text + text_size) = 0x00; - } - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; + if (png_ptr->zstream.avail_out == 0) + { + uInt avail = ZLIB_IO_MAX; + if (avail > *out_size) + avail = (uInt)*out_size; + *out_size -= avail; - png_free(png_ptr, chunkdata); - chunkdata = text; - *newlength=text_size; - } - else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[50]; + png_ptr->zstream.avail_out = avail; + } - png_snprintf(umsg, 50, - "Unknown zTXt compression type %d", comp_type); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, "Unknown zTXt compression type"); -#endif + /* Use Z_SYNC_FLUSH when there is no more chunk data to ensure that all + * the available output is produced; this allows reading of truncated + * streams. + */ + ret = inflate(&png_ptr->zstream, + *chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH)); + } + while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0)); - *(chunkdata + prefix_size) = 0x00; - *newlength=prefix_size; + *out_size += png_ptr->zstream.avail_out; + png_ptr->zstream.avail_out = 0; /* Should not be required, but is safe */ + + /* Ensure the error message pointer is always set: */ + png_zstream_error(png_ptr, ret); + return ret; } - return chunkdata; + else + { + png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed"); + return Z_STREAM_ERROR; + } } #endif -/* read and check the IDHR chunk */ +/* Read and check the IDHR chunk */ void /* PRIVATE */ -png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { png_byte buf[13]; png_uint_32 width, height; int bit_depth, color_type, compression_type, filter_type; int interlace_type; - png_debug(1, "in png_handle_IHDR\n"); + png_debug(1, "in png_handle_IHDR"); if (png_ptr->mode & PNG_HAVE_IHDR) - png_error(png_ptr, "Out of place IHDR"); + png_chunk_error(png_ptr, "out of place"); - /* check the length */ + /* Check the length */ if (length != 13) - png_error(png_ptr, "Invalid IHDR chunk"); + png_chunk_error(png_ptr, "invalid"); png_ptr->mode |= PNG_HAVE_IHDR; @@ -374,79 +810,93 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) filter_type = buf[11]; interlace_type = buf[12]; - /* set internal variables */ + /* Set internal variables */ png_ptr->width = width; png_ptr->height = height; png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->interlaced = (png_byte)interlace_type; png_ptr->color_type = (png_byte)color_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED png_ptr->filter_type = (png_byte)filter_type; #endif png_ptr->compression_type = (png_byte)compression_type; - /* find number of channels */ + /* Find number of channels */ switch (png_ptr->color_type) { + default: /* invalid, png_set_IHDR calls png_error */ case PNG_COLOR_TYPE_GRAY: case PNG_COLOR_TYPE_PALETTE: png_ptr->channels = 1; break; + case PNG_COLOR_TYPE_RGB: png_ptr->channels = 3; break; + case PNG_COLOR_TYPE_GRAY_ALPHA: png_ptr->channels = 2; break; + case PNG_COLOR_TYPE_RGB_ALPHA: png_ptr->channels = 4; break; } - /* set up other useful info */ + /* Set up other useful info */ png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width); - png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); - png_debug1(3,"channels = %d\n", png_ptr->channels); - png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); + png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width); + png_debug1(3, "bit_depth = %d", png_ptr->bit_depth); + png_debug1(3, "channels = %d", png_ptr->channels); + png_debug1(3, "rowbytes = %lu", (unsigned long)png_ptr->rowbytes); png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - color_type, interlace_type, compression_type, filter_type); + color_type, interlace_type, compression_type, filter_type); } -/* read and check the palette */ +/* Read and check the palette */ void /* PRIVATE */ -png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { png_color palette[PNG_MAX_PALETTE_LENGTH]; int num, i; -#ifndef PNG_NO_POINTER_INDEXING +#ifdef PNG_POINTER_INDEXING_SUPPORTED png_colorp pal_ptr; #endif - png_debug(1, "in png_handle_PLTE\n"); + png_debug(1, "in png_handle_PLTE"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before PLTE"); + png_chunk_error(png_ptr, "missing IHDR"); + + /* Moved to before the 'after IDAT' check below because otherwise duplicate + * PLTE chunks are potentially ignored (the spec says there shall not be more + * than one PLTE, the error is not treated as benign, so this check trumps + * the requirement that PLTE appears before IDAT.) + */ + else if (png_ptr->mode & PNG_HAVE_PLTE) + png_chunk_error(png_ptr, "duplicate"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { - png_warning(png_ptr, "Invalid PLTE after IDAT"); + /* This is benign because the non-benign error happened before, when an + * IDAT was encountered in a color-mapped image with no PLTE. + */ png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (png_ptr->mode & PNG_HAVE_PLTE) - png_error(png_ptr, "Duplicate PLTE chunk"); png_ptr->mode |= PNG_HAVE_PLTE; - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) + if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) { - png_warning(png_ptr, - "Ignoring PLTE chunk in grayscale PNG"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "ignored in grayscale PNG"); return; } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) + +#ifndef PNG_READ_OPT_PLTE_SUPPORTED if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) { png_crc_finish(png_ptr, length); @@ -456,21 +906,21 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) { + png_crc_finish(png_ptr, length); + if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_warning(png_ptr, "Invalid palette chunk"); - png_crc_finish(png_ptr, length); - return; - } + png_chunk_benign_error(png_ptr, "invalid"); + else - { - png_error(png_ptr, "Invalid palette chunk"); - } + png_chunk_error(png_ptr, "invalid"); + + return; } + /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */ num = (int)length / 3; -#ifndef PNG_NO_POINTER_INDEXING +#ifdef PNG_POINTER_INDEXING_SUPPORTED for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) { png_byte buf[3]; @@ -486,42 +936,51 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_byte buf[3]; png_crc_read(png_ptr, buf, 3); - /* don't depend upon png_color being any order */ + /* Don't depend upon png_color being any order */ palette[i].red = buf[0]; palette[i].green = buf[1]; palette[i].blue = buf[2]; } #endif - /* If we actually NEED the PLTE chunk (ie for a paletted image), we do - whatever the normal CRC configuration tells us. However, if we - have an RGB image, the PLTE can be considered ancillary, so - we will act as though it is. */ -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) + /* If we actually need the PLTE chunk (ie for a paletted image), we do + * whatever the normal CRC configuration tells us. However, if we + * have an RGB image, the PLTE can be considered ancillary, so + * we will act as though it is. + */ +#ifndef PNG_READ_OPT_PLTE_SUPPORTED if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #endif { png_crc_finish(png_ptr, 0); } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) + +#ifndef PNG_READ_OPT_PLTE_SUPPORTED else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ { /* If we don't want to use the data from an ancillary chunk, - we have two options: an error abort, or a warning and we - ignore the data in this chunk (which should be OK, since - it's considered ancillary for a RGB or RGBA image). */ + * we have two options: an error abort, or a warning and we + * ignore the data in this chunk (which should be OK, since + * it's considered ancillary for a RGB or RGBA image). + * + * IMPLEMENTATION NOTE: this is only here because png_crc_finish uses the + * chunk type to determine whether to check the ancillary or the critical + * flags. + */ if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) { if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) { - png_chunk_error(png_ptr, "CRC error"); + png_chunk_benign_error(png_ptr, "CRC error"); } + else { png_chunk_warning(png_ptr, "CRC error"); return; } } + /* Otherwise, we (optionally) emit a warning and use the chunk. */ else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) { @@ -530,175 +989,152 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif + /* TODO: png_set_PLTE has the side effect of setting png_ptr->palette to its + * own copy of the palette. This has the side effect that when png_start_row + * is called (this happens after any call to png_read_update_info) the + * info_ptr palette gets changed. This is extremely unexpected and + * confusing. + * + * Fix this by not sharing the palette in this way. + */ png_set_PLTE(png_ptr, info_ptr, palette, num); -#if defined(PNG_READ_tRNS_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - if (png_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); - png_ptr->num_trans = (png_uint_16)num; - } - if (info_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); - info_ptr->num_trans = (png_uint_16)num; - } - } + /* The three chunks, bKGD, hIST and tRNS *must* appear after PLTE and before + * IDAT. Prior to 1.6.0 this was not checked; instead the code merely + * checked the apparent validity of a tRNS chunk inserted before PLTE on a + * palette PNG. 1.6.0 attempts to rigorously follow the standard and + * therefore does a benign error if the erroneous condition is detected *and* + * cancels the tRNS if the benign error returns. The alternative is to + * amend the standard since it would be rather hypocritical of the standards + * maintainers to ignore it. + */ +#ifdef PNG_READ_tRNS_SUPPORTED + if (png_ptr->num_trans > 0 || + (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)) + { + /* Cancel this because otherwise it would be used if the transforms + * require it. Don't cancel the 'valid' flag because this would prevent + * detection of duplicate chunks. + */ + png_ptr->num_trans = 0; + + if (info_ptr != NULL) + info_ptr->num_trans = 0; + + png_chunk_benign_error(png_ptr, "tRNS must be after"); } #endif +#ifdef PNG_READ_hIST_SUPPORTED + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0) + png_chunk_benign_error(png_ptr, "hIST must be after"); +#endif + +#ifdef PNG_READ_bKGD_SUPPORTED + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0) + png_chunk_benign_error(png_ptr, "bKGD must be after"); +#endif } void /* PRIVATE */ -png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_debug(1, "in png_handle_IEND\n"); + png_debug(1, "in png_handle_IEND"); if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) - { - png_error(png_ptr, "No image in file"); - } + png_chunk_error(png_ptr, "out of place"); png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); - if (length != 0) - { - png_warning(png_ptr, "Incorrect IEND chunk length"); - } png_crc_finish(png_ptr, length); - (void) info_ptr; /* quiet compiler warnings about unused info_ptr */ + if (length != 0) + png_chunk_benign_error(png_ptr, "invalid"); + + PNG_UNUSED(info_ptr) } -#if defined(PNG_READ_gAMA_SUPPORTED) +#ifdef PNG_READ_gAMA_SUPPORTED void /* PRIVATE */ -png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { png_fixed_point igamma; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif png_byte buf[4]; - png_debug(1, "in png_handle_gAMA\n"); + png_debug(1, "in png_handle_gAMA"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before gAMA"); - else if (png_ptr->mode & PNG_HAVE_IDAT) + png_chunk_error(png_ptr, "missing IHDR"); + + else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) { - png_warning(png_ptr, "Invalid gAMA after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place gAMA chunk"); - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate gAMA chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } if (length != 4) { - png_warning(png_ptr, "Incorrect gAMA chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 4); + if (png_crc_finish(png_ptr, 0)) return; - igamma = (png_fixed_point)png_get_uint_32(buf); - /* check for zero gamma */ - if (igamma == 0) - { - png_warning(png_ptr, - "Ignoring gAMA chunk with gamma=0"); - return; - } - -#if defined(PNG_READ_sRGB_SUPPORTED) - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) - if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); -#endif - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ + igamma = png_get_fixed_point(NULL, buf); -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float)igamma / (float)100000.0; -# ifdef PNG_READ_GAMMA_SUPPORTED - png_ptr->gamma = file_gamma; -# endif - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_gAMA_fixed(png_ptr, info_ptr, igamma); -#endif + png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma); + png_colorspace_sync(png_ptr, info_ptr); } #endif -#if defined(PNG_READ_sBIT_SUPPORTED) +#ifdef PNG_READ_sBIT_SUPPORTED void /* PRIVATE */ -png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_size_t truelen; + unsigned int truelen; png_byte buf[4]; - png_debug(1, "in png_handle_sBIT\n"); + png_debug(1, "in png_handle_sBIT"); buf[0] = buf[1] = buf[2] = buf[3] = 0; if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sBIT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) + png_chunk_error(png_ptr, "missing IHDR"); + + else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) { - png_warning(png_ptr, "Invalid sBIT after IDAT"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (png_ptr->mode & PNG_HAVE_PLTE) - { - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sBIT chunk"); - } + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) { - png_warning(png_ptr, "Duplicate sBIT chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); return; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) truelen = 3; + else - truelen = (png_size_t)png_ptr->channels; + truelen = png_ptr->channels; if (length != truelen || length > 4) { - png_warning(png_ptr, "Incorrect sBIT chunk length"); + png_chunk_benign_error(png_ptr, "invalid"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, truelen); + if (png_crc_finish(png_ptr, 0)) return; @@ -709,6 +1145,7 @@ png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_ptr->sig_bit.blue = buf[2]; png_ptr->sig_bit.alpha = buf[3]; } + else { png_ptr->sig_bit.gray = buf[0]; @@ -717,551 +1154,606 @@ png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_ptr->sig_bit.blue = buf[0]; png_ptr->sig_bit.alpha = buf[1]; } + png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); } #endif -#if defined(PNG_READ_cHRM_SUPPORTED) +#ifdef PNG_READ_cHRM_SUPPORTED void /* PRIVATE */ -png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_byte buf[4]; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif - png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue; - - png_uint_32 uint_x, uint_y; + png_byte buf[32]; + png_xy xy; - png_debug(1, "in png_handle_cHRM\n"); + png_debug(1, "in png_handle_cHRM"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before cHRM"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid cHRM after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Missing PLTE before cHRM"); + png_chunk_error(png_ptr, "missing IHDR"); - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) + else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) { - png_warning(png_ptr, "Duplicate cHRM chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } if (length != 32) { - png_warning(png_ptr, "Incorrect cHRM chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); + png_crc_read(png_ptr, buf, 32); - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM white point"); - png_crc_finish(png_ptr, 24); + if (png_crc_finish(png_ptr, 0)) return; - } - int_x_white = (png_fixed_point)uint_x; - int_y_white = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM red point"); - png_crc_finish(png_ptr, 16); + xy.whitex = png_get_fixed_point(NULL, buf); + xy.whitey = png_get_fixed_point(NULL, buf + 4); + xy.redx = png_get_fixed_point(NULL, buf + 8); + xy.redy = png_get_fixed_point(NULL, buf + 12); + xy.greenx = png_get_fixed_point(NULL, buf + 16); + xy.greeny = png_get_fixed_point(NULL, buf + 20); + xy.bluex = png_get_fixed_point(NULL, buf + 24); + xy.bluey = png_get_fixed_point(NULL, buf + 28); + + if (xy.whitex == PNG_FIXED_ERROR || + xy.whitey == PNG_FIXED_ERROR || + xy.redx == PNG_FIXED_ERROR || + xy.redy == PNG_FIXED_ERROR || + xy.greenx == PNG_FIXED_ERROR || + xy.greeny == PNG_FIXED_ERROR || + xy.bluex == PNG_FIXED_ERROR || + xy.bluey == PNG_FIXED_ERROR) + { + png_chunk_benign_error(png_ptr, "invalid values"); return; } - int_x_red = (png_fixed_point)uint_x; - int_y_red = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM green point"); - png_crc_finish(png_ptr, 8); + /* If a colorspace error has already been output skip this chunk */ + if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) return; - } - int_x_green = (png_fixed_point)uint_x; - int_y_green = (png_fixed_point)uint_y; - - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) + if (png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) { - png_warning(png_ptr, "Invalid cHRM blue point"); - png_crc_finish(png_ptr, 0); + png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; + png_colorspace_sync(png_ptr, info_ptr); + png_chunk_benign_error(png_ptr, "duplicate"); return; } - int_x_blue = (png_fixed_point)uint_x; - int_y_blue = (png_fixed_point)uint_y; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float)int_x_white / (float)100000.0; - white_y = (float)int_y_white / (float)100000.0; - red_x = (float)int_x_red / (float)100000.0; - red_y = (float)int_y_red / (float)100000.0; - green_x = (float)int_x_green / (float)100000.0; - green_y = (float)int_y_green / (float)100000.0; - blue_x = (float)int_x_blue / (float)100000.0; - blue_y = (float)int_y_blue / (float)100000.0; -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) - if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB)) - { - if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000)) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", - white_x, white_y, red_x, red_y); - fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", - green_x, green_y, blue_x, blue_y); -#else - fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", - int_x_white, int_y_white, int_x_red, int_y_red); - fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", - int_x_green, int_y_green, int_x_blue, int_y_blue); -#endif -#endif /* PNG_NO_CONSOLE_IO */ - } - png_crc_finish(png_ptr, 0); - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_cHRM_fixed(png_ptr, info_ptr, - int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue); -#endif - if (png_crc_finish(png_ptr, 0)) - return; + png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; + (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy, + 1/*prefer cHRM values*/); + png_colorspace_sync(png_ptr, info_ptr); } #endif -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED void /* PRIVATE */ -png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - int intent; - png_byte buf[1]; + png_byte intent; - png_debug(1, "in png_handle_sRGB\n"); + png_debug(1, "in png_handle_sRGB"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sRGB"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sRGB after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sRGB chunk"); + png_chunk_error(png_ptr, "missing IHDR"); - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) + else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) { - png_warning(png_ptr, "Duplicate sRGB chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } if (length != 1) { - png_warning(png_ptr, "Incorrect sRGB chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } - png_crc_read(png_ptr, buf, 1); + png_crc_read(png_ptr, &intent, 1); + if (png_crc_finish(png_ptr, 0)) return; - intent = buf[0]; - /* check for bad intent */ - if (intent >= PNG_sRGB_INTENT_LAST) - { - png_warning(png_ptr, "Unknown sRGB intent"); + /* If a colorspace error has already been output skip this chunk */ + if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) return; - } -#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)) + /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect + * this. + */ + if (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) { - png_fixed_point igamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - igamma=info_ptr->int_gamma; -#else -# ifdef PNG_FLOATING_POINT_SUPPORTED - igamma=(png_fixed_point)(info_ptr->gamma * 100000.); -# endif -#endif - if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_FIXED_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); -# else -# ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); -# endif -# endif -#endif - } + png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; + png_colorspace_sync(png_ptr, info_ptr); + png_chunk_benign_error(png_ptr, "too many profiles"); + return; } -#endif /* PNG_READ_gAMA_SUPPORTED */ - -#ifdef PNG_READ_cHRM_SUPPORTED -#ifdef PNG_FIXED_POINT_SUPPORTED - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_blue, 6000, 1000)) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); - } -#endif /* PNG_FIXED_POINT_SUPPORTED */ -#endif /* PNG_READ_cHRM_SUPPORTED */ - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); + (void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent); + png_colorspace_sync(png_ptr, info_ptr); } #endif /* PNG_READ_sRGB_SUPPORTED */ -#if defined(PNG_READ_iCCP_SUPPORTED) +#ifdef PNG_READ_iCCP_SUPPORTED void /* PRIVATE */ -png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ +png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +/* Note: this does not properly handle profiles that are > 64K under DOS */ { - png_charp chunkdata; - png_byte compression_type; - png_bytep pC; - png_charp profile; - png_uint_32 skip = 0; - png_uint_32 profile_size, profile_length; - png_size_t slength, prefix_length, data_length; + png_const_charp errmsg = NULL; /* error message output, or no error */ + int finished = 0; /* crc checked */ - png_debug(1, "in png_handle_iCCP\n"); + png_debug(1, "in png_handle_iCCP"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iCCP"); - else if (png_ptr->mode & PNG_HAVE_IDAT) + png_chunk_error(png_ptr, "missing IHDR"); + + else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) { - png_warning(png_ptr, "Invalid iCCP after IDAT"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place iCCP chunk"); - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) + /* Consistent with all the above colorspace handling an obviously *invalid* + * chunk is just ignored, so does not invalidate the color space. An + * alternative is to set the 'invalid' flags at the start of this routine + * and only clear them in they were not set before and all the tests pass. + * The minimum 'deflate' stream is assumed to be just the 2 byte header and 4 + * byte checksum. The keyword must be one character and there is a + * terminator (0) byte and the compression method. + */ + if (length < 9) { - png_warning(png_ptr, "Duplicate iCCP chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too short"); return; } -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) + /* If a colorspace error has already been output skip this chunk */ + if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) { - png_warning(png_ptr, "iCCP chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; + png_crc_finish(png_ptr, length); + return; } -#endif - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) + /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect + * this. + */ + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) == 0) { - png_free(png_ptr, chunkdata); - return; - } + uInt read_length, keyword_length; + char keyword[81]; - chunkdata[slength] = 0x00; + /* Find the keyword; the keyword plus separator and compression method + * bytes can be at most 81 characters long. + */ + read_length = 81; /* maximum */ + if (read_length > length) + read_length = (uInt)length; - for (profile = chunkdata; *profile; profile++) - /* empty loop to find end of name */ ; + png_crc_read(png_ptr, (png_bytep)keyword, read_length); + length -= read_length; - ++profile; + keyword_length = 0; + while (keyword_length < 80 && keyword_length < read_length && + keyword[keyword_length] != 0) + ++keyword_length; - /* there should be at least one zero (the compression type byte) - following the separator, and we should be on it */ - if ( profile >= chunkdata + slength - 1) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Malformed iCCP chunk"); - return; - } + /* TODO: make the keyword checking common */ + if (keyword_length >= 1 && keyword_length <= 79) + { + /* We only understand '0' compression - deflate - so if we get a + * different value we can't safely decode the chunk. + */ + if (keyword_length+1 < read_length && + keyword[keyword_length+1] == PNG_COMPRESSION_TYPE_BASE) + { + read_length -= keyword_length+2; - /* compression_type should always be zero */ - compression_type = *profile++; - if (compression_type) - { - png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); - compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 - wrote nonzero) */ - } + if (png_inflate_claim(png_ptr, png_iCCP, + png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN ? 15 : 0) == Z_OK) + { + Byte profile_header[132]; + Byte local_buffer[PNG_INFLATE_BUF_SIZE]; + png_alloc_size_t size = (sizeof profile_header); - prefix_length = profile - chunkdata; - chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, - slength, prefix_length, &data_length); + png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2); + png_ptr->zstream.avail_in = read_length; + (void)png_inflate_read(png_ptr, local_buffer, + (sizeof local_buffer), &length, profile_header, &size, + 0/*finish: don't, because the output is too small*/); - profile_length = data_length - prefix_length; + if (size == 0) + { + /* We have the ICC profile header; do the basic header checks. + */ + const png_uint_32 profile_length = + png_get_uint_32(profile_header); - if ( prefix_length > data_length || profile_length < 4) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Profile size field missing from iCCP chunk"); - return; - } + if (png_icc_check_length(png_ptr, &png_ptr->colorspace, + keyword, profile_length)) + { + /* The length is apparently ok, so we can check the 132 + * byte header. + */ + if (png_icc_check_header(png_ptr, &png_ptr->colorspace, + keyword, profile_length, profile_header, + png_ptr->color_type)) + { + /* Now read the tag table; a variable size buffer is + * needed at this point, allocate one for the whole + * profile. The header check has already validated + * that none of these stuff will overflow. + */ + const png_uint_32 tag_count = png_get_uint_32( + profile_header+128); + png_bytep profile = png_read_buffer(png_ptr, + profile_length, 2/*silent*/); + + if (profile != NULL) + { + memcpy(profile, profile_header, + (sizeof profile_header)); + + size = 12 * tag_count; + + (void)png_inflate_read(png_ptr, local_buffer, + (sizeof local_buffer), &length, + profile + (sizeof profile_header), &size, 0); + + /* Still expect a a buffer error because we expect + * there to be some tag data! + */ + if (size == 0) + { + if (png_icc_check_tag_table(png_ptr, + &png_ptr->colorspace, keyword, profile_length, + profile)) + { + /* The profile has been validated for basic + * security issues, so read the whole thing in. + */ + size = profile_length - (sizeof profile_header) + - 12 * tag_count; + + (void)png_inflate_read(png_ptr, local_buffer, + (sizeof local_buffer), &length, + profile + (sizeof profile_header) + + 12 * tag_count, &size, 1/*finish*/); + + if (length > 0 && !(png_ptr->flags & + PNG_FLAG_BENIGN_ERRORS_WARN)) + errmsg = "extra compressed data"; + + /* But otherwise allow extra data: */ + else if (size == 0) + { + if (length > 0) + { + /* This can be handled completely, so + * keep going. + */ + png_chunk_warning(png_ptr, + "extra compressed data"); + } + + png_crc_finish(png_ptr, length); + finished = 1; + +# ifdef PNG_sRGB_SUPPORTED + /* Check for a match against sRGB */ + png_icc_set_sRGB(png_ptr, + &png_ptr->colorspace, profile, + png_ptr->zstream.adler); +# endif + + /* Steal the profile for info_ptr. */ + if (info_ptr != NULL) + { + png_free_data(png_ptr, info_ptr, + PNG_FREE_ICCP, 0); + + info_ptr->iccp_name = png_voidcast(char*, + png_malloc_base(png_ptr, + keyword_length+1)); + if (info_ptr->iccp_name != NULL) + { + memcpy(info_ptr->iccp_name, keyword, + keyword_length+1); + info_ptr->iccp_proflen = + profile_length; + info_ptr->iccp_profile = profile; + png_ptr->read_buffer = NULL; /*steal*/ + info_ptr->free_me |= PNG_FREE_ICCP; + info_ptr->valid |= PNG_INFO_iCCP; + } + + else + { + png_ptr->colorspace.flags |= + PNG_COLORSPACE_INVALID; + errmsg = "out of memory"; + } + } + + /* else the profile remains in the read + * buffer which gets reused for subsequent + * chunks. + */ + + if (info_ptr != NULL) + png_colorspace_sync(png_ptr, info_ptr); + + if (errmsg == NULL) + { + png_ptr->zowner = 0; + return; + } + } + + else if (size > 0) + errmsg = "truncated"; + + else + errmsg = png_ptr->zstream.msg; + } + + /* else png_icc_check_tag_table output an error */ + } + + else /* profile truncated */ + errmsg = png_ptr->zstream.msg; + } + + else + errmsg = "out of memory"; + } + + /* else png_icc_check_header output an error */ + } - /* Check the profile_size recorded in the first 32 bits of the ICC profile */ - pC = (png_bytep)(chunkdata+prefix_length); - profile_size = ((*(pC ))<<24) | - ((*(pC+1))<<16) | - ((*(pC+2))<< 8) | - ((*(pC+3)) ); + /* else png_icc_check_length output an error */ + } - if(profile_size < profile_length) - profile_length = profile_size; + else /* profile truncated */ + errmsg = png_ptr->zstream.msg; - if(profile_size > profile_length) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Ignoring truncated iCCP profile."); - return; + /* Release the stream */ + png_ptr->zowner = 0; + } + + else /* png_inflate_claim failed */ + errmsg = png_ptr->zstream.msg; + } + + else + errmsg = "bad compression method"; /* or missing */ + } + + else + errmsg = "bad keyword"; } - png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, - chunkdata + prefix_length, profile_length); - png_free(png_ptr, chunkdata); + else + errmsg = "too many profiles"; + + /* Failure: the reason is in 'errmsg' */ + if (!finished) + png_crc_finish(png_ptr, length); + + png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; + png_colorspace_sync(png_ptr, info_ptr); + if (errmsg != NULL) /* else already output */ + png_chunk_benign_error(png_ptr, errmsg); } #endif /* PNG_READ_iCCP_SUPPORTED */ -#if defined(PNG_READ_sPLT_SUPPORTED) +#ifdef PNG_READ_sPLT_SUPPORTED void /* PRIVATE */ -png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { - png_bytep chunkdata; - png_bytep entry_start; + png_bytep entry_start, buffer; png_sPLT_t new_palette; -#ifdef PNG_NO_POINTER_INDEXING png_sPLT_entryp pp; -#endif - int data_length, entry_size, i; + png_uint_32 data_length; + int entry_size, i; png_uint_32 skip = 0; - png_size_t slength; + png_uint_32 dl; + png_size_t max_dl; - png_debug(1, "in png_handle_sPLT\n"); + png_debug(1, "in png_handle_sPLT"); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + + if (--png_ptr->user_chunk_cache_max == 1) + { + png_warning(png_ptr, "No space in chunk cache for sPLT"); + png_crc_finish(png_ptr, length); + return; + } + } +#endif if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sPLT"); + png_chunk_error(png_ptr, "missing IHDR"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { - png_warning(png_ptr, "Invalid sPLT after IDAT"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } #ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) + if (length > 65535U) { - png_warning(png_ptr, "sPLT chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too large to fit in memory"); + return; } #endif - chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) + buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); + if (buffer == NULL) { - png_free(png_ptr, chunkdata); + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); return; } - chunkdata[slength] = 0x00; - for (entry_start = chunkdata; *entry_start; entry_start++) - /* empty loop to find end of name */ ; + /* WARNING: this may break if size_t is less than 32 bits; it is assumed + * that the PNG_MAX_MALLOC_64K test is enabled in this case, but this is a + * potential breakage point if the types in pngconf.h aren't exactly right. + */ + png_crc_read(png_ptr, buffer, length); + + if (png_crc_finish(png_ptr, skip)) + return; + + buffer[length] = 0; + + for (entry_start = buffer; *entry_start; entry_start++) + /* Empty loop to find end of name */ ; + ++entry_start; - /* a sample depth should follow the separator, and we should be on it */ - if (entry_start > chunkdata + slength - 2) + /* A sample depth should follow the separator, and we should be on it */ + if (entry_start > buffer + length - 2) { - png_free(png_ptr, chunkdata); png_warning(png_ptr, "malformed sPLT chunk"); return; } new_palette.depth = *entry_start++; entry_size = (new_palette.depth == 8 ? 6 : 10); - data_length = (slength - (entry_start - chunkdata)); + /* This must fit in a png_uint_32 because it is derived from the original + * chunk data length. + */ + data_length = length - (png_uint_32)(entry_start - buffer); - /* integrity-check the data length */ + /* Integrity-check the data length */ if (data_length % entry_size) { - png_free(png_ptr, chunkdata); png_warning(png_ptr, "sPLT chunk has bad length"); return; } - new_palette.nentries = (png_int_32) ( data_length / entry_size); - if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX / - png_sizeof(png_sPLT_entry))) + dl = (png_int_32)(data_length / entry_size); + max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry)); + + if (dl > max_dl) { png_warning(png_ptr, "sPLT chunk too long"); return; } + + new_palette.nentries = (png_int_32)(data_length / entry_size); + new_palette.entries = (png_sPLT_entryp)png_malloc_warn( - png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry)); + png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry))); + if (new_palette.entries == NULL) { png_warning(png_ptr, "sPLT chunk requires too much memory"); return; } -#ifndef PNG_NO_POINTER_INDEXING +#ifdef PNG_POINTER_INDEXING_SUPPORTED for (i = 0; i < new_palette.nentries; i++) { - png_sPLT_entryp pp = new_palette.entries + i; + pp = new_palette.entries + i; if (new_palette.depth == 8) { - pp->red = *entry_start++; - pp->green = *entry_start++; - pp->blue = *entry_start++; - pp->alpha = *entry_start++; + pp->red = *entry_start++; + pp->green = *entry_start++; + pp->blue = *entry_start++; + pp->alpha = *entry_start++; } + else { - pp->red = png_get_uint_16(entry_start); entry_start += 2; - pp->green = png_get_uint_16(entry_start); entry_start += 2; - pp->blue = png_get_uint_16(entry_start); entry_start += 2; - pp->alpha = png_get_uint_16(entry_start); entry_start += 2; + pp->red = png_get_uint_16(entry_start); entry_start += 2; + pp->green = png_get_uint_16(entry_start); entry_start += 2; + pp->blue = png_get_uint_16(entry_start); entry_start += 2; + pp->alpha = png_get_uint_16(entry_start); entry_start += 2; } + pp->frequency = png_get_uint_16(entry_start); entry_start += 2; } #else pp = new_palette.entries; + for (i = 0; i < new_palette.nentries; i++) { if (new_palette.depth == 8) { - pp[i].red = *entry_start++; - pp[i].green = *entry_start++; - pp[i].blue = *entry_start++; - pp[i].alpha = *entry_start++; + pp[i].red = *entry_start++; + pp[i].green = *entry_start++; + pp[i].blue = *entry_start++; + pp[i].alpha = *entry_start++; } + else { - pp[i].red = png_get_uint_16(entry_start); entry_start += 2; - pp[i].green = png_get_uint_16(entry_start); entry_start += 2; - pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; - pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; + pp[i].red = png_get_uint_16(entry_start); entry_start += 2; + pp[i].green = png_get_uint_16(entry_start); entry_start += 2; + pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; + pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; + + pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2; } #endif - /* discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)chunkdata; + /* Discard all chunk data except the name and stash that */ + new_palette.name = (png_charp)buffer; png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); - png_free(png_ptr, chunkdata); png_free(png_ptr, new_palette.entries); } #endif /* PNG_READ_sPLT_SUPPORTED */ -#if defined(PNG_READ_tRNS_SUPPORTED) +#ifdef PNG_READ_tRNS_SUPPORTED void /* PRIVATE */ -png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - int bit_mask; - png_debug(1, "in png_handle_tRNS\n"); - - /* For non-indexed color, mask off any bits in the tRNS value that - * exceed the bit depth. Some creators were writing extra bits there. - * This is not needed for indexed color. */ - bit_mask = (1 << png_ptr->bit_depth) - 1; + png_debug(1, "in png_handle_tRNS"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tRNS"); + png_chunk_error(png_ptr, "missing IHDR"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { - png_warning(png_ptr, "Invalid tRNS after IDAT"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { - png_warning(png_ptr, "Duplicate tRNS chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); return; } @@ -1271,58 +1763,60 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if (length != 2) { - png_warning(png_ptr, "Incorrect tRNS chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 2); png_ptr->num_trans = 1; - png_ptr->trans_values.gray = png_get_uint_16(buf) & bit_mask; + png_ptr->trans_color.gray = png_get_uint_16(buf); } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { png_byte buf[6]; if (length != 6) { - png_warning(png_ptr, "Incorrect tRNS chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } - png_crc_read(png_ptr, buf, (png_size_t)length); + + png_crc_read(png_ptr, buf, length); png_ptr->num_trans = 1; - png_ptr->trans_values.red = png_get_uint_16(buf) & bit_mask; - png_ptr->trans_values.green = png_get_uint_16(buf + 2) & bit_mask; - png_ptr->trans_values.blue = png_get_uint_16(buf + 4) & bit_mask; + png_ptr->trans_color.red = png_get_uint_16(buf); + png_ptr->trans_color.green = png_get_uint_16(buf + 2); + png_ptr->trans_color.blue = png_get_uint_16(buf + 4); } + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (!(png_ptr->mode & PNG_HAVE_PLTE)) { - /* Should be an error, but we can cope with it. */ - png_warning(png_ptr, "Missing PLTE before tRNS"); - } - if (length > (png_uint_32)png_ptr->num_palette || - length > PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); + /* TODO: is this actually an error in the ISO spec? */ png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } - if (length == 0) + + if (length > png_ptr->num_palette || length > PNG_MAX_PALETTE_LENGTH || + length == 0) { - png_warning(png_ptr, "Zero length tRNS chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } - png_crc_read(png_ptr, readbuf, (png_size_t)length); + + png_crc_read(png_ptr, readbuf, length); png_ptr->num_trans = (png_uint_16)length; } + else { - png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid with alpha channel"); return; } @@ -1332,136 +1826,147 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) return; } + /* TODO: this is a horrible side effect in the palette case because the + * png_struct ends up with a pointer to the tRNS buffer owned by the + * png_info. Fix this. + */ png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, - &(png_ptr->trans_values)); + &(png_ptr->trans_color)); } #endif -#if defined(PNG_READ_bKGD_SUPPORTED) +#ifdef PNG_READ_bKGD_SUPPORTED void /* PRIVATE */ -png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_size_t truelen; + unsigned int truelen; png_byte buf[6]; + png_color_16 background; - png_debug(1, "in png_handle_bKGD\n"); + png_debug(1, "in png_handle_bKGD"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before bKGD"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid bKGD after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE))) { - png_warning(png_ptr, "Missing PLTE before bKGD"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) { - png_warning(png_ptr, "Duplicate bKGD chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); return; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) truelen = 1; + else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) truelen = 6; + else truelen = 2; if (length != truelen) { - png_warning(png_ptr, "Incorrect bKGD chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, truelen); + if (png_crc_finish(png_ptr, 0)) return; /* We convert the index value into RGB components so that we can allow * arbitrary RGB values for background when we have transparency, and * so it is easy to determine the RGB values of the background color - * from the info_ptr struct. */ + * from the info_ptr struct. + */ if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - png_ptr->background.index = buf[0]; - if(info_ptr->num_palette) + background.index = buf[0]; + + if (info_ptr && info_ptr->num_palette) { - if(buf[0] > info_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect bKGD chunk index value"); - return; - } - png_ptr->background.red = - (png_uint_16)png_ptr->palette[buf[0]].red; - png_ptr->background.green = - (png_uint_16)png_ptr->palette[buf[0]].green; - png_ptr->background.blue = - (png_uint_16)png_ptr->palette[buf[0]].blue; + if (buf[0] >= info_ptr->num_palette) + { + png_chunk_benign_error(png_ptr, "invalid index"); + return; + } + + background.red = (png_uint_16)png_ptr->palette[buf[0]].red; + background.green = (png_uint_16)png_ptr->palette[buf[0]].green; + background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue; } + + else + background.red = background.green = background.blue = 0; + + background.gray = 0; } + else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ { - png_ptr->background.red = - png_ptr->background.green = - png_ptr->background.blue = - png_ptr->background.gray = png_get_uint_16(buf); + background.index = 0; + background.red = + background.green = + background.blue = + background.gray = png_get_uint_16(buf); } + else { - png_ptr->background.red = png_get_uint_16(buf); - png_ptr->background.green = png_get_uint_16(buf + 2); - png_ptr->background.blue = png_get_uint_16(buf + 4); + background.index = 0; + background.red = png_get_uint_16(buf); + background.green = png_get_uint_16(buf + 2); + background.blue = png_get_uint_16(buf + 4); + background.gray = 0; } - png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); + png_set_bKGD(png_ptr, info_ptr, &background); } #endif -#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_READ_hIST_SUPPORTED void /* PRIVATE */ -png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { unsigned int num, i; png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - png_debug(1, "in png_handle_hIST\n"); + png_debug(1, "in png_handle_hIST"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before hIST"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid hIST after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (!(png_ptr->mode & PNG_HAVE_PLTE)) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & PNG_HAVE_IDAT) || !(png_ptr->mode & PNG_HAVE_PLTE)) { - png_warning(png_ptr, "Missing PLTE before hIST"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) { - png_warning(png_ptr, "Duplicate hIST chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); return; } num = length / 2 ; - if (num != (unsigned int) png_ptr->num_palette || num > - (unsigned int) PNG_MAX_PALETTE_LENGTH) + + if (num != png_ptr->num_palette || num > PNG_MAX_PALETTE_LENGTH) { - png_warning(png_ptr, "Incorrect hIST chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } @@ -1480,39 +1985,42 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif -#if defined(PNG_READ_pHYs_SUPPORTED) +#ifdef PNG_READ_pHYs_SUPPORTED void /* PRIVATE */ -png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { png_byte buf[9]; png_uint_32 res_x, res_y; int unit_type; - png_debug(1, "in png_handle_pHYs\n"); + png_debug(1, "in png_handle_pHYs"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pHYs"); + png_chunk_error(png_ptr, "missing IHDR"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { - png_warning(png_ptr, "Invalid pHYs after IDAT"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_warning(png_ptr, "Duplicate pHYs chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); return; } if (length != 9) { - png_warning(png_ptr, "Incorrect pHYs chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 9); + if (png_crc_finish(png_ptr, 0)) return; @@ -1523,39 +2031,42 @@ png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif -#if defined(PNG_READ_oFFs_SUPPORTED) +#ifdef PNG_READ_oFFs_SUPPORTED void /* PRIVATE */ -png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { png_byte buf[9]; png_int_32 offset_x, offset_y; int unit_type; - png_debug(1, "in png_handle_oFFs\n"); + png_debug(1, "in png_handle_oFFs"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before oFFs"); + png_chunk_error(png_ptr, "missing IHDR"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { - png_warning(png_ptr, "Invalid oFFs after IDAT"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) { - png_warning(png_ptr, "Duplicate oFFs chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); return; } if (length != 9) { - png_warning(png_ptr, "Incorrect oFFs chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 9); + if (png_crc_finish(png_ptr, 0)) return; @@ -1566,288 +2077,245 @@ png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif -#if defined(PNG_READ_pCAL_SUPPORTED) -/* read the pCAL chunk (described in the PNG Extensions document) */ +#ifdef PNG_READ_pCAL_SUPPORTED +/* Read the pCAL chunk (described in the PNG Extensions document) */ void /* PRIVATE */ -png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_charp purpose; png_int_32 X0, X1; png_byte type, nparams; - png_charp buf, units, endptr; + png_bytep buffer, buf, units, endptr; png_charpp params; - png_size_t slength; int i; - png_debug(1, "in png_handle_pCAL\n"); + png_debug(1, "in png_handle_pCAL"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pCAL"); + png_chunk_error(png_ptr, "missing IHDR"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { - png_warning(png_ptr, "Invalid pCAL after IDAT"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) { - png_warning(png_ptr, "Duplicate pCAL chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); return; } - png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", - length + 1); - purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (purpose == NULL) - { - png_warning(png_ptr, "No memory for pCAL purpose."); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)purpose, slength); + png_debug1(2, "Allocating and reading pCAL chunk data (%u bytes)", + length + 1); - if (png_crc_finish(png_ptr, 0)) + buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); + + if (buffer == NULL) { - png_free(png_ptr, purpose); + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); return; } - purpose[slength] = 0x00; /* null terminate the last string */ + png_crc_read(png_ptr, buffer, length); + + if (png_crc_finish(png_ptr, 0)) + return; + + buffer[length] = 0; /* Null terminate the last string */ - png_debug(3, "Finding end of pCAL purpose string\n"); - for (buf = purpose; *buf; buf++) - /* empty loop */ ; + png_debug(3, "Finding end of pCAL purpose string"); + for (buf = buffer; *buf; buf++) + /* Empty loop */ ; - endptr = purpose + slength; + endptr = buffer + length; /* We need to have at least 12 bytes after the purpose string - in order to get the parameter information. */ + * in order to get the parameter information. + */ if (endptr <= buf + 12) { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); + png_chunk_benign_error(png_ptr, "invalid"); return; } - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); + png_debug(3, "Reading pCAL X0, X1, type, nparams, and units"); X0 = png_get_int_32((png_bytep)buf+1); X1 = png_get_int_32((png_bytep)buf+5); type = buf[9]; nparams = buf[10]; units = buf + 11; - png_debug(3, "Checking pCAL equation type and number of parameters\n"); + png_debug(3, "Checking pCAL equation type and number of parameters"); /* Check that we have the right number of parameters for known - equation types. */ + * equation types. + */ if ((type == PNG_EQUATION_LINEAR && nparams != 2) || (type == PNG_EQUATION_BASE_E && nparams != 3) || (type == PNG_EQUATION_ARBITRARY && nparams != 3) || (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) { - png_warning(png_ptr, "Invalid pCAL parameters for equation type"); - png_free(png_ptr, purpose); + png_chunk_benign_error(png_ptr, "invalid parameter count"); return; } + else if (type >= PNG_EQUATION_LAST) { - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); + png_chunk_benign_error(png_ptr, "unrecognized equation type"); } for (buf = units; *buf; buf++) /* Empty loop to move past the units string. */ ; - png_debug(3, "Allocating pCAL parameters array\n"); - params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_charp))) ; + png_debug(3, "Allocating pCAL parameters array"); + + params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, + nparams * (sizeof (png_charp)))); + if (params == NULL) - { - png_free(png_ptr, purpose); - png_warning(png_ptr, "No memory for pCAL params."); - return; - } + { + png_chunk_benign_error(png_ptr, "out of memory"); + return; + } /* Get pointers to the start of each parameter string. */ - for (i = 0; i < (int)nparams; i++) + for (i = 0; i < nparams; i++) { buf++; /* Skip the null string terminator from previous parameter. */ - png_debug1(3, "Reading pCAL parameter %d\n", i); - for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++) + png_debug1(3, "Reading pCAL parameter %d", i); + + for (params[i] = (png_charp)buf; buf <= endptr && *buf != 0; buf++) /* Empty loop to move past each parameter string */ ; /* Make sure we haven't run out of data yet */ if (buf > endptr) { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); png_free(png_ptr, params); + png_chunk_benign_error(png_ptr, "invalid data"); return; } } - png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, - units, params); + png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams, + (png_charp)units, params); - png_free(png_ptr, purpose); png_free(png_ptr, params); } #endif -#if defined(PNG_READ_sCAL_SUPPORTED) -/* read the sCAL chunk */ +#ifdef PNG_READ_sCAL_SUPPORTED +/* Read the sCAL chunk */ void /* PRIVATE */ -png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_charp buffer, ep; -#ifdef PNG_FLOATING_POINT_SUPPORTED - double width, height; - png_charp vp; -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp swidth, sheight; -#endif -#endif - png_size_t slength; + png_bytep buffer; + png_size_t i; + int state; - png_debug(1, "in png_handle_sCAL\n"); + png_debug(1, "in png_handle_sCAL"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sCAL"); + png_chunk_error(png_ptr, "missing IHDR"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { - png_warning(png_ptr, "Invalid sCAL after IDAT"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); return; } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) { - png_warning(png_ptr, "Duplicate sCAL chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); return; } - png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", - length + 1); - buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (buffer == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk"); - return; - } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)buffer, slength); - - if (png_crc_finish(png_ptr, 0)) + /* Need unit type, width, \0, height: minimum 4 bytes */ + else if (length < 4) { - png_free(png_ptr, buffer); + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } - buffer[slength] = 0x00; /* null terminate the last string */ + png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)", + length + 1); - ep = buffer + 1; /* skip unit byte */ + buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); -#ifdef PNG_FLOATING_POINT_SUPPORTED - width = png_strtod(png_ptr, ep, &vp); - if (*vp) + if (buffer == NULL) { - png_warning(png_ptr, "malformed width string in sCAL chunk"); - return; + png_chunk_benign_error(png_ptr, "out of memory"); + png_crc_finish(png_ptr, length); + return; } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); - return; - } - png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - for (ep = buffer; *ep; ep++) - /* empty loop */ ; - ep++; + png_crc_read(png_ptr, buffer, length); + buffer[length] = 0; /* Null terminate the last string */ - if (buffer + slength < ep) - { - png_warning(png_ptr, "Truncated sCAL chunk"); -#if defined(PNG_FIXED_POINT_SUPPORTED) && \ - !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); -#endif - png_free(png_ptr, buffer); - return; - } + if (png_crc_finish(png_ptr, 0)) + return; -#ifdef PNG_FLOATING_POINT_SUPPORTED - height = png_strtod(png_ptr, ep, &vp); - if (*vp) + /* Validate the unit. */ + if (buffer[0] != 1 && buffer[0] != 2) { - png_warning(png_ptr, "malformed height string in sCAL chunk"); - return; + png_chunk_benign_error(png_ptr, "invalid unit"); + return; } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); - return; - } - png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - if (buffer + slength < ep -#ifdef PNG_FLOATING_POINT_SUPPORTED - || width <= 0. || height <= 0. -#endif - ) + /* Validate the ASCII numbers, need two ASCII numbers separated by + * a '\0' and they need to fit exactly in the chunk data. + */ + i = 1; + state = 0; + + if (!png_check_fp_number((png_const_charp)buffer, length, &state, &i) || + i >= length || buffer[i++] != 0) + png_chunk_benign_error(png_ptr, "bad width format"); + + else if (!PNG_FP_IS_POSITIVE(state)) + png_chunk_benign_error(png_ptr, "non-positive width"); + + else { - png_warning(png_ptr, "Invalid sCAL data"); - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif - return; - } + png_size_t heighti = i; + state = 0; + if (!png_check_fp_number((png_const_charp)buffer, length, &state, &i) || + i != length) + png_chunk_benign_error(png_ptr, "bad height format"); -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); -#endif -#endif + else if (!PNG_FP_IS_POSITIVE(state)) + png_chunk_benign_error(png_ptr, "non-positive height"); - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif + else + /* This is the (only) success case. */ + png_set_sCAL_s(png_ptr, info_ptr, buffer[0], + (png_charp)buffer+1, (png_charp)buffer+heighti); + } } #endif -#if defined(PNG_READ_tIME_SUPPORTED) +#ifdef PNG_READ_tIME_SUPPORTED void /* PRIVATE */ -png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { png_byte buf[7]; png_time mod_time; - png_debug(1, "in png_handle_tIME\n"); + png_debug(1, "in png_handle_tIME"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Out of place tIME chunk"); + png_chunk_error(png_ptr, "missing IHDR"); + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) { - png_warning(png_ptr, "Duplicate tIME chunk"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); return; } @@ -1856,12 +2324,13 @@ png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if (length != 7) { - png_warning(png_ptr, "Incorrect tIME chunk length"); png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); return; } png_crc_read(png_ptr, buf, 7); + if (png_crc_finish(png_ptr, 0)) return; @@ -1876,644 +2345,1136 @@ png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif -#if defined(PNG_READ_tEXt_SUPPORTED) +#ifdef PNG_READ_tEXt_SUPPORTED /* Note: this does not properly handle chunks that are > 64K under DOS */ void /* PRIVATE */ -png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_textp text_ptr; + png_text text_info; + png_bytep buffer; png_charp key; png_charp text; png_uint_32 skip = 0; - png_size_t slength; - int ret; - png_debug(1, "in png_handle_tEXt\n"); + png_debug(1, "in png_handle_tEXt"); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + + if (--png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); + return; + } + } +#endif if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tEXt"); + png_chunk_error(png_ptr, "missing IHDR"); if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; #ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) + if (length > 65535U) { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too large to fit in memory"); + return; } #endif - key = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (key == NULL) + buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); + + if (buffer == NULL) { - png_warning(png_ptr, "No memory to process text chunk."); + png_chunk_benign_error(png_ptr, "out of memory"); return; } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)key, slength); + + png_crc_read(png_ptr, buffer, length); if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, key); return; - } - key[slength] = 0x00; + key = (png_charp)buffer; + key[length] = 0; for (text = key; *text; text++) - /* empty loop to find end of key */ ; + /* Empty loop to find end of key */ ; - if (text != key + slength) + if (text != key + length) text++; - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr, "Not enough memory to process text chunk."); - png_free(png_ptr, key); - return; - } - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = text; - text_ptr->text_length = png_strlen(text); - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + text_info.compression = PNG_TEXT_COMPRESSION_NONE; + text_info.key = key; + text_info.lang = NULL; + text_info.lang_key = NULL; + text_info.itxt_length = 0; + text_info.text = text; + text_info.text_length = strlen(text); - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - if (ret) - png_warning(png_ptr, "Insufficient memory to process text chunk."); + if (png_set_text_2(png_ptr, info_ptr, &text_info, 1)) + png_warning(png_ptr, "Insufficient memory to process text chunk"); } #endif -#if defined(PNG_READ_zTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ +#ifdef PNG_READ_zTXt_SUPPORTED +/* Note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ -png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_textp text_ptr; - png_charp chunkdata; - png_charp text; - int comp_type; - int ret; - png_size_t slength, prefix_len, data_len; + png_const_charp errmsg = NULL; + png_bytep buffer; + png_uint_32 keyword_length; + + png_debug(1, "in png_handle_zTXt"); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + + if (--png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); + return; + } + } +#endif - png_debug(1, "in png_handle_zTXt\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before zTXt"); + png_chunk_error(png_ptr, "missing IHDR"); if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"zTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif + buffer = png_read_buffer(png_ptr, length, 2/*silent*/); - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) + if (buffer == NULL) { - png_warning(png_ptr,"Out of memory processing zTXt chunk."); - return; + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); + return; } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + + png_crc_read(png_ptr, buffer, length); + if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); return; - } - chunkdata[slength] = 0x00; + /* TODO: also check that the keyword contents match the spec! */ + for (keyword_length = 0; + keyword_length < length && buffer[keyword_length] != 0; + ++keyword_length) + /* Empty loop to find end of name */ ; - for (text = chunkdata; *text; text++) - /* empty loop */ ; + if (keyword_length > 79 || keyword_length < 1) + errmsg = "bad keyword"; + + /* zTXt must have some LZ data after the keyword, although it may expand to + * zero bytes; we need a '\0' at the end of the keyword, the compression type + * then the LZ data: + */ + else if (keyword_length + 3 > length) + errmsg = "truncated"; + + else if (buffer[keyword_length+1] != PNG_COMPRESSION_TYPE_BASE) + errmsg = "unknown compression type"; - /* zTXt must have some text after the chunkdataword */ - if (text >= chunkdata + slength - 2) - { - png_warning(png_ptr, "Truncated zTXt chunk"); - png_free(png_ptr, chunkdata); - return; - } else { - comp_type = *(++text); - if (comp_type != PNG_TEXT_COMPRESSION_zTXt) - { - png_warning(png_ptr, "Unknown compression type in zTXt chunk"); - comp_type = PNG_TEXT_COMPRESSION_zTXt; - } - text++; /* skip the compression_method byte */ - } - prefix_len = text - chunkdata; + png_alloc_size_t uncompressed_length = PNG_SIZE_MAX; - chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, - (png_size_t)length, prefix_len, &data_len); + /* TODO: at present png_decompress_chunk imposes a single application + * level memory limit, this should be split to different values for iCCP + * and text chunks. + */ + if (png_decompress_chunk(png_ptr, length, keyword_length+2, + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + { + png_text text; + + /* It worked; png_ptr->read_buffer now looks like a tEXt chunk except + * for the extra compression type byte and the fact that it isn't + * necessarily '\0' terminated. + */ + buffer = png_ptr->read_buffer; + buffer[uncompressed_length+(keyword_length+2)] = 0; + + text.compression = PNG_TEXT_COMPRESSION_zTXt; + text.key = (png_charp)buffer; + text.text = (png_charp)(buffer + keyword_length+2); + text.text_length = uncompressed_length; + text.itxt_length = 0; + text.lang = NULL; + text.lang_key = NULL; + + if (png_set_text_2(png_ptr, info_ptr, &text, 1)) + errmsg = "insufficient memory"; + } - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) - { - png_warning(png_ptr,"Not enough memory to process zTXt chunk."); - png_free(png_ptr, chunkdata); - return; + else + errmsg = png_ptr->zstream.msg; } - text_ptr->compression = comp_type; - text_ptr->key = chunkdata; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = chunkdata + prefix_len; - text_ptr->text_length = data_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store zTXt chunk."); + if (errmsg != NULL) + png_chunk_benign_error(png_ptr, errmsg); } #endif -#if defined(PNG_READ_iTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ +#ifdef PNG_READ_iTXt_SUPPORTED +/* Note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ -png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_textp text_ptr; - png_charp chunkdata; - png_charp key, lang, text, lang_key; - int comp_flag; - int comp_type = 0; - int ret; - png_size_t slength, prefix_len, data_len; + png_const_charp errmsg = NULL; + png_bytep buffer; + png_uint_32 prefix_length; + + png_debug(1, "in png_handle_iTXt"); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } - png_debug(1, "in png_handle_iTXt\n"); + if (--png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); + return; + } + } +#endif if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iTXt"); + png_chunk_error(png_ptr, "missing IHDR"); if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"iTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif + buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) + if (buffer == NULL) { - png_warning(png_ptr, "No memory to process iTXt chunk."); - return; + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); + return; } - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + + png_crc_read(png_ptr, buffer, length); + if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); return; - } - chunkdata[slength] = 0x00; + /* First the keyword. */ + for (prefix_length=0; + prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* Perform a basic check on the keyword length here. */ + if (prefix_length > 79 || prefix_length < 1) + errmsg = "bad keyword"; + + /* Expect keyword, compression flag, compression type, language, translated + * keyword (both may be empty but are 0 terminated) then the text, which may + * be empty. + */ + else if (prefix_length + 5 > length) + errmsg = "truncated"; + + else if (buffer[prefix_length+1] == 0 || + (buffer[prefix_length+1] == 1 && + buffer[prefix_length+2] == PNG_COMPRESSION_TYPE_BASE)) + { + int compressed = buffer[prefix_length+1] != 0; + png_uint_32 language_offset, translated_keyword_offset; + png_alloc_size_t uncompressed_length = 0; + + /* Now the language tag */ + prefix_length += 3; + language_offset = prefix_length; + + for (; prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* WARNING: the length may be invalid here, this is checked below. */ + translated_keyword_offset = ++prefix_length; + + for (; prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* prefix_length should now be at the trailing '\0' of the translated + * keyword, but it may already be over the end. None of this arithmetic + * can overflow because chunks are at most 2^31 bytes long, but on 16-bit + * systems the available allocaton may overflow. + */ + ++prefix_length; + + if (!compressed && prefix_length <= length) + uncompressed_length = length - prefix_length; + + else if (compressed && prefix_length < length) + { + uncompressed_length = PNG_SIZE_MAX; + + /* TODO: at present png_decompress_chunk imposes a single application + * level memory limit, this should be split to different values for + * iCCP and text chunks. + */ + if (png_decompress_chunk(png_ptr, length, prefix_length, + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + buffer = png_ptr->read_buffer; - for (lang = chunkdata; *lang; lang++) - /* empty loop */ ; - lang++; /* skip NUL separator */ + else + errmsg = png_ptr->zstream.msg; + } - /* iTXt must have a language tag (possibly empty), two compression bytes, - translated keyword (possibly empty), and possibly some text after the - keyword */ + else + errmsg = "truncated"; - if (lang >= chunkdata + slength - 3) - { - png_warning(png_ptr, "Truncated iTXt chunk"); - png_free(png_ptr, chunkdata); - return; + if (errmsg == NULL) + { + png_text text; + + buffer[uncompressed_length+prefix_length] = 0; + + if (compressed) + text.compression = PNG_ITXT_COMPRESSION_NONE; + + else + text.compression = PNG_ITXT_COMPRESSION_zTXt; + + text.key = (png_charp)buffer; + text.lang = (png_charp)buffer + language_offset; + text.lang_key = (png_charp)buffer + translated_keyword_offset; + text.text = (png_charp)buffer + prefix_length; + text.text_length = 0; + text.itxt_length = uncompressed_length; + + if (png_set_text_2(png_ptr, info_ptr, &text, 1)) + errmsg = "insufficient memory"; + } } + else + errmsg = "bad compression info"; + + if (errmsg != NULL) + png_chunk_benign_error(png_ptr, errmsg); +} +#endif + +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +/* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */ +static int +png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) +{ + png_alloc_size_t limit = PNG_SIZE_MAX; + + if (png_ptr->unknown_chunk.data != NULL) { - comp_flag = *lang++; - comp_type = *lang++; + png_free(png_ptr, png_ptr->unknown_chunk.data); + png_ptr->unknown_chunk.data = NULL; } - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ +# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED + if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < limit) + limit = png_ptr->user_chunk_malloc_max; + +# elif PNG_USER_CHUNK_MALLOC_MAX > 0 + if (PNG_USER_CHUNK_MALLOC_MAX < limit) + limit = PNG_USER_CHUNK_MALLOC_MAX; +# endif - if (lang_key >= chunkdata + slength) + if (length <= limit) { - png_warning(png_ptr, "Truncated iTXt chunk"); - png_free(png_ptr, chunkdata); - return; + PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name); + /* The following is safe because of the PNG_SIZE_MAX init above */ + png_ptr->unknown_chunk.size = (png_size_t)length/*SAFE*/; + /* 'mode' is a flag array, only the bottom four bits matter here */ + png_ptr->unknown_chunk.location = (png_byte)png_ptr->mode/*SAFE*/; + + if (length == 0) + png_ptr->unknown_chunk.data = NULL; + + else + { + /* Do a 'warn' here - it is handled below. */ + png_ptr->unknown_chunk.data = png_voidcast(png_bytep, + png_malloc_warn(png_ptr, length)); + } } - for (text = lang_key; *text; text++) - /* empty loop */ ; - text++; /* skip NUL separator */ - if (text >= chunkdata + slength) + if (png_ptr->unknown_chunk.data == NULL && length > 0) { - png_warning(png_ptr, "Malformed iTXt chunk"); - png_free(png_ptr, chunkdata); - return; + /* This is benign because we clean up correctly */ + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "unknown chunk exceeds memory limits"); + return 0; } - prefix_len = text - chunkdata; - - key=chunkdata; - if (comp_flag) - chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, - (size_t)length, prefix_len, &data_len); else - data_len=png_strlen(chunkdata + prefix_len); - text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); - if (text_ptr == NULL) { - png_warning(png_ptr,"Not enough memory to process iTXt chunk."); - png_free(png_ptr, chunkdata); - return; + if (length > 0) + png_crc_read(png_ptr, png_ptr->unknown_chunk.data, length); + png_crc_finish(png_ptr, 0); + return 1; } - text_ptr->compression = (int)comp_flag + 1; - text_ptr->lang_key = chunkdata+(lang_key-key); - text_ptr->lang = chunkdata+(lang-key); - text_ptr->itxt_length = data_len; - text_ptr->text_length = 0; - text_ptr->key = chunkdata; - text_ptr->text = chunkdata + prefix_len; - - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); - if (ret) - png_error(png_ptr, "Insufficient memory to store iTXt chunk."); } -#endif +#endif /* PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ -/* This function is called when we haven't found a handler for a - chunk. If there isn't a problem with the chunk itself (ie bad - chunk name, CRC, or a critical chunk), the chunk is silently ignored - -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which - case it will be saved away to be written out later. */ +/* Handle an unknown, or known but disabled, chunk */ void /* PRIVATE */ -png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, + png_uint_32 length, int keep) { - png_uint_32 skip = 0; + int handled = 0; /* the chunk was handled */ + + png_debug(1, "in png_handle_unknown"); + +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED + /* NOTE: this code is based on the code in libpng-1.4.12 except for fixing + * the bug which meant that setting a non-default behavior for a specific + * chunk would be ignored (the default was always used unless a user + * callback was installed). + * + * 'keep' is the value from the png_chunk_unknown_handling, the setting for + * this specific chunk_name, if PNG_HANDLE_AS_UNKNOWN_SUPPORTED, if not it + * will always be PNG_HANDLE_CHUNK_AS_DEFAULT and it needs to be set here. + * This is just an optimization to avoid multiple calls to the lookup + * function. + */ +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name); +# endif +# endif - png_debug(1, "in png_handle_unknown\n"); + /* One of the following methods will read the chunk or skip it (at least one + * of these is always defined because this is the only way to switch on + * PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + */ +# ifdef PNG_READ_USER_CHUNKS_SUPPORTED + /* The user callback takes precedence over the chunk keep value, but the + * keep value is still required to validate a save of a critical chunk. + */ + if (png_ptr->read_user_chunk_fn != NULL) + { + if (png_cache_unknown_chunk(png_ptr, length)) + { + /* Callback to user unknown chunk handler */ + int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr, + &png_ptr->unknown_chunk); + + /* ret is: + * negative: An error occured, png_chunk_error will be called. + * zero: The chunk was not handled, the chunk will be discarded + * unless png_set_keep_unknown_chunks has been used to set + * a 'keep' behavior for this particular chunk, in which + * case that will be used. A critical chunk will cause an + * error at this point unless it is to be saved. + * positive: The chunk was handled, libpng will ignore/discard it. + */ + if (ret < 0) + png_chunk_error(png_ptr, "error in user chunk"); - if (png_ptr->mode & PNG_HAVE_IDAT) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IDAT; -#endif - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ - png_ptr->mode |= PNG_AFTER_IDAT; - } + else if (ret == 0) + { + /* If the keep value is 'default' or 'never' override it, but + * still error out on critical chunks unless the keep value is + * 'always' While this is weird it is the behavior in 1.4.12. + * A possible improvement would be to obey the value set for the + * chunk, but this would be an API change that would probably + * damage some applications. + * + * The png_app_warning below catches the case that matters, where + * the application has not set specific save or ignore for this + * chunk or global save or ignore. + */ + if (keep < PNG_HANDLE_CHUNK_IF_SAFE) + { +# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE) + { + png_chunk_warning(png_ptr, "Saving unknown chunk:"); + png_app_warning(png_ptr, + "forcing save of an unhandled chunk;" + " please call png_set_keep_unknown_chunks"); + /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ + } +# endif + keep = PNG_HANDLE_CHUNK_IF_SAFE; + } + } - png_check_chunk_name(png_ptr, png_ptr->chunk_name); + else /* chunk was handled */ + { + handled = 1; + /* Critical chunks can be safely discarded at this point. */ + keep = PNG_HANDLE_CHUNK_NEVER; + } + } - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - } + else + keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */ + } -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) || - (png_ptr->read_user_chunk_fn != NULL)) - { -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - png_strncpy((png_charp)png_ptr->unknown_chunk.name, - (png_charp)png_ptr->chunk_name, 5); - png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); - png_ptr->unknown_chunk.size = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - int ret; - ret = (*(png_ptr->read_user_chunk_fn)) - (png_ptr, &png_ptr->unknown_chunk); - if (ret < 0) - png_chunk_error(png_ptr, "error in user chunk"); - if (ret == 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - png_set_unknown_chunks(png_ptr, info_ptr, - &png_ptr->unknown_chunk, 1); - } - } -#else - png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); -#endif - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } - else -#endif - skip = length; + else + /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */ +# endif /* PNG_READ_USER_CHUNKS_SUPPORTED */ - png_crc_finish(png_ptr, skip); +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + { + /* keep is currently just the per-chunk setting, if there was no + * setting change it to the global default now (not that this may + * still be AS_DEFAULT) then obtain the cache of the chunk if required, + * if not simply skip the chunk. + */ + if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT) + keep = png_ptr->unknown_default; + + if (keep == PNG_HANDLE_CHUNK_ALWAYS || + (keep == PNG_HANDLE_CHUNK_IF_SAFE && + PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))) + { + if (!png_cache_unknown_chunk(png_ptr, length)) + keep = PNG_HANDLE_CHUNK_NEVER; + } -#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) - (void) info_ptr; /* quiet compiler warnings about unused info_ptr */ -#endif + else + png_crc_finish(png_ptr, length); + } +# else +# ifndef PNG_READ_USER_CHUNKS_SUPPORTED +# error no method to support READ_UNKNOWN_CHUNKS +# endif + + { + /* If here there is no read callback pointer set and no support is + * compiled in to just save the unknown chunks, so simply skip this + * chunk. If 'keep' is something other than AS_DEFAULT or NEVER then + * the app has erroneously asked for unknown chunk saving when there + * is no support. + */ + if (keep > PNG_HANDLE_CHUNK_NEVER) + png_app_error(png_ptr, "no unknown chunk support available"); + + png_crc_finish(png_ptr, length); + } +# endif + +# ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED + /* Now store the chunk in the chunk list if appropriate, and if the limits + * permit it. + */ + if (keep == PNG_HANDLE_CHUNK_ALWAYS || + (keep == PNG_HANDLE_CHUNK_IF_SAFE && + PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))) + { +# ifdef PNG_USER_LIMITS_SUPPORTED + switch (png_ptr->user_chunk_cache_max) + { + case 2: + png_ptr->user_chunk_cache_max = 1; + png_chunk_benign_error(png_ptr, "no space in chunk cache"); + /* FALL THROUGH */ + case 1: + /* NOTE: prior to 1.6.0 this case resulted in an unknown critical + * chunk being skipped, now there will be a hard error below. + */ + break; + + default: /* not at limit */ + --(png_ptr->user_chunk_cache_max); + /* FALL THROUGH */ + case 0: /* no limit */ +# endif /* PNG_USER_LIMITS_SUPPORTED */ + /* Here when the limit isn't reached or when limits are compiled + * out; store the chunk. + */ + png_set_unknown_chunks(png_ptr, info_ptr, + &png_ptr->unknown_chunk, 1); + handled = 1; +# ifdef PNG_USER_LIMITS_SUPPORTED + break; + } +# endif + } +# else /* no store support! */ + PNG_UNUSED(info_ptr) +# error untested code (reading unknown chunks with no store support) +# endif + + /* Regardless of the error handling below the cached data (if any) can be + * freed now. Notice that the data is not freed if there is a png_error, but + * it will be freed by destroy_read_struct. + */ + if (png_ptr->unknown_chunk.data != NULL) + png_free(png_ptr, png_ptr->unknown_chunk.data); + png_ptr->unknown_chunk.data = NULL; + +#else /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ + /* There is no support to read an unknown chunk, so just skip it. */ + png_crc_finish(png_ptr, length); + PNG_UNUSED(info_ptr) + PNG_UNUSED(keep) +#endif /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ + + /* Check for unhandled critical chunks */ + if (!handled && PNG_CHUNK_CRITICAL(png_ptr->chunk_name)) + png_chunk_error(png_ptr, "unhandled critical chunk"); } /* This function is called to verify that a chunk name is valid. - This function can't have the "critical chunk check" incorporated - into it, since in the future we will need to be able to call user - functions to handle unknown critical chunks after we check that - the chunk name itself is valid. */ + * This function can't have the "critical chunk check" incorporated + * into it, since in the future we will need to be able to call user + * functions to handle unknown critical chunks after we check that + * the chunk name itself is valid. + */ -#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) +/* Bit hacking: the test for an invalid byte in the 4 byte chunk name is: + * + * ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) + */ void /* PRIVATE */ -png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) +png_check_chunk_name(png_structrp png_ptr, png_uint_32 chunk_name) { - png_debug(1, "in png_check_chunk_name\n"); - if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || - isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) + int i; + + png_debug(1, "in png_check_chunk_name"); + + for (i=1; i<=4; ++i) { - png_chunk_error(png_ptr, "invalid chunk type"); + int c = chunk_name & 0xff; + + if (c < 65 || c > 122 || (c > 90 && c < 97)) + png_chunk_error(png_ptr, "invalid chunk type"); + + chunk_name >>= 8; } } -/* Combines the row recently read in with the existing pixels in the - row. This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined, - a zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ - +/* Combines the row recently read in with the existing pixels in the row. This + * routine takes care of alpha and transparency if requested. This routine also + * handles the two methods of progressive display of interlaced images, + * depending on the 'display' value; if 'display' is true then the whole row + * (dp) is filled from the start by replicating the available pixels. If + * 'display' is false only those pixels present in the pass are filled in. + */ void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) +png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) { - png_debug(1,"in png_combine_row\n"); - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width)); - } - else - { - switch (png_ptr->row_info.pixel_depth) + unsigned int pixel_depth = png_ptr->transformed_pixel_depth; + png_const_bytep sp = png_ptr->row_buf + 1; + png_uint_32 row_width = png_ptr->width; + unsigned int pass = png_ptr->pass; + png_bytep end_ptr = 0; + png_byte end_byte = 0; + unsigned int end_mask; + + png_debug(1, "in png_combine_row"); + + /* Added in 1.5.6: it should not be possible to enter this routine until at + * least one row has been read from the PNG data and transformed. + */ + if (pixel_depth == 0) + png_error(png_ptr, "internal row logic error"); + + /* Added in 1.5.4: the pixel depth should match the information returned by + * any call to png_read_update_info at this point. Do not continue if we got + * this wrong. + */ + if (png_ptr->info_rowbytes != 0 && png_ptr->info_rowbytes != + PNG_ROWBYTES(pixel_depth, row_width)) + png_error(png_ptr, "internal row size calculation error"); + + /* Don't expect this to ever happen: */ + if (row_width == 0) + png_error(png_ptr, "internal row width error"); + + /* Preserve the last byte in cases where only part of it will be overwritten, + * the multiply below may overflow, we don't care because ANSI-C guarantees + * we get the low bits. + */ + end_mask = (pixel_depth * row_width) & 7; + if (end_mask != 0) + { + /* end_ptr == NULL is a flag to say do nothing */ + end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1; + end_byte = *end_ptr; +# ifdef PNG_READ_PACKSWAP_SUPPORTED + if (png_ptr->transformations & PNG_PACKSWAP) /* little-endian byte */ + end_mask = 0xff << end_mask; + + else /* big-endian byte */ +# endif + end_mask = 0xff >> end_mask; + /* end_mask is now the bits to *keep* from the destination row */ + } + + /* For non-interlaced images this reduces to a memcpy(). A memcpy() + * will also happen if interlacing isn't supported or if the application + * does not call png_set_interlace_handling(). In the latter cases the + * caller just gets a sequence of the unexpanded rows from each interlace + * pass. + */ +#ifdef PNG_READ_INTERLACING_SUPPORTED + if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE) && + pass < 6 && (display == 0 || + /* The following copies everything for 'display' on passes 0, 2 and 4. */ + (display == 1 && (pass & 1) != 0))) + { + /* Narrow images may have no bits in a pass; the caller should handle + * this, but this test is cheap: + */ + if (row_width <= PNG_PASS_START_COL(pass)) + return; + + if (pixel_depth < 8) { - case 1: + /* For pixel depths up to 4 bpp the 8-pixel mask can be expanded to fit + * into 32 bits, then a single loop over the bytes using the four byte + * values in the 32-bit mask can be used. For the 'display' option the + * expanded mask may also not require any masking within a byte. To + * make this work the PACKSWAP option must be taken into account - it + * simply requires the pixels to be reversed in each byte. + * + * The 'regular' case requires a mask for each of the first 6 passes, + * the 'display' case does a copy for the even passes in the range + * 0..6. This has already been handled in the test above. + * + * The masks are arranged as four bytes with the first byte to use in + * the lowest bits (little-endian) regardless of the order (PACKSWAP or + * not) of the pixels in each byte. + * + * NOTE: the whole of this logic depends on the caller of this function + * only calling it on rows appropriate to the pass. This function only + * understands the 'x' logic; the 'y' logic is handled by the caller. + * + * The following defines allow generation of compile time constant bit + * masks for each pixel depth and each possibility of swapped or not + * swapped bytes. Pass 'p' is in the range 0..6; 'x', a pixel index, + * is in the range 0..7; and the result is 1 if the pixel is to be + * copied in the pass, 0 if not. 'S' is for the sparkle method, 'B' + * for the block method. + * + * With some compilers a compile time expression of the general form: + * + * (shift >= 32) ? (a >> (shift-32)) : (b >> shift) + * + * Produces warnings with values of 'shift' in the range 33 to 63 + * because the right hand side of the ?: expression is evaluated by + * the compiler even though it isn't used. Microsoft Visual C (various + * versions) and the Intel C compiler are known to do this. To avoid + * this the following macros are used in 1.5.6. This is a temporary + * solution to avoid destabilizing the code during the release process. + */ +# if PNG_USE_COMPILE_TIME_MASKS +# define PNG_LSR(x,s) ((x)>>((s) & 0x1f)) +# define PNG_LSL(x,s) ((x)<<((s) & 0x1f)) +# else +# define PNG_LSR(x,s) ((x)>>(s)) +# define PNG_LSL(x,s) ((x)<<(s)) +# endif +# define S_COPY(p,x) (((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\ + PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1) +# define B_COPY(p,x) (((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\ + PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1) + + /* Return a mask for pass 'p' pixel 'x' at depth 'd'. The mask is + * little endian - the first pixel is at bit 0 - however the extra + * parameter 's' can be set to cause the mask position to be swapped + * within each byte, to match the PNG format. This is done by XOR of + * the shift with 7, 6 or 4 for bit depths 1, 2 and 4. + */ +# define PIXEL_MASK(p,x,d,s) \ + (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0)))) + + /* Hence generate the appropriate 'block' or 'sparkle' pixel copy mask. + */ +# define S_MASKx(p,x,d,s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) +# define B_MASKx(p,x,d,s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) + + /* Combine 8 of these to get the full mask. For the 1-bpp and 2-bpp + * cases the result needs replicating, for the 4-bpp case the above + * generates a full 32 bits. + */ +# define MASK_EXPAND(m,d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1))) + +# define S_MASK(p,d,s) MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\ + S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\ + S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d) + +# define B_MASK(p,d,s) MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\ + B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\ + B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d) + +#if PNG_USE_COMPILE_TIME_MASKS + /* Utility macros to construct all the masks for a depth/swap + * combination. The 's' parameter says whether the format is PNG + * (big endian bytes) or not. Only the three odd-numbered passes are + * required for the display/block algorithm. + */ +# define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\ + S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) } + +# define B_MASKS(d,s) { B_MASK(1,d,s), S_MASK(3,d,s), S_MASK(5,d,s) } + +# define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2)) + + /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and + * then pass: + */ + static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] = { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_inc, s_start, s_end; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) + /* Little-endian byte masks for PACKSWAP */ + { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) }, + /* Normal (big-endian byte) masks - PNG format */ + { S_MASKS(1,1), S_MASKS(2,1), S_MASKS(4,1) } + }; + + /* display_mask has only three entries for the odd passes, so index by + * pass>>1. + */ + static PNG_CONST png_uint_32 display_mask[2][3][3] = + { + /* Little-endian byte masks for PACKSWAP */ + { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) }, + /* Normal (big-endian byte) masks - PNG format */ + { B_MASKS(1,1), B_MASKS(2,1), B_MASKS(4,1) } + }; + +# define MASK(pass,depth,display,png)\ + ((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\ + row_mask[png][DEPTH_INDEX(depth)][pass]) + +#else /* !PNG_USE_COMPILE_TIME_MASKS */ + /* This is the runtime alternative: it seems unlikely that this will + * ever be either smaller or faster than the compile time approach. + */ +# define MASK(pass,depth,display,png)\ + ((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png)) +#endif /* !PNG_USE_COMPILE_TIME_MASKS */ + + /* Use the appropriate mask to copy the required bits. In some cases + * the byte mask will be 0 or 0xff, optimize these cases. row_width is + * the number of pixels, but the code copies bytes, so it is necessary + * to special case the end. + */ + png_uint_32 pixels_per_byte = 8 / pixel_depth; + png_uint_32 mask; + +# ifdef PNG_READ_PACKSWAP_SUPPORTED if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } + mask = MASK(pass, pixel_depth, display, 0); + else -#endif +# endif + mask = MASK(pass, pixel_depth, display, 1); + + for (;;) + { + png_uint_32 m; + + /* It doesn't matter in the following if png_uint_32 has more than + * 32 bits because the high bits always match those in m<<24; it is, + * however, essential to use OR here, not +, because of this. + */ + m = mask; + mask = (m >> 8) | (m << 24); /* rotate right to good compilers */ + m &= 0xff; + + if (m != 0) /* something to copy */ { - s_start = 7; - s_end = 0; - s_inc = -1; + if (m != 0xff) + *dp = (png_byte)((*dp & ~m) | (*sp & m)); + else + *dp = *sp; } - shift = s_start; + /* NOTE: this may overwrite the last byte with garbage if the image + * is not an exact number of bytes wide; libpng has always done + * this. + */ + if (row_width <= pixels_per_byte) + break; /* May need to restore part of the last byte */ - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - int value; + row_width -= pixels_per_byte; + ++dp; + ++sp; + } + } - value = (*sp >> shift) & 0x01; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } + else /* pixel_depth >= 8 */ + { + unsigned int bytes_to_copy, bytes_to_jump; - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; + /* Validate the depth - it must be a multiple of 8 */ + if (pixel_depth & 7) + png_error(png_ptr, "invalid user transform pixel depth"); - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 2: + pixel_depth >>= 3; /* now in bytes */ + row_width *= pixel_depth; + + /* Regardless of pass number the Adam 7 interlace always results in a + * fixed number of pixels to copy then to skip. There may be a + * different number of pixels to skip at the start though. + */ { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; + unsigned int offset = PNG_PASS_START_COL(pass) * pixel_depth; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } + row_width -= offset; + dp += offset; + sp += offset; + } - shift = s_start; + /* Work out the bytes to copy. */ + if (display) + { + /* When doing the 'block' algorithm the pixel in the pass gets + * replicated to adjacent pixels. This is why the even (0,2,4,6) + * passes are skipped above - the entire expanded row is copied. + */ + bytes_to_copy = (1<<((6-pass)>>1)) * pixel_depth; - for (i = 0; i < row_width; i++) - { - if (m & mask) + /* But don't allow this number to exceed the actual row width. */ + if (bytes_to_copy > row_width) + bytes_to_copy = row_width; + } + + else /* normal row; Adam7 only ever gives us one pixel to copy. */ + bytes_to_copy = pixel_depth; + + /* In Adam7 there is a constant offset between where the pixels go. */ + bytes_to_jump = PNG_PASS_COL_OFFSET(pass) * pixel_depth; + + /* And simply copy these bytes. Some optimization is possible here, + * depending on the value of 'bytes_to_copy'. Special case the low + * byte counts, which we know to be frequent. + * + * Notice that these cases all 'return' rather than 'break' - this + * avoids an unnecessary test on whether to restore the last byte + * below. + */ + switch (bytes_to_copy) + { + case 1: + for (;;) { - value = (*sp >> shift) & 0x03; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); + *dp = *sp; + + if (row_width <= bytes_to_jump) + return; + + dp += bytes_to_jump; + sp += bytes_to_jump; + row_width -= bytes_to_jump; } - if (shift == s_end) + case 2: + /* There is a possibility of a partial copy at the end here; this + * slows the code down somewhat. + */ + do { - shift = s_start; - sp++; - dp++; + dp[0] = sp[0], dp[1] = sp[1]; + + if (row_width <= bytes_to_jump) + return; + + sp += bytes_to_jump; + dp += bytes_to_jump; + row_width -= bytes_to_jump; } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 4: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; + while (row_width > 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; + /* And there can only be one byte left at this point: */ + *dp = *sp; + return; - for (i = 0; i < row_width; i++) - { - if (m & mask) + case 3: + /* This can only be the RGB case, so each copy is exactly one + * pixel and it is not necessary to check for a partial copy. + */ + for(;;) { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); + dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2]; + + if (row_width <= bytes_to_jump) + return; + + sp += bytes_to_jump; + dp += bytes_to_jump; + row_width -= bytes_to_jump; } - if (shift == s_end) + default: +#if PNG_ALIGN_TYPE != PNG_ALIGN_NONE + /* Check for double byte alignment and, if possible, use a + * 16-bit copy. Don't attempt this for narrow images - ones that + * are less than an interlace panel wide. Don't attempt it for + * wide bytes_to_copy either - use the memcpy there. + */ + if (bytes_to_copy < 16 /*else use memcpy*/ && + png_isaligned(dp, png_uint_16) && + png_isaligned(sp, png_uint_16) && + bytes_to_copy % (sizeof (png_uint_16)) == 0 && + bytes_to_jump % (sizeof (png_uint_16)) == 0) { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - default: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - png_byte m = 0x80; + /* Everything is aligned for png_uint_16 copies, but try for + * png_uint_32 first. + */ + if (png_isaligned(dp, png_uint_32) && + png_isaligned(sp, png_uint_32) && + bytes_to_copy % (sizeof (png_uint_32)) == 0 && + bytes_to_jump % (sizeof (png_uint_32)) == 0) + { + png_uint_32p dp32 = png_aligncast(png_uint_32p,dp); + png_const_uint_32p sp32 = png_aligncastconst( + png_const_uint_32p, sp); + size_t skip = (bytes_to_jump-bytes_to_copy) / + (sizeof (png_uint_32)); + + do + { + size_t c = bytes_to_copy; + do + { + *dp32++ = *sp32++; + c -= (sizeof (png_uint_32)); + } + while (c > 0); + + if (row_width <= bytes_to_jump) + return; + + dp32 += skip; + sp32 += skip; + row_width -= bytes_to_jump; + } + while (bytes_to_copy <= row_width); + + /* Get to here when the row_width truncates the final copy. + * There will be 1-3 bytes left to copy, so don't try the + * 16-bit loop below. + */ + dp = (png_bytep)dp32; + sp = (png_const_bytep)sp32; + do + *dp++ = *sp++; + while (--row_width > 0); + return; + } + /* Else do it in 16-bit quantities, but only if the size is + * not too large. + */ + else + { + png_uint_16p dp16 = png_aligncast(png_uint_16p, dp); + png_const_uint_16p sp16 = png_aligncastconst( + png_const_uint_16p, sp); + size_t skip = (bytes_to_jump-bytes_to_copy) / + (sizeof (png_uint_16)); + + do + { + size_t c = bytes_to_copy; + do + { + *dp16++ = *sp16++; + c -= (sizeof (png_uint_16)); + } + while (c > 0); + + if (row_width <= bytes_to_jump) + return; + + dp16 += skip; + sp16 += skip; + row_width -= bytes_to_jump; + } + while (bytes_to_copy <= row_width); + + /* End of row - 1 byte left, bytes_to_copy > row_width: */ + dp = (png_bytep)dp16; + sp = (png_const_bytep)sp16; + do + *dp++ = *sp++; + while (--row_width > 0); + return; + } + } +#endif /* PNG_ALIGN_ code */ - for (i = 0; i < row_width; i++) - { - if (m & mask) + /* The true default - use a memcpy: */ + for (;;) { - png_memcpy(dp, sp, pixel_bytes); - } + memcpy(dp, sp, bytes_to_copy); - sp += pixel_bytes; - dp += pixel_bytes; + if (row_width <= bytes_to_jump) + return; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; + sp += bytes_to_jump; + dp += bytes_to_jump; + row_width -= bytes_to_jump; + if (bytes_to_copy > row_width) + bytes_to_copy = row_width; + } } - } + + /* NOT REACHED*/ + } /* pixel_depth >= 8 */ + + /* Here if pixel_depth < 8 to check 'end_ptr' below. */ } + else +#endif + + /* If here then the switch above wasn't used so just memcpy the whole row + * from the temporary row buffer (notice that this overwrites the end of the + * destination row if it is a partial byte.) + */ + memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width)); + + /* Restore the overwritten bits from the last byte if necessary. */ + if (end_ptr != NULL) + *end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask)); } #ifdef PNG_READ_INTERLACING_SUPPORTED -/* OLD pre-1.0.9 interface: -void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations) - */ void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) +png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, + png_uint_32 transformations /* Because these may affect the byte layout */) { - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* offset to next interlace block */ - PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Offset to next interlace block */ + static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - png_debug(1,"in png_do_read_interlace\n"); + png_debug(1, "in png_do_read_interlace"); if (row != NULL && row_info != NULL) { png_uint_32 final_width; @@ -2533,7 +3494,7 @@ png_do_read_interlace(png_structp png_ptr) png_uint_32 i; int j; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (transformations & PNG_PACKSWAP) { sshift = (int)((row_info->width + 7) & 0x07); @@ -2542,6 +3503,7 @@ png_do_read_interlace(png_structp png_ptr) s_end = 0; s_inc = -1; } + else #endif { @@ -2557,26 +3519,32 @@ png_do_read_interlace(png_structp png_ptr) v = (png_byte)((*sp >> sshift) & 0x01); for (j = 0; j < jstop; j++) { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); + unsigned int tmp = *dp & (0x7f7f >> (7 - dshift)); + tmp |= v << dshift; + *dp = (png_byte)(tmp & 0xff); + if (dshift == s_end) { dshift = s_start; dp--; } + else dshift += s_inc; } + if (sshift == s_end) { sshift = s_start; sp--; } + else sshift += s_inc; } break; } + case 2: { png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); @@ -2586,7 +3554,7 @@ png_do_read_interlace(png_structp png_ptr) int jstop = png_pass_inc[pass]; png_uint_32 i; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (transformations & PNG_PACKSWAP) { sshift = (int)(((row_info->width + 3) & 0x03) << 1); @@ -2595,6 +3563,7 @@ png_do_read_interlace(png_structp png_ptr) s_end = 0; s_inc = -2; } + else #endif { @@ -2613,26 +3582,32 @@ png_do_read_interlace(png_structp png_ptr) v = (png_byte)((*sp >> sshift) & 0x03); for (j = 0; j < jstop; j++) { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); + unsigned int tmp = *dp & (0x3f3f >> (6 - dshift)); + tmp |= v << dshift; + *dp = (png_byte)(tmp & 0xff); + if (dshift == s_end) { dshift = s_start; dp--; } + else dshift += s_inc; } + if (sshift == s_end) { sshift = s_start; sp--; } + else sshift += s_inc; } break; } + case 4: { png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); @@ -2642,7 +3617,7 @@ png_do_read_interlace(png_structp png_ptr) png_uint_32 i; int jstop = png_pass_inc[pass]; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (transformations & PNG_PACKSWAP) { sshift = (int)(((row_info->width + 1) & 0x01) << 2); @@ -2651,6 +3626,7 @@ png_do_read_interlace(png_structp png_ptr) s_end = 0; s_inc = -4; } + else #endif { @@ -2663,35 +3639,44 @@ png_do_read_interlace(png_structp png_ptr) for (i = 0; i < row_info->width; i++) { - png_byte v = (png_byte)((*sp >> sshift) & 0xf); + png_byte v = (png_byte)((*sp >> sshift) & 0x0f); int j; for (j = 0; j < jstop; j++) { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); + unsigned int tmp = *dp & (0xf0f >> (4 - dshift)); + tmp |= v << dshift; + *dp = (png_byte)(tmp & 0xff); + if (dshift == s_end) { dshift = s_start; dp--; } + else dshift += s_inc; } + if (sshift == s_end) { sshift = s_start; sp--; } + else sshift += s_inc; } break; } + default: { png_size_t pixel_bytes = (row_info->pixel_depth >> 3); - png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes; + + png_bytep sp = row + (png_size_t)(row_info->width - 1) + * pixel_bytes; + png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; int jstop = png_pass_inc[pass]; @@ -2702,351 +3687,569 @@ png_do_read_interlace(png_structp png_ptr) png_byte v[8]; int j; - png_memcpy(v, sp, pixel_bytes); + memcpy(v, sp, pixel_bytes); + for (j = 0; j < jstop; j++) { - png_memcpy(dp, v, pixel_bytes); + memcpy(dp, v, pixel_bytes); dp -= pixel_bytes; } + sp -= pixel_bytes; } break; } } + row_info->width = final_width; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width); } -#if !defined(PNG_READ_PACKSWAP_SUPPORTED) - transformations = transformations; /* silence compiler warning */ +#ifndef PNG_READ_PACKSWAP_SUPPORTED + PNG_UNUSED(transformations) /* Silence compiler warning */ #endif } #endif /* PNG_READ_INTERLACING_SUPPORTED */ +static void +png_read_filter_row_sub(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t i; + png_size_t istop = row_info->rowbytes; + unsigned int bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + + PNG_UNUSED(prev_row) + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); + rp++; + } +} + +static void +png_read_filter_row_up(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t i; + png_size_t istop = row_info->rowbytes; + png_bytep rp = row; + png_const_bytep pp = prev_row; + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } +} + +static void +png_read_filter_row_avg(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_size_t i; + png_bytep rp = row; + png_const_bytep pp = prev_row; + unsigned int bpp = (row_info->pixel_depth + 7) >> 3; + png_size_t istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) / 2 )) & 0xff); + + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); + + rp++; + } +} + +static void +png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp_end = row + row_info->rowbytes; + int a, c; + + /* First pixel/byte */ + c = *prev_row++; + a = *row + c; + *row++ = (png_byte)a; + + /* Remainder */ + while (row < rp_end) + { + int b, pa, pb, pc, p; + + a &= 0xff; /* From previous iteration or start */ + b = *prev_row++; + + p = b - c; + pc = a - c; + +# ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +# else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +# endif + + /* Find the best predictor, the least of pa, pb, pc favoring the earlier + * ones in the case of a tie. + */ + if (pb < pa) pa = pb, a = b; + if (pc < pa) a = c; + + /* Calculate the current pixel in a, and move the previous row pixel to c + * for the next time round the loop + */ + c = b; + a += *row; + *row++ = (png_byte)a; + } +} + +static void +png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + int bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp_end = row + bpp; + + /* Process the first pixel in the row completely (this is the same as 'up' + * because there is only one candidate predictor for the first row). + */ + while (row < rp_end) + { + int a = *row + *prev_row++; + *row++ = (png_byte)a; + } + + /* Remainder */ + rp_end += row_info->rowbytes - bpp; + + while (row < rp_end) + { + int a, b, c, pa, pb, pc, p; + + c = *(prev_row - bpp); + a = *(row - bpp); + b = *prev_row++; + + p = b - c; + pc = a - c; + +# ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +# else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +# endif + + if (pb < pa) pa = pb, a = b; + if (pc < pa) a = c; + + c = b; + a += *row; + *row++ = (png_byte)a; + } +} + +static void +png_init_filter_functions(png_structrp pp) + /* This function is called once for every PNG image to set the + * implementations required to reverse the filtering of PNG rows. Reversing + * the filter is the first transformation performed on the row data. It is + * performed in place, therefore an implementation can be selected based on + * the image pixel format. If the implementation depends on image width then + * take care to ensure that it works corretly if the image is interlaced - + * interlacing causes the actual row width to vary. + */ +{ + unsigned int bpp = (pp->pixel_depth + 7) >> 3; + + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub; + pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg; + if (bpp == 1) + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth_1byte_pixel; + else + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth_multibyte_pixel; + +#ifdef PNG_FILTER_OPTIMIZATIONS + /* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to + * call to install hardware optimizations for the above functions; simply + * replace whatever elements of the pp->read_filter[] array with a hardware + * specific (or, for that matter, generic) optimization. + * + * To see an example of this examine what configure.ac does when + * --enable-arm-neon is specified on the command line. + */ + PNG_FILTER_OPTIMIZATIONS(pp, bpp); +#endif +} + +void /* PRIVATE */ +png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, + png_const_bytep prev_row, int filter) +{ + /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define + * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic + * implementations. See png_init_filter_functions above. + */ + if (pp->read_filter[0] == NULL) + png_init_filter_functions(pp); + if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST) + pp->read_filter[filter-1](row_info, row, prev_row); +} + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED void /* PRIVATE */ -png_read_filter_row(png_structp, png_row_infop row_info, png_bytep row, - png_bytep prev_row, int filter) +png_read_IDAT_data(png_structrp png_ptr, png_bytep output, + png_alloc_size_t avail_out) { - png_debug(1, "in png_read_filter_row\n"); - png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); - switch (filter) + /* Loop reading IDATs and decompressing the result into output[avail_out] */ + png_ptr->zstream.next_out = output; + png_ptr->zstream.avail_out = 0; /* safety: set below */ + + if (output == NULL) + avail_out = 0; + + do { - case PNG_FILTER_VALUE_NONE: - break; - case PNG_FILTER_VALUE_SUB: + int ret; + png_byte tmpbuf[PNG_INFLATE_BUF_SIZE]; + + if (png_ptr->zstream.avail_in == 0) { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; + uInt avail_in; + png_bytep buffer; - for (i = bpp; i < istop; i++) + while (png_ptr->idat_size == 0) { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; + png_crc_finish(png_ptr, 0); + + png_ptr->idat_size = png_read_chunk_header(png_ptr); + /* This is an error even in the 'check' case because the code just + * consumed a non-IDAT header. + */ + if (png_ptr->chunk_name != png_IDAT) + png_error(png_ptr, "Not enough image data"); } - break; + + avail_in = png_ptr->IDAT_read_size; + + if (avail_in > png_ptr->idat_size) + avail_in = (uInt)png_ptr->idat_size; + + /* A PNG with a gradually increasing IDAT size will defeat this attempt + * to minimize memory usage by causing lots of re-allocs, but + * realistically doing IDAT_read_size re-allocs is not likely to be a + * big problem. + */ + buffer = png_read_buffer(png_ptr, avail_in, 0/*error*/); + + png_crc_read(png_ptr, buffer, avail_in); + png_ptr->idat_size -= avail_in; + + png_ptr->zstream.next_in = buffer; + png_ptr->zstream.avail_in = avail_in; } - case PNG_FILTER_VALUE_UP: + + /* And set up the output side. */ + if (output != NULL) /* standard read */ { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; + uInt out = ZLIB_IO_MAX; - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - break; + if (out > avail_out) + out = (uInt)avail_out; + + avail_out -= out; + png_ptr->zstream.avail_out = out; } - case PNG_FILTER_VALUE_AVG: + + else /* check for end */ { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) / 2 )) & 0xff); - rp++; - } + png_ptr->zstream.next_out = tmpbuf; + png_ptr->zstream.avail_out = (sizeof tmpbuf); + } - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - (int)(*pp++ + *lp++) / 2 ) & 0xff); - rp++; - } + /* Use NO_FLUSH; this gives zlib the maximum opportunity to optimize the + * process. If the LZ stream is truncated the sequential reader will + * terminally damage the stream, above, by reading the chunk header of the + * following chunk (it then exits with png_error). + * + * TODO: deal more elegantly with truncated IDAT lists. + */ + ret = inflate(&png_ptr->zstream, Z_NO_FLUSH); + + /* Take the unconsumed output back (so, in the 'check' case this just + * counts up). + */ + avail_out += png_ptr->zstream.avail_out; + png_ptr->zstream.avail_out = 0; + + if (ret == Z_STREAM_END) + { + /* Do this for safety; we won't read any more into this row. */ + png_ptr->zstream.next_out = NULL; + + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + + if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0) + png_chunk_benign_error(png_ptr, "Extra compressed data"); break; } - case PNG_FILTER_VALUE_PAETH: + + if (ret != Z_OK) { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } + png_zstream_error(png_ptr, ret); + + if (output != NULL) + png_chunk_error(png_ptr, png_ptr->zstream.msg); - for (i = 0; i < istop; i++) /* use leftover rp,pp */ + else /* checking */ { - int a, b, c, pa, pb, pc, p; + png_chunk_benign_error(png_ptr, png_ptr->zstream.msg); + return; + } + } + } while (avail_out > 0); - a = *lp++; - b = *pp++; - c = *cp++; + if (avail_out > 0) + { + /* The stream ended before the image; this is the same as too few IDATs so + * should be handled the same way. + */ + if (output != NULL) + png_error(png_ptr, "Not enough image data"); - p = b - c; - pc = a - c; + else /* checking */ + png_chunk_benign_error(png_ptr, "Too much image data"); + } +} -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif +void /* PRIVATE */ +png_read_finish_IDAT(png_structrp png_ptr) +{ + /* We don't need any more data and the stream should have ended, however the + * LZ end code may actually not have been processed. In this case we must + * read it otherwise stray unread IDAT data or, more likely, an IDAT chunk + * may still remain to be consumed. + */ + if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) + { + /* The NULL causes png_read_IDAT_data to swallow any remaining bytes in + * the compressed stream, but the stream may be damaged too, so even after + * this call we may need to terminate the zstream ownership. + */ + png_read_IDAT_data(png_ptr, NULL, 0); + png_ptr->zstream.next_out = NULL; /* safety */ + + /* Now clear everything out for safety; the following may not have been + * done. + */ + if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) + { + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; + } + } - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ + /* If the zstream has not been released do it now *and* terminate the reading + * of the final IDAT chunk. + */ + if (png_ptr->zowner == png_IDAT) + { + /* Always do this; the pointers otherwise point into the read buffer. */ + png_ptr->zstream.next_in = NULL; + png_ptr->zstream.avail_in = 0; - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + /* Now we no longer own the zstream. */ + png_ptr->zowner = 0; - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - break; - } - default: - png_warning(png_ptr, "Ignoring bad adaptive filter type"); - *row=0; - break; + /* The slightly weird semantics of the sequential IDAT reading is that we + * are always in or at the end of an IDAT chunk, so we always need to do a + * crc_finish here. If idat_size is non-zero we also need to read the + * spurious bytes at the end of the chunk now. + */ + (void)png_crc_finish(png_ptr, png_ptr->idat_size); } } void /* PRIVATE */ -png_read_finish_row(png_structp png_ptr) +png_read_finish_row(png_structrp png_ptr) { -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ - PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ - PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ - PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ - PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif /* PNG_READ_INTERLACING_SUPPORTED */ - png_debug(1, "in png_read_finish_row\n"); + png_debug(1, "in png_read_finish_row"); png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) return; +#ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) { png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, - png_ptr->rowbytes + 1); + + /* TO DO: don't do this if prev_row isn't needed (requires + * read-ahead of the next row's filter byte. + */ + memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + do { png_ptr->pass++; + if (png_ptr->pass >= 7) break; + png_ptr->iwidth = (png_ptr->width + png_pass_inc[png_ptr->pass] - 1 - png_pass_start[png_ptr->pass]) / png_pass_inc[png_ptr->pass]; - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - if (!(png_ptr->transformations & PNG_INTERLACE)) { png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (!(png_ptr->num_rows)) - continue; + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; } + else /* if (png_ptr->transformations & PNG_INTERLACE) */ - break; - } while (png_ptr->iwidth == 0); + break; /* libpng deinterlacing sees every row */ + + } while (png_ptr->num_rows == 0 || png_ptr->iwidth == 0); if (png_ptr->pass < 7) return; } +#endif /* PNG_READ_INTERLACING_SUPPORTED */ - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IDAT; -#endif - char extra; - int ret; - - png_ptr->zstream.next_out = (Bytef *)&extra; - png_ptr->zstream.avail_out = (uInt)1; - for(;;) - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_warning(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression Error"); - - if (!(png_ptr->zstream.avail_out)) - { - png_warning(png_ptr, "Extra compressed data."); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - - } - png_ptr->zstream.avail_out = 0; - } - - if (png_ptr->idat_size || png_ptr->zstream.avail_in) - png_warning(png_ptr, "Extra compression data"); - - inflateReset(&png_ptr->zstream); - - png_ptr->mode |= PNG_AFTER_IDAT; + /* Here after at the end of the last row of the last pass. */ + png_read_finish_IDAT(png_ptr); } +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ void /* PRIVATE */ -png_read_start_row(png_structp png_ptr) +png_read_start_row(png_structrp png_ptr) { -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ - PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ - PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ - PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ - PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif int max_pixel_depth; - png_uint_32 row_bytes; + png_size_t row_bytes; + + png_debug(1, "in png_read_start_row"); - png_debug(1, "in png_read_start_row\n"); - png_ptr->zstream.avail_in = 0; +#ifdef PNG_READ_TRANSFORMS_SUPPORTED png_init_read_transformations(png_ptr); +#endif +#ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) { if (!(png_ptr->transformations & PNG_INTERLACE)) png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; + png_pass_ystart[0]) / png_pass_yinc[0]; + else png_ptr->num_rows = png_ptr->height; png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1; - - png_ptr->irowbytes = (png_size_t)row_bytes; - if((png_uint_32)png_ptr->irowbytes != row_bytes) - png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; } + else +#endif /* PNG_READ_INTERLACING_SUPPORTED */ { png_ptr->num_rows = png_ptr->height; png_ptr->iwidth = png_ptr->width; - png_ptr->irowbytes = png_ptr->rowbytes + 1; } + max_pixel_depth = png_ptr->pixel_depth; -#if defined(PNG_READ_PACK_SUPPORTED) + /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpliar set of + * calculations to calculate the final pixel depth, then + * png_do_read_transforms actually does the transforms. This means that the + * code which effectively calculates this value is actually repeated in three + * separate places. They must all match. Innocent changes to the order of + * transformations can and will break libpng in a way that causes memory + * overwrites. + * + * TODO: fix this. + */ +#ifdef PNG_READ_PACK_SUPPORTED if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) max_pixel_depth = 8; #endif -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED if (png_ptr->transformations & PNG_EXPAND) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (png_ptr->num_trans) max_pixel_depth = 32; + else max_pixel_depth = 24; } + else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) { if (max_pixel_depth < 8) max_pixel_depth = 8; + if (png_ptr->num_trans) max_pixel_depth *= 2; } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { if (png_ptr->num_trans) @@ -3058,56 +4261,81 @@ png_read_start_row(png_structp png_ptr) } #endif -#if defined(PNG_READ_FILLER_SUPPORTED) +#ifdef PNG_READ_EXPAND_16_SUPPORTED + if (png_ptr->transformations & PNG_EXPAND_16) + { +# ifdef PNG_READ_EXPAND_SUPPORTED + /* In fact it is an error if it isn't supported, but checking is + * the safe way. + */ + if (png_ptr->transformations & PNG_EXPAND) + { + if (png_ptr->bit_depth < 16) + max_pixel_depth *= 2; + } + else +# endif + png_ptr->transformations &= ~PNG_EXPAND_16; + } +#endif + +#ifdef PNG_READ_FILLER_SUPPORTED if (png_ptr->transformations & (PNG_FILLER)) { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - max_pixel_depth = 32; - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) { if (max_pixel_depth <= 8) max_pixel_depth = 16; + else max_pixel_depth = 32; } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB || + png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (max_pixel_depth <= 32) max_pixel_depth = 32; + else max_pixel_depth = 64; } } #endif -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED if (png_ptr->transformations & PNG_GRAY_TO_RGB) { if ( -#if defined(PNG_READ_EXPAND_SUPPORTED) - (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || +#ifdef PNG_READ_EXPAND_SUPPORTED + (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || #endif -#if defined(PNG_READ_FILLER_SUPPORTED) - (png_ptr->transformations & (PNG_FILLER)) || +#ifdef PNG_READ_FILLER_SUPPORTED + (png_ptr->transformations & (PNG_FILLER)) || #endif - png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { if (max_pixel_depth <= 16) max_pixel_depth = 32; + else max_pixel_depth = 64; } + else { if (max_pixel_depth <= 8) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) max_pixel_depth = 32; - else + + else max_pixel_depth = 24; - } + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) max_pixel_depth = 64; + else max_pixel_depth = 48; } @@ -3116,46 +4344,115 @@ png_read_start_row(png_structp png_ptr) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - int user_pixel_depth=png_ptr->user_transform_depth* + if (png_ptr->transformations & PNG_USER_TRANSFORM) + { + int user_pixel_depth = png_ptr->user_transform_depth * png_ptr->user_transform_channels; - if(user_pixel_depth > max_pixel_depth) - max_pixel_depth=user_pixel_depth; - } + + if (user_pixel_depth > max_pixel_depth) + max_pixel_depth = user_pixel_depth; + } #endif - /* align the width on the next larger 8 pixels. Mainly used - for interlacing */ + /* This value is stored in png_struct and double checked in the row read + * code. + */ + png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth; + png_ptr->transformed_pixel_depth = 0; /* calculated on demand */ + + /* Align the width on the next larger 8 pixels. Mainly used + * for interlacing + */ row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); - /* calculate the maximum bytes needed, adding a byte and a pixel - for safety's sake */ - row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) + - 1 + ((max_pixel_depth + 7) >> 3); + /* Calculate the maximum bytes needed, adding a byte and a pixel + * for safety's sake + */ + row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) + + 1 + ((max_pixel_depth + 7) >> 3); + #ifdef PNG_MAX_MALLOC_64K if (row_bytes > (png_uint_32)65536L) png_error(png_ptr, "This image requires a row greater than 64KB"); #endif - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); - png_ptr->row_buf = png_ptr->big_row_buf+32; + + if (row_bytes + 48 > png_ptr->old_big_row_buf_size) + { + png_free(png_ptr, png_ptr->big_row_buf); + png_free(png_ptr, png_ptr->big_prev_row); + + if (png_ptr->interlaced) + png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, + row_bytes + 48); + + else + png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48); + + png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48); + +#ifdef PNG_ALIGNED_MEMORY_SUPPORTED + /* Use 16-byte aligned memory for row_buf with at least 16 bytes + * of padding before and after row_buf; treat prev_row similarly. + * NOTE: the alignment is to the start of the pixels, one beyond the start + * of the buffer, because of the filter byte. Prior to libpng 1.5.6 this + * was incorrect; the filter byte was aligned, which had the exact + * opposite effect of that intended. + */ + { + png_bytep temp = png_ptr->big_row_buf + 32; + int extra = (int)((temp - (png_bytep)0) & 0x0f); + png_ptr->row_buf = temp - extra - 1/*filter byte*/; + + temp = png_ptr->big_prev_row + 32; + extra = (int)((temp - (png_bytep)0) & 0x0f); + png_ptr->prev_row = temp - extra - 1/*filter byte*/; + } + +#else + /* Use 31 bytes of padding before and 17 bytes after row_buf. */ + png_ptr->row_buf = png_ptr->big_row_buf + 31; + png_ptr->prev_row = png_ptr->big_prev_row + 31; +#endif + png_ptr->old_big_row_buf_size = row_bytes + 48; + } #ifdef PNG_MAX_MALLOC_64K - if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) + if (png_ptr->rowbytes > 65535) png_error(png_ptr, "This image requires a row greater than 64KB"); + #endif - if ((png_uint_32)png_ptr->rowbytes > (png_uint_32) -2) - png_error(png_ptr, "Row has too many bytes to allocate in memory."); - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( - png_ptr->rowbytes + 1)); - - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - - png_debug1(3, "width = %lu,\n", png_ptr->width); - png_debug1(3, "height = %lu,\n", png_ptr->height); - png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); - png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); + if (png_ptr->rowbytes > (PNG_SIZE_MAX - 1)) + png_error(png_ptr, "Row has too many bytes to allocate in memory"); + + memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + + png_debug1(3, "width = %u,", png_ptr->width); + png_debug1(3, "height = %u,", png_ptr->height); + png_debug1(3, "iwidth = %u,", png_ptr->iwidth); + png_debug1(3, "num_rows = %u,", png_ptr->num_rows); + png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes); + png_debug1(3, "irowbytes = %lu", + (unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1); + + /* The sequential reader needs a buffer for IDAT, but the progressive reader + * does not, so free the read buffer now regardless; the sequential reader + * reallocates it on demand. + */ + if (png_ptr->read_buffer) + { + png_bytep buffer = png_ptr->read_buffer; + + png_ptr->read_buffer_size = 0; + png_ptr->read_buffer = NULL; + png_free(png_ptr, buffer); + } + + /* Finally claim the zstream for the inflate of the IDAT data, use the bits + * value from the stream (note that this will result in a fatal error if the + * IDAT stream has a bogus deflate header window_bits value, but this should + * not be happening any longer!) + */ + if (png_inflate_claim(png_ptr, png_IDAT, 0) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); png_ptr->flags |= PNG_FLAG_ROW_INIT; } diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngset.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngset.c index 2480a1618..a1b9d4967 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngset.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngset.c @@ -1,375 +1,262 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.2.21 [October 4, 2007] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * The functions here are used during reads to store data from the file * into the info struct, and during writes to store application data * into the info struct for writing into the file. This abstracts the * info struct and allows us to change the structure in the future. */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if defined(PNG_bKGD_SUPPORTED) +#ifdef PNG_bKGD_SUPPORTED void PNGAPI -png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) +png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_color_16p background) { - png_debug1(1, "in %s storage function\n", "bKGD"); - if (png_ptr == NULL || info_ptr == NULL) + png_debug1(1, "in %s storage function", "bKGD"); + + if (png_ptr == NULL || info_ptr == NULL || background == NULL) return; - png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16)); + info_ptr->background = *background; info_ptr->valid |= PNG_INFO_bKGD; } #endif -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_cHRM(png_structp png_ptr, png_infop info_ptr, - double white_x, double white_y, double red_x, double red_y, - double green_x, double green_y, double blue_x, double blue_y) +#ifdef PNG_cHRM_SUPPORTED +void PNGFAPI +png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr, + png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, + png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, + png_fixed_point blue_x, png_fixed_point blue_y) { - png_debug1(1, "in %s storage function\n", "cHRM"); + png_xy xy; + + png_debug1(1, "in %s storage function", "cHRM fixed"); + if (png_ptr == NULL || info_ptr == NULL) return; - if (white_x < 0.0 || white_y < 0.0 || - red_x < 0.0 || red_y < 0.0 || - green_x < 0.0 || green_y < 0.0 || - blue_x < 0.0 || blue_y < 0.0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > 21474.83 || white_y > 21474.83 || - red_x > 21474.83 || red_y > 21474.83 || - green_x > 21474.83 || green_y > 21474.83 || - blue_x > 21474.83 || blue_y > 21474.83) - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } + xy.redx = red_x; + xy.redy = red_y; + xy.greenx = green_x; + xy.greeny = green_y; + xy.bluex = blue_x; + xy.bluey = blue_y; + xy.whitex = white_x; + xy.whitey = white_y; - info_ptr->x_white = (float)white_x; - info_ptr->y_white = (float)white_y; - info_ptr->x_red = (float)red_x; - info_ptr->y_red = (float)red_y; - info_ptr->x_green = (float)green_x; - info_ptr->y_green = (float)green_y; - info_ptr->x_blue = (float)blue_x; - info_ptr->y_blue = (float)blue_y; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); - info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); - info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); - info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); - info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); - info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); - info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); - info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); -#endif - info_ptr->valid |= PNG_INFO_cHRM; + if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy, + 2/* override with app values*/)) + info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; + + png_colorspace_sync_info(png_ptr, info_ptr); } -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, - png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, - png_fixed_point blue_x, png_fixed_point blue_y) + +void PNGFAPI +png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr, + png_fixed_point int_red_X, png_fixed_point int_red_Y, + png_fixed_point int_red_Z, png_fixed_point int_green_X, + png_fixed_point int_green_Y, png_fixed_point int_green_Z, + png_fixed_point int_blue_X, png_fixed_point int_blue_Y, + png_fixed_point int_blue_Z) { - png_debug1(1, "in %s storage function\n", "cHRM"); + png_XYZ XYZ; + + png_debug1(1, "in %s storage function", "cHRM XYZ fixed"); + if (png_ptr == NULL || info_ptr == NULL) return; - if (white_x < 0 || white_y < 0 || - red_x < 0 || red_y < 0 || - green_x < 0 || green_y < 0 || - blue_x < 0 || blue_y < 0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - if (white_x > (double) PNG_UINT_31_MAX || - white_y > (double) PNG_UINT_31_MAX || - red_x > (double) PNG_UINT_31_MAX || - red_y > (double) PNG_UINT_31_MAX || - green_x > (double) PNG_UINT_31_MAX || - green_y > (double) PNG_UINT_31_MAX || - blue_x > (double) PNG_UINT_31_MAX || - blue_y > (double) PNG_UINT_31_MAX) -#else - if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || - blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || - blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L) -#endif - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } - info_ptr->int_x_white = white_x; - info_ptr->int_y_white = white_y; - info_ptr->int_x_red = red_x; - info_ptr->int_y_red = red_y; - info_ptr->int_x_green = green_x; - info_ptr->int_y_green = green_y; - info_ptr->int_x_blue = blue_x; - info_ptr->int_y_blue = blue_y; -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->x_white = (float)(white_x/100000.); - info_ptr->y_white = (float)(white_y/100000.); - info_ptr->x_red = (float)( red_x/100000.); - info_ptr->y_red = (float)( red_y/100000.); - info_ptr->x_green = (float)(green_x/100000.); - info_ptr->y_green = (float)(green_y/100000.); - info_ptr->x_blue = (float)( blue_x/100000.); - info_ptr->y_blue = (float)( blue_y/100000.); -#endif - info_ptr->valid |= PNG_INFO_cHRM; + XYZ.red_X = int_red_X; + XYZ.red_Y = int_red_Y; + XYZ.red_Z = int_red_Z; + XYZ.green_X = int_green_X; + XYZ.green_Y = int_green_Y; + XYZ.green_Z = int_green_Z; + XYZ.blue_X = int_blue_X; + XYZ.blue_Y = int_blue_Y; + XYZ.blue_Z = int_blue_Z; + + if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace, &XYZ, 2)) + info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; + + png_colorspace_sync_info(png_ptr, info_ptr); } -#endif -#endif -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED +# ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI -png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) +png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, + double white_x, double white_y, double red_x, double red_y, + double green_x, double green_y, double blue_x, double blue_y) { - double gamma; - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* Check for overflow */ - if (file_gamma > 21474.83) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=21474.83; - } - else - gamma=file_gamma; - info_ptr->gamma = (float)gamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = (int)(gamma*100000.+.5); -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0.0) - png_warning(png_ptr, "Setting gamma=0"); + png_set_cHRM_fixed(png_ptr, info_ptr, + png_fixed(png_ptr, white_x, "cHRM White X"), + png_fixed(png_ptr, white_y, "cHRM White Y"), + png_fixed(png_ptr, red_x, "cHRM Red X"), + png_fixed(png_ptr, red_y, "cHRM Red Y"), + png_fixed(png_ptr, green_x, "cHRM Green X"), + png_fixed(png_ptr, green_y, "cHRM Green Y"), + png_fixed(png_ptr, blue_x, "cHRM Blue X"), + png_fixed(png_ptr, blue_y, "cHRM Blue Y")); } -#endif + void PNGAPI -png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point - int_gamma) +png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, + double red_Y, double red_Z, double green_X, double green_Y, double green_Z, + double blue_X, double blue_Y, double blue_Z) +{ + png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, + png_fixed(png_ptr, red_X, "cHRM Red X"), + png_fixed(png_ptr, red_Y, "cHRM Red Y"), + png_fixed(png_ptr, red_Z, "cHRM Red Z"), + png_fixed(png_ptr, green_X, "cHRM Red X"), + png_fixed(png_ptr, green_Y, "cHRM Red Y"), + png_fixed(png_ptr, green_Z, "cHRM Red Z"), + png_fixed(png_ptr, blue_X, "cHRM Red X"), + png_fixed(png_ptr, blue_Y, "cHRM Red Y"), + png_fixed(png_ptr, blue_Z, "cHRM Red Z")); +} +# endif /* PNG_FLOATING_POINT_SUPPORTED */ + +#endif /* PNG_cHRM_SUPPORTED */ + +#ifdef PNG_gAMA_SUPPORTED +void PNGFAPI +png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr, + png_fixed_point file_gamma) { - png_fixed_point gamma; + png_debug1(1, "in %s storage function", "gAMA"); - png_debug1(1, "in %s storage function\n", "gAMA"); if (png_ptr == NULL || info_ptr == NULL) return; - if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=PNG_UINT_31_MAX; - } - else - { - if (int_gamma < 0) - { - png_warning(png_ptr, "Setting negative gamma to zero"); - gamma=0; - } - else - gamma=int_gamma; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = (float)(gamma/100000.); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = gamma; -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0) - png_warning(png_ptr, "Setting gamma=0"); + png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma); + png_colorspace_sync_info(png_ptr, info_ptr); } + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_gAMA(png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma) +{ + png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma, + "png_set_gAMA")); +} +# endif #endif -#if defined(PNG_hIST_SUPPORTED) +#ifdef PNG_hIST_SUPPORTED void PNGAPI -png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) +png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_uint_16p hist) { int i; - png_debug1(1, "in %s storage function\n", "hIST"); + png_debug1(1, "in %s storage function", "hIST"); + if (png_ptr == NULL || info_ptr == NULL) return; + if (info_ptr->num_palette == 0 || info_ptr->num_palette > PNG_MAX_PALETTE_LENGTH) { - png_warning(png_ptr, - "Invalid palette size, hIST allocation skipped."); - return; + png_warning(png_ptr, + "Invalid palette size, hIST allocation skipped"); + + return; } -#ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); -#endif - /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version - 1.2.1 */ - png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, - (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16))); - if (png_ptr->hist == NULL) - { - png_warning(png_ptr, "Insufficient memory for hIST chunk data."); - return; - } - for (i = 0; i < info_ptr->num_palette; i++) - png_ptr->hist[i] = hist[i]; - info_ptr->hist = png_ptr->hist; - info_ptr->valid |= PNG_INFO_hIST; + /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in + * version 1.2.1 + */ + info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr, + PNG_MAX_PALETTE_LENGTH * (sizeof (png_uint_16)))); + + if (info_ptr->hist == NULL) + { + png_warning(png_ptr, "Insufficient memory for hIST chunk data"); + return; + } -#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_HIST; -#else - png_ptr->flags |= PNG_FLAG_FREE_HIST; -#endif + + for (i = 0; i < info_ptr->num_palette; i++) + info_ptr->hist[i] = hist[i]; + + info_ptr->valid |= PNG_INFO_hIST; } #endif void PNGAPI -png_set_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) +png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) { - png_debug1(1, "in %s storage function\n", "IHDR"); + png_debug1(1, "in %s storage function", "IHDR"); + if (png_ptr == NULL || info_ptr == NULL) return; - /* check for width and height valid values */ - if (width == 0 || height == 0) - png_error(png_ptr, "Image width or height is zero in IHDR"); -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (width > png_ptr->user_width_max || height > png_ptr->user_height_max) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#else - if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#endif - if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image size in IHDR"); - if ( width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - png_warning(png_ptr, "Width is too large for libpng to process pixels"); - - /* check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth in IHDR"); - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - png_error(png_ptr, "Invalid color type in IHDR"); - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); - - if (interlace_type >= PNG_INTERLACE_LAST) - png_error(png_ptr, "Unknown interlace method in IHDR"); - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_error(png_ptr, "Unknown compression method in IHDR"); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); - if(filter_type != PNG_FILTER_TYPE_BASE) - { - if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - png_error(png_ptr, "Unknown filter method in IHDR"); - if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) - png_warning(png_ptr, "Invalid filter method in IHDR"); - } -#else - if(filter_type != PNG_FILTER_TYPE_BASE) - png_error(png_ptr, "Unknown filter method in IHDR"); -#endif - info_ptr->width = width; info_ptr->height = height; info_ptr->bit_depth = (png_byte)bit_depth; - info_ptr->color_type =(png_byte) color_type; + info_ptr->color_type = (png_byte)color_type; info_ptr->compression_type = (png_byte)compression_type; info_ptr->filter_type = (png_byte)filter_type; info_ptr->interlace_type = (png_byte)interlace_type; + + png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, + info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, + info_ptr->compression_type, info_ptr->filter_type); + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) info_ptr->channels = 1; + else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) info_ptr->channels = 3; + else info_ptr->channels = 1; + if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) info_ptr->channels++; + info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - /* check for potential overflow */ - if (width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - info_ptr->rowbytes = (png_size_t)0; + /* Check for potential overflow */ + if (width > + (PNG_UINT_32_MAX >> 3) /* 8-byte RRGGBBAA pixels */ + - 48 /* bigrowbuf hack */ + - 1 /* filter byte */ + - 7*8 /* rounding of width to multiple of 8 pixels */ + - 8) /* extra max_pixel_depth pad */ + info_ptr->rowbytes = 0; else - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width); + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); } -#if defined(PNG_oFFs_SUPPORTED) +#ifdef PNG_oFFs_SUPPORTED void PNGAPI -png_set_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type) +png_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr, + png_int_32 offset_x, png_int_32 offset_y, int unit_type) { - png_debug1(1, "in %s storage function\n", "oFFs"); + png_debug1(1, "in %s storage function", "oFFs"); + if (png_ptr == NULL || info_ptr == NULL) return; @@ -380,141 +267,236 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr, } #endif -#if defined(PNG_pCAL_SUPPORTED) +#ifdef PNG_pCAL_SUPPORTED void PNGAPI -png_set_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params) +png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, + int nparams, png_const_charp units, png_charpp params) { - png_uint_32 length; + png_size_t length; int i; - png_debug1(1, "in %s storage function\n", "pCAL"); - if (png_ptr == NULL || info_ptr == NULL) + png_debug1(1, "in %s storage function", "pCAL"); + + if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL + || (nparams > 0 && params == NULL)) return; - length = png_strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); - info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); + length = strlen(purpose) + 1; + png_debug1(3, "allocating purpose for info (%lu bytes)", + (unsigned long)length); + + /* TODO: validate format of calibration name and unit name */ + + /* Check that the type matches the specification. */ + if (type < 0 || type > 3) + png_error(png_ptr, "Invalid pCAL equation type"); + + if (nparams < 0 || nparams > 255) + png_error(png_ptr, "Invalid pCAL parameter count"); + + /* Validate params[nparams] */ + for (i=0; i<nparams; ++i) + if (params[i] == NULL || + !png_check_fp_string(params[i], strlen(params[i]))) + png_error(png_ptr, "Invalid format for pCAL parameter"); + + info_ptr->pcal_purpose = png_voidcast(png_charp, + png_malloc_warn(png_ptr, length)); + if (info_ptr->pcal_purpose == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL purpose."); - return; - } - png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); + { + png_warning(png_ptr, "Insufficient memory for pCAL purpose"); + return; + } + + memcpy(info_ptr->pcal_purpose, purpose, length); - png_debug(3, "storing X0, X1, type, and nparams in info\n"); + png_debug(3, "storing X0, X1, type, and nparams in info"); info_ptr->pcal_X0 = X0; info_ptr->pcal_X1 = X1; info_ptr->pcal_type = (png_byte)type; info_ptr->pcal_nparams = (png_byte)nparams; - length = png_strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)\n", length); - info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); + length = strlen(units) + 1; + png_debug1(3, "allocating units for info (%lu bytes)", + (unsigned long)length); + + info_ptr->pcal_units = png_voidcast(png_charp, + png_malloc_warn(png_ptr, length)); + if (info_ptr->pcal_units == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL units."); - return; - } - png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); + { + png_warning(png_ptr, "Insufficient memory for pCAL units"); + return; + } + + memcpy(info_ptr->pcal_units, units, length); + + info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, + (png_size_t)((nparams + 1) * (sizeof (png_charp))))); - info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, - (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); if (info_ptr->pcal_params == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL params."); - return; - } + { + png_warning(png_ptr, "Insufficient memory for pCAL params"); + return; + } - info_ptr->pcal_params[nparams] = NULL; + memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp))); for (i = 0; i < nparams; i++) { - length = png_strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); + length = strlen(params[i]) + 1; + png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, + (unsigned long)length); + info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); + if (info_ptr->pcal_params[i] == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL parameter."); - return; - } - png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); + { + png_warning(png_ptr, "Insufficient memory for pCAL parameter"); + return; + } + + memcpy(info_ptr->pcal_params[i], params[i], length); } info_ptr->valid |= PNG_INFO_pCAL; -#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_PCAL; -#endif } #endif -#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_sCAL_SUPPORTED void PNGAPI -png_set_sCAL(png_structp png_ptr, png_infop info_ptr, - int unit, double width, double height) +png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, + int unit, png_const_charp swidth, png_const_charp sheight) { - png_debug1(1, "in %s storage function\n", "sCAL"); + png_size_t lengthw = 0, lengthh = 0; + + png_debug1(1, "in %s storage function", "sCAL"); + if (png_ptr == NULL || info_ptr == NULL) return; - info_ptr->scal_unit = (png_byte)unit; - info_ptr->scal_pixel_width = width; - info_ptr->scal_pixel_height = height; + /* Double check the unit (should never get here with an invalid + * unit unless this is an API call.) + */ + if (unit != 1 && unit != 2) + png_error(png_ptr, "Invalid sCAL unit"); - info_ptr->valid |= PNG_INFO_sCAL; -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int unit, png_charp swidth, png_charp sheight) -{ - png_uint_32 length; + if (swidth == NULL || (lengthw = strlen(swidth)) == 0 || + swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw)) + png_error(png_ptr, "Invalid sCAL width"); - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; + if (sheight == NULL || (lengthh = strlen(sheight)) == 0 || + sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh)) + png_error(png_ptr, "Invalid sCAL height"); info_ptr->scal_unit = (png_byte)unit; - length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); + ++lengthw; + + png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw); + + info_ptr->scal_s_width = png_voidcast(png_charp, + png_malloc_warn(png_ptr, lengthw)); + if (info_ptr->scal_s_width == NULL) { - png_warning(png_ptr, - "Memory allocation failed while processing sCAL."); + png_warning(png_ptr, "Memory allocation failed while processing sCAL"); + return; } - png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); - length = png_strlen(sheight) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); + memcpy(info_ptr->scal_s_width, swidth, lengthw); + + ++lengthh; + + png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh); + + info_ptr->scal_s_height = png_voidcast(png_charp, + png_malloc_warn(png_ptr, lengthh)); + if (info_ptr->scal_s_height == NULL) { png_free (png_ptr, info_ptr->scal_s_width); - png_warning(png_ptr, - "Memory allocation failed while processing sCAL."); + info_ptr->scal_s_width = NULL; + + png_warning(png_ptr, "Memory allocation failed while processing sCAL"); + return; } - png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); + + memcpy(info_ptr->scal_s_height, sheight, lengthh); info_ptr->valid |= PNG_INFO_sCAL; -#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_SCAL; -#endif } -#endif -#endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit, + double width, double height) +{ + png_debug1(1, "in %s storage function", "sCAL"); + + /* Check the arguments. */ + if (width <= 0) + png_warning(png_ptr, "Invalid sCAL width ignored"); + + else if (height <= 0) + png_warning(png_ptr, "Invalid sCAL height ignored"); + + else + { + /* Convert 'width' and 'height' to ASCII. */ + char swidth[PNG_sCAL_MAX_DIGITS+1]; + char sheight[PNG_sCAL_MAX_DIGITS+1]; + + png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width, + PNG_sCAL_PRECISION); + png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height, + PNG_sCAL_PRECISION); + + png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); + } +} +# endif + +# ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_sCAL_fixed(png_const_structrp png_ptr, png_inforp info_ptr, int unit, + png_fixed_point width, png_fixed_point height) +{ + png_debug1(1, "in %s storage function", "sCAL"); + + /* Check the arguments. */ + if (width <= 0) + png_warning(png_ptr, "Invalid sCAL width ignored"); + + else if (height <= 0) + png_warning(png_ptr, "Invalid sCAL height ignored"); + + else + { + /* Convert 'width' and 'height' to ASCII. */ + char swidth[PNG_sCAL_MAX_DIGITS+1]; + char sheight[PNG_sCAL_MAX_DIGITS+1]; + + png_ascii_from_fixed(png_ptr, swidth, (sizeof swidth), width); + png_ascii_from_fixed(png_ptr, sheight, (sizeof sheight), height); + + png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); + } +} +# endif #endif -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED void PNGAPI -png_set_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type) +png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr, + png_uint_32 res_x, png_uint_32 res_y, int unit_type) { - png_debug1(1, "in %s storage function\n", "pHYs"); + png_debug1(1, "in %s storage function", "pHYs"); + if (png_ptr == NULL || info_ptr == NULL) return; @@ -526,718 +508,1099 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr, #endif void PNGAPI -png_set_PLTE(png_structp png_ptr, png_infop info_ptr, - png_colorp palette, int num_palette) +png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, + png_const_colorp palette, int num_palette) { - png_debug1(1, "in %s storage function\n", "PLTE"); + png_debug1(1, "in %s storage function", "PLTE"); + if (png_ptr == NULL || info_ptr == NULL) return; if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) png_error(png_ptr, "Invalid palette length"); - else - { + + else + { png_warning(png_ptr, "Invalid palette length"); return; - } - } + } + } - /* - * It may not actually be necessary to set png_ptr->palette here; + if ((num_palette > 0 && palette == NULL) || + (num_palette == 0 +# ifdef PNG_MNG_FEATURES_SUPPORTED + && (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 +# endif + )) + { + png_chunk_report(png_ptr, "Invalid palette", PNG_CHUNK_ERROR); + return; + } + + /* It may not actually be necessary to set png_ptr->palette here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. + * + * 1.6.0: the above statement appears to be incorrect; something has to set + * the palette inside png_struct on read. */ -#ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); -#endif /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead - of num_palette entries, - in case of an invalid PNG file that has too-large sample values. */ - png_ptr->palette = (png_colorp)png_malloc(png_ptr, - PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); - png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * - png_sizeof(png_color)); - png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color)); + * of num_palette entries, in case of an invalid PNG file that has + * too-large sample values. + */ + png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr, + PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)))); + + if (num_palette > 0) + memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color))); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; -#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_PLTE; -#else - png_ptr->flags |= PNG_FLAG_FREE_PLTE; -#endif info_ptr->valid |= PNG_INFO_PLTE; } -#if defined(PNG_sBIT_SUPPORTED) +#ifdef PNG_sBIT_SUPPORTED void PNGAPI -png_set_sBIT(png_structp png_ptr, png_infop info_ptr, - png_color_8p sig_bit) +png_set_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_color_8p sig_bit) { - png_debug1(1, "in %s storage function\n", "sBIT"); - if (png_ptr == NULL || info_ptr == NULL) + png_debug1(1, "in %s storage function", "sBIT"); + + if (png_ptr == NULL || info_ptr == NULL || sig_bit == NULL) return; - png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); + info_ptr->sig_bit = *sig_bit; info_ptr->valid |= PNG_INFO_sBIT; } #endif -#if defined(PNG_sRGB_SUPPORTED) +#ifdef PNG_sRGB_SUPPORTED void PNGAPI -png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) +png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent) { - png_debug1(1, "in %s storage function\n", "sRGB"); + png_debug1(1, "in %s storage function", "sRGB"); + if (png_ptr == NULL || info_ptr == NULL) return; - info_ptr->srgb_intent = (png_byte)intent; - info_ptr->valid |= PNG_INFO_sRGB; + (void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent); + png_colorspace_sync_info(png_ptr, info_ptr); } void PNGAPI -png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, - int intent) +png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, + int srgb_intent) { -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_file_gamma; -#endif -#endif -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, - int_green_y, int_blue_x, int_blue_y; -#endif -#endif - png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); + png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); + if (png_ptr == NULL || info_ptr == NULL) return; - png_set_sRGB(png_ptr, info_ptr, intent); - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float).45455; - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - int_file_gamma = 45455L; - png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FIXED_POINT_SUPPORTED - int_white_x = 31270L; - int_white_y = 32900L; - int_red_x = 64000L; - int_red_y = 33000L; - int_green_x = 30000L; - int_green_y = 60000L; - int_blue_x = 15000L; - int_blue_y = 6000L; + if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent)) + { + /* This causes the gAMA and cHRM to be written too */ + info_ptr->colorspace.flags |= + PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM; + } - png_set_cHRM_fixed(png_ptr, info_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, - int_blue_x, int_blue_y); -#endif -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float).3127; - white_y = (float).3290; - red_x = (float).64; - red_y = (float).33; - green_x = (float).30; - green_y = (float).60; - blue_x = (float).15; - blue_y = (float).06; - - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#endif + png_colorspace_sync_info(png_ptr, info_ptr); } -#endif +#endif /* sRGB */ -#if defined(PNG_iCCP_SUPPORTED) +#ifdef PNG_iCCP_SUPPORTED void PNGAPI -png_set_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen) +png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_charp name, int compression_type, + png_const_bytep profile, png_uint_32 proflen) { png_charp new_iccp_name; - png_charp new_iccp_profile; + png_bytep new_iccp_profile; + png_size_t length; + + png_debug1(1, "in %s storage function", "iCCP"); - png_debug1(1, "in %s storage function\n", "iCCP"); if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) return; - new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1); + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + png_app_error(png_ptr, "Invalid iCCP compression method"); + + /* Set the colorspace first because this validates the profile; do not + * override previously set app cHRM or gAMA here (because likely as not the + * application knows better than libpng what the correct values are.) Pass + * the info_ptr color_type field to png_colorspace_set_ICC because in the + * write case it has not yet been stored in png_ptr. + */ + { + int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name, + proflen, profile, info_ptr->color_type); + + png_colorspace_sync_info(png_ptr, info_ptr); + + /* Don't do any of the copying if the profile was bad, or inconsistent. */ + if (!result) + return; + + /* But do write the gAMA and cHRM chunks from the profile. */ + info_ptr->colorspace.flags |= + PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM; + } + + length = strlen(name)+1; + new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length)); + if (new_iccp_name == NULL) { - png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); + png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk"); return; } - png_strncpy(new_iccp_name, name, png_strlen(name)+1); - new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); + + memcpy(new_iccp_name, name, length); + new_iccp_profile = png_voidcast(png_bytep, + png_malloc_warn(png_ptr, proflen)); + if (new_iccp_profile == NULL) { - png_free (png_ptr, new_iccp_name); - png_warning(png_ptr, "Insufficient memory to process iCCP profile."); + png_free(png_ptr, new_iccp_name); + png_benign_error(png_ptr, + "Insufficient memory to process iCCP profile"); return; } - png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); + + memcpy(new_iccp_profile, profile, proflen); png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); info_ptr->iccp_proflen = proflen; info_ptr->iccp_name = new_iccp_name; info_ptr->iccp_profile = new_iccp_profile; - /* Compression is always zero but is here so the API and info structure - * does not have to change if we introduce multiple compression types */ - info_ptr->iccp_compression = (png_byte)compression_type; -#ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ICCP; -#endif info_ptr->valid |= PNG_INFO_iCCP; } #endif -#if defined(PNG_TEXT_SUPPORTED) +#ifdef PNG_TEXT_SUPPORTED void PNGAPI -png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) +png_set_text(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_textp text_ptr, int num_text) { int ret; - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); + if (ret) - png_error(png_ptr, "Insufficient memory to store text"); + png_error(png_ptr, "Insufficient memory to store text"); } int /* PRIVATE */ -png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) +png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_textp text_ptr, int num_text) { int i; - png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? - "text" : (png_const_charp)png_ptr->chunk_name)); + png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" : + (unsigned long)png_ptr->chunk_name); - if (png_ptr == NULL || info_ptr == NULL || num_text == 0) + if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL) return(0); /* Make sure we have enough space in the "text" array in info_struct - * to hold all of the incoming text_ptr objects. + * to hold all of the incoming text_ptr objects. This compare can't overflow + * because max_text >= num_text (anyway, subtract of two positive integers + * can't overflow in any case.) */ - if (info_ptr->num_text + num_text > info_ptr->max_text) + if (num_text > info_ptr->max_text - info_ptr->num_text) { - if (info_ptr->text != NULL) + int old_num_text = info_ptr->num_text; + int max_text; + png_textp new_text = NULL; + + /* Calculate an appropriate max_text, checking for overflow. */ + max_text = old_num_text; + if (num_text <= INT_MAX - max_text) { - png_textp old_text; - int old_max; - - old_max = info_ptr->max_text; - info_ptr->max_text = info_ptr->num_text + num_text + 8; - old_text = info_ptr->text; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); - if (info_ptr->text == NULL) - { - png_free(png_ptr, old_text); - return(1); - } - png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * - png_sizeof(png_text))); - png_free(png_ptr, old_text); + max_text += num_text; + + /* Round up to a multiple of 8 */ + if (max_text < INT_MAX-8) + max_text = (max_text + 8) & ~0x7; + + else + max_text = INT_MAX; + + /* Now allocate a new array and copy the old members in, this does all + * the overflow checks. + */ + new_text = png_voidcast(png_textp,png_realloc_array(png_ptr, + info_ptr->text, old_num_text, max_text-old_num_text, + sizeof *new_text)); } - else + + if (new_text == NULL) { - info_ptr->max_text = num_text + 8; - info_ptr->num_text = 0; - info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); - if (info_ptr->text == NULL) - return(1); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TEXT; -#endif + png_chunk_report(png_ptr, "too many text chunks", + PNG_CHUNK_WRITE_ERROR); + return 1; } - png_debug1(3, "allocated %d entries for info_ptr->text\n", - info_ptr->max_text); + + png_free(png_ptr, info_ptr->text); + + info_ptr->text = new_text; + info_ptr->free_me |= PNG_FREE_TEXT; + info_ptr->max_text = max_text; + /* num_text is adjusted below as the entries are copied in */ + + png_debug1(3, "allocated %d entries for info_ptr->text", max_text); } + for (i = 0; i < num_text; i++) { - png_size_t text_length,key_len; - png_size_t lang_len,lang_key_len; + size_t text_length, key_len; + size_t lang_len, lang_key_len; png_textp textp = &(info_ptr->text[info_ptr->num_text]); if (text_ptr[i].key == NULL) continue; - key_len = png_strlen(text_ptr[i].key); + if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE || + text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST) + { + png_chunk_report(png_ptr, "text compression mode is out of range", + PNG_CHUNK_WRITE_ERROR); + continue; + } - if(text_ptr[i].compression <= 0) + key_len = strlen(text_ptr[i].key); + + if (text_ptr[i].compression <= 0) { - lang_len = 0; - lang_key_len = 0; + lang_len = 0; + lang_key_len = 0; } + else -#ifdef PNG_iTXt_SUPPORTED +# ifdef PNG_iTXt_SUPPORTED { - /* set iTXt data */ - if (text_ptr[i].lang != NULL) - lang_len = png_strlen(text_ptr[i].lang); - else - lang_len = 0; - if (text_ptr[i].lang_key != NULL) - lang_key_len = png_strlen(text_ptr[i].lang_key); - else - lang_key_len = 0; + /* Set iTXt data */ + + if (text_ptr[i].lang != NULL) + lang_len = strlen(text_ptr[i].lang); + + else + lang_len = 0; + + if (text_ptr[i].lang_key != NULL) + lang_key_len = strlen(text_ptr[i].lang_key); + + else + lang_key_len = 0; } -#else +# else /* PNG_iTXt_SUPPORTED */ { - png_warning(png_ptr, "iTXt chunk not supported."); - continue; + png_chunk_report(png_ptr, "iTXt chunk not supported", + PNG_CHUNK_WRITE_ERROR); + continue; } -#endif +# endif if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') { text_length = 0; -#ifdef PNG_iTXt_SUPPORTED - if(text_ptr[i].compression > 0) +# ifdef PNG_iTXt_SUPPORTED + if (text_ptr[i].compression > 0) textp->compression = PNG_ITXT_COMPRESSION_NONE; + else -#endif +# endif textp->compression = PNG_TEXT_COMPRESSION_NONE; } + else { - text_length = png_strlen(text_ptr[i].text); + text_length = strlen(text_ptr[i].text); textp->compression = text_ptr[i].compression; } - textp->key = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); + textp->key = png_voidcast(png_charp,png_malloc_base(png_ptr, + key_len + text_length + lang_len + lang_key_len + 4)); + if (textp->key == NULL) - return(1); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", - (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), - (int)textp->key); - - png_memcpy(textp->key, text_ptr[i].key, - (png_size_t)(key_len)); - *(textp->key+key_len) = '\0'; -#ifdef PNG_iTXt_SUPPORTED + { + png_chunk_report(png_ptr, "text chunk: out of memory", + PNG_CHUNK_WRITE_ERROR); + return 1; + } + + png_debug2(2, "Allocated %lu bytes at %p in png_set_text", + (unsigned long)(png_uint_32) + (key_len + lang_len + lang_key_len + text_length + 4), + textp->key); + + memcpy(textp->key, text_ptr[i].key, key_len); + *(textp->key + key_len) = '\0'; + if (text_ptr[i].compression > 0) { - textp->lang=textp->key + key_len + 1; - png_memcpy(textp->lang, text_ptr[i].lang, lang_len); - *(textp->lang+lang_len) = '\0'; - textp->lang_key=textp->lang + lang_len + 1; - png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); - *(textp->lang_key+lang_key_len) = '\0'; - textp->text=textp->lang_key + lang_key_len + 1; + textp->lang = textp->key + key_len + 1; + memcpy(textp->lang, text_ptr[i].lang, lang_len); + *(textp->lang + lang_len) = '\0'; + textp->lang_key = textp->lang + lang_len + 1; + memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); + *(textp->lang_key + lang_key_len) = '\0'; + textp->text = textp->lang_key + lang_key_len + 1; } + else -#endif { -#ifdef PNG_iTXt_SUPPORTED textp->lang=NULL; textp->lang_key=NULL; -#endif - textp->text=textp->key + key_len + 1; + textp->text = textp->key + key_len + 1; } - if(text_length) - png_memcpy(textp->text, text_ptr[i].text, - (png_size_t)(text_length)); - *(textp->text+text_length) = '\0'; -#ifdef PNG_iTXt_SUPPORTED - if(textp->compression > 0) + if (text_length) + memcpy(textp->text, text_ptr[i].text, text_length); + + *(textp->text + text_length) = '\0'; + +# ifdef PNG_iTXt_SUPPORTED + if (textp->compression > 0) { textp->text_length = 0; textp->itxt_length = text_length; } + else -#endif +# endif { textp->text_length = text_length; -#ifdef PNG_iTXt_SUPPORTED textp->itxt_length = 0; -#endif } + info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); + png_debug1(3, "transferred text chunk %d", info_ptr->num_text); } + return(0); } #endif -#if defined(PNG_tIME_SUPPORTED) +#ifdef PNG_tIME_SUPPORTED void PNGAPI -png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) +png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_timep mod_time) { - png_debug1(1, "in %s storage function\n", "tIME"); - if (png_ptr == NULL || info_ptr == NULL || + png_debug1(1, "in %s storage function", "tIME"); + + if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL || (png_ptr->mode & PNG_WROTE_tIME)) return; - png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time)); + if (mod_time->month == 0 || mod_time->month > 12 || + mod_time->day == 0 || mod_time->day > 31 || + mod_time->hour > 23 || mod_time->minute > 59 || + mod_time->second > 60) + { + png_warning(png_ptr, "Ignoring invalid time value"); + return; + } + + info_ptr->mod_time = *mod_time; info_ptr->valid |= PNG_INFO_tIME; } #endif -#if defined(PNG_tRNS_SUPPORTED) +#ifdef PNG_tRNS_SUPPORTED void PNGAPI -png_set_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep trans, int num_trans, png_color_16p trans_values) +png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, + png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color) { - png_debug1(1, "in %s storage function\n", "tRNS"); + png_debug1(1, "in %s storage function", "tRNS"); + if (png_ptr == NULL || info_ptr == NULL) return; - if (trans != NULL) + if (trans_alpha != NULL) { - /* - * It may not actually be necessary to set png_ptr->trans here; + /* It may not actually be necessary to set png_ptr->trans_alpha here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. + * + * 1.6.0: The above statement is incorrect; png_handle_tRNS effectively + * relies on png_set_tRNS storing the information in png_struct + * (otherwise it won't be there for the code in pngrtran.c). */ -#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); -#endif + /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, - (png_uint_32)PNG_MAX_PALETTE_LENGTH); - if (num_trans <= PNG_MAX_PALETTE_LENGTH) - png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TRNS; -#else - png_ptr->flags |= PNG_FLAG_FREE_TRNS; -#endif + png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep, + png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); + + if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) + memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans); } - if (trans_values != NULL) + if (trans_color != NULL) { - png_memcpy(&(info_ptr->trans_values), trans_values, - png_sizeof(png_color_16)); + int sample_max = (1 << info_ptr->bit_depth); + + if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY && + trans_color->gray > sample_max) || + (info_ptr->color_type == PNG_COLOR_TYPE_RGB && + (trans_color->red > sample_max || + trans_color->green > sample_max || + trans_color->blue > sample_max))) + png_warning(png_ptr, + "tRNS chunk has out-of-range samples for bit_depth"); + + info_ptr->trans_color = *trans_color; + if (num_trans == 0) - num_trans = 1; + num_trans = 1; } + info_ptr->num_trans = (png_uint_16)num_trans; - info_ptr->valid |= PNG_INFO_tRNS; + + if (num_trans != 0) + { + info_ptr->valid |= PNG_INFO_tRNS; + info_ptr->free_me |= PNG_FREE_TRNS; + } } #endif -#if defined(PNG_sPLT_SUPPORTED) +#ifdef PNG_sPLT_SUPPORTED void PNGAPI -png_set_sPLT(png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries) +png_set_sPLT(png_const_structrp png_ptr, + png_inforp info_ptr, png_const_sPLT_tp entries, int nentries) +/* + * entries - array of png_sPLT_t structures + * to be added to the list of palettes + * in the info structure. + * + * nentries - number of palette structures to be + * added. + */ { - png_sPLT_tp np; - int i; + png_sPLT_tp np; - if (png_ptr == NULL || info_ptr == NULL) - return; + if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL) + return; + + /* Use the internal realloc function, which checks for all the possible + * overflows. Notice that the parameters are (int) and (size_t) + */ + np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr, + info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries, + sizeof *np)); - np = (png_sPLT_tp)png_malloc_warn(png_ptr, - (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); - if (np == NULL) - { - png_warning(png_ptr, "No memory for sPLT palettes."); + if (np == NULL) + { + /* Out of memory or too many chunks */ + png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR); return; - } - - png_memcpy(np, info_ptr->splt_palettes, - info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes=NULL; - - for (i = 0; i < nentries; i++) - { - png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; - png_sPLT_tp from = entries + i; - - to->name = (png_charp)png_malloc_warn(png_ptr, - png_strlen(from->name) + 1); - if (to->name == NULL) - { - png_warning(png_ptr, - "Out of memory while processing sPLT chunk"); - } - /* TODO: use png_malloc_warn */ - png_strncpy(to->name, from->name, png_strlen(from->name)+1); - to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, - from->nentries * png_sizeof(png_sPLT_entry)); - /* TODO: use png_malloc_warn */ - png_memcpy(to->entries, from->entries, - from->nentries * png_sizeof(png_sPLT_entry)); - if (to->entries == NULL) - { - png_warning(png_ptr, - "Out of memory while processing sPLT chunk"); - png_free(png_ptr,to->name); - to->name = NULL; - } - to->nentries = from->nentries; - to->depth = from->depth; - } - - info_ptr->splt_palettes = np; - info_ptr->splt_palettes_num += nentries; - info_ptr->valid |= PNG_INFO_sPLT; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SPLT; -#endif + } + + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes = np; + info_ptr->free_me |= PNG_FREE_SPLT; + + np += info_ptr->splt_palettes_num; + + do + { + png_size_t length; + + /* Skip invalid input entries */ + if (entries->name == NULL || entries->entries == NULL) + { + /* png_handle_sPLT doesn't do this, so this is an app error */ + png_app_error(png_ptr, "png_set_sPLT: invalid sPLT"); + /* Just skip the invalid entry */ + continue; + } + + np->depth = entries->depth; + + /* In the even of out-of-memory just return - there's no point keeping on + * trying to add sPLT chunks. + */ + length = strlen(entries->name) + 1; + np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length)); + + if (np->name == NULL) + break; + + memcpy(np->name, entries->name, length); + + /* IMPORTANT: we have memory now that won't get freed if something else + * goes wrong, this code must free it. png_malloc_array produces no + * warnings, use a png_chunk_report (below) if there is an error. + */ + np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr, + entries->nentries, sizeof (png_sPLT_entry))); + + if (np->entries == NULL) + { + png_free(png_ptr, np->name); + break; + } + + np->nentries = entries->nentries; + /* This multiply can't overflow because png_malloc_array has already + * checked it when doing the allocation. + */ + memcpy(np->entries, entries->entries, + entries->nentries * sizeof (png_sPLT_entry)); + + /* Note that 'continue' skips the advance of the out pointer and out + * count, so an invalid entry is not added. + */ + info_ptr->valid |= PNG_INFO_sPLT; + ++(info_ptr->splt_palettes_num); + ++np; + } + while (++entries, --nentries); + + if (nentries > 0) + png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR); } #endif /* PNG_sPLT_SUPPORTED */ -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_unknown_chunks(png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) +#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +static png_byte +check_location(png_const_structrp png_ptr, int location) { - png_unknown_chunkp np; - int i; + location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT); - if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) - return; + /* New in 1.6.0; copy the location and check it. This is an API + * change, previously the app had to use the + * png_set_unknown_chunk_location API below for each chunk. + */ + if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT)) + { + /* Write struct, so unknown chunks come from the app */ + png_app_warning(png_ptr, + "png_set_unknown_chunks now expects a valid location"); + /* Use the old behavior */ + location = (png_byte)(png_ptr->mode & + (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)); + } - np = (png_unknown_chunkp)png_malloc_warn(png_ptr, - (info_ptr->unknown_chunks_num + num_unknowns) * - png_sizeof(png_unknown_chunk)); - if (np == NULL) - { - png_warning(png_ptr, - "Out of memory while processing unknown chunk."); - return; - } - - png_memcpy(np, info_ptr->unknown_chunks, - info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks=NULL; - - for (i = 0; i < num_unknowns; i++) - { - png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; - png_unknown_chunkp from = unknowns + i; - - png_strncpy((png_charp)to->name, (png_charp)from->name, 5); - to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); - if (to->data == NULL) - { - png_warning(png_ptr, - "Out of memory while processing unknown chunk."); - } - else - { - png_memcpy(to->data, from->data, from->size); - to->size = from->size; - - /* note our location in the read or write sequence */ - to->location = (png_byte)(png_ptr->mode & 0xff); - } - } - - info_ptr->unknown_chunks = np; - info_ptr->unknown_chunks_num += num_unknowns; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_UNKN; -#endif + /* This need not be an internal error - if the app calls + * png_set_unknown_chunks on a read pointer it must get the location right. + */ + if (location == 0) + png_error(png_ptr, "invalid location in png_set_unknown_chunks"); + + /* Now reduce the location to the top-most set bit by removing each least + * significant bit in turn. + */ + while (location != (location & -location)) + location &= ~(location & -location); + + /* The cast is safe because 'location' is a bit mask and only the low four + * bits are significant. + */ + return (png_byte)location; } + void PNGAPI -png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, - int chunk, int location) +png_set_unknown_chunks(png_const_structrp png_ptr, + png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) { - if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < - (int)info_ptr->unknown_chunks_num) - info_ptr->unknown_chunks[chunk].location = (png_byte)location; + png_unknown_chunkp np; + + if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 || + unknowns == NULL) + return; + + /* Check for the failure cases where support has been disabled at compile + * time. This code is hardly ever compiled - it's here because + * STORE_UNKNOWN_CHUNKS is set by both read and write code (compiling in this + * code) but may be meaningless if the read or write handling of unknown + * chunks is not compiled in. + */ +# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \ + defined(PNG_READ_SUPPORTED) + if (png_ptr->mode & PNG_IS_READ_STRUCT) + { + png_app_error(png_ptr, "no unknown chunk support on read"); + return; + } +# endif +# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \ + defined(PNG_WRITE_SUPPORTED) + if (!(png_ptr->mode & PNG_IS_READ_STRUCT)) + { + png_app_error(png_ptr, "no unknown chunk support on write"); + return; + } +# endif + + /* Prior to 1.6.0 this code used png_malloc_warn; however, this meant that + * unknown critical chunks could be lost with just a warning resulting in + * undefined behavior. Now png_chunk_report is used to provide behavior + * appropriate to read or write. + */ + np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr, + info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns, + sizeof *np)); + + if (np == NULL) + { + png_chunk_report(png_ptr, "too many unknown chunks", + PNG_CHUNK_WRITE_ERROR); + return; + } + + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks = np; /* safe because it is initialized */ + info_ptr->free_me |= PNG_FREE_UNKN; + + np += info_ptr->unknown_chunks_num; + + /* Increment unknown_chunks_num each time round the loop to protect the + * just-allocated chunk data. + */ + for (; num_unknowns > 0; --num_unknowns, ++unknowns) + { + memcpy(np->name, unknowns->name, (sizeof np->name)); + np->name[(sizeof np->name)-1] = '\0'; + np->location = check_location(png_ptr, unknowns->location); + + if (unknowns->size == 0) + { + np->data = NULL; + np->size = 0; + } + + else + { + np->data = png_voidcast(png_bytep, + png_malloc_base(png_ptr, unknowns->size)); + + if (np->data == NULL) + { + png_chunk_report(png_ptr, "unknown chunk: out of memory", + PNG_CHUNK_WRITE_ERROR); + /* But just skip storing the unknown chunk */ + continue; + } + + memcpy(np->data, unknowns->data, unknowns->size); + np->size = unknowns->size; + } + + /* These increments are skipped on out-of-memory for the data - the + * unknown chunk entry gets overwritten if the png_chunk_report returns. + * This is correct in the read case (the chunk is just dropped.) + */ + ++np; + ++(info_ptr->unknown_chunks_num); + } } -#endif -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) void PNGAPI -png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) +png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, + int chunk, int location) { - /* This function is deprecated in favor of png_permit_mng_features() - and will be removed from libpng-1.3.0 */ - png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); - if (png_ptr == NULL) - return; - png_ptr->mng_features_permitted = (png_byte) - ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | - ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); + /* This API is pretty pointless in 1.6.0 because the location can be set + * before the call to png_set_unknown_chunks. + * + * TODO: add a png_app_warning in 1.7 + */ + if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && + chunk < info_ptr->unknown_chunks_num) + { + if ((location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0) + { + png_app_error(png_ptr, "invalid unknown chunk location"); + /* Fake out the pre 1.6.0 behavior: */ + if ((location & PNG_HAVE_IDAT)) /* undocumented! */ + location = PNG_AFTER_IDAT; + + else + location = PNG_HAVE_IHDR; /* also undocumented */ + } + + info_ptr->unknown_chunks[chunk].location = + check_location(png_ptr, location); + } } #endif -#endif -#if defined(PNG_MNG_FEATURES_SUPPORTED) + +#ifdef PNG_MNG_FEATURES_SUPPORTED png_uint_32 PNGAPI -png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) +png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features) { - png_debug(1, "in png_permit_mng_features\n"); + png_debug(1, "in png_permit_mng_features"); + if (png_ptr == NULL) - return (png_uint_32)0; - png_ptr->mng_features_permitted = - (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); - return (png_uint_32)png_ptr->mng_features_permitted; + return 0; + + png_ptr->mng_features_permitted = mng_features & PNG_ALL_MNG_FEATURES; + + return png_ptr->mng_features_permitted; } #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +static unsigned int +add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep) +{ + unsigned int i; + + /* Utility function: update the 'keep' state of a chunk if it is already in + * the list, otherwise add it to the list. + */ + for (i=0; i<count; ++i, list += 5) if (memcmp(list, add, 4) == 0) + { + list[4] = (png_byte)keep; + return count; + } + + if (keep != PNG_HANDLE_CHUNK_AS_DEFAULT) + { + ++count; + memcpy(list, add, 4); + list[4] = (png_byte)keep; + } + + return count; +} + void PNGAPI -png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep - chunk_list, int num_chunks) +png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, + png_const_bytep chunk_list, int num_chunks_in) { - png_bytep new_list, p; - int i, old_num_chunks; - if (png_ptr == NULL) - return; - if (num_chunks == 0) - { - if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) - png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; + png_bytep new_list; + unsigned int num_chunks, old_num_chunks; - if(keep == PNG_HANDLE_CHUNK_ALWAYS) - png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; + if (png_ptr == NULL) return; - } - if (chunk_list == NULL) + + if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST) + { + png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep"); return; - old_num_chunks=png_ptr->num_chunk_list; - new_list=(png_bytep)png_malloc(png_ptr, - (png_uint_32)(5*(num_chunks+old_num_chunks))); - if(png_ptr->chunk_list != NULL) - { - png_memcpy(new_list, png_ptr->chunk_list, - (png_size_t)(5*old_num_chunks)); - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - } - png_memcpy(new_list+5*old_num_chunks, chunk_list, - (png_size_t)(5*num_chunks)); - for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5) - *p=(png_byte)keep; - png_ptr->num_chunk_list=old_num_chunks+num_chunks; - png_ptr->chunk_list=new_list; -#ifdef PNG_FREE_ME_SUPPORTED - png_ptr->free_me |= PNG_FREE_LIST; -#endif + } + + if (num_chunks_in <= 0) + { + png_ptr->unknown_default = keep; + + /* '0' means just set the flags, so stop here */ + if (num_chunks_in == 0) + return; + } + + if (num_chunks_in < 0) + { + /* Ignore all unknown chunks and all chunks recognized by + * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND + */ + static PNG_CONST png_byte chunks_to_ignore[] = { + 98, 75, 71, 68, '\0', /* bKGD */ + 99, 72, 82, 77, '\0', /* cHRM */ + 103, 65, 77, 65, '\0', /* gAMA */ + 104, 73, 83, 84, '\0', /* hIST */ + 105, 67, 67, 80, '\0', /* iCCP */ + 105, 84, 88, 116, '\0', /* iTXt */ + 111, 70, 70, 115, '\0', /* oFFs */ + 112, 67, 65, 76, '\0', /* pCAL */ + 112, 72, 89, 115, '\0', /* pHYs */ + 115, 66, 73, 84, '\0', /* sBIT */ + 115, 67, 65, 76, '\0', /* sCAL */ + 115, 80, 76, 84, '\0', /* sPLT */ + 115, 84, 69, 82, '\0', /* sTER */ + 115, 82, 71, 66, '\0', /* sRGB */ + 116, 69, 88, 116, '\0', /* tEXt */ + 116, 73, 77, 69, '\0', /* tIME */ + 122, 84, 88, 116, '\0' /* zTXt */ + }; + + chunk_list = chunks_to_ignore; + num_chunks = (sizeof chunks_to_ignore)/5; + } + + else /* num_chunks_in > 0 */ + { + if (chunk_list == NULL) + { + /* Prior to 1.6.0 this was silently ignored, now it is an app_error + * which can be switched off. + */ + png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list"); + return; + } + + num_chunks = num_chunks_in; + } + + old_num_chunks = png_ptr->num_chunk_list; + if (png_ptr->chunk_list == NULL) + old_num_chunks = 0; + + /* Since num_chunks is always restricted to UINT_MAX/5 this can't overflow. + */ + if (num_chunks + old_num_chunks > UINT_MAX/5) + { + png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks"); + return; + } + + /* If these chunks are being reset to the default then no more memory is + * required because add_one_chunk above doesn't extend the list if the 'keep' + * parameter is the default. + */ + if (keep) + { + new_list = png_voidcast(png_bytep, png_malloc(png_ptr, + 5 * (num_chunks + old_num_chunks))); + + if (old_num_chunks > 0) + memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks); + } + + else if (old_num_chunks > 0) + new_list = png_ptr->chunk_list; + + else + new_list = NULL; + + /* Add the new chunks together with each one's handling code. If the chunk + * already exists the code is updated, otherwise the chunk is added to the + * end. (In libpng 1.6.0 order no longer matters because this code enforces + * the earlier convention that the last setting is the one that is used.) + */ + if (new_list != NULL) + { + png_const_bytep inlist; + png_bytep outlist; + unsigned int i; + + for (i=0; i<num_chunks; ++i) + old_num_chunks = add_one_chunk(new_list, old_num_chunks, + chunk_list+5*i, keep); + + /* Now remove any spurious 'default' entries. */ + num_chunks = 0; + for (i=0, inlist=outlist=new_list; i<old_num_chunks; ++i, inlist += 5) + if (inlist[4]) + { + if (outlist != inlist) + memcpy(outlist, inlist, 5); + outlist += 5; + ++num_chunks; + } + + /* This means the application has removed all the specialized handling. */ + if (num_chunks == 0) + { + if (png_ptr->chunk_list != new_list) + png_free(png_ptr, new_list); + + new_list = NULL; + } + } + + else + num_chunks = 0; + + png_ptr->num_chunk_list = num_chunks; + + if (png_ptr->chunk_list != new_list) + { + if (png_ptr->chunk_list != NULL) + png_free(png_ptr, png_ptr->chunk_list); + + png_ptr->chunk_list = new_list; + } } #endif -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED void PNGAPI -png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, - png_user_chunk_ptr read_user_chunk_fn) +png_set_read_user_chunk_fn(png_structrp png_ptr, png_voidp user_chunk_ptr, + png_user_chunk_ptr read_user_chunk_fn) { - png_debug(1, "in png_set_read_user_chunk_fn\n"); + png_debug(1, "in png_set_read_user_chunk_fn"); + if (png_ptr == NULL) return; + png_ptr->read_user_chunk_fn = read_user_chunk_fn; png_ptr->user_chunk_ptr = user_chunk_ptr; } #endif -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_INFO_IMAGE_SUPPORTED void PNGAPI -png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) +png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr, + png_bytepp row_pointers) { - png_debug1(1, "in %s storage function\n", "rows"); + png_debug1(1, "in %s storage function", "rows"); if (png_ptr == NULL || info_ptr == NULL) return; - if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) + if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); + info_ptr->row_pointers = row_pointers; - if(row_pointers) + + if (row_pointers) info_ptr->valid |= PNG_INFO_IDAT; } #endif -#ifdef PNG_WRITE_SUPPORTED void PNGAPI -png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) +png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size) { if (png_ptr == NULL) return; - if(png_ptr->zbuf) - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf_size = (png_size_t)size; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + if (size == 0 || size > PNG_UINT_31_MAX) + png_error(png_ptr, "invalid compression buffer size"); + +# ifdef PNG_SEQUENTIAL_READ_SUPPORTED + if (png_ptr->mode & PNG_IS_READ_STRUCT) + { + png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */ + return; + } +# endif + +# ifdef PNG_WRITE_SUPPORTED + if (!(png_ptr->mode & PNG_IS_READ_STRUCT)) + { + if (png_ptr->zowner != 0) + { + png_warning(png_ptr, + "Compression buffer size cannot be changed because it is in use"); + return; + } + + if (size > ZLIB_IO_MAX) + { + png_warning(png_ptr, + "Compression buffer size limited to system maximum"); + size = ZLIB_IO_MAX; /* must fit */ + } + + else if (size < 6) + { + /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH + * if this is permitted. + */ + png_warning(png_ptr, + "Compression buffer size cannot be reduced below 6"); + return; + } + + if (png_ptr->zbuffer_size != size) + { + png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); + png_ptr->zbuffer_size = (uInt)size; + } + } +# endif } -#endif void PNGAPI -png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) +png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask) { if (png_ptr && info_ptr) - info_ptr->valid &= ~(mask); + info_ptr->valid &= ~mask; } -#ifndef PNG_1_0_X -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -/* function was added to libpng 1.2.0 and should always exist by default */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +/* This function was added to libpng 1.2.6 */ void PNGAPI -png_set_asm_flags (png_structp png_ptr, png_uint_32) +png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max, + png_uint_32 user_height_max) { -/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ - if (png_ptr != NULL) - png_ptr->asm_flags = 0; + /* Images with dimensions larger than these limits will be + * rejected by png_set_IHDR(). To accept any PNG datastream + * regardless of dimensions, set both limits to 0x7ffffffL. + */ + if (png_ptr == NULL) + return; + + png_ptr->user_width_max = user_width_max; + png_ptr->user_height_max = user_height_max; } -/* this function was added to libpng 1.2.0 */ +/* This function was added to libpng 1.4.0 */ void PNGAPI -png_set_mmx_thresholds (png_structp png_ptr, - png_byte, - png_uint_32) +png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max) { -/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ - if (png_ptr == NULL) - return; + if (png_ptr) + png_ptr->user_chunk_cache_max = user_chunk_cache_max; } -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* this function was added to libpng 1.2.6 */ +/* This function was added to libpng 1.4.1 */ void PNGAPI -png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, - png_uint_32 user_height_max) +png_set_chunk_malloc_max (png_structrp png_ptr, + png_alloc_size_t user_chunk_malloc_max) { - /* Images with dimensions larger than these limits will be - * rejected by png_set_IHDR(). To accept any PNG datastream - * regardless of dimensions, set both limits to 0x7ffffffL. - */ - if(png_ptr == NULL) return; - png_ptr->user_width_max = user_width_max; - png_ptr->user_height_max = user_height_max; + if (png_ptr) + png_ptr->user_chunk_malloc_max = user_chunk_malloc_max; } #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ -#endif /* ?PNG_1_0_X */ + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +void PNGAPI +png_set_benign_errors(png_structrp png_ptr, int allowed) +{ + png_debug(1, "in png_set_benign_errors"); + + /* If allowed is 1, png_benign_error() is treated as a warning. + * + * If allowed is 0, png_benign_error() is treated as an error (which + * is the default behavior if png_set_benign_errors() is not called). + */ + + if (allowed) + png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN | + PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN; + + else + png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN | + PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN); +} +#endif /* PNG_BENIGN_ERRORS_SUPPORTED */ + +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Whether to report invalid palette index; added at libng-1.5.10. + * It is possible for an indexed (color-type==3) PNG file to contain + * pixels with invalid (out-of-range) indexes if the PLTE chunk has + * fewer entries than the image's bit-depth would allow. We recover + * from this gracefully by filling any incomplete palette with zeroes + * (opaque black). By default, when this occurs libpng will issue + * a benign error. This API can be used to override that behavior. + */ +void PNGAPI +png_set_check_for_invalid_index(png_structrp png_ptr, int allowed) +{ + png_debug(1, "in png_set_check_for_invalid_index"); + + if (allowed > 0) + png_ptr->num_palette_max = 0; + + else + png_ptr->num_palette_max = -1; +} +#endif #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngstruct.h b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngstruct.h new file mode 100644 index 000000000..89605b18b --- /dev/null +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngstruct.h @@ -0,0 +1,489 @@ + +/* pngstruct.h - header file for PNG reference library + * + * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * Last changed in libpng 1.6.1 [March 28, 2013] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* The structure that holds the information to read and write PNG files. + * The only people who need to care about what is inside of this are the + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application. + */ + +#ifndef PNGSTRUCT_H +#define PNGSTRUCT_H +/* zlib.h defines the structure z_stream, an instance of which is included + * in this structure and is required for decompressing the LZ compressed + * data in PNG files. + */ +#ifndef ZLIB_CONST + /* We must ensure that zlib uses 'const' in declarations. */ +# define ZLIB_CONST +#endif +#include "../../../juce_core/zip/zlib/zlib.h" +#ifdef const + /* zlib.h sometimes #defines const to nothing, undo this. */ +# undef const +#endif + +/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility + * with older builds. + */ +#if ZLIB_VERNUM < 0x1260 +# define PNGZ_MSG_CAST(s) png_constcast(char*,s) +# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b) +#else +# define PNGZ_MSG_CAST(s) (s) +# define PNGZ_INPUT_CAST(b) (b) +#endif + +/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib + * can handle at once. This type need be no larger than 16 bits (so maximum of + * 65535), this define allows us to discover how big it is, but limited by the + * maximuum for png_size_t. The value can be overriden in a library build + * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably + * lower value (e.g. 255 works). A lower value may help memory usage (slightly) + * and may even improve performance on some systems (and degrade it on others.) + */ +#ifndef ZLIB_IO_MAX +# define ZLIB_IO_MAX ((uInt)-1) +#endif + +#ifdef PNG_WRITE_SUPPORTED +/* The type of a compression buffer list used by the write code. */ +typedef struct png_compression_buffer +{ + struct png_compression_buffer *next; + png_byte output[1]; /* actually zbuf_size */ +} png_compression_buffer, *png_compression_bufferp; + +#define PNG_COMPRESSION_BUFFER_SIZE(pp)\ + (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size) +#endif + +/* Colorspace support; structures used in png_struct, png_info and in internal + * functions to hold and communicate information about the color space. + * + * PNG_COLORSPACE_SUPPORTED is only required if the application will perform + * colorspace corrections, otherwise all the colorspace information can be + * skipped and the size of libpng can be reduced (significantly) by compiling + * out the colorspace support. + */ +#ifdef PNG_COLORSPACE_SUPPORTED +/* The chromaticities of the red, green and blue colorants and the chromaticity + * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)). + */ +typedef struct png_xy +{ + png_fixed_point redx, redy; + png_fixed_point greenx, greeny; + png_fixed_point bluex, bluey; + png_fixed_point whitex, whitey; +} png_xy; + +/* The same data as above but encoded as CIE XYZ values. When this data comes + * from chromaticities the sum of the Y values is assumed to be 1.0 + */ +typedef struct png_XYZ +{ + png_fixed_point red_X, red_Y, red_Z; + png_fixed_point green_X, green_Y, green_Z; + png_fixed_point blue_X, blue_Y, blue_Z; +} png_XYZ; +#endif /* COLORSPACE */ + +#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) +/* A colorspace is all the above plus, potentially, profile information, + * however at present libpng does not use the profile internally so it is only + * stored in the png_info struct (if iCCP is supported.) The rendering intent + * is retained here and is checked. + * + * The file gamma encoding information is also stored here and gamma correction + * is done by libpng, whereas color correction must currently be done by the + * application. + */ +typedef struct png_colorspace +{ +#ifdef PNG_GAMMA_SUPPORTED + png_fixed_point gamma; /* File gamma */ +#endif + +#ifdef PNG_COLORSPACE_SUPPORTED + png_xy end_points_xy; /* End points as chromaticities */ + png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */ + png_uint_16 rendering_intent; /* Rendering intent of a profile */ +#endif + + /* Flags are always defined to simplify the code. */ + png_uint_16 flags; /* As defined below */ +} png_colorspace, * PNG_RESTRICT png_colorspacerp; + +typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp; + +/* General flags for the 'flags' field */ +#define PNG_COLORSPACE_HAVE_GAMMA 0x0001 +#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002 +#define PNG_COLORSPACE_HAVE_INTENT 0x0004 +#define PNG_COLORSPACE_FROM_gAMA 0x0008 +#define PNG_COLORSPACE_FROM_cHRM 0x0010 +#define PNG_COLORSPACE_FROM_sRGB 0x0020 +#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040 +#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */ +#define PNG_COLORSPACE_INVALID 0x8000 +#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags)) +#endif /* COLORSPACE || GAMMA */ + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */ + png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */ + jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */ + size_t jmp_buf_size; /* size of the above, if allocated */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ +#ifdef PNG_WARNINGS_SUPPORTED + png_error_ptr warning_fn; /* function for printing warnings */ +#endif + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions */ + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */ + z_stream zstream; /* decompression structure */ + +#ifdef PNG_WRITE_SUPPORTED + png_compression_bufferp zbuffer_list; /* Created on demand during write */ + uInt zbuffer_size; /* size of the actual buffer */ + + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ +#endif +/* Added at libpng 1.5.4 */ +#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED + int zlib_text_level; /* holds zlib compression level */ + int zlib_text_method; /* holds zlib compression method */ + int zlib_text_window_bits; /* holds zlib compression window bits */ + int zlib_text_mem_level; /* holds zlib compression memory level */ + int zlib_text_strategy; /* holds zlib compression strategy */ +#endif +/* End of material added at libpng 1.5.4 */ +/* Added at libpng 1.6.0 */ +#ifdef PNG_WRITE_SUPPORTED + int zlib_set_level; /* Actual values set into the zstream on write */ + int zlib_set_method; + int zlib_set_window_bits; + int zlib_set_mem_level; + int zlib_set_strategy; +#endif + + png_uint_32 width; /* width of image in pixels */ + png_uint_32 height; /* height of image in pixels */ + png_uint_32 num_rows; /* number of rows in current pass */ + png_uint_32 usr_width; /* width of row at start of write */ + png_size_t rowbytes; /* size of row in bytes */ + png_uint_32 iwidth; /* width of current interlaced row in pixels */ + png_uint_32 row_number; /* current row in interlace pass */ + png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */ + png_bytep prev_row; /* buffer to save previous (unfiltered) row. + * This is a pointer into big_prev_row + */ + png_bytep row_buf; /* buffer to save current (unfiltered) row. + * This is a pointer into big_row_buf + */ +#ifdef PNG_WRITE_SUPPORTED + png_bytep sub_row; /* buffer to save "sub" row when filtering */ + png_bytep up_row; /* buffer to save "up" row when filtering */ + png_bytep avg_row; /* buffer to save "avg" row when filtering */ + png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ +#endif + png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */ + + png_uint_32 idat_size; /* current IDAT size for read */ + png_uint_32 crc; /* current chunk CRC value */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + +/* Added at libpng-1.5.10 */ +#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED + int num_palette_max; /* maximum palette index found in IDAT */ +#endif + + png_uint_16 num_trans; /* number of transparency values */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row: write only */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ +#ifdef PNG_WRITE_SUPPORTED + png_byte usr_channels; /* channels at start of write: write only */ +#endif + png_byte sig_bytes; /* magic bytes read/written from start of file */ + png_byte maximum_pixel_depth; + /* pixel depth used for the row buffers */ + png_byte transformed_pixel_depth; + /* pixel depth after read/write transforms */ +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif + +#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) + png_byte background_gamma_type; + png_fixed_point background_gamma; + png_color_16 background; /* background color in screen gamma space */ +#ifdef PNG_READ_GAMMA_SUPPORTED + png_color_16 background_1; /* background normalized to gamma 1.0 */ +#endif +#endif /* PNG_bKGD_SUPPORTED */ + +#ifdef PNG_WRITE_FLUSH_SUPPORTED + png_flush_ptr output_flush_fn; /* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED + int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */ + png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */ + + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans_alpha; /* alpha values for paletted files */ + png_color_16 trans_color; /* transparent color for non-paletted files */ +#endif + + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* For the Borland special 64K segment handler */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED + png_bytep palette_lookup; /* lookup table for quantizing */ + png_bytep quantize_index; /* index translation for palette files */ +#endif + +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED + png_byte heuristic_method; /* heuristic for row filter selection */ + png_byte num_prev_filters; /* number of weights for previous rows */ + png_bytep prev_filters; /* filter type(s) of previous row(s) */ + png_uint_16p filter_weights; /* weight(s) for previous line(s) */ + png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ + png_uint_16p filter_costs; /* relative filter calculation cost */ + png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ +#endif + + /* Options */ +#ifdef PNG_SET_OPTION_SUPPORTED + png_byte options; /* On/off state (up to 4 options) */ +#endif + +#if PNG_LIBPNG_VER < 10700 +/* To do: remove this from libpng-1.7 */ +#ifdef PNG_TIME_RFC1123_SUPPORTED + char time_buffer[29]; /* String to hold RFC 1123 time text */ +#endif +#endif + +/* New members added in libpng-1.0.6 */ + + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ + +#ifdef PNG_USER_CHUNKS_SUPPORTED + png_voidp user_chunk_ptr; +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif +#endif + +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + int unknown_default; /* As PNG_HANDLE_* */ + unsigned int num_chunk_list; /* Number of entries in the list */ + png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name + * followed by a PNG_HANDLE_* byte */ +#endif + +/* New members added in libpng-1.0.3 */ +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + png_byte rgb_to_gray_status; + /* Added in libpng 1.5.5 to record setting of coefficients: */ + png_byte rgb_to_gray_coefficients_set; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */ +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) +/* Changed from png_byte to png_uint_32 at version 1.2.0 */ + png_uint_32 mng_features_permitted; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#ifdef PNG_MNG_FEATURES_SUPPORTED + png_byte filter_type; +#endif + +/* New members added in libpng-1.2.0 */ + +/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + +/* New member added in libpng-1.0.13 and 1.2.0 */ + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + +#ifdef PNG_READ_QUANTIZE_SUPPORTED +/* The following three members were added at version 1.0.14 and 1.2.4 */ + png_bytep quantize_sort; /* working sort array */ + png_bytep index_to_palette; /* where the original index currently is + in the palette */ + png_bytep palette_to_index; /* which original index points to this + palette color */ +#endif + +/* New members added in libpng-1.0.16 and 1.2.6 */ + png_byte compression_type; + +#ifdef PNG_USER_LIMITS_SUPPORTED + png_uint_32 user_width_max; + png_uint_32 user_height_max; + + /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown + * chunks that can be stored (0 means unlimited). + */ + png_uint_32 user_chunk_cache_max; + + /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk + * can occupy when decompressed. 0 means unlimited. + */ + png_alloc_size_t user_chunk_malloc_max; +#endif + +/* New member added in libpng-1.0.25 and 1.2.17 */ +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED + /* Temporary storage for unknown chunk that the library doesn't recognize, + * used while reading the chunk. + */ + png_unknown_chunk unknown_chunk; +#endif + +/* New member added in libpng-1.2.26 */ + png_size_t old_big_row_buf_size; + +#ifdef PNG_READ_SUPPORTED +/* New member added in libpng-1.2.30 */ + png_bytep read_buffer; /* buffer for reading chunk data */ + png_alloc_size_t read_buffer_size; /* current size of the buffer */ +#endif +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED + uInt IDAT_read_size; /* limit on read buffer size for IDAT */ +#endif + +#ifdef PNG_IO_STATE_SUPPORTED +/* New member added in libpng-1.4.0 */ + png_uint_32 io_state; +#endif + +/* New member added in libpng-1.5.6 */ + png_bytep big_prev_row; + +/* New member added in libpng-1.5.7 */ + void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info, + png_bytep row, png_const_bytep prev_row); + +#ifdef PNG_READ_SUPPORTED +#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) + png_colorspace colorspace; +#endif +#endif +}; +#endif /* PNGSTRUCT_H */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngtrans.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngtrans.c index 8c8faa13c..20558af3a 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngtrans.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngtrans.c @@ -1,47 +1,59 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.2.17 May 15, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.0 [February 14, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* turn on BGR-to-RGB mapping */ +/* Turn on BGR-to-RGB mapping */ void PNGAPI -png_set_bgr(png_structp png_ptr) +png_set_bgr(png_structrp png_ptr) { - png_debug(1, "in png_set_bgr\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_bgr"); + + if (png_ptr == NULL) + return; + png_ptr->transformations |= PNG_BGR; } #endif #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* turn on 16 bit byte swapping */ +/* Turn on 16 bit byte swapping */ void PNGAPI -png_set_swap(png_structp png_ptr) +png_set_swap(png_structrp png_ptr) { - png_debug(1, "in png_set_swap\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_swap"); + + if (png_ptr == NULL) + return; + if (png_ptr->bit_depth == 16) png_ptr->transformations |= PNG_SWAP_BYTES; } #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* turn on pixel packing */ +/* Turn on pixel packing */ void PNGAPI -png_set_packing(png_structp png_ptr) +png_set_packing(png_structrp png_ptr) { - png_debug(1, "in png_set_packing\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_packing"); + + if (png_ptr == NULL) + return; + if (png_ptr->bit_depth < 8) { png_ptr->transformations |= PNG_PACK; @@ -51,12 +63,15 @@ png_set_packing(png_structp png_ptr) #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* turn on packed pixel swapping */ +/* Turn on packed pixel swapping */ void PNGAPI -png_set_packswap(png_structp png_ptr) +png_set_packswap(png_structrp png_ptr) { - png_debug(1, "in png_set_packswap\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_packswap"); + + if (png_ptr == NULL) + return; + if (png_ptr->bit_depth < 8) png_ptr->transformations |= PNG_PACKSWAP; } @@ -64,10 +79,13 @@ png_set_packswap(png_structp png_ptr) #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) void PNGAPI -png_set_shift(png_structp png_ptr, png_color_8p true_bits) +png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits) { - png_debug(1, "in png_set_shift\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_shift"); + + if (png_ptr == NULL) + return; + png_ptr->transformations |= PNG_SHIFT; png_ptr->shift = *true_bits; } @@ -76,9 +94,10 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits) #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) int PNGAPI -png_set_interlace_handling(png_structp png_ptr) +png_set_interlace_handling(png_structrp png_ptr) { - png_debug(1, "in png_set_interlace handling\n"); + png_debug(1, "in png_set_interlace handling"); + if (png_ptr && png_ptr->interlaced) { png_ptr->transformations |= PNG_INTERLACE; @@ -96,57 +115,115 @@ png_set_interlace_handling(png_structp png_ptr) * that don't like bytes as parameters. */ void PNGAPI -png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) +png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc) { - png_debug(1, "in png_set_filler\n"); - if(png_ptr == NULL) return; - png_ptr->transformations |= PNG_FILLER; - png_ptr->filler = (png_byte)filler; - if (filler_loc == PNG_FILLER_AFTER) - png_ptr->flags |= PNG_FLAG_FILLER_AFTER; - else - png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; + png_debug(1, "in png_set_filler"); - /* This should probably go in the "do_read_filler" routine. - * I attempted to do that in libpng-1.0.1a but that caused problems - * so I restored it in libpng-1.0.2a - */ + if (png_ptr == NULL) + return; - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + /* In libpng 1.6 it is possible to determine whether this is a read or write + * operation and therefore to do more checking here for a valid call. + */ + if (png_ptr->mode & PNG_IS_READ_STRUCT) { - png_ptr->usr_channels = 4; +# ifdef PNG_READ_FILLER_SUPPORTED + /* On read png_set_filler is always valid, regardless of the base PNG + * format, because other transformations can give a format where the + * filler code can execute (basically an 8 or 16-bit component RGB or G + * format.) + * + * NOTE: usr_channels is not used by the read code! (This has led to + * confusion in the past.) The filler is only used in the read code. + */ + png_ptr->filler = (png_uint_16)filler; +# else + png_app_error(png_ptr, "png_set_filler not supported on read"); + PNG_UNUSED(filler) /* not used in the write case */ + return; +# endif } - /* Also I added this in libpng-1.0.2a (what happens when we expand - * a less-than-8-bit grayscale to GA? */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) + else /* write */ { - png_ptr->usr_channels = 2; +# ifdef PNG_WRITE_FILLER_SUPPORTED + /* On write the usr_channels parameter must be set correctly at the + * start to record the number of channels in the app-supplied data. + */ + switch (png_ptr->color_type) + { + case PNG_COLOR_TYPE_RGB: + png_ptr->usr_channels = 4; + break; + + case PNG_COLOR_TYPE_GRAY: + if (png_ptr->bit_depth >= 8) + { + png_ptr->usr_channels = 2; + break; + } + + else + { + /* There simply isn't any code in libpng to strip out bits + * from bytes when the components are less than a byte in + * size! + */ + png_app_error(png_ptr, + "png_set_filler is invalid for low bit depth gray output"); + return; + } + + default: + png_app_error(png_ptr, + "png_set_filler: inappropriate color type"); + return; + } +# else + png_app_error(png_ptr, "png_set_filler not supported on write"); + return; +# endif } + + /* Here on success - libpng supports the operation, set the transformation + * and the flag to say where the filler channel is. + */ + png_ptr->transformations |= PNG_FILLER; + + if (filler_loc == PNG_FILLER_AFTER) + png_ptr->flags |= PNG_FLAG_FILLER_AFTER; + + else + png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; } -#if !defined(PNG_1_0_X) /* Added to libpng-1.2.7 */ void PNGAPI -png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) +png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc) { - png_debug(1, "in png_set_add_alpha\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_add_alpha"); + + if (png_ptr == NULL) + return; + png_set_filler(png_ptr, filler, filler_loc); - png_ptr->transformations |= PNG_ADD_ALPHA; + /* The above may fail to do anything. */ + if (png_ptr->transformations & PNG_FILLER) + png_ptr->transformations |= PNG_ADD_ALPHA; } -#endif #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) void PNGAPI -png_set_swap_alpha(png_structp png_ptr) +png_set_swap_alpha(png_structrp png_ptr) { - png_debug(1, "in png_set_swap_alpha\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_swap_alpha"); + + if (png_ptr == NULL) + return; + png_ptr->transformations |= PNG_SWAP_ALPHA; } #endif @@ -154,40 +231,43 @@ png_set_swap_alpha(png_structp png_ptr) #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) void PNGAPI -png_set_invert_alpha(png_structp png_ptr) +png_set_invert_alpha(png_structrp png_ptr) { - png_debug(1, "in png_set_invert_alpha\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_invert_alpha"); + + if (png_ptr == NULL) + return; + png_ptr->transformations |= PNG_INVERT_ALPHA; } #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) void PNGAPI -png_set_invert_mono(png_structp png_ptr) +png_set_invert_mono(png_structrp png_ptr) { - png_debug(1, "in png_set_invert_mono\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_invert_mono"); + + if (png_ptr == NULL) + return; + png_ptr->transformations |= PNG_INVERT_MONO; } -/* invert monochrome grayscale data */ +/* Invert monochrome grayscale data */ void /* PRIVATE */ png_do_invert(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_invert\n"); + png_debug(1, "in png_do_invert"); + /* This test removed from libpng version 1.0.13 and 1.2.0: * if (row_info->bit_depth == 1 && */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row == NULL || row_info == NULL) - return; -#endif if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; + png_size_t i; + png_size_t istop = row_info->rowbytes; for (i = 0; i < istop; i++) { @@ -195,47 +275,49 @@ png_do_invert(png_row_infop row_info, png_bytep row) rp++; } } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && row_info->bit_depth == 8) { png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; + png_size_t i; + png_size_t istop = row_info->rowbytes; - for (i = 0; i < istop; i+=2) + for (i = 0; i < istop; i += 2) { *rp = (png_byte)(~(*rp)); - rp+=2; + rp += 2; } } + +#ifdef PNG_16BIT_SUPPORTED else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && row_info->bit_depth == 16) { png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; + png_size_t i; + png_size_t istop = row_info->rowbytes; - for (i = 0; i < istop; i+=4) + for (i = 0; i < istop; i += 4) { *rp = (png_byte)(~(*rp)); - *(rp+1) = (png_byte)(~(*(rp+1))); - rp+=4; + *(rp + 1) = (png_byte)(~(*(rp + 1))); + rp += 4; } } +#endif } #endif +#ifdef PNG_16BIT_SUPPORTED #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* swaps byte order on 16 bit depth images */ +/* Swaps byte order on 16 bit depth images */ void /* PRIVATE */ png_do_swap(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_swap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth == 16) + png_debug(1, "in png_do_swap"); + + if (row_info->bit_depth == 16) { png_bytep rp = row; png_uint_32 i; @@ -250,6 +332,7 @@ png_do_swap(png_row_infop row_info, png_bytep row) } } #endif +#endif #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) static PNG_CONST png_byte onebppswaptable[256] = { @@ -357,27 +440,28 @@ static PNG_CONST png_byte fourbppswaptable[256] = { 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF }; -/* swaps pixel packing order within bytes */ +/* Swaps pixel packing order within bytes */ void /* PRIVATE */ png_do_packswap(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_packswap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth < 8) + png_debug(1, "in png_do_packswap"); + + if (row_info->bit_depth < 8) { - png_bytep rp, end, table; + png_bytep rp; + png_const_bytep end, table; end = row + row_info->rowbytes; if (row_info->bit_depth == 1) - table = (png_bytep)onebppswaptable; + table = onebppswaptable; + else if (row_info->bit_depth == 2) - table = (png_bytep)twobppswaptable; + table = twobppswaptable; + else if (row_info->bit_depth == 4) - table = (png_bytep)fourbppswaptable; + table = fourbppswaptable; + else return; @@ -389,174 +473,130 @@ png_do_packswap(png_row_infop row_info, png_bytep row) #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* remove filler or alpha byte(s) */ +/* Remove a channel - this used to be 'png_do_strip_filler' but it used a + * somewhat weird combination of flags to determine what to do. All the calls + * to png_do_strip_filler are changed in 1.5.2 to call this instead with the + * correct arguments. + * + * The routine isn't general - the channel must be the channel at the start or + * end (not in the middle) of each pixel. + */ void /* PRIVATE */ -png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) +png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) { - png_debug(1, "in png_do_strip_filler\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif + png_bytep sp = row; /* source pointer */ + png_bytep dp = row; /* destination pointer */ + png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */ + + /* At the start sp will point to the first byte to copy and dp to where + * it is copied to. ep always points just beyond the end of the row, so + * the loop simply copies (channels-1) channels until sp reaches ep. + * + * at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc. + * nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc. + */ + + /* GA, GX, XG cases */ + if (row_info->channels == 2) { - png_bytep sp=row; - png_bytep dp=row; - png_uint_32 row_width=row_info->width; - png_uint_32 i; + if (row_info->bit_depth == 8) + { + if (at_start) /* Skip initial filler */ + ++sp; + else /* Skip initial channel and, for sp, the filler */ + sp += 2, ++dp; + + /* For a 1 pixel wide image there is nothing to do */ + while (sp < ep) + *dp++ = *sp, sp += 2; + + row_info->pixel_depth = 8; + } - if ((row_info->color_type == PNG_COLOR_TYPE_RGB || - (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - (flags & PNG_FLAG_STRIP_ALPHA))) && - row_info->channels == 4) + else if (row_info->bit_depth == 16) { - if (row_info->bit_depth == 8) - { - /* This converts from RGBX or RGBA to RGB */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - dp+=3; sp+=4; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp++; - } - } - /* This converts from XRGB or ARGB to RGB */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ - sp += 8; dp += 6; - for (i = 1; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ - for (i = 0; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - sp+=2; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 48; - row_info->rowbytes = row_width * 6; - } - row_info->channels = 3; + if (at_start) /* Skip initial filler */ + sp += 2; + else /* Skip initial channel and, for sp, the filler */ + sp += 4, dp += 2; + + while (sp < ep) + *dp++ = *sp++, *dp++ = *sp, sp += 3; + + row_info->pixel_depth = 16; } - else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY || - (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - (flags & PNG_FLAG_STRIP_ALPHA))) && - row_info->channels == 2) + + else + return; /* bad bit depth */ + + row_info->channels = 1; + + /* Finally fix the color type if it records an alpha channel */ + if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + row_info->color_type = PNG_COLOR_TYPE_GRAY; + } + + /* RGBA, RGBX, XRGB cases */ + else if (row_info->channels == 4) + { + if (row_info->bit_depth == 8) { - if (row_info->bit_depth == 8) + if (at_start) /* Skip initial filler */ + ++sp; + else /* Skip initial channels and, for sp, the filler */ + sp += 4, dp += 3; + + /* Note that the loop adds 3 to dp and 4 to sp each time. */ + while (sp < ep) + *dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2; + + row_info->pixel_depth = 24; + } + + else if (row_info->bit_depth == 16) + { + if (at_start) /* Skip initial filler */ + sp += 2; + else /* Skip initial channels and, for sp, the filler */ + sp += 8, dp += 6; + + while (sp < ep) { - /* This converts from GX or GA to G */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - for (i = 0; i < row_width; i++) - { - *dp++ = *sp++; - sp++; - } - } - /* This converts from XG or AG to G */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; + /* Copy 6 bytes, skip 2 */ + *dp++ = *sp++, *dp++ = *sp++; + *dp++ = *sp++, *dp++ = *sp++; + *dp++ = *sp++, *dp++ = *sp, sp += 3; } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from GGXX or GGAA to GG */ - sp += 4; dp += 2; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXGG or AAGG to GG */ - for (i = 0; i < row_width; i++) - { - sp += 2; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - row_info->channels = 1; + + row_info->pixel_depth = 48; } - if (flags & PNG_FLAG_STRIP_ALPHA) - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; + + else + return; /* bad bit depth */ + + row_info->channels = 3; + + /* Finally fix the color type if it records an alpha channel */ + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + row_info->color_type = PNG_COLOR_TYPE_RGB; } + + else + return; /* The filler channel has gone already */ + + /* Fix the rowbytes value. */ + row_info->rowbytes = dp-row; } #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* swaps red and blue bytes within a pixel */ +/* Swaps red and blue bytes within a pixel */ void /* PRIVATE */ png_do_bgr(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_bgr\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) + png_debug(1, "in png_do_bgr"); + + if ((row_info->color_type & PNG_COLOR_MASK_COLOR)) { png_uint_32 row_width = row_info->width; if (row_info->bit_depth == 8) @@ -573,6 +613,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row) *(rp + 2) = save; } } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { png_bytep rp; @@ -586,6 +627,8 @@ png_do_bgr(png_row_infop row_info, png_bytep row) } } } + +#ifdef PNG_16BIT_SUPPORTED else if (row_info->bit_depth == 16) { if (row_info->color_type == PNG_COLOR_TYPE_RGB) @@ -603,6 +646,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row) *(rp + 5) = save; } } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { png_bytep rp; @@ -619,28 +663,128 @@ png_do_bgr(png_row_infop row_info, png_bytep row) } } } +#endif } } #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ +#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ + defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) +/* Added at libpng-1.5.10 */ +void /* PRIVATE */ +png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) +{ + if (png_ptr->num_palette < (1 << row_info->bit_depth) && + png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */ + { + /* Calculations moved outside switch in an attempt to stop different + * compiler warnings. 'padding' is in *bits* within the last byte, it is + * an 'int' because pixel_depth becomes an 'int' in the expression below, + * and this calculation is used because it avoids warnings that other + * forms produced on either GCC or MSVC. + */ + int padding = (-row_info->pixel_depth * row_info->width) & 7; + png_bytep rp = png_ptr->row_buf + row_info->rowbytes; + + switch (row_info->bit_depth) + { + case 1: + { + /* in this case, all bytes must be 0 so we don't need + * to unpack the pixels except for the rightmost one. + */ + for (; rp > png_ptr->row_buf; rp--) + { + if (*rp >> padding != 0) + png_ptr->num_palette_max = 1; + padding = 0; + } + + break; + } + + case 2: + { + for (; rp > png_ptr->row_buf; rp--) + { + int i = ((*rp >> padding) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 2) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 4) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 6) & 0x03); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + padding = 0; + } + + break; + } + + case 4: + { + for (; rp > png_ptr->row_buf; rp--) + { + int i = ((*rp >> padding) & 0x0f); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + i = (((*rp >> padding) >> 4) & 0x0f); + + if (i > png_ptr->num_palette_max) + png_ptr->num_palette_max = i; + + padding = 0; + } + + break; + } + + case 8: + { + for (; rp > png_ptr->row_buf; rp--) + { + if (*rp > png_ptr->num_palette_max) + png_ptr->num_palette_max = (int) *rp; + } + + break; + } + + default: + break; + } + } +} +#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */ + #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED void PNGAPI -png_set_user_transform_info(png_structp png_ptr, png_voidp +png_set_user_transform_info(png_structrp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels) { - png_debug(1, "in png_set_user_transform_info\n"); - if(png_ptr == NULL) return; -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + png_debug(1, "in png_set_user_transform_info"); + + if (png_ptr == NULL) + return; png_ptr->user_transform_ptr = user_transform_ptr; png_ptr->user_transform_depth = (png_byte)user_transform_depth; png_ptr->user_transform_channels = (png_byte)user_transform_channels; -#else - if(user_transform_ptr || user_transform_depth || user_transform_channels) - png_warning(png_ptr, - "This version of libpng does not support user transform info"); -#endif } #endif @@ -649,14 +793,38 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp * associated with this pointer before png_write_destroy and png_read_destroy * are called. */ +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED png_voidp PNGAPI -png_get_user_transform_ptr(png_structp png_ptr) +png_get_user_transform_ptr(png_const_structrp png_ptr) { -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if (png_ptr == NULL) return (NULL); - return ((png_voidp)png_ptr->user_transform_ptr); -#else - return (NULL); + if (png_ptr == NULL) + return (NULL); + + return png_ptr->user_transform_ptr; +} #endif + +#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED +png_uint_32 PNGAPI +png_get_current_row_number(png_const_structrp png_ptr) +{ + /* See the comments in png.h - this is the sub-image row when reading and + * interlaced image. + */ + if (png_ptr != NULL) + return png_ptr->row_number; + + return PNG_UINT_32_MAX; /* help the app not to fail silently */ +} + +png_byte PNGAPI +png_get_current_pass_number(png_const_structrp png_ptr) +{ + if (png_ptr != NULL) + return png_ptr->pass; + return 8; /* invalid */ } +#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */ +#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED || + PNG_WRITE_USER_TRANSFORM_SUPPORTED */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwio.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwio.c index 34da2b23e..c5fca989c 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwio.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwio.c @@ -1,12 +1,15 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * Last changed in libpng 1.6.0 [February 14, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file provides a location for all output. Users who need * special handling are expected to write functions that have the same * arguments as these and perform similar functions, but that possibly @@ -15,220 +18,147 @@ * them at run time with png_set_write_fn(...). */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" + #ifdef PNG_WRITE_SUPPORTED /* Write the data to whatever output you are using. The default routine - writes to a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered writes. This should never be asked - to write more than 64K on a 16 bit machine. */ + * writes to a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered writes. This should never be asked + * to write more than 64K on a 16 bit machine. + */ void /* PRIVATE */ -png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length) { + /* NOTE: write_data_fn must not change the buffer! */ if (png_ptr->write_data_fn != NULL ) - (*(png_ptr->write_data_fn))(png_ptr, data, length); + (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data), + length); + else png_error(png_ptr, "Call to NULL write function"); } -#if !defined(PNG_NO_STDIO) +#ifdef PNG_STDIO_SUPPORTED /* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -void PNGAPI + * not writing to a standard C stream, you should create a replacement + * write_data function and use it at run time with png_set_write_fn(), rather + * than changing the library. + */ +void PNGCBAPI png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_uint_32 check; - - if(png_ptr == NULL) return; -#if defined(_WIN32_WCE) - if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); -#endif - if (check != length) - png_error(png_ptr, "Write Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ + png_size_t check; -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) + if (png_ptr == NULL) + return; -void PNGAPI -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; + check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); - if(png_ptr == NULL) return; - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(near_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) - err = 0; -#else - err = fwrite(buf, 1, written, io_ptr); -#endif - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } if (check != length) png_error(png_ptr, "Write Error"); } - -#endif #endif /* This function is called to output any data pending writing (normally - to disk). After png_flush is called, there should be no data pending - writing in any buffers. */ -#if defined(PNG_WRITE_FLUSH_SUPPORTED) + * to disk). After png_flush is called, there should be no data pending + * writing in any buffers. + */ +#ifdef PNG_WRITE_FLUSH_SUPPORTED void /* PRIVATE */ -png_flush(png_structp png_ptr) +png_flush(png_structrp png_ptr) { if (png_ptr->output_flush_fn != NULL) (*(png_ptr->output_flush_fn))(png_ptr); } -#if !defined(PNG_NO_STDIO) -void PNGAPI +# ifdef PNG_STDIO_SUPPORTED +void PNGCBAPI png_default_flush(png_structp png_ptr) { -#if !defined(_WIN32_WCE) png_FILE_p io_ptr; -#endif - if(png_ptr == NULL) return; -#if !defined(_WIN32_WCE) - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif + + if (png_ptr == NULL) + return; + + io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr)); + fflush(io_ptr); } -#endif +# endif #endif /* This function allows the application to supply new output functions for - libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png output data structure - io_ptr - pointer to user supplied structure containing info about - the output functions. May be NULL. - write_data_fn - pointer to a new output function that takes as its - arguments a pointer to a png_struct, a pointer to - data to be written, and a 32-bit unsigned int that is - the number of bytes to be written. The new write - function should call png_error(png_ptr, "Error msg") - to exit and output any fatal error messages. - flush_data_fn - pointer to a new flush function that takes as its - arguments a pointer to a png_struct. After a call to - the flush function, there should be no data in any buffers - or pending transmission. If the output method doesn't do - any buffering of ouput, a function prototype must still be - supplied although it doesn't have to do anything. If - PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - time, output_flush_fn will be ignored, although it must be - supplied for compatibility. */ + * libpng if standard C streams aren't being used. + * + * This function takes as its arguments: + * png_ptr - pointer to a png output data structure + * io_ptr - pointer to user supplied structure containing info about + * the output functions. May be NULL. + * write_data_fn - pointer to a new output function that takes as its + * arguments a pointer to a png_struct, a pointer to + * data to be written, and a 32-bit unsigned int that is + * the number of bytes to be written. The new write + * function should call png_error(png_ptr, "Error msg") + * to exit and output any fatal error messages. May be + * NULL, in which case libpng's default function will + * be used. + * flush_data_fn - pointer to a new flush function that takes as its + * arguments a pointer to a png_struct. After a call to + * the flush function, there should be no data in any buffers + * or pending transmission. If the output method doesn't do + * any buffering of output, a function prototype must still be + * supplied although it doesn't have to do anything. If + * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile + * time, output_flush_fn will be ignored, although it must be + * supplied for compatibility. May be NULL, in which case + * libpng's default function will be used, if + * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not + * a good idea if io_ptr does not point to a standard + * *FILE structure. + */ void PNGAPI -png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) +png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr, + png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + png_ptr->io_ptr = io_ptr; -#if !defined(PNG_NO_STDIO) +#ifdef PNG_STDIO_SUPPORTED if (write_data_fn != NULL) png_ptr->write_data_fn = write_data_fn; + else png_ptr->write_data_fn = png_default_write_data; #else png_ptr->write_data_fn = write_data_fn; #endif -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) +#ifdef PNG_WRITE_FLUSH_SUPPORTED +# ifdef PNG_STDIO_SUPPORTED + if (output_flush_fn != NULL) png_ptr->output_flush_fn = output_flush_fn; + else png_ptr->output_flush_fn = png_default_flush; -#else + +# else png_ptr->output_flush_fn = output_flush_fn; -#endif +# endif #endif /* PNG_WRITE_FLUSH_SUPPORTED */ /* It is an error to read while writing a png file */ if (png_ptr->read_data_fn != NULL) { png_ptr->read_data_fn = NULL; + png_warning(png_ptr, - "Attempted to set both read_data_fn and write_data_fn in"); - png_warning(png_ptr, - "the same structure. Resetting read_data_fn to NULL."); + "Can't set both read_data_fn and write_data_fn in the" + " same structure"); } } - -#if defined(USE_FAR_KEYWORD) -#if defined(_MSC_VER) -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - FP_OFF(near_ptr) = FP_OFF(ptr); - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(FP_SEG(ptr) != FP_SEG(far_ptr)) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# else -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - near_ptr = (void FAR *)ptr; - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(far_ptr != ptr) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# endif -# endif #endif /* PNG_WRITE_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwrite.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwrite.c index 5ab5bbccc..4c686824d 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwrite.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwrite.c @@ -1,18 +1,76 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ -/* get internal access to png.h */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" +#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) +# include <errno.h> +#endif + #ifdef PNG_WRITE_SUPPORTED +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +/* Write out all the unknown chunks for the current given location */ +static void +write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, + unsigned int where) +{ + if (info_ptr->unknown_chunks_num) + { + png_const_unknown_chunkp up; + + png_debug(5, "writing extra chunks"); + + for (up = info_ptr->unknown_chunks; + up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; + ++up) + if (up->location & where) + { + /* If per-chunk unknown chunk handling is enabled use it, otherwise + * just write the chunks the application has set. + */ +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + int keep = png_handle_as_unknown(png_ptr, up->name); + + /* NOTE: this code is radically different from the read side in the + * matter of handling an ancillary unknown chunk. In the read side + * the default behavior is to discard it, in the code below the default + * behavior is to write it. Critical chunks are, however, only + * written if explicitly listed or if the default is set to write all + * unknown chunks. + * + * The default handling is also slightly weird - it is not possible to + * stop the writing of all unsafe-to-copy chunks! + * + * TODO: REVIEW: this would seem to be a bug. + */ + if (keep != PNG_HANDLE_CHUNK_NEVER && + ((up->name[3] & 0x20) /* safe-to-copy overrides everything */ || + keep == PNG_HANDLE_CHUNK_ALWAYS || + (keep == PNG_HANDLE_CHUNK_AS_DEFAULT && + png_ptr->unknown_default == PNG_HANDLE_CHUNK_ALWAYS))) +#endif + { + /* TODO: review, what is wrong with a zero length unknown chunk? */ + if (up->size == 0) + png_warning(png_ptr, "Writing zero-length unknown chunk"); + + png_write_chunk(png_ptr, up->name, up->data, up->size); + } + } + } +} +#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */ + /* Writes all the PNG information. This is the suggested way to use the * library. If you have a new chunk to add, make a function to write it, * and put it in the correct location here. If you want the chunk written @@ -23,112 +81,120 @@ * them in png_write_end(), and compressing them. */ void PNGAPI -png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) +png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) { - png_debug(1, "in png_write_info_before_PLTE\n"); + png_debug(1, "in png_write_info_before_PLTE"); + if (png_ptr == NULL || info_ptr == NULL) return; + if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) { - png_write_sig(png_ptr); /* write PNG signature */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) + /* Write PNG signature */ + png_write_sig(png_ptr); + +#ifdef PNG_MNG_FEATURES_SUPPORTED + if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) && \ + (png_ptr->mng_features_permitted)) { - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); - png_ptr->mng_features_permitted=0; + png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); + png_ptr->mng_features_permitted = 0; } #endif - /* write IHDR information. */ + + /* Write IHDR information. */ png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, - info_ptr->filter_type, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - info_ptr->interlace_type); -#else - 0); -#endif - /* the rest of these check to see if the valid field has the appropriate - flag set, and if it does, writes the chunk. */ -#if defined(PNG_WRITE_gAMA_SUPPORTED) - if (info_ptr->valid & PNG_INFO_gAMA) - { -# ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_gAMA(png_ptr, info_ptr->gamma); + info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, + info_ptr->filter_type, +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + info_ptr->interlace_type #else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma); + 0 +#endif + ); + + /* The rest of these check to see if the valid field has the appropriate + * flag set, and if it does, writes the chunk. + * + * 1.6.0: COLORSPACE support controls the writing of these chunks too, and + * the chunks will be written if the WRITE routine is there and information + * is available in the COLORSPACE. (See png_colorspace_sync_info in png.c + * for where the valid flags get set.) + * + * Under certain circumstances the colorspace can be invalidated without + * syncing the info_struct 'valid' flags; this happens if libpng detects and + * error and calls png_error while the color space is being set, yet the + * application continues writing the PNG. So check the 'invalid' flag here + * too. + */ +#ifdef PNG_GAMMA_SUPPORTED +# ifdef PNG_WRITE_gAMA_SUPPORTED + if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) && + (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) && + (info_ptr->valid & PNG_INFO_gAMA)) + png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma); # endif #endif - } -#endif -#if defined(PNG_WRITE_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); -#endif -#if defined(PNG_WRITE_iCCP_SUPPORTED) - if (info_ptr->valid & PNG_INFO_iCCP) - png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, - info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); -#endif -#if defined(PNG_WRITE_sBIT_SUPPORTED) + +#ifdef PNG_COLORSPACE_SUPPORTED + /* Write only one of sRGB or an ICC profile. If a profile was supplied + * and it matches one of the known sRGB ones issue a warning. + */ +# ifdef PNG_WRITE_iCCP_SUPPORTED + if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) && + (info_ptr->valid & PNG_INFO_iCCP)) + { +# ifdef PNG_WRITE_sRGB_SUPPORTED + if (info_ptr->valid & PNG_INFO_sRGB) + png_app_warning(png_ptr, + "profile matches sRGB but writing iCCP instead"); +# endif + + png_write_iCCP(png_ptr, info_ptr->iccp_name, + info_ptr->iccp_profile); + } +# ifdef PNG_WRITE_sRGB_SUPPORTED + else +# endif +# endif + +# ifdef PNG_WRITE_sRGB_SUPPORTED + if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) && + (info_ptr->valid & PNG_INFO_sRGB)) + png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent); +# endif /* WRITE_sRGB */ +#endif /* COLORSPACE */ + +#ifdef PNG_WRITE_sBIT_SUPPORTED if (info_ptr->valid & PNG_INFO_sBIT) png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); #endif -#if defined(PNG_WRITE_cHRM_SUPPORTED) - if (info_ptr->valid & PNG_INFO_cHRM) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_cHRM(png_ptr, - info_ptr->x_white, info_ptr->y_white, - info_ptr->x_red, info_ptr->y_red, - info_ptr->x_green, info_ptr->y_green, - info_ptr->x_blue, info_ptr->y_blue); -#else -# ifdef PNG_FIXED_POINT_SUPPORTED - png_write_cHRM_fixed(png_ptr, - info_ptr->int_x_white, info_ptr->int_y_white, - info_ptr->int_x_red, info_ptr->int_y_red, - info_ptr->int_x_green, info_ptr->int_y_green, - info_ptr->int_x_blue, info_ptr->int_y_blue); + +#ifdef PNG_COLORSPACE_SUPPORTED +# ifdef PNG_WRITE_cHRM_SUPPORTED + if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) && + (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) && + (info_ptr->valid & PNG_INFO_cHRM)) + png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy); # endif #endif - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && !(up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR); #endif + png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; } } void PNGAPI -png_write_info(png_structp png_ptr, png_infop info_ptr) +png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) { #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) int i; #endif - png_debug(1, "in png_write_info\n"); + png_debug(1, "in png_write_info"); if (png_ptr == NULL || info_ptr == NULL) return; @@ -137,152 +203,136 @@ png_write_info(png_structp png_ptr, png_infop info_ptr) if (info_ptr->valid & PNG_INFO_PLTE) png_write_PLTE(png_ptr, info_ptr->palette, - (png_uint_32)info_ptr->num_palette); + (png_uint_32)info_ptr->num_palette); + else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) png_error(png_ptr, "Valid palette required for paletted images"); -#if defined(PNG_WRITE_tRNS_SUPPORTED) +#ifdef PNG_WRITE_tRNS_SUPPORTED if (info_ptr->valid & PNG_INFO_tRNS) + { +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED + /* Invert the alpha channel (in tRNS) */ + if ((png_ptr->transformations & PNG_INVERT_ALPHA) && + info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel (in tRNS) */ - if ((png_ptr->transformations & PNG_INVERT_ALPHA) && - info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - int j; - for (j=0; j<(int)info_ptr->num_trans; j++) - info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); - } -#endif - png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), - info_ptr->num_trans, info_ptr->color_type); + int j; + for (j = 0; j<(int)info_ptr->num_trans; j++) + info_ptr->trans_alpha[j] = + (png_byte)(255 - info_ptr->trans_alpha[j]); } #endif -#if defined(PNG_WRITE_bKGD_SUPPORTED) + png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color), + info_ptr->num_trans, info_ptr->color_type); + } +#endif +#ifdef PNG_WRITE_bKGD_SUPPORTED if (info_ptr->valid & PNG_INFO_bKGD) png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); #endif -#if defined(PNG_WRITE_hIST_SUPPORTED) + +#ifdef PNG_WRITE_hIST_SUPPORTED if (info_ptr->valid & PNG_INFO_hIST) png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); #endif -#if defined(PNG_WRITE_oFFs_SUPPORTED) + +#ifdef PNG_WRITE_oFFs_SUPPORTED if (info_ptr->valid & PNG_INFO_oFFs) png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, - info_ptr->offset_unit_type); + info_ptr->offset_unit_type); #endif -#if defined(PNG_WRITE_pCAL_SUPPORTED) + +#ifdef PNG_WRITE_pCAL_SUPPORTED if (info_ptr->valid & PNG_INFO_pCAL) png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, - info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, - info_ptr->pcal_units, info_ptr->pcal_params); + info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, + info_ptr->pcal_units, info_ptr->pcal_params); #endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) + +#ifdef PNG_WRITE_sCAL_SUPPORTED if (info_ptr->valid & PNG_INFO_sCAL) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) - png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, info_ptr->scal_s_width, info_ptr->scal_s_height); -#else - png_warning(png_ptr, - "png_write_sCAL not supported; sCAL chunk not written."); -#endif -#endif -#endif -#if defined(PNG_WRITE_pHYs_SUPPORTED) +#endif /* sCAL */ + +#ifdef PNG_WRITE_pHYs_SUPPORTED if (info_ptr->valid & PNG_INFO_pHYs) png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, - info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) + info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); +#endif /* pHYs */ + +#ifdef PNG_WRITE_tIME_SUPPORTED if (info_ptr->valid & PNG_INFO_tIME) { png_write_tIME(png_ptr, &(info_ptr->mod_time)); png_ptr->mode |= PNG_WROTE_tIME; } -#endif -#if defined(PNG_WRITE_sPLT_SUPPORTED) +#endif /* tIME */ + +#ifdef PNG_WRITE_sPLT_SUPPORTED if (info_ptr->valid & PNG_INFO_sPLT) - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) + for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) + png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); +#endif /* sPLT */ + +#ifdef PNG_WRITE_TEXT_SUPPORTED /* Check to see if we need to write text chunks */ for (i = 0; i < info_ptr->num_text; i++) { - png_debug2(2, "Writing header text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ + png_debug2(2, "Writing header text chunk %d, type %d", i, + info_ptr->text[i].compression); + /* An internationalized chunk? */ if (info_ptr->text[i].compression > 0) { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); +#ifdef PNG_WRITE_iTXt_SUPPORTED + /* Write international chunk */ + png_write_iTXt(png_ptr, + info_ptr->text[i].compression, + info_ptr->text[i].key, + info_ptr->text[i].lang, + info_ptr->text[i].lang_key, + info_ptr->text[i].text); #else png_warning(png_ptr, "Unable to write international text"); #endif /* Mark this chunk as written */ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; } + /* If we want a compressed text chunk */ else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ +#ifdef PNG_WRITE_zTXt_SUPPORTED + /* Write compressed chunk */ png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); + info_ptr->text[i].text, 0, + info_ptr->text[i].compression); #else png_warning(png_ptr, "Unable to write compressed text"); #endif /* Mark this chunk as written */ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; } + else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ +#ifdef PNG_WRITE_tEXt_SUPPORTED + /* Write uncompressed chunk */ png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, - 0); + info_ptr->text[i].text, + 0); + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; #else + /* Can't get here */ png_warning(png_ptr, "Unable to write uncompressed text"); #endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; } } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); +#endif /* tEXt */ - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_PLTE); #endif } @@ -292,68 +342,78 @@ png_write_info(png_structp png_ptr, png_infop info_ptr) * comments, I suggest writing them here, and compressing them. */ void PNGAPI -png_write_end(png_structp png_ptr, png_infop info_ptr) +png_write_end(png_structrp png_ptr, png_inforp info_ptr) { - png_debug(1, "in png_write_end\n"); + png_debug(1, "in png_write_end"); + if (png_ptr == NULL) return; + if (!(png_ptr->mode & PNG_HAVE_IDAT)) png_error(png_ptr, "No IDATs written into file"); - /* see if user wants us to write information chunks */ +#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED + if (png_ptr->num_palette_max > png_ptr->num_palette) + png_benign_error(png_ptr, "Wrote palette index exceeding num_palette"); +#endif + + /* See if user wants us to write information chunks */ if (info_ptr != NULL) { -#if defined(PNG_WRITE_TEXT_SUPPORTED) +#ifdef PNG_WRITE_TEXT_SUPPORTED int i; /* local index variable */ #endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - /* check to see if user has supplied a time chunk */ +#ifdef PNG_WRITE_tIME_SUPPORTED + /* Check to see if user has supplied a time chunk */ if ((info_ptr->valid & PNG_INFO_tIME) && - !(png_ptr->mode & PNG_WROTE_tIME)) + !(png_ptr->mode & PNG_WROTE_tIME)) png_write_tIME(png_ptr, &(info_ptr->mod_time)); + #endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* loop through comment chunks */ +#ifdef PNG_WRITE_TEXT_SUPPORTED + /* Loop through comment chunks */ for (i = 0; i < info_ptr->num_text; i++) { - png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, + png_debug2(2, "Writing trailer text chunk %d, type %d", i, info_ptr->text[i].compression); - /* an internationalized chunk? */ + /* An internationalized chunk? */ if (info_ptr->text[i].compression > 0) { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); +#ifdef PNG_WRITE_iTXt_SUPPORTED + /* Write international chunk */ + png_write_iTXt(png_ptr, + info_ptr->text[i].compression, + info_ptr->text[i].key, + info_ptr->text[i].lang, + info_ptr->text[i].lang_key, + info_ptr->text[i].text); #else - png_warning(png_ptr, "Unable to write international text"); + png_warning(png_ptr, "Unable to write international text"); #endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; } + else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ +#ifdef PNG_WRITE_zTXt_SUPPORTED + /* Write compressed chunk */ png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); + info_ptr->text[i].text, 0, + info_ptr->text[i].compression); #else png_warning(png_ptr, "Unable to write compressed text"); #endif /* Mark this chunk as written */ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; } + else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ +#ifdef PNG_WRITE_tEXt_SUPPORTED + /* Write uncompressed chunk */ png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0); + info_ptr->text[i].text, 0); #else png_warning(png_ptr, "Unable to write uncompressed text"); #endif @@ -363,43 +423,35 @@ png_write_end(png_structp png_ptr, png_infop info_ptr) } } #endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != PNG_HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_AFTER_IDAT) && - ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT); #endif } png_ptr->mode |= PNG_AFTER_IDAT; - /* write end of PNG file */ + /* Write end of PNG file */ png_write_IEND(png_ptr); + /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03, + * and restored again in libpng-1.2.30, may cause some applications that + * do not set png_ptr->output_flush_fn to crash. If your application + * experiences a problem, please try building libpng with + * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to + * png-mng-implement at lists.sf.net . + */ +#ifdef PNG_WRITE_FLUSH_SUPPORTED +# ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED + png_flush(png_ptr); +# endif +#endif } -#if defined(PNG_WRITE_tIME_SUPPORTED) -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ +#ifdef PNG_CONVERT_tIME_SUPPORTED void PNGAPI -png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) +png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime) { - png_debug(1, "in png_convert_from_struct_tm\n"); + png_debug(1, "in png_convert_from_struct_tm"); + ptime->year = (png_uint_16)(1900 + ttime->tm_year); ptime->month = (png_byte)(ttime->tm_mon + 1); ptime->day = (png_byte)ttime->tm_mday; @@ -413,273 +465,90 @@ png_convert_from_time_t(png_timep ptime, time_t ttime) { struct tm *tbuf; - png_debug(1, "in png_convert_from_time_t\n"); + png_debug(1, "in png_convert_from_time_t"); + tbuf = gmtime(&ttime); png_convert_from_struct_tm(ptime, tbuf); } #endif -#endif /* Initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) +PNG_FUNCTION(png_structp,PNGAPI +png_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED) { -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); +#ifndef PNG_USER_MEM_SUPPORTED + png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr, + error_fn, warn_fn, NULL, NULL, NULL); +#else + return png_create_write_struct_2(user_png_ver, error_ptr, error_fn, + warn_fn, NULL, NULL, NULL); } /* Alternate initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) +PNG_FUNCTION(png_structp,PNGAPI +png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) { + png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr, + error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); #endif /* PNG_USER_MEM_SUPPORTED */ - png_structp png_ptr; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - int i; - png_debug(1, "in png_create_write_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); -#else - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); -#endif /* PNG_USER_MEM_SUPPORTED */ - if (png_ptr == NULL) - return (NULL); - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; - png_destroy_struct(png_ptr); - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#endif -#endif + /* Set the zlib control values to defaults; they can be overridden by the + * application after the struct has been created. + */ + png_ptr->zbuffer_size = PNG_ZBUF_SIZE; -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif /* PNG_USER_MEM_SUPPORTED */ - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); + /* The 'zlib_strategy' setting is irrelevant because png_default_claim in + * pngwutil.c defaults it according to whether or not filters will be used, + * and ignores this setting. + */ + png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY; + png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION; + png_ptr->zlib_mem_level = 8; + png_ptr->zlib_window_bits = 15; + png_ptr->zlib_method = 8; + +#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED + png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY; + png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION; + png_ptr->zlib_text_mem_level = 8; + png_ptr->zlib_text_window_bits = 15; + png_ptr->zlib_text_method = 8; +#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */ + + /* This is a highly dubious configuration option; by default it is off, but + * it may be appropriate for private builds that are testing extensions not + * conformant to the current specification, or of applications that must not + * fail to write at all costs! + */ +# ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED + png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; + /* In stable builds only warn if an application error can be completely + * handled. + */ +# endif - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); + /* App warnings are warnings in release (or release candidate) builds but + * are errors during development. + */ +# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC + png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; +# endif - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) + if (png_ptr != NULL) { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - png_snprintf(msg, 80, - "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } + /* TODO: delay this, it can be done in png_init_io() (if the app doesn't + * do it itself) avoiding setting the default function if it is not + * required. + */ + png_set_write_fn(png_ptr, NULL, NULL, NULL); } - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -/* Initialize png_ptr structure, and allocate any memory needed */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Deprecated. */ -#undef png_write_init -void PNGAPI -png_write_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - png_snprintf(msg, 80, - "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for writing is too small."); - } - if(png_sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by the application for writing is too small."); - } - png_write_init_3(&png_ptr, user_png_ver, png_struct_size); + return png_ptr; } -#endif /* PNG_1_0_X || PNG_1_2_X */ - - -void PNGAPI -png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ - png_structp png_ptr=*ptr_ptr; -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i = 0; - - if (png_ptr == NULL) - return; - - do - { - if (user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_write_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_write_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); -#endif - - if (png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - *ptr_ptr = png_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif -} /* Write a few rows of image data. If the image is interlaced, * either you will have to write the 7 sub images, or, if you @@ -687,18 +556,18 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, * "write" the image seven times. */ void PNGAPI -png_write_rows(png_structp png_ptr, png_bytepp row, - png_uint_32 num_rows) +png_write_rows(png_structrp png_ptr, png_bytepp row, + png_uint_32 num_rows) { png_uint_32 i; /* row counter */ png_bytepp rp; /* row pointer */ - png_debug(1, "in png_write_rows\n"); + png_debug(1, "in png_write_rows"); if (png_ptr == NULL) return; - /* loop through the rows */ + /* Loop through the rows */ for (i = 0, rp = row; i < num_rows; i++, rp++) { png_write_row(png_ptr, *rp); @@ -709,7 +578,7 @@ png_write_rows(png_structp png_ptr, png_bytepp row, * if you are writing an interlaced image. */ void PNGAPI -png_write_image(png_structp png_ptr, png_bytepp image) +png_write_image(png_structrp png_ptr, png_bytepp image) { png_uint_32 i; /* row index */ int pass, num_pass; /* pass variables */ @@ -718,18 +587,20 @@ png_write_image(png_structp png_ptr, png_bytepp image) if (png_ptr == NULL) return; - png_debug(1, "in png_write_image\n"); -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* intialize interlace handling. If image is not interlaced, - this will set pass to 1 */ + png_debug(1, "in png_write_image"); + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Initialize interlace handling. If image is not interlaced, + * this will set pass to 1 + */ num_pass = png_set_interlace_handling(png_ptr); #else num_pass = 1; #endif - /* loop through passes */ + /* Loop through passes */ for (pass = 0; pass < num_pass; pass++) { - /* loop through image */ + /* Loop through image */ for (i = 0, rp = image; i < png_ptr->height; i++, rp++) { png_write_row(png_ptr, *rp); @@ -737,58 +608,69 @@ png_write_image(png_structp png_ptr, png_bytepp image) } } -/* called by user to write a row of image data */ +/* Called by user to write a row of image data */ void PNGAPI -png_write_row(png_structp png_ptr, png_bytep row) +png_write_row(png_structrp png_ptr, png_const_bytep row) { + /* 1.5.6: moved from png_struct to be a local structure: */ + png_row_info row_info; + if (png_ptr == NULL) return; - png_debug2(1, "in png_write_row (row %ld, pass %d)\n", + + png_debug2(1, "in png_write_row (row %u, pass %d)", png_ptr->row_number, png_ptr->pass); - /* initialize transformations and other stuff if first time */ + /* Initialize transformations and other stuff if first time */ if (png_ptr->row_number == 0 && png_ptr->pass == 0) { - /* make sure we wrote the header info */ - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - png_error(png_ptr, - "png_write_info was never called before png_write_row."); + /* Make sure we wrote the header info */ + if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) + png_error(png_ptr, + "png_write_info was never called before png_write_row"); - /* check for transforms that have been set but were defined out */ + /* Check for transforms that have been set but were defined out */ #if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_INVERT_MONO) + png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined"); #endif + #if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_FILLER) + png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined"); #endif -#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); +#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ + defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + png_warning(png_ptr, + "PNG_WRITE_PACKSWAP_SUPPORTED is not defined"); #endif + #if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_PACK) + png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined"); #endif + #if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_SHIFT) + png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined"); #endif + #if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_BGR) + png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined"); #endif + #if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_SWAP_BYTES) + png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined"); #endif png_write_start_row(png_ptr); } -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* if interlaced and not interested in row, return */ +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* If interlaced and not interested in row, return */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { switch (png_ptr->pass) @@ -800,6 +682,7 @@ png_write_row(png_structp png_ptr, png_bytep row) return; } break; + case 1: if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) { @@ -807,6 +690,7 @@ png_write_row(png_structp png_ptr, png_bytep row) return; } break; + case 2: if ((png_ptr->row_number & 0x07) != 4) { @@ -814,6 +698,7 @@ png_write_row(png_structp png_ptr, png_bytep row) return; } break; + case 3: if ((png_ptr->row_number & 0x03) || png_ptr->width < 3) { @@ -821,6 +706,7 @@ png_write_row(png_structp png_ptr, png_bytep row) return; } break; + case 4: if ((png_ptr->row_number & 0x03) != 2) { @@ -828,6 +714,7 @@ png_write_row(png_structp png_ptr, png_bytep row) return; } break; + case 5: if ((png_ptr->row_number & 0x01) || png_ptr->width < 2) { @@ -835,6 +722,7 @@ png_write_row(png_structp png_ptr, png_bytep row) return; } break; + case 6: if (!(png_ptr->row_number & 0x01)) { @@ -842,41 +730,39 @@ png_write_row(png_structp png_ptr, png_bytep row) return; } break; + + default: /* error: ignore it */ + break; } } #endif - /* set up row info for transformations */ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->usr_width; - png_ptr->row_info.channels = png_ptr->usr_channels; - png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth; - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); + /* Set up row info for transformations */ + row_info.color_type = png_ptr->color_type; + row_info.width = png_ptr->usr_width; + row_info.channels = png_ptr->usr_channels; + row_info.bit_depth = png_ptr->usr_bit_depth; + row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels); + row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); - png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); - png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); - png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); - png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); + png_debug1(3, "row_info->color_type = %d", row_info.color_type); + png_debug1(3, "row_info->width = %u", row_info.width); + png_debug1(3, "row_info->channels = %d", row_info.channels); + png_debug1(3, "row_info->bit_depth = %d", row_info.bit_depth); + png_debug1(3, "row_info->pixel_depth = %d", row_info.pixel_depth); + png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes); /* Copy user's row into buffer, leaving room for filter byte. */ - png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, - png_ptr->row_info.rowbytes); + memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes); -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* handle interlacing */ +#ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Handle interlacing */ if (png_ptr->interlaced && png_ptr->pass < 6 && - (png_ptr->transformations & PNG_INTERLACE)) + (png_ptr->transformations & PNG_INTERLACE)) { - png_do_write_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass); - /* this should always get caught above, but still ... */ - if (!(png_ptr->row_info.width)) + png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass); + /* This should always get caught above, but still ... */ + if (!(row_info.width)) { png_write_finish_row(png_ptr); return; @@ -884,11 +770,20 @@ png_write_row(png_structp png_ptr, png_bytep row) } #endif - /* handle other transformations */ +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED + /* Handle other transformations */ if (png_ptr->transformations) - png_do_write_transformations(png_ptr); + png_do_write_transformations(png_ptr, &row_info); +#endif + + /* At this point the row_info pixel depth must match the 'transformed' depth, + * which is also the output depth. + */ + if (row_info.pixel_depth != png_ptr->pixel_depth || + row_info.pixel_depth != png_ptr->transformed_pixel_depth) + png_error(png_ptr, "internal write transform logic error"); -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED /* Write filter_method 64 (intrapixel differencing) only if * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and * 2. Libpng did not write a PNG signature (this filter_method is only @@ -898,248 +793,177 @@ png_write_row(png_structp png_ptr, png_bytep row) * 4. The filter_method is 64 and * 5. The color_type is RGB or RGBA */ - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) { /* Intrapixel differencing */ - png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1); } #endif +/* Added at libpng-1.5.10 */ +#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED + /* Check for out-of-range palette index */ + if (row_info.color_type == PNG_COLOR_TYPE_PALETTE && + png_ptr->num_palette_max >= 0) + png_do_check_palette_indexes(png_ptr, &row_info); +#endif + /* Find a filter if necessary, filter the row and write it out. */ - png_write_find_filter(png_ptr, &(png_ptr->row_info)); + png_write_find_filter(png_ptr, &row_info); if (png_ptr->write_row_fn != NULL) (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); } -#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#ifdef PNG_WRITE_FLUSH_SUPPORTED /* Set the automatic flush interval or 0 to turn flushing off */ void PNGAPI -png_set_flush(png_structp png_ptr, int nrows) +png_set_flush(png_structrp png_ptr, int nrows) { - png_debug(1, "in png_set_flush\n"); + png_debug(1, "in png_set_flush"); + if (png_ptr == NULL) return; + png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); } -/* flush the current output buffers now */ +/* Flush the current output buffers now */ void PNGAPI -png_write_flush(png_structp png_ptr) +png_write_flush(png_structrp png_ptr) { - int wrote_IDAT; + png_debug(1, "in png_write_flush"); - png_debug(1, "in png_write_flush\n"); if (png_ptr == NULL) return; + /* We have already written out all of the data */ if (png_ptr->row_number >= png_ptr->num_rows) - return; - - do - { - int ret; - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); - wrote_IDAT = 0; - - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - wrote_IDAT = 1; - } - } while(wrote_IDAT == 1); + return; - /* If there is any data left to be output, write it into a new IDAT */ - if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } + png_compress_IDAT(png_ptr, NULL, 0, Z_SYNC_FLUSH); png_ptr->flush_rows = 0; png_flush(png_ptr); } #endif /* PNG_WRITE_FLUSH_SUPPORTED */ -/* free all memory used by the write */ -void PNGAPI -png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; -#endif - - png_debug(1, "in png_destroy_write_struct\n"); - if (png_ptr_ptr != NULL) - { - png_ptr = *png_ptr_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */ #endif - } - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; +/* Free any memory used in png_ptr struct without freeing the struct itself. */ +static void +png_write_destroy(png_structrp png_ptr) +{ + png_debug(1, "in png_write_destroy"); - if (info_ptr != NULL) - { - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); + /* Free any memory zlib uses */ + if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) + deflateEnd(&png_ptr->zstream); -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } + /* Free our memory. png_free checks NULL for us. */ + png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); + png_free(png_ptr, png_ptr->row_buf); +#ifdef PNG_WRITE_FILTER_SUPPORTED + png_free(png_ptr, png_ptr->prev_row); + png_free(png_ptr, png_ptr->sub_row); + png_free(png_ptr, png_ptr->up_row); + png_free(png_ptr, png_ptr->avg_row); + png_free(png_ptr, png_ptr->paeth_row); #endif -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = NULL; - } - - if (png_ptr != NULL) - { - png_write_destroy(png_ptr); -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = NULL; - } -} - - -/* Free any memory used in png_ptr struct (old method) */ -void /* PRIVATE */ -png_write_destroy(png_structp png_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* save jump buffer */ -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_write_destroy\n"); - /* free any memory zlib uses */ - deflateEnd(&png_ptr->zstream); - - /* free our memory. png_free checks NULL for us. */ - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->row_buf); - png_free(png_ptr, png_ptr->prev_row); - png_free(png_ptr, png_ptr->sub_row); - png_free(png_ptr, png_ptr->up_row); - png_free(png_ptr, png_ptr->avg_row); - png_free(png_ptr, png_ptr->paeth_row); - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_free(png_ptr, png_ptr->prev_filters); - png_free(png_ptr, png_ptr->filter_weights); - png_free(png_ptr, png_ptr->inv_filter_weights); +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED + /* Use this to save a little code space, it doesn't free the filter_costs */ + png_reset_filter_heuristics(png_ptr); png_free(png_ptr, png_ptr->filter_costs); png_free(png_ptr, png_ptr->inv_filter_costs); #endif -#ifdef PNG_SETJMP_SUPPORTED - /* reset structure */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); +#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED + png_free(png_ptr, png_ptr->chunk_list); #endif - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif + /* The error handling and memory handling information is left intact at this + * point: the jmp_buf may still have to be freed. See png_destroy_png_struct + * for how this happens. + */ +} - png_memset(png_ptr, 0, png_sizeof (png_struct)); +/* Free all memory used by the write. + * In libpng 1.6.0 this API changed quietly to no longer accept a NULL value for + * *png_ptr_ptr. Prior to 1.6.0 it would accept such a value and it would free + * the passed in info_structs but it would quietly fail to free any of the data + * inside them. In 1.6.0 it quietly does nothing (it has to be quiet because it + * has no png_ptr.) + */ +void PNGAPI +png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) +{ + png_debug(1, "in png_destroy_write_struct"); - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif + if (png_ptr_ptr != NULL) + { + png_structrp png_ptr = *png_ptr_ptr; -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); -#endif + if (png_ptr != NULL) /* added in libpng 1.6.0 */ + { + png_destroy_info_struct(png_ptr, info_ptr_ptr); + + *png_ptr_ptr = NULL; + png_write_destroy(png_ptr); + png_destroy_png_struct(png_ptr); + } + } } /* Allow the application to select one or more row filters to use. */ void PNGAPI -png_set_filter(png_structp png_ptr, int method, int filters) +png_set_filter(png_structrp png_ptr, int method, int filters) { - png_debug(1, "in png_set_filter\n"); + png_debug(1, "in png_set_filter"); + if (png_ptr == NULL) return; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (method == PNG_INTRAPIXEL_DIFFERENCING)) - method = PNG_FILTER_TYPE_BASE; + +#ifdef PNG_MNG_FEATURES_SUPPORTED + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (method == PNG_INTRAPIXEL_DIFFERENCING)) + method = PNG_FILTER_TYPE_BASE; + #endif if (method == PNG_FILTER_TYPE_BASE) { switch (filters & (PNG_ALL_FILTERS | 0x07)) { -#ifndef PNG_NO_WRITE_FILTER +#ifdef PNG_WRITE_FILTER_SUPPORTED case 5: case 6: - case 7: png_warning(png_ptr, "Unknown row filter for method 0"); -#endif /* PNG_NO_WRITE_FILTER */ + case 7: png_app_error(png_ptr, "Unknown row filter for method 0"); + /* FALL THROUGH */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ case PNG_FILTER_VALUE_NONE: - png_ptr->do_filter=PNG_FILTER_NONE; break; -#ifndef PNG_NO_WRITE_FILTER + png_ptr->do_filter = PNG_FILTER_NONE; break; + +#ifdef PNG_WRITE_FILTER_SUPPORTED case PNG_FILTER_VALUE_SUB: - png_ptr->do_filter=PNG_FILTER_SUB; break; + png_ptr->do_filter = PNG_FILTER_SUB; break; + case PNG_FILTER_VALUE_UP: - png_ptr->do_filter=PNG_FILTER_UP; break; + png_ptr->do_filter = PNG_FILTER_UP; break; + case PNG_FILTER_VALUE_AVG: - png_ptr->do_filter=PNG_FILTER_AVG; break; + png_ptr->do_filter = PNG_FILTER_AVG; break; + case PNG_FILTER_VALUE_PAETH: - png_ptr->do_filter=PNG_FILTER_PAETH; break; - default: png_ptr->do_filter = (png_byte)filters; break; + png_ptr->do_filter = PNG_FILTER_PAETH; break; + + default: + png_ptr->do_filter = (png_byte)filters; break; #else - default: png_warning(png_ptr, "Unknown row filter for method 0"); -#endif /* PNG_NO_WRITE_FILTER */ + default: + png_app_error(png_ptr, "Unknown row filter for method 0"); +#endif /* PNG_WRITE_FILTER_SUPPORTED */ } /* If we have allocated the row_buf, this means we have already started @@ -1153,11 +977,11 @@ png_set_filter(png_structp png_ptr, int method, int filters) */ if (png_ptr->row_buf != NULL) { -#ifndef PNG_NO_WRITE_FILTER +#ifdef PNG_WRITE_FILTER_SUPPORTED if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL) { png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_ptr->rowbytes + 1)); png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; } @@ -1166,12 +990,14 @@ png_set_filter(png_structp png_ptr, int method, int filters) if (png_ptr->prev_row == NULL) { png_warning(png_ptr, "Can't add Up filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_UP; + png_ptr->do_filter = (png_byte)(png_ptr->do_filter & + ~PNG_FILTER_UP); } + else { png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_ptr->rowbytes + 1)); png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; } } @@ -1181,12 +1007,14 @@ png_set_filter(png_structp png_ptr, int method, int filters) if (png_ptr->prev_row == NULL) { png_warning(png_ptr, "Can't add Average filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_AVG; + png_ptr->do_filter = (png_byte)(png_ptr->do_filter & + ~PNG_FILTER_AVG); } + else { png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_ptr->rowbytes + 1)); png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; } } @@ -1199,16 +1027,17 @@ png_set_filter(png_structp png_ptr, int method, int filters) png_warning(png_ptr, "Can't add Paeth filter after starting"); png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH); } + else { png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_ptr->rowbytes + 1)); png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; } } if (png_ptr->do_filter == PNG_NO_FILTERS) -#endif /* PNG_NO_WRITE_FILTER */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ png_ptr->do_filter = PNG_FILTER_NONE; } } @@ -1223,292 +1052,1280 @@ png_set_filter(png_structp png_ptr, int method, int filters) * filtered data going to zlib more consistent, hopefully resulting in * better compression. */ -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ -void PNGAPI -png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, - int num_weights, png_doublep filter_weights, - png_doublep filter_costs) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */ +/* Convenience reset API. */ +static void +png_reset_filter_heuristics(png_structrp png_ptr) { - int i; - - png_debug(1, "in png_set_filter_heuristics\n"); - if (png_ptr == NULL) - return; - if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) + /* Clear out any old values in the 'weights' - this must be done because if + * the app calls set_filter_heuristics multiple times with different + * 'num_weights' values we would otherwise potentially have wrong sized + * arrays. + */ + png_ptr->num_prev_filters = 0; + png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; + if (png_ptr->prev_filters != NULL) { - png_warning(png_ptr, "Unknown filter heuristic method"); - return; + png_bytep old = png_ptr->prev_filters; + png_ptr->prev_filters = NULL; + png_free(png_ptr, old); } - - if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT) + if (png_ptr->filter_weights != NULL) { - heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; + png_uint_16p old = png_ptr->filter_weights; + png_ptr->filter_weights = NULL; + png_free(png_ptr, old); } - if (num_weights < 0 || filter_weights == NULL || - heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) + if (png_ptr->inv_filter_weights != NULL) { - num_weights = 0; + png_uint_16p old = png_ptr->inv_filter_weights; + png_ptr->inv_filter_weights = NULL; + png_free(png_ptr, old); } - png_ptr->num_prev_filters = (png_byte)num_weights; - png_ptr->heuristic_method = (png_byte)heuristic_method; + /* Leave the filter_costs - this array is fixed size. */ +} + +static int +png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method, + int num_weights) +{ + if (png_ptr == NULL) + return 0; - if (num_weights > 0) + /* Clear out the arrays */ + png_reset_filter_heuristics(png_ptr); + + /* Check arguments; the 'reset' function makes the correct settings for the + * unweighted case, but we must handle the weight case by initializing the + * arrays for the caller. + */ + if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { - if (png_ptr->prev_filters == NULL) + int i; + + if (num_weights > 0) { png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_byte) * num_weights)); + (png_uint_32)((sizeof (png_byte)) * num_weights)); /* To make sure that the weighting starts out fairly */ for (i = 0; i < num_weights; i++) { png_ptr->prev_filters[i] = 255; } - } - if (png_ptr->filter_weights == NULL) - { png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); + (png_uint_32)((sizeof (png_uint_16)) * num_weights)); png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); + (png_uint_32)((sizeof (png_uint_16)) * num_weights)); + for (i = 0; i < num_weights; i++) { png_ptr->inv_filter_weights[i] = png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; } + + /* Safe to set this now */ + png_ptr->num_prev_filters = (png_byte)num_weights; } + /* If, in the future, there are other filter methods, this would + * need to be based on png_ptr->filter. + */ + if (png_ptr->filter_costs == NULL) + { + png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST)); + + png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST)); + } + + for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) + { + png_ptr->inv_filter_costs[i] = + png_ptr->filter_costs[i] = PNG_COST_FACTOR; + } + + /* All the arrays are inited, safe to set this: */ + png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED; + + /* Return the 'ok' code. */ + return 1; + } + else if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT || + heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) + { + return 1; + } + else + { + png_warning(png_ptr, "Unknown filter heuristic method"); + return 0; + } +} + +/* Provide floating and fixed point APIs */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method, + int num_weights, png_const_doublep filter_weights, + png_const_doublep filter_costs) +{ + png_debug(1, "in png_set_filter_heuristics"); + + /* The internal API allocates all the arrays and ensures that the elements of + * those arrays are set to the default value. + */ + if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights)) + return; + + /* If using the weighted method copy in the weights. */ + if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int i; for (i = 0; i < num_weights; i++) { - if (filter_weights[i] < 0.0) + if (filter_weights[i] <= 0.0) { png_ptr->inv_filter_weights[i] = png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; } + else { png_ptr->inv_filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5); + (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5); + png_ptr->filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5); + (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5); } } - } - - /* If, in the future, there are other filter methods, this would - * need to be based on png_ptr->filter. - */ - if (png_ptr->filter_costs == NULL) - { - png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) + /* Here is where we set the relative costs of the different filters. We + * should take the desired compression level into account when setting + * the costs, so that Paeth, for instance, has a high relative cost at low + * compression levels, while it has a lower relative cost at higher + * compression settings. The filter types are in order of increasing + * relative cost, so it would be possible to do this with an algorithm. + */ + for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0) { png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; + (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5); + + png_ptr->filter_costs[i] = + (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5); } } +} +#endif /* FLOATING_POINT */ - /* Here is where we set the relative costs of the different filters. We - * should take the desired compression level into account when setting - * the costs, so that Paeth, for instance, has a high relative cost at low - * compression levels, while it has a lower relative cost at higher - * compression settings. The filter types are in order of increasing - * relative cost, so it would be possible to do this with an algorithm. +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method, + int num_weights, png_const_fixed_point_p filter_weights, + png_const_fixed_point_p filter_costs) +{ + png_debug(1, "in png_set_filter_heuristics_fixed"); + + /* The internal API allocates all the arrays and ensures that the elements of + * those arrays are set to the default value. */ - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) + if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights)) + return; + + /* If using the weighted method copy in the weights. */ + if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { - if (filter_costs == NULL || filter_costs[i] < 0.0) + int i; + for (i = 0; i < num_weights; i++) { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; + if (filter_weights[i] <= 0) + { + png_ptr->inv_filter_weights[i] = + png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; + } + + else + { + png_ptr->inv_filter_weights[i] = (png_uint_16) + ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1); + + png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR* + PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]); + } } - else if (filter_costs[i] >= 1.0) + + /* Here is where we set the relative costs of the different filters. We + * should take the desired compression level into account when setting + * the costs, so that Paeth, for instance, has a high relative cost at low + * compression levels, while it has a lower relative cost at higher + * compression settings. The filter types are in order of increasing + * relative cost, so it would be possible to do this with an algorithm. + */ + for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) + if (filter_costs[i] >= PNG_FP_1) { - png_ptr->inv_filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5); - png_ptr->filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5); + png_uint_32 tmp; + + /* Use a 32 bit unsigned temporary here because otherwise the + * intermediate value will be a 32 bit *signed* integer (ANSI rules) + * and this will get the wrong answer on division. + */ + tmp = PNG_COST_FACTOR*PNG_FP_1 + (filter_costs[i]/2); + tmp /= filter_costs[i]; + + png_ptr->inv_filter_costs[i] = (png_uint_16)tmp; + + tmp = PNG_COST_FACTOR * filter_costs[i] + PNG_FP_HALF; + tmp /= PNG_FP_1; + + png_ptr->filter_costs[i] = (png_uint_16)tmp; } } } +#endif /* FIXED_POINT */ #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ void PNGAPI -png_set_compression_level(png_structp png_ptr, int level) +png_set_compression_level(png_structrp png_ptr, int level) { - png_debug(1, "in png_set_compression_level\n"); + png_debug(1, "in png_set_compression_level"); + if (png_ptr == NULL) return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; + png_ptr->zlib_level = level; } void PNGAPI -png_set_compression_mem_level(png_structp png_ptr, int mem_level) +png_set_compression_mem_level(png_structrp png_ptr, int mem_level) { - png_debug(1, "in png_set_compression_mem_level\n"); + png_debug(1, "in png_set_compression_mem_level"); + if (png_ptr == NULL) return; - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; + png_ptr->zlib_mem_level = mem_level; } void PNGAPI -png_set_compression_strategy(png_structp png_ptr, int strategy) +png_set_compression_strategy(png_structrp png_ptr, int strategy) { - png_debug(1, "in png_set_compression_strategy\n"); + png_debug(1, "in png_set_compression_strategy"); + if (png_ptr == NULL) return; + + /* The flag setting here prevents the libpng dynamic selection of strategy. + */ png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; png_ptr->zlib_strategy = strategy; } +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ void PNGAPI -png_set_compression_window_bits(png_structp png_ptr, int window_bits) +png_set_compression_window_bits(png_structrp png_ptr, int window_bits) { if (png_ptr == NULL) return; + + /* Prior to 1.6.0 this would warn but then set the window_bits value, this + * meant that negative window bits values could be selected which would cause + * libpng to write a non-standard PNG file with raw deflate or gzip + * compressed IDAT or ancillary chunks. Such files can be read and there is + * no warning on read, so this seems like a very bad idea. + */ if (window_bits > 15) + { png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); + window_bits = 15; + } + else if (window_bits < 8) + { png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); -#ifndef WBITS_8_OK - /* avoid libpng bug with 256-byte windows */ - if (window_bits == 8) - { - png_warning(png_ptr, "Compression window is being reset to 512"); - window_bits=9; - } -#endif - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS; + window_bits = 8; + } + png_ptr->zlib_window_bits = window_bits; } void PNGAPI -png_set_compression_method(png_structp png_ptr, int method) +png_set_compression_method(png_structrp png_ptr, int method) { - png_debug(1, "in png_set_compression_method\n"); + png_debug(1, "in png_set_compression_method"); + if (png_ptr == NULL) return; + + /* This would produce an invalid PNG file if it worked, but it doesn't and + * deflate will fault it, so it is harmless to just warn here. + */ if (method != 8) png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD; + png_ptr->zlib_method = method; } +/* The following were added to libpng-1.5.4 */ +#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED +void PNGAPI +png_set_text_compression_level(png_structrp png_ptr, int level) +{ + png_debug(1, "in png_set_text_compression_level"); + + if (png_ptr == NULL) + return; + + png_ptr->zlib_text_level = level; +} + void PNGAPI -png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) +png_set_text_compression_mem_level(png_structrp png_ptr, int mem_level) { + png_debug(1, "in png_set_text_compression_mem_level"); + if (png_ptr == NULL) return; + + png_ptr->zlib_text_mem_level = mem_level; +} + +void PNGAPI +png_set_text_compression_strategy(png_structrp png_ptr, int strategy) +{ + png_debug(1, "in png_set_text_compression_strategy"); + + if (png_ptr == NULL) + return; + + png_ptr->zlib_text_strategy = strategy; +} + +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ +void PNGAPI +png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits) +{ + if (png_ptr == NULL) + return; + + if (window_bits > 15) + { + png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); + window_bits = 15; + } + + else if (window_bits < 8) + { + png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); + window_bits = 8; + } + + png_ptr->zlib_text_window_bits = window_bits; +} + +void PNGAPI +png_set_text_compression_method(png_structrp png_ptr, int method) +{ + png_debug(1, "in png_set_text_compression_method"); + + if (png_ptr == NULL) + return; + + if (method != 8) + png_warning(png_ptr, "Only compression method 8 is supported by PNG"); + + png_ptr->zlib_text_method = method; +} +#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ +/* end of API added to libpng-1.5.4 */ + +void PNGAPI +png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn) +{ + if (png_ptr == NULL) + return; + png_ptr->write_row_fn = write_row_fn; } -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED void PNGAPI -png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - write_user_transform_fn) +png_set_write_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr + write_user_transform_fn) { - png_debug(1, "in png_set_write_user_transform_fn\n"); + png_debug(1, "in png_set_write_user_transform_fn"); + if (png_ptr == NULL) return; + png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->write_user_transform_fn = write_user_transform_fn; } #endif -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_INFO_IMAGE_SUPPORTED void PNGAPI -png_write_png(png_structp png_ptr, png_infop info_ptr, - int transforms, voidp params) +png_write_png(png_structrp png_ptr, png_inforp info_ptr, + int transforms, voidp params) { if (png_ptr == NULL || info_ptr == NULL) return; -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif /* Write the file header information. */ png_write_info(png_ptr, info_ptr); /* ------ these transformations don't touch the info structure ------- */ -#if defined(PNG_WRITE_INVERT_SUPPORTED) - /* invert monochrome pixels */ +#ifdef PNG_WRITE_INVERT_SUPPORTED + /* Invert monochrome pixels */ if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); + png_set_invert_mono(png_ptr); #endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) +#ifdef PNG_WRITE_SHIFT_SUPPORTED /* Shift the pixels up to a legal bit depth and fill in * as appropriate to correctly scale the image. */ if ((transforms & PNG_TRANSFORM_SHIFT) - && (info_ptr->valid & PNG_INFO_sBIT)) - png_set_shift(png_ptr, &info_ptr->sig_bit); + && (info_ptr->valid & PNG_INFO_sBIT)) + png_set_shift(png_ptr, &info_ptr->sig_bit); #endif -#if defined(PNG_WRITE_PACK_SUPPORTED) - /* pack pixels into bytes */ +#ifdef PNG_WRITE_PACK_SUPPORTED + /* Pack pixels into bytes */ if (transforms & PNG_TRANSFORM_PACKING) png_set_packing(png_ptr); #endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - /* swap location of alpha bytes from ARGB to RGBA */ +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED + /* Swap location of alpha bytes from ARGB to RGBA */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); + png_set_swap_alpha(png_ptr); #endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - if (transforms & PNG_TRANSFORM_STRIP_FILLER) - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); +#ifdef PNG_WRITE_FILLER_SUPPORTED + /* Pack XRGB/RGBX/ARGB/RGBA into RGB (4 channels -> 3 channels) */ + if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) + png_set_filler(png_ptr, 0, PNG_FILLER_AFTER); + + else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); #endif -#if defined(PNG_WRITE_BGR_SUPPORTED) - /* flip BGR pixels to RGB */ +#ifdef PNG_WRITE_BGR_SUPPORTED + /* Flip BGR pixels to RGB */ if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); + png_set_bgr(png_ptr); #endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) - /* swap bytes of 16-bit files to most significant byte first */ +#ifdef PNG_WRITE_SWAP_SUPPORTED + /* Swap bytes of 16-bit files to most significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); + png_set_swap(png_ptr); #endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - /* swap bits of 1, 2, 4 bit packed pixel formats */ +#ifdef PNG_WRITE_PACKSWAP_SUPPORTED + /* Swap bits of 1, 2, 4 bit packed pixel formats */ if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); + png_set_packswap(png_ptr); +#endif + +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED + /* Invert the alpha channel from opacity to transparency */ + if (transforms & PNG_TRANSFORM_INVERT_ALPHA) + png_set_invert_alpha(png_ptr); #endif /* ----------------------- end of transformations ------------------- */ - /* write the bits */ + /* Write the bits */ if (info_ptr->valid & PNG_INFO_IDAT) png_write_image(png_ptr, info_ptr->row_pointers); /* It is REQUIRED to call this to finish writing the rest of the file */ png_write_end(png_ptr, info_ptr); - (void) transforms; /* quiet compiler warnings */ - (void) params; + PNG_UNUSED(transforms) /* Quiet compiler warnings */ + PNG_UNUSED(params) } #endif + + +#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED +#ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */ +/* Initialize the write structure - general purpose utility. */ +static int +png_image_write_init(png_imagep image) +{ + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image, + png_safe_error, png_safe_warning); + + if (png_ptr != NULL) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (info_ptr != NULL) + { + png_controlp control = png_voidcast(png_controlp, + png_malloc_warn(png_ptr, (sizeof *control))); + + if (control != NULL) + { + memset(control, 0, (sizeof *control)); + + control->png_ptr = png_ptr; + control->info_ptr = info_ptr; + control->for_write = 1; + + image->opaque = control; + return 1; + } + + /* Error clean up */ + png_destroy_info_struct(png_ptr, &info_ptr); + } + + png_destroy_write_struct(&png_ptr, NULL); + } + + return png_image_error(image, "png_image_write_: out of memory"); +} + +/* Arguments to png_image_write_main: */ +typedef struct +{ + /* Arguments: */ + png_imagep image; + png_const_voidp buffer; + png_int_32 row_stride; + png_const_voidp colormap; + int convert_to_8bit; + /* Local variables: */ + png_const_voidp first_row; + ptrdiff_t row_bytes; + png_voidp local_row; +} png_image_write_control; + +/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to + * do any necessary byte swapping. The component order is defined by the + * png_image format value. + */ +static int +png_write_image_16bit(png_voidp argument) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + + png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, + display->first_row); + png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row); + png_uint_16p row_end; + const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; + int aindex = 0; + png_uint_32 y = image->height; + + if (image->format & PNG_FORMAT_FLAG_ALPHA) + { + if (image->format & PNG_FORMAT_FLAG_AFIRST) + { + aindex = -1; + ++input_row; /* To point to the first component */ + ++output_row; + } + + else + aindex = channels; + } + + else + png_error(png_ptr, "png_write_image: internal call error"); + + /* Work out the output row end and count over this, note that the increment + * above to 'row' means that row_end can actually be beyond the end of the + * row; this is correct. + */ + row_end = output_row + image->width * (channels+1); + + while (y-- > 0) + { + png_const_uint_16p in_ptr = input_row; + png_uint_16p out_ptr = output_row; + + while (out_ptr < row_end) + { + const png_uint_16 alpha = in_ptr[aindex]; + png_uint_32 reciprocal = 0; + int c; + + out_ptr[aindex] = alpha; + + /* Calculate a reciprocal. The correct calculation is simply + * component/alpha*65535 << 15. (I.e. 15 bits of precision); this + * allows correct rounding by adding .5 before the shift. 'reciprocal' + * is only initialized when required. + */ + if (alpha > 0 && alpha < 65535) + reciprocal = ((0xffff<<15)+(alpha>>1))/alpha; + + c = channels; + do /* always at least one channel */ + { + png_uint_16 component = *in_ptr++; + + /* The following gives 65535 for an alpha of 0, which is fine, + * otherwise if 0/0 is represented as some other value there is more + * likely to be a discontinuity which will probably damage + * compression when moving from a fully transparent area to a + * nearly transparent one. (The assumption here is that opaque + * areas tend not to be 0 intensity.) + */ + if (component >= alpha) + component = 65535; + + /* component<alpha, so component/alpha is less than one and + * component*reciprocal is less than 2^31. + */ + else if (component > 0 && alpha < 65535) + { + png_uint_32 calc = component * reciprocal; + calc += 16384; /* round to nearest */ + component = (png_uint_16)(calc >> 15); + } + + *out_ptr++ = component; + } + while (--c > 0); + + /* Skip to next component (skip the intervening alpha channel) */ + ++in_ptr; + ++out_ptr; + } + + png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); + input_row += display->row_bytes/(sizeof (png_uint_16)); + } + + return 1; +} + +/* Given 16-bit input (1 to 4 channels) write 8-bit output. If an alpha channel + * is present it must be removed from the components, the components are then + * written in sRGB encoding. No components are added or removed. + * + * Calculate an alpha reciprocal to reverse pre-multiplication. As above the + * calculation can be done to 15 bits of accuracy; however, the output needs to + * be scaled in the range 0..255*65535, so include that scaling here. + */ +#define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha) + +static png_byte +png_unpremultiply(png_uint_32 component, png_uint_32 alpha, + png_uint_32 reciprocal/*from the above macro*/) +{ + /* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0 + * is represented as some other value there is more likely to be a + * discontinuity which will probably damage compression when moving from a + * fully transparent area to a nearly transparent one. (The assumption here + * is that opaque areas tend not to be 0 intensity.) + * + * There is a rounding problem here; if alpha is less than 128 it will end up + * as 0 when scaled to 8 bits. To avoid introducing spurious colors into the + * output change for this too. + */ + if (component >= alpha || alpha < 128) + return 255; + + /* component<alpha, so component/alpha is less than one and + * component*reciprocal is less than 2^31. + */ + else if (component > 0) + { + /* The test is that alpha/257 (rounded) is less than 255, the first value + * that becomes 255 is 65407. + * NOTE: this must agree with the PNG_DIV257 macro (which must, therefore, + * be exact!) [Could also test reciprocal != 0] + */ + if (alpha < 65407) + { + component *= reciprocal; + component += 64; /* round to nearest */ + component >>= 7; + } + + else + component *= 255; + + /* Convert the component to sRGB. */ + return (png_byte)PNG_sRGB_FROM_LINEAR(component); + } + + else + return 0; +} + +static int +png_write_image_8bit(png_voidp argument) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + + png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, + display->first_row); + png_bytep output_row = png_voidcast(png_bytep, display->local_row); + png_uint_32 y = image->height; + const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; + + if (image->format & PNG_FORMAT_FLAG_ALPHA) + { + png_bytep row_end; + int aindex; + + if (image->format & PNG_FORMAT_FLAG_AFIRST) + { + aindex = -1; + ++input_row; /* To point to the first component */ + ++output_row; + } + + else + aindex = channels; + + /* Use row_end in place of a loop counter: */ + row_end = output_row + image->width * (channels+1); + + while (y-- > 0) + { + png_const_uint_16p in_ptr = input_row; + png_bytep out_ptr = output_row; + + while (out_ptr < row_end) + { + png_uint_16 alpha = in_ptr[aindex]; + png_byte alphabyte = (png_byte)PNG_DIV257(alpha); + png_uint_32 reciprocal = 0; + int c; + + /* Scale and write the alpha channel. */ + out_ptr[aindex] = alphabyte; + + if (alphabyte > 0 && alphabyte < 255) + reciprocal = UNP_RECIPROCAL(alpha); + + c = channels; + do /* always at least one channel */ + *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal); + while (--c > 0); + + /* Skip to next component (skip the intervening alpha channel) */ + ++in_ptr; + ++out_ptr; + } /* while out_ptr < row_end */ + + png_write_row(png_ptr, png_voidcast(png_const_bytep, + display->local_row)); + input_row += display->row_bytes/(sizeof (png_uint_16)); + } /* while y */ + } + + else + { + /* No alpha channel, so the row_end really is the end of the row and it + * is sufficient to loop over the components one by one. + */ + png_bytep row_end = output_row + image->width * channels; + + while (y-- > 0) + { + png_const_uint_16p in_ptr = input_row; + png_bytep out_ptr = output_row; + + while (out_ptr < row_end) + { + png_uint_32 component = *in_ptr++; + + component *= 255; + *out_ptr++ = (png_byte)PNG_sRGB_FROM_LINEAR(component); + } + + png_write_row(png_ptr, output_row); + input_row += display->row_bytes/(sizeof (png_uint_16)); + } + } + + return 1; +} + +static void +png_image_set_PLTE(png_image_write_control *display) +{ + const png_imagep image = display->image; + const void *cmap = display->colormap; + const int entries = image->colormap_entries > 256 ? 256 : + (int)image->colormap_entries; + + /* NOTE: the caller must check for cmap != NULL and entries != 0 */ + const png_uint_32 format = image->format; + const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); + +# ifdef PNG_FORMAT_BGR_SUPPORTED + const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 && + (format & PNG_FORMAT_FLAG_ALPHA) != 0; +# else +# define afirst 0 +# endif + +# ifdef PNG_FORMAT_BGR_SUPPORTED + const int bgr = (format & PNG_FORMAT_FLAG_BGR) ? 2 : 0; +# else +# define bgr 0 +# endif + + int i, num_trans; + png_color palette[256]; + png_byte tRNS[256]; + + memset(tRNS, 255, (sizeof tRNS)); + memset(palette, 0, (sizeof palette)); + + for (i=num_trans=0; i<entries; ++i) + { + /* This gets automatically converted to sRGB with reversal of the + * pre-multiplication if the color-map has an alpha channel. + */ + if (format & PNG_FORMAT_FLAG_LINEAR) + { + png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap); + + entry += i * channels; + + if (channels & 1) /* no alpha */ + { + if (channels >= 3) /* RGB */ + { + palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 * + entry[(2 ^ bgr)]); + palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 * + entry[1]); + palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 * + entry[bgr]); + } + + else /* Gray */ + palette[i].blue = palette[i].red = palette[i].green = + (png_byte)PNG_sRGB_FROM_LINEAR(255 * *entry); + } + + else /* alpha */ + { + png_uint_16 alpha = entry[afirst ? 0 : channels-1]; + png_byte alphabyte = (png_byte)PNG_DIV257(alpha); + png_uint_32 reciprocal = 0; + + /* Calculate a reciprocal, as in the png_write_image_8bit code above + * this is designed to produce a value scaled to 255*65535 when + * divided by 128 (i.e. asr 7). + */ + if (alphabyte > 0 && alphabyte < 255) + reciprocal = (((0xffff*0xff)<<7)+(alpha>>1))/alpha; + + tRNS[i] = alphabyte; + if (alphabyte < 255) + num_trans = i+1; + + if (channels >= 3) /* RGB */ + { + palette[i].blue = png_unpremultiply(entry[afirst + (2 ^ bgr)], + alpha, reciprocal); + palette[i].green = png_unpremultiply(entry[afirst + 1], alpha, + reciprocal); + palette[i].red = png_unpremultiply(entry[afirst + bgr], alpha, + reciprocal); + } + + else /* gray */ + palette[i].blue = palette[i].red = palette[i].green = + png_unpremultiply(entry[afirst], alpha, reciprocal); + } + } + + else /* Color-map has sRGB values */ + { + png_const_bytep entry = png_voidcast(png_const_bytep, cmap); + + entry += i * channels; + + switch (channels) + { + case 4: + tRNS[i] = entry[afirst ? 0 : 3]; + if (tRNS[i] < 255) + num_trans = i+1; + /* FALL THROUGH */ + case 3: + palette[i].blue = entry[afirst + (2 ^ bgr)]; + palette[i].green = entry[afirst + 1]; + palette[i].red = entry[afirst + bgr]; + break; + + case 2: + tRNS[i] = entry[1 ^ afirst]; + if (tRNS[i] < 255) + num_trans = i+1; + /* FALL THROUGH */ + case 1: + palette[i].blue = palette[i].red = palette[i].green = + entry[afirst]; + break; + + default: + break; + } + } + } + +# ifdef afirst +# undef afirst +# endif +# ifdef bgr +# undef bgr +# endif + + png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette, + entries); + + if (num_trans > 0) + png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS, + num_trans, NULL); + + image->colormap_entries = entries; +} + +static int +png_image_write_main(png_voidp argument) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + argument); + png_imagep image = display->image; + png_structrp png_ptr = image->opaque->png_ptr; + png_inforp info_ptr = image->opaque->info_ptr; + png_uint_32 format = image->format; + + int colormap = (format & PNG_FORMAT_FLAG_COLORMAP) != 0; + int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR) != 0; /* input */ + int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0; + int write_16bit = linear && !colormap && !display->convert_to_8bit; + +# ifdef PNG_BENIGN_ERRORS_SUPPORTED + /* Make sure we error out on any bad situation */ + png_set_benign_errors(png_ptr, 0/*error*/); +# endif + + /* Default the 'row_stride' parameter if required. */ + if (display->row_stride == 0) + display->row_stride = PNG_IMAGE_ROW_STRIDE(*image); + + /* Set the required transforms then write the rows in the correct order. */ + if (format & PNG_FORMAT_FLAG_COLORMAP) + { + if (display->colormap != NULL && image->colormap_entries > 0) + { + png_uint_32 entries = image->colormap_entries; + + png_set_IHDR(png_ptr, info_ptr, image->width, image->height, + entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)), + PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + png_image_set_PLTE(display); + } + + else + png_error(image->opaque->png_ptr, + "no color-map for color-mapped image"); + } + + else + png_set_IHDR(png_ptr, info_ptr, image->width, image->height, + write_16bit ? 16 : 8, + ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) + + ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0), + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + /* Counter-intuitively the data transformations must be called *after* + * png_write_info, not before as in the read code, but the 'set' functions + * must still be called before. Just set the color space information, never + * write an interlaced image. + */ + + if (write_16bit) + { + /* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */ + png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR); + + if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB)) + png_set_cHRM_fixed(png_ptr, info_ptr, + /* color x y */ + /* white */ 31270, 32900, + /* red */ 64000, 33000, + /* green */ 30000, 60000, + /* blue */ 15000, 6000 + ); + } + + else if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB)) + png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL); + + /* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit + * space must still be gamma encoded. + */ + else + png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE); + + /* Write the file header. */ + png_write_info(png_ptr, info_ptr); + + /* Now set up the data transformations (*after* the header is written), + * remove the handled transformations from the 'format' flags for checking. + * + * First check for a little endian system if writing 16 bit files. + */ + if (write_16bit) + { + PNG_CONST png_uint_16 le = 0x0001; + + if (*(png_const_bytep)&le) + png_set_swap(png_ptr); + } + +# ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED + if (format & PNG_FORMAT_FLAG_BGR) + { + if (!colormap && (format & PNG_FORMAT_FLAG_COLOR) != 0) + png_set_bgr(png_ptr); + format &= ~PNG_FORMAT_FLAG_BGR; + } +# endif + +# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + { + if (!colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0) + png_set_swap_alpha(png_ptr); + format &= ~PNG_FORMAT_FLAG_AFIRST; + } +# endif + + /* If there are 16 or fewer color-map entries we wrote a lower bit depth + * above, but the application data is still byte packed. + */ + if (colormap && image->colormap_entries <= 16) + png_set_packing(png_ptr); + + /* That should have handled all (both) the transforms. */ + if ((format & ~(png_uint_32)(PNG_FORMAT_FLAG_COLOR | PNG_FORMAT_FLAG_LINEAR | + PNG_FORMAT_FLAG_ALPHA | PNG_FORMAT_FLAG_COLORMAP)) != 0) + png_error(png_ptr, "png_write_image: unsupported transformation"); + + { + png_const_bytep row = png_voidcast(png_const_bytep, display->buffer); + ptrdiff_t row_bytes = display->row_stride; + + if (linear) + row_bytes *= (sizeof (png_uint_16)); + + if (row_bytes < 0) + row += (image->height-1) * (-row_bytes); + + display->first_row = row; + display->row_bytes = row_bytes; + } + + /* Apply 'fast' options if the flag is set. */ + if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0) + { + png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS); + /* NOTE: determined by experiment using pngstest, this reflects some + * balance between the time to write the image once and the time to read + * it about 50 times. The speed-up in pngstest was about 10-20% of the + * total (user) time on a heavily loaded system. + */ + png_set_compression_level(png_ptr, 3); + } + + /* Check for the cases that currently require a pre-transform on the row + * before it is written. This only applies when the input is 16-bit and + * either there is an alpha channel or it is converted to 8-bit. + */ + if ((linear && alpha) || (!colormap && display->convert_to_8bit)) + { + png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr, + png_get_rowbytes(png_ptr, info_ptr))); + int result; + + display->local_row = row; + if (write_16bit) + result = png_safe_execute(image, png_write_image_16bit, display); + else + result = png_safe_execute(image, png_write_image_8bit, display); + display->local_row = NULL; + + png_free(png_ptr, row); + + /* Skip the 'write_end' on error: */ + if (!result) + return 0; + } + + /* Otherwise this is the case where the input is in a format currently + * supported by the rest of the libpng write code; call it directly. + */ + else + { + png_const_bytep row = png_voidcast(png_const_bytep, display->first_row); + ptrdiff_t row_bytes = display->row_bytes; + png_uint_32 y = image->height; + + while (y-- > 0) + { + png_write_row(png_ptr, row); + row += row_bytes; + } + } + + png_write_end(png_ptr, info_ptr); + return 1; +} + +int PNGAPI +png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, + const void *buffer, png_int_32 row_stride, const void *colormap) +{ + /* Write the image to the given (FILE*). */ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (file != NULL) + { + if (png_image_write_init(image)) + { + png_image_write_control display; + int result; + + /* This is slightly evil, but png_init_io doesn't do anything other + * than this and we haven't changed the standard IO functions so + * this saves a 'safe' function. + */ + image->opaque->png_ptr->io_ptr = file; + + memset(&display, 0, (sizeof display)); + display.image = image; + display.buffer = buffer; + display.row_stride = row_stride; + display.colormap = colormap; + display.convert_to_8bit = convert_to_8bit; + + result = png_safe_execute(image, png_image_write_main, &display); + png_image_free(image); + return result; + } + + else + return 0; + } + + else + return png_image_error(image, + "png_image_write_to_stdio: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION"); + + else + return 0; +} + +int PNGAPI +png_image_write_to_file(png_imagep image, const char *file_name, + int convert_to_8bit, const void *buffer, png_int_32 row_stride, + const void *colormap) +{ + /* Write the image to the named file. */ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (file_name != NULL) + { + FILE *fp = fopen(file_name, "wb"); + + if (fp != NULL) + { + if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer, + row_stride, colormap)) + { + int error; /* from fflush/fclose */ + + /* Make sure the file is flushed correctly. */ + if (fflush(fp) == 0 && ferror(fp) == 0) + { + if (fclose(fp) == 0) + return 1; + + error = errno; /* from fclose */ + } + + else + { + error = errno; /* from fflush or ferror */ + (void)fclose(fp); + } + + (void)remove(file_name); + /* The image has already been cleaned up; this is just used to + * set the error (because the original write succeeded). + */ + return png_image_error(image, strerror(error)); + } + + else + { + /* Clean up: just the opened file. */ + (void)fclose(fp); + (void)remove(file_name); + return 0; + } + } + + else + return png_image_error(image, strerror(errno)); + } + + else + return png_image_error(image, + "png_image_write_to_file: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_write_to_file: incorrect PNG_IMAGE_VERSION"); + + else + return 0; +} +#endif /* PNG_STDIO_SUPPORTED */ +#endif /* SIMPLIFIED_WRITE */ #endif /* PNG_WRITE_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwtran.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwtran.c index 19b29682c..2cdd7c95c 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwtran.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwtran.c @@ -1,84 +1,98 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.2.9 April 14, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * Last changed in libpng 1.6.0 [February 14, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" + #ifdef PNG_WRITE_SUPPORTED +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED /* Transform the data according to the user's wishes. The order of * transformations is significant. */ void /* PRIVATE */ -png_do_write_transformations(png_structp png_ptr) +png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) { - png_debug(1, "in png_do_write_transformations\n"); + png_debug(1, "in png_do_write_transformations"); if (png_ptr == NULL) return; -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED if (png_ptr->transformations & PNG_USER_TRANSFORM) - if(png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* user write transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ + if (png_ptr->write_user_transform_fn != NULL) + (*(png_ptr->write_user_transform_fn)) /* User write transform + function */ + (png_ptr, /* png_ptr */ + row_info, /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_size_t rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ #endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) + +#ifdef PNG_WRITE_FILLER_SUPPORTED if (png_ptr->transformations & PNG_FILLER) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->flags); + png_do_strip_channel(row_info, png_ptr->row_buf + 1, + !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); #endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) + +#ifdef PNG_WRITE_PACKSWAP_SUPPORTED if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_packswap(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_PACK_SUPPORTED) + +#ifdef PNG_WRITE_PACK_SUPPORTED if (png_ptr->transformations & PNG_PACK) - png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->bit_depth); + png_do_pack(row_info, png_ptr->row_buf + 1, + (png_uint_32)png_ptr->bit_depth); #endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) + +#ifdef PNG_WRITE_SWAP_SUPPORTED if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_swap(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) + +#ifdef PNG_WRITE_SHIFT_SUPPORTED if (png_ptr->transformations & PNG_SHIFT) - png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); + png_do_shift(row_info, png_ptr->row_buf + 1, + &(png_ptr->shift)); #endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) + +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) + +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_BGR_SUPPORTED) + +#ifdef PNG_WRITE_BGR_SUPPORTED if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_bgr(row_info, png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_INVERT_SUPPORTED) + +#ifdef PNG_WRITE_INVERT_SUPPORTED if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_invert(row_info, png_ptr->row_buf + 1); #endif } -#if defined(PNG_WRITE_PACK_SUPPORTED) +#ifdef PNG_WRITE_PACK_SUPPORTED /* Pack pixels into bytes. Pass the true bit depth in bit_depth. The * row_info bit depth should be 8 (one pixel per byte). The channels * should be 1 (this only happens on grayscale and paletted images). @@ -86,11 +100,9 @@ png_do_write_transformations(png_structp png_ptr) void /* PRIVATE */ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) { - png_debug(1, "in png_do_pack\n"); + png_debug(1, "in png_do_pack"); + if (row_info->bit_depth == 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif row_info->channels == 1) { switch ((int)bit_depth) @@ -111,9 +123,12 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) { if (*sp != 0) v |= mask; + sp++; + if (mask > 1) mask >>= 1; + else { mask = 0x80; @@ -122,10 +137,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) v = 0; } } + if (mask != 0x80) *dp = (png_byte)v; + break; } + case 2: { png_bytep sp, dp; @@ -137,12 +155,14 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp = row; shift = 6; v = 0; + for (i = 0; i < row_width; i++) { png_byte value; value = (png_byte)(*sp & 0x03); v |= (value << shift); + if (shift == 0) { shift = 6; @@ -150,14 +170,19 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp++; v = 0; } + else shift -= 2; + sp++; } + if (shift != 6) *dp = (png_byte)v; + break; } + case 4: { png_bytep sp, dp; @@ -169,6 +194,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp = row; shift = 4; v = 0; + for (i = 0; i < row_width; i++) { png_byte value; @@ -183,25 +209,32 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp++; v = 0; } + else shift -= 4; sp++; } + if (shift != 4) *dp = (png_byte)v; + break; } + + default: + break; } + row_info->bit_depth = (png_byte)bit_depth; row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); + row_info->width); } } #endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) +#ifdef PNG_WRITE_SHIFT_SUPPORTED /* Shift pixel values to take advantage of whole range. Pass the * true number of bits in bit_depth. The row should be packed * according to row_info->bit_depth. Thus, if you had a row of @@ -210,15 +243,12 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) * data to 0 to 15. */ void /* PRIVATE */ -png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) +png_do_shift(png_row_infop row_info, png_bytep row, + png_const_color_8p bit_depth) { - png_debug(1, "in png_do_shift\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && -#else - if ( -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) + png_debug(1, "in png_do_shift"); + + if (row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift_start[4], shift_dec[4]; int channels = 0; @@ -228,19 +258,23 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) shift_start[channels] = row_info->bit_depth - bit_depth->red; shift_dec[channels] = bit_depth->red; channels++; + shift_start[channels] = row_info->bit_depth - bit_depth->green; shift_dec[channels] = bit_depth->green; channels++; + shift_start[channels] = row_info->bit_depth - bit_depth->blue; shift_dec[channels] = bit_depth->blue; channels++; } + else { shift_start[channels] = row_info->bit_depth - bit_depth->gray; shift_dec[channels] = bit_depth->gray; channels++; } + if (row_info->color_type & PNG_COLOR_MASK_ALPHA) { shift_start[channels] = row_info->bit_depth - bit_depth->alpha; @@ -248,37 +282,44 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) channels++; } - /* with low row depths, could only be grayscale, so one channel */ + /* With low row depths, could only be grayscale, so one channel */ if (row_info->bit_depth < 8) { png_bytep bp = row; - png_uint_32 i; - png_byte mask; - png_uint_32 row_bytes = row_info->rowbytes; + png_size_t i; + unsigned int mask; + png_size_t row_bytes = row_info->rowbytes; if (bit_depth->gray == 1 && row_info->bit_depth == 2) mask = 0x55; + else if (row_info->bit_depth == 4 && bit_depth->gray == 3) mask = 0x11; + else mask = 0xff; for (i = 0; i < row_bytes; i++, bp++) { - png_uint_16 v; int j; + unsigned int v, out; v = *bp; - *bp = 0; + out = 0; + for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) { if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); + out |= v << j; + else - *bp |= (png_byte)((v >> (-j)) & mask); + out |= (v >> (-j)) & mask; } + + *bp = (png_byte)(out & 0xff); } } + else if (row_info->bit_depth == 8) { png_bytep bp = row; @@ -288,21 +329,26 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) for (i = 0; i < istop; i++, bp++) { - png_uint_16 v; + const unsigned int c = i%channels; int j; - int c = (int)(i%channels); + unsigned int v, out; v = *bp; - *bp = 0; + out = 0; + for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) { if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); + out |= v << j; + else - *bp |= (png_byte)((v >> (-j)) & 0xff); + out |= v >> (-j); } + + *bp = (png_byte)(out & 0xff); } } + else { png_bytep bp; @@ -311,20 +357,22 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) for (bp = row, i = 0; i < istop; i++) { - int c = (int)(i%channels); - png_uint_16 value, v; + const unsigned int c = i%channels; int j; + unsigned int value, v; - v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); + v = png_get_uint_16(bp); value = 0; + for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) { if (j > 0) - value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); + value |= v << j; + else - value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); + value |= v >> (-j); } - *bp++ = (png_byte)(value >> 8); + *bp++ = (png_byte)((value >> 8) & 0xff); *bp++ = (png_byte)(value & 0xff); } } @@ -332,23 +380,22 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) } #endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED void /* PRIVATE */ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif + png_debug(1, "in png_do_write_swap_alpha"); + { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - /* This converts from ARGB to RGBA */ if (row_info->bit_depth == 8) { + /* This converts from ARGB to RGBA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; + for (i = 0, sp = dp = row; i < row_width; i++) { png_byte save = *(sp++); @@ -358,9 +405,11 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save; } } - /* This converts from AARRGGBB to RRGGBBAA */ + +#ifdef PNG_WRITE_16BIT_SUPPORTED else { + /* This converts from AARRGGBB to RRGGBBAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -380,12 +429,14 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save[1]; } } +#endif /* PNG_WRITE_16BIT_SUPPORTED */ } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { - /* This converts from AG to GA */ if (row_info->bit_depth == 8) { + /* This converts from AG to GA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -397,9 +448,11 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save; } } - /* This converts from AAGG to GGAA */ + +#ifdef PNG_WRITE_16BIT_SUPPORTED else { + /* This converts from AAGG to GGAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -415,31 +468,31 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save[1]; } } +#endif /* PNG_WRITE_16BIT_SUPPORTED */ } } } #endif -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED void /* PRIVATE */ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif + png_debug(1, "in png_do_write_invert_alpha"); + { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - /* This inverts the alpha channel in RGBA */ if (row_info->bit_depth == 8) { + /* This inverts the alpha channel in RGBA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; + for (i = 0, sp = dp = row; i < row_width; i++) { - /* does nothing + /* Does nothing *(dp++) = *(sp++); *(dp++) = *(sp++); *(dp++) = *(sp++); @@ -448,16 +501,18 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++)); } } - /* This inverts the alpha channel in RRGGBBAA */ + +#ifdef PNG_WRITE_16BIT_SUPPORTED else { + /* This inverts the alpha channel in RRGGBBAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; for (i = 0, sp = dp = row; i < row_width; i++) { - /* does nothing + /* Does nothing *(dp++) = *(sp++); *(dp++) = *(sp++); *(dp++) = *(sp++); @@ -470,12 +525,14 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++)); } } +#endif /* PNG_WRITE_16BIT_SUPPORTED */ } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { - /* This inverts the alpha channel in GA */ if (row_info->bit_depth == 8) { + /* This inverts the alpha channel in GA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -486,16 +543,18 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++)); } } - /* This inverts the alpha channel in GGAA */ + +#ifdef PNG_WRITE_16BIT_SUPPORTED else { + /* This inverts the alpha channel in GGAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; for (i = 0, sp = dp = row; i < row_width; i++) { - /* does nothing + /* Does nothing *(dp++) = *(sp++); *(dp++) = *(sp++); */ @@ -504,22 +563,21 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++)); } } +#endif /* PNG_WRITE_16BIT_SUPPORTED */ } } } #endif +#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ +#ifdef PNG_MNG_FEATURES_SUPPORTED +/* Undoes intrapixel differencing */ void /* PRIVATE */ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) + png_debug(1, "in png_do_write_intrapixel"); + + if ((row_info->color_type & PNG_COLOR_MASK_COLOR)) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; @@ -530,17 +588,21 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 3; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 4; + else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - *(rp) = (png_byte)((*rp - *(rp+1))&0xff); - *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); + *(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff); + *(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff); } } + +#ifdef PNG_WRITE_16BIT_SUPPORTED else if (row_info->bit_depth == 16) { png_bytep rp; @@ -548,24 +610,27 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 6; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 8; + else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); - png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); - png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0-s1) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp+1) = (png_byte)(red & 0xff); - *(rp+4) = (png_byte)((blue >> 8) & 0xff); - *(rp+5) = (png_byte)(blue & 0xff); + png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); + png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); + png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); + png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); + png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); + *(rp ) = (png_byte)((red >> 8) & 0xff); + *(rp + 1) = (png_byte)(red & 0xff); + *(rp + 4) = (png_byte)((blue >> 8) & 0xff); + *(rp + 5) = (png_byte)(blue & 0xff); } } +#endif /* PNG_WRITE_16BIT_SUPPORTED */ } } #endif /* PNG_MNG_FEATURES_SUPPORTED */ diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwutil.c b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwutil.c index f6ad8782b..c90ff8bd0 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwutil.c +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwutil.c @@ -1,17 +1,21 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.2.20 Septhember 3, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.6.0 [February 14, 2013] + * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ -#define PNG_INTERNAL -#include "png.h" +#include "pngpriv.h" + #ifdef PNG_WRITE_SUPPORTED +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED /* Place a 32-bit number into a buffer in PNG byte order. We work * with unsigned numbers for convenience, although one supported * ancillary chunk uses signed (two's complement) numbers. @@ -25,19 +29,6 @@ png_save_uint_32(png_bytep buf, png_uint_32 i) buf[3] = (png_byte)(i & 0xff); } -/* The png_save_int_32 function assumes integers are stored in two's - * complement format. If this isn't the case, then this routine needs to - * be modified to write data in two's complement format. - */ -void PNGAPI -png_save_int_32(png_bytep buf, png_int_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} - /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. @@ -48,323 +39,710 @@ png_save_uint_16(png_bytep buf, unsigned int i) buf[0] = (png_byte)((i >> 8) & 0xff); buf[1] = (png_byte)(i & 0xff); } +#endif -/* Write a PNG chunk all at once. The type is an array of ASCII characters - * representing the chunk name. The array must be at least 4 bytes in - * length, and does not need to be null terminated. To be safe, pass the - * pre-defined chunk names here, and if you need a new one, define it - * where the others are defined. The length is the length of the data. - * All the data must be present. If that is not possible, use the - * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() - * functions instead. +/* Simple function to write the signature. If we have already written + * the magic bytes of the signature, or more likely, the PNG stream is + * being embedded into another stream and doesn't need its own signature, + * we should call png_set_sig_bytes() to tell libpng how many of the + * bytes have already been written. */ void PNGAPI -png_write_chunk(png_structp png_ptr, png_bytep chunk_name, - png_bytep data, png_size_t length) +png_write_sig(png_structrp png_ptr) { - if(png_ptr == NULL) return; - png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); - png_write_chunk_data(png_ptr, data, length); - png_write_chunk_end(png_ptr); + png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that the signature is being written */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE; +#endif + + /* Write the rest of the 8 byte signature */ + png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], + (png_size_t)(8 - png_ptr->sig_bytes)); + + if (png_ptr->sig_bytes < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; } /* Write the start of a PNG chunk. The type is the chunk type. * The total_length is the sum of the lengths of all the data you will be * passing in png_write_chunk_data(). */ -void PNGAPI -png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, - png_uint_32 length) +static void +png_write_chunk_header(png_structrp png_ptr, png_uint_32 chunk_name, + png_uint_32 length) { - png_byte buf[4]; - png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); - if(png_ptr == NULL) return; + png_byte buf[8]; + +#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) + PNG_CSTRING_FROM_CHUNK(buf, chunk_name); + png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length); +#endif - /* write the length */ + if (png_ptr == NULL) + return; + +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that the chunk header is being written. + * PNG_IO_CHUNK_HDR requires a single I/O call. + */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR; +#endif + + /* Write the length and the chunk name */ png_save_uint_32(buf, length); - png_write_data(png_ptr, buf, (png_size_t)4); + png_save_uint_32(buf + 4, chunk_name); + png_write_data(png_ptr, buf, 8); + + /* Put the chunk name into png_ptr->chunk_name */ + png_ptr->chunk_name = chunk_name; - /* write the chunk name */ - png_write_data(png_ptr, chunk_name, (png_size_t)4); - /* reset the crc and run it over the chunk name */ + /* Reset the crc and run it over the chunk name */ png_reset_crc(png_ptr); - png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); + + png_calculate_crc(png_ptr, buf + 4, 4); + +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that chunk data will (possibly) be written. + * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls. + */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA; +#endif +} + +void PNGAPI +png_write_chunk_start(png_structrp png_ptr, png_const_bytep chunk_string, + png_uint_32 length) +{ + png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length); } -/* Write the data of a PNG chunk started with png_write_chunk_start(). +/* Write the data of a PNG chunk started with png_write_chunk_header(). * Note that multiple calls to this function are allowed, and that the * sum of the lengths from these calls *must* add up to the total_length - * given to png_write_chunk_start(). + * given to png_write_chunk_header(). */ void PNGAPI -png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) +png_write_chunk_data(png_structrp png_ptr, png_const_bytep data, + png_size_t length) { - /* write the data, and run the CRC over it */ - if(png_ptr == NULL) return; + /* Write the data, and run the CRC over it */ + if (png_ptr == NULL) + return; + if (data != NULL && length > 0) { - png_calculate_crc(png_ptr, data, length); png_write_data(png_ptr, data, length); + + /* Update the CRC after writing the data, + * in case that the user I/O routine alters it. + */ + png_calculate_crc(png_ptr, data, length); } } -/* Finish a chunk started with png_write_chunk_start(). */ +/* Finish a chunk started with png_write_chunk_header(). */ void PNGAPI -png_write_chunk_end(png_structp png_ptr) +png_write_chunk_end(png_structrp png_ptr) { png_byte buf[4]; - if(png_ptr == NULL) return; + if (png_ptr == NULL) return; + +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that the chunk CRC is being written. + * PNG_IO_CHUNK_CRC requires a single I/O function call. + */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC; +#endif - /* write the crc */ + /* Write the crc in a single operation */ png_save_uint_32(buf, png_ptr->crc); png_write_data(png_ptr, buf, (png_size_t)4); } -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. +/* Write a PNG chunk all at once. The type is an array of ASCII characters + * representing the chunk name. The array must be at least 4 bytes in + * length, and does not need to be null terminated. To be safe, pass the + * pre-defined chunk names here, and if you need a new one, define it + * where the others are defined. The length is the length of the data. + * All the data must be present. If that is not possible, use the + * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() + * functions instead. */ -void /* PRIVATE */ -png_write_sig(png_structp png_ptr) +static void +png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, + png_const_bytep data, png_size_t length) { - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - /* write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)8 - png_ptr->sig_bytes); - if(png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} + if (png_ptr == NULL) + return; -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) -/* - * This pair of functions encapsulates the operation of (a) compressing a - * text string, and (b) issuing it later as a series of chunk data writes. - * The compression_state structure is shared context for these functions - * set up by the caller in order to make the whole mess thread-safe. - */ + /* On 64 bit architectures 'length' may not fit in a png_uint_32. */ + if (length > PNG_UINT_31_MAX) + png_error(png_ptr, "length exceeds PNG maxima"); -typedef struct -{ - char *input; /* the uncompressed input data */ - int input_len; /* its length */ - int num_output_ptr; /* number of output pointers used */ - int max_output_ptr; /* size of output_ptr */ - png_charpp output_ptr; /* array of pointers to output */ -} compression_state; + png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length); + png_write_chunk_data(png_ptr, data, length); + png_write_chunk_end(png_ptr); +} -/* compress given text into storage in the png_ptr structure */ -static int /* PRIVATE */ -png_text_compress(png_structp png_ptr, - png_charp text, png_size_t text_len, int compression, - compression_state *comp) +/* This is the API that calls the internal function above. */ +void PNGAPI +png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string, + png_const_bytep data, png_size_t length) { - int ret; + png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data, + length); +} - comp->num_output_ptr = 0; - comp->max_output_ptr = 0; - comp->output_ptr = NULL; - comp->input = NULL; - comp->input_len = 0; +/* This is used below to find the size of an image to pass to png_deflate_claim, + * so it only needs to be accurate if the size is less than 16384 bytes (the + * point at which a lower LZ window size can be used.) + */ +static png_alloc_size_t +png_image_size(png_structrp png_ptr) +{ + /* Only return sizes up to the maximum of a png_uint_32, do this by limiting + * the width and height used to 15 bits. + */ + png_uint_32 h = png_ptr->height; - /* we may just want to pass the text right through */ - if (compression == PNG_TEXT_COMPRESSION_NONE) + if (png_ptr->rowbytes < 32768 && h < 32768) { - comp->input = text; - comp->input_len = text_len; - return((int)text_len); + if (png_ptr->interlaced) + { + /* Interlacing makes the image larger because of the replication of + * both the filter byte and the padding to a byte boundary. + */ + png_uint_32 w = png_ptr->width; + unsigned int pd = png_ptr->pixel_depth; + png_alloc_size_t cb_base; + int pass; + + for (cb_base=0, pass=0; pass<=6; ++pass) + { + png_uint_32 pw = PNG_PASS_COLS(w, pass); + + if (pw > 0) + cb_base += (PNG_ROWBYTES(pd, pw)+1) * PNG_PASS_ROWS(h, pass); + } + + return cb_base; + } + + else + return (png_ptr->rowbytes+1) * h; } - if (compression >= PNG_TEXT_COMPRESSION_LAST) + else + return 0xffffffffU; +} + +#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED + /* This is the code to hack the first two bytes of the deflate stream (the + * deflate header) to correct the windowBits value to match the actual data + * size. Note that the second argument is the *uncompressed* size but the + * first argument is the *compressed* data (and it must be deflate + * compressed.) + */ +static void +optimize_cmf(png_bytep data, png_alloc_size_t data_size) +{ + /* Optimize the CMF field in the zlib stream. The resultant zlib stream is + * still compliant to the stream specification. + */ + if (data_size <= 16384) /* else windowBits must be 15 */ { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - png_snprintf(msg, 50, "Unknown compression type %d", compression); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "Unknown compression type"); -#endif + unsigned int z_cmf = data[0]; /* zlib compression method and flags */ + + if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) + { + unsigned int z_cinfo; + unsigned int half_z_window_size; + + z_cinfo = z_cmf >> 4; + half_z_window_size = 1U << (z_cinfo + 7); + + if (data_size <= half_z_window_size) /* else no change */ + { + unsigned int tmp; + + do + { + half_z_window_size >>= 1; + --z_cinfo; + } + while (z_cinfo > 0 && data_size <= half_z_window_size); + + z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); + + data[0] = (png_byte)z_cmf; + tmp = data[1] & 0xe0; + tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f; + data[1] = (png_byte)tmp; + } + } } +} +#else +# define optimize_cmf(dp,dl) ((void)0) +#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */ - /* We can't write the chunk until we find out how much data we have, - * which means we need to run the compressor first and save the - * output. This shouldn't be a problem, as the vast majority of - * comments should be reasonable, but we will set up an array of - * malloc'd pointers to be sure. - * - * If we knew the application was well behaved, we could simplify this - * greatly by assuming we can always malloc an output buffer large - * enough to hold the compressed text ((1001 * text_len / 1000) + 12) - * and malloc this directly. The only time this would be a bad idea is - * if we can't malloc more than 64K and we have 64K of random input - * data, or if the input string is incredibly large (although this - * wouldn't cause a failure, just a slowdown due to swapping). - */ +/* Initialize the compressor for the appropriate type of compression. */ +static int +png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, + png_alloc_size_t data_size) +{ + if (png_ptr->zowner != 0) + { + char msg[64]; + + PNG_STRING_FROM_CHUNK(msg, owner); + msg[4] = ':'; + msg[5] = ' '; + PNG_STRING_FROM_CHUNK(msg+6, png_ptr->zowner); + /* So the message that results is "<chunk> using zstream"; this is an + * internal error, but is very useful for debugging. i18n requirements + * are minimal. + */ + (void)png_safecat(msg, (sizeof msg), 10, " using zstream"); +# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC + png_warning(png_ptr, msg); + + /* Attempt sane error recovery */ + if (png_ptr->zowner == png_IDAT) /* don't steal from IDAT */ + { + png_ptr->zstream.msg = PNGZ_MSG_CAST("in use by IDAT"); + return Z_STREAM_ERROR; + } - /* set up the compression buffers */ - png_ptr->zstream.avail_in = (uInt)text_len; - png_ptr->zstream.next_in = (Bytef *)text; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; + png_ptr->zowner = 0; +# else + png_error(png_ptr, msg); +# endif + } - /* this is the same compression loop as in png_write_row() */ - do { - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - if (ret != Z_OK) + int level = png_ptr->zlib_level; + int method = png_ptr->zlib_method; + int windowBits = png_ptr->zlib_window_bits; + int memLevel = png_ptr->zlib_mem_level; + int strategy; /* set below */ + int ret; /* zlib return code */ + + if (owner == png_IDAT) { - /* error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); + if (png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) + strategy = png_ptr->zlib_strategy; + + else if (png_ptr->do_filter != PNG_FILTER_NONE) + strategy = PNG_Z_DEFAULT_STRATEGY; + else - png_error(png_ptr, "zlib error"); + strategy = PNG_Z_DEFAULT_NOFILTER_STRATEGY; } - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) + + else { - /* make sure the output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; +# ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED + level = png_ptr->zlib_text_level; + method = png_ptr->zlib_text_method; + windowBits = png_ptr->zlib_text_window_bits; + memLevel = png_ptr->zlib_text_mem_level; + strategy = png_ptr->zlib_text_strategy; +# else + /* If customization is not supported the values all come from the + * IDAT values except for the strategy, which is fixed to the + * default. (This is the pre-1.6.0 behavior too, although it was + * implemented in a very different way.) + */ + strategy = Z_DEFAULT_STRATEGY; +# endif + } - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, old_max - * png_sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); + /* Adjust 'windowBits' down if larger than 'data_size'; to stop this + * happening just pass 32768 as the data_size parameter. Notice that zlib + * requires an extra 262 bytes in the window in addition to the data to be + * able to see the whole of the data, so if data_size+262 takes us to the + * next windowBits size we need to fix up the value later. (Because even + * though deflate needs the extra window, inflate does not!) + */ + if (data_size <= 16384) + { + /* IMPLEMENTATION NOTE: this 'half_window_size' stuff is only here to + * work round a Microsoft Visual C misbehavior which, contrary to C-90, + * widens the result of the following shift to 64-bits if (and, + * apparently, only if) it is used in a test. + */ + unsigned int half_window_size = 1U << (windowBits-1); + + while (data_size + 262 <= half_window_size) + { + half_window_size >>= 1; + --windowBits; } + } - /* save the data */ - comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; + /* Check against the previous initialized values, if any. */ + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) && + (png_ptr->zlib_set_level != level || + png_ptr->zlib_set_method != method || + png_ptr->zlib_set_window_bits != windowBits || + png_ptr->zlib_set_mem_level != memLevel || + png_ptr->zlib_set_strategy != strategy)) + { + if (deflateEnd(&png_ptr->zstream) != Z_OK) + png_warning(png_ptr, "deflateEnd failed (ignored)"); - /* and reset the buffer */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED; } - /* continue until we don't have any more to compress */ - } while (png_ptr->zstream.avail_in); - /* finish the compression */ - do - { - /* tell zlib we are finished */ - ret = deflate(&png_ptr->zstream, Z_FINISH); + /* For safety clear out the input and output pointers (currently zlib + * doesn't use them on Init, but it might in the future). + */ + png_ptr->zstream.next_in = NULL; + png_ptr->zstream.avail_in = 0; + png_ptr->zstream.next_out = NULL; + png_ptr->zstream.avail_out = 0; + + /* Now initialize if required, setting the new parameters, otherwise just + * to a simple reset to the previous parameters. + */ + if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) + ret = deflateReset(&png_ptr->zstream); + + else + { + ret = deflateInit2(&png_ptr->zstream, level, method, windowBits, + memLevel, strategy); + + if (ret == Z_OK) + png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; + } + /* The return code is from either deflateReset or deflateInit2; they have + * pretty much the same set of error codes. + */ if (ret == Z_OK) + png_ptr->zowner = owner; + + else + png_zstream_error(png_ptr, ret); + + return ret; + } +} + +/* Clean up (or trim) a linked list of compression buffers. */ +void /* PRIVATE */ +png_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *listp) +{ + png_compression_bufferp list = *listp; + + if (list != NULL) + { + *listp = NULL; + + do { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) + png_compression_bufferp next = list->next; + + png_free(png_ptr, list); + list = next; + } + while (list != NULL); + } +} + +#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED +/* This pair of functions encapsulates the operation of (a) compressing a + * text string, and (b) issuing it later as a series of chunk data writes. + * The compression_state structure is shared context for these functions + * set up by the caller to allow access to the relevant local variables. + * + * compression_buffer (new in 1.6.0) is just a linked list of zbuffer_size + * temporary buffers. From 1.6.0 it is retained in png_struct so that it will + * be correctly freed in the event of a write error (previous implementations + * just leaked memory.) + */ +typedef struct +{ + png_const_bytep input; /* The uncompressed input data */ + png_alloc_size_t input_len; /* Its length */ + png_uint_32 output_len; /* Final compressed length */ + png_byte output[1024]; /* First block of output */ +} compression_state; + +static void +png_text_compress_init(compression_state *comp, png_const_bytep input, + png_alloc_size_t input_len) +{ + comp->input = input; + comp->input_len = input_len; + comp->output_len = 0; +} + +/* Compress the data in the compression state input */ +static int +png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, + compression_state *comp, png_uint_32 prefix_len) +{ + int ret; + + /* To find the length of the output it is necessary to first compress the + * input, the result is buffered rather than using the two-pass algorithm + * that is used on the inflate side; deflate is assumed to be slower and a + * PNG writer is assumed to have more memory available than a PNG reader. + * + * IMPLEMENTATION NOTE: the zlib API deflateBound() can be used to find an + * upper limit on the output size, but it is always bigger than the input + * size so it is likely to be more efficient to use this linked-list + * approach. + */ + ret = png_deflate_claim(png_ptr, chunk_name, comp->input_len); + + if (ret != Z_OK) + return ret; + + /* Set up the compression buffers, we need a loop here to avoid overflowing a + * uInt. Use ZLIB_IO_MAX to limit the input. The output is always limited + * by the output buffer size, so there is no need to check that. Since this + * is ANSI-C we know that an 'int', hence a uInt, is always at least 16 bits + * in size. + */ + { + png_compression_bufferp *end = &png_ptr->zbuffer_list; + png_alloc_size_t input_len = comp->input_len; /* may be zero! */ + png_uint_32 output_len; + + /* zlib updates these for us: */ + png_ptr->zstream.next_in = PNGZ_INPUT_CAST(comp->input); + png_ptr->zstream.avail_in = 0; /* Set below */ + png_ptr->zstream.next_out = comp->output; + png_ptr->zstream.avail_out = (sizeof comp->output); + + output_len = png_ptr->zstream.avail_out; + + do + { + uInt avail_in = ZLIB_IO_MAX; + + if (avail_in > input_len) + avail_in = (uInt)input_len; + + input_len -= avail_in; + + png_ptr->zstream.avail_in = avail_in; + + if (png_ptr->zstream.avail_out == 0) { - /* check to make sure our output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) + png_compression_buffer *next; + + /* Chunk data is limited to 2^31 bytes in length, so the prefix + * length must be counted here. + */ + if (output_len + prefix_len > PNG_UINT_31_MAX) + { + ret = Z_MEM_ERROR; + break; + } + + /* Need a new (malloc'ed) buffer, but there may be one present + * already. + */ + next = *end; + if (next == NULL) { - int old_max; + next = png_voidcast(png_compression_bufferp, png_malloc_base + (png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) + if (next == NULL) { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - /* This could be optimized to realloc() */ - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, - old_max * png_sizeof (png_charp)); - png_free(png_ptr, old_ptr); + ret = Z_MEM_ERROR; + break; } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); + + /* Link in this buffer (so that it will be freed later) */ + next->next = NULL; + *end = next; } - /* save off the data */ - comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; + png_ptr->zstream.next_out = next->output; + png_ptr->zstream.avail_out = png_ptr->zbuffer_size; + output_len += png_ptr->zstream.avail_out; - /* and reset the buffer pointers */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; + /* Move 'end' to the next buffer pointer. */ + end = &next->next; } + + /* Compress the data */ + ret = deflate(&png_ptr->zstream, + input_len > 0 ? Z_NO_FLUSH : Z_FINISH); + + /* Claw back input data that was not consumed (because avail_in is + * reset above every time round the loop). + */ + input_len += png_ptr->zstream.avail_in; + png_ptr->zstream.avail_in = 0; /* safety */ } - else if (ret != Z_STREAM_END) + while (ret == Z_OK); + + /* There may be some space left in the last output buffer, this needs to + * be subtracted from output_len. + */ + output_len -= png_ptr->zstream.avail_out; + png_ptr->zstream.avail_out = 0; /* safety */ + comp->output_len = output_len; + + /* Now double check the output length, put in a custom message if it is + * too long. Otherwise ensure the z_stream::msg pointer is set to + * something. + */ + if (output_len + prefix_len >= PNG_UINT_31_MAX) { - /* we got an error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); + png_ptr->zstream.msg = PNGZ_MSG_CAST("compressed data too long"); + ret = Z_MEM_ERROR; } - } while (ret != Z_STREAM_END); - /* text length is number of buffers plus last buffer */ - text_len = png_ptr->zbuf_size * comp->num_output_ptr; - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; + else + png_zstream_error(png_ptr, ret); + + /* Reset zlib for another zTXt/iTXt or image data */ + png_ptr->zowner = 0; - return((int)text_len); + /* The only success case is Z_STREAM_END, input_len must be 0, if not this + * is an internal error. + */ + if (ret == Z_STREAM_END && input_len == 0) + { + /* Fix up the deflate header, if required */ + optimize_cmf(comp->output, comp->input_len); + + /* But Z_OK is returned, not Z_STREAM_END; this allows the claim + * function above to return Z_STREAM_END on an error (though it never + * does in the current versions of zlib.) + */ + return Z_OK; + } + + else + return ret; + } } -/* ship the compressed text out via chunk writes */ -static void /* PRIVATE */ -png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) +/* Ship the compressed text out via chunk writes */ +static void +png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp) { - int i; + png_uint_32 output_len = comp->output_len; + png_const_bytep output = comp->output; + png_uint_32 avail = (sizeof comp->output); + png_compression_buffer *next = png_ptr->zbuffer_list; + + for (;;) + { + if (avail > output_len) + avail = output_len; + + png_write_chunk_data(png_ptr, output, avail); + + output_len -= avail; + + if (output_len == 0 || next == NULL) + break; + + avail = png_ptr->zbuffer_size; + output = next->output; + next = next->next; + } + + /* This is an internal error; 'next' must have been NULL! */ + if (output_len > 0) + png_error(png_ptr, "error writing ancillary chunked compressed data"); +} +#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */ + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, + * and if invalid, correct the keyword rather than discarding the entire + * chunk. The PNG 1.0 specification requires keywords 1-79 characters in + * length, forbids leading or trailing whitespace, multiple internal spaces, + * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. + * + * The 'new_key' buffer must be 80 characters in size (for the keyword plus a + * trailing '\0'). If this routine returns 0 then there was no keyword, or a + * valid one could not be generated, and the caller must png_error. + */ +static png_uint_32 +png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) +{ + png_const_charp orig_key = key; + png_uint_32 key_len = 0; + int bad_character = 0; + int space = 1; + + png_debug(1, "in png_check_keyword"); - /* handle the no-compression case */ - if (comp->input) + if (key == NULL) { - png_write_chunk_data(png_ptr, (png_bytep)comp->input, - (png_size_t)comp->input_len); - return; + *new_key = 0; + return 0; } - /* write saved output buffers, if any */ - for (i = 0; i < comp->num_output_ptr; i++) + while (*key && key_len < 79) { - png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], - png_ptr->zbuf_size); - png_free(png_ptr, comp->output_ptr[i]); - comp->output_ptr[i]=NULL; + png_byte ch = (png_byte)(0xff & *key++); + + if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) + *new_key++ = ch, ++key_len, space = 0; + + else if (!space) + { + /* A space or an invalid character when one wasn't seen immediately + * before; output just a space. + */ + *new_key++ = 32, ++key_len, space = 1; + + /* If the character was not a space then it is invalid. */ + if (ch != 32) + bad_character = ch; + } + + else if (!bad_character) + bad_character = ch; /* just skip it, record the first error */ + } + + if (key_len > 0 && space) /* trailing space */ + { + --key_len, --new_key; + if (!bad_character) + bad_character = 32; + } + + /* Terminate the keyword */ + *new_key = 0; + + if (key_len == 0) + return 0; + + /* Try to only output one warning per keyword: */ + if (*key) /* keyword too long */ + png_warning(png_ptr, "keyword truncated"); + + else if (bad_character) + { + PNG_WARNING_PARAMETERS(p) + + png_warning_parameter(p, 1, orig_key); + png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character); + + png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'"); } - if (comp->max_output_ptr != 0) - png_free(png_ptr, comp->output_ptr); - comp->output_ptr=NULL; - /* write anything left in zbuf */ - if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) - png_write_chunk_data(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - /* reset zlib for another zTXt/iTXt or image data */ - deflateReset(&png_ptr->zstream); - png_ptr->zstream.data_type = Z_BINARY; + return key_len; } #endif @@ -373,16 +751,14 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) * information being correct. */ void /* PRIVATE */ -png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, - int bit_depth, int color_type, int compression_type, int filter_type, - int interlace_type) +png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, + int bit_depth, int color_type, int compression_type, int filter_type, + int interlace_type) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; -#endif - png_byte buf[13]; /* buffer to store the IHDR info */ + png_byte buf[13]; /* Buffer to store the IHDR info */ + + png_debug(1, "in png_write_IHDR"); - png_debug(1, "in png_write_IHDR\n"); /* Check that we have valid input data from the application info */ switch (color_type) { @@ -393,35 +769,61 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, case 2: case 4: case 8: - case 16: png_ptr->channels = 1; break; - default: png_error(png_ptr,"Invalid bit depth for grayscale image"); +#ifdef PNG_WRITE_16BIT_SUPPORTED + case 16: +#endif + png_ptr->channels = 1; break; + + default: + png_error(png_ptr, + "Invalid bit depth for grayscale image"); } break; + case PNG_COLOR_TYPE_RGB: +#ifdef PNG_WRITE_16BIT_SUPPORTED if (bit_depth != 8 && bit_depth != 16) +#else + if (bit_depth != 8) +#endif png_error(png_ptr, "Invalid bit depth for RGB image"); + png_ptr->channels = 3; break; + case PNG_COLOR_TYPE_PALETTE: switch (bit_depth) { case 1: case 2: case 4: - case 8: png_ptr->channels = 1; break; - default: png_error(png_ptr, "Invalid bit depth for paletted image"); + case 8: + png_ptr->channels = 1; + break; + + default: + png_error(png_ptr, "Invalid bit depth for paletted image"); } break; + case PNG_COLOR_TYPE_GRAY_ALPHA: if (bit_depth != 8 && bit_depth != 16) png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); + png_ptr->channels = 2; break; + case PNG_COLOR_TYPE_RGB_ALPHA: +#ifdef PNG_WRITE_16BIT_SUPPORTED if (bit_depth != 8 && bit_depth != 16) +#else + if (bit_depth != 8) +#endif png_error(png_ptr, "Invalid bit depth for RGBA image"); + png_ptr->channels = 4; break; + default: png_error(png_ptr, "Invalid image color type specified"); } @@ -442,14 +844,14 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, * 5. The color_type is RGB or RGBA */ if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && +#ifdef PNG_MNG_FEATURES_SUPPORTED + !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && #endif - filter_type != PNG_FILTER_TYPE_BASE) + filter_type != PNG_FILTER_TYPE_BASE) { png_warning(png_ptr, "Invalid filter type specified"); filter_type = PNG_FILTER_TYPE_BASE; @@ -457,7 +859,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, #ifdef PNG_WRITE_INTERLACING_SUPPORTED if (interlace_type != PNG_INTERLACE_NONE && - interlace_type != PNG_INTERLACE_ADAM7) + interlace_type != PNG_INTERLACE_ADAM7) { png_warning(png_ptr, "Invalid interlace type specified"); interlace_type = PNG_INTERLACE_ADAM7; @@ -466,11 +868,11 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, interlace_type=PNG_INTERLACE_NONE; #endif - /* save off the relevent information */ + /* Save the relevent information */ png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->color_type = (png_byte)color_type; png_ptr->interlaced = (png_byte)interlace_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED png_ptr->filter_type = (png_byte)filter_type; #endif png_ptr->compression_type = (png_byte)compression_type; @@ -479,12 +881,12 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); - /* set the usr info, so any transformations can modify it */ + /* Set the usr info, so any transformations can modify it */ png_ptr->usr_width = png_ptr->width; png_ptr->usr_bit_depth = png_ptr->bit_depth; png_ptr->usr_channels = png_ptr->channels; - /* pack the header information into the buffer */ + /* Pack the header information into the buffer */ png_save_uint_32(buf, width); png_save_uint_32(buf + 4, height); buf[8] = (png_byte)bit_depth; @@ -493,93 +895,68 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, buf[11] = (png_byte)filter_type; buf[12] = (png_byte)interlace_type; - /* write the chunk */ - png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13); + /* Write the chunk */ + png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13); - /* initialize zlib with PNG info */ - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; if (!(png_ptr->do_filter)) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - png_ptr->bit_depth < 8) + png_ptr->bit_depth < 8) png_ptr->do_filter = PNG_FILTER_NONE; + else png_ptr->do_filter = PNG_ALL_FILTERS; } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)) - { - if (png_ptr->do_filter != PNG_FILTER_NONE) - png_ptr->zlib_strategy = Z_FILTERED; - else - png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL)) - png_ptr->zlib_level = Z_DEFAULT_COMPRESSION; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL)) - png_ptr->zlib_mem_level = 8; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS)) - png_ptr->zlib_window_bits = 15; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) - png_ptr->zlib_method = 8; - if (deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, - png_ptr->zlib_method, png_ptr->zlib_window_bits, - png_ptr->zlib_mem_level, png_ptr->zlib_strategy) != Z_OK) - png_error(png_ptr, "zlib failed to initialize compressor"); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - /* libpng is not interested in zstream.data_type */ - /* set it to a predefined value, to avoid its evaluation inside zlib */ - png_ptr->zstream.data_type = Z_BINARY; - - png_ptr->mode = PNG_HAVE_IHDR; + + png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */ } -/* write the palette. We are careful not to trust png_color to be in the +/* Write the palette. We are careful not to trust png_color to be in the * correct order for PNG, so people can redefine it to any convenient * structure. */ void /* PRIVATE */ -png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) +png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, + png_uint_32 num_pal) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_PLTE; -#endif png_uint_32 i; - png_colorp pal_ptr; + png_const_colorp pal_ptr; png_byte buf[3]; - png_debug(1, "in png_write_PLTE\n"); + png_debug(1, "in png_write_PLTE"); + if (( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && +#ifdef PNG_MNG_FEATURES_SUPPORTED + !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && #endif - num_pal == 0) || num_pal > 256) + num_pal == 0) || num_pal > 256) { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_error(png_ptr, "Invalid number of colors in palette"); - } - else - { - png_warning(png_ptr, "Invalid number of colors in palette"); - return; - } + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_error(png_ptr, "Invalid number of colors in palette"); + } + + else + { + png_warning(png_ptr, "Invalid number of colors in palette"); + return; + } } if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) { png_warning(png_ptr, - "Ignoring request to write a PLTE chunk in grayscale PNG"); + "Ignoring request to write a PLTE chunk in grayscale PNG"); + return; } png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); + png_debug1(3, "num_palette = %d", png_ptr->num_palette); + + png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3)); +#ifdef PNG_POINTER_INDEXING_SUPPORTED - png_write_chunk_start(png_ptr, png_PLTE, num_pal * 3); -#ifndef PNG_NO_POINTER_INDEXING for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) { buf[0] = pal_ptr->red; @@ -587,9 +964,13 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) buf[2] = pal_ptr->blue; png_write_chunk_data(png_ptr, buf, (png_size_t)3); } + #else - /* This is a little slower but some buggy compilers need to do this instead */ + /* This is a little slower but some buggy compilers need to do this + * instead + */ pal_ptr=palette; + for (i = 0; i < num_pal; i++) { buf[0] = pal_ptr[i].red; @@ -597,307 +978,374 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) buf[2] = pal_ptr[i].blue; png_write_chunk_data(png_ptr, buf, (png_size_t)3); } + #endif png_write_chunk_end(png_ptr); png_ptr->mode |= PNG_HAVE_PLTE; } -/* write an IDAT chunk */ +/* This is similar to png_text_compress, above, except that it does not require + * all of the data at once and, instead of buffering the compressed result, + * writes it as IDAT chunks. Unlike png_text_compress it *can* png_error out + * because it calls the write interface. As a result it does its own error + * reporting and does not return an error code. In the event of error it will + * just call png_error. The input data length may exceed 32-bits. The 'flush' + * parameter is exactly the same as that to deflate, with the following + * meanings: + * + * Z_NO_FLUSH: normal incremental output of compressed data + * Z_SYNC_FLUSH: do a SYNC_FLUSH, used by png_write_flush + * Z_FINISH: this is the end of the input, do a Z_FINISH and clean up + * + * The routine manages the acquire and release of the png_ptr->zstream by + * checking and (at the end) clearing png_ptr->zowner, it does some sanity + * checks on the 'mode' flags while doing this. + */ void /* PRIVATE */ -png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) +png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, + png_alloc_size_t input_len, int flush) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - png_debug(1, "in png_write_IDAT\n"); + if (png_ptr->zowner != png_IDAT) + { + /* First time. Ensure we have a temporary buffer for compression and + * trim the buffer list if it has more than one entry to free memory. + * If 'WRITE_COMPRESSED_TEXT' is not set the list will never have been + * created at this point, but the check here is quick and safe. + */ + if (png_ptr->zbuffer_list == NULL) + { + png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp, + png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); + png_ptr->zbuffer_list->next = NULL; + } + + else + png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list->next); + + /* It is a terminal error if we can't claim the zstream. */ + if (png_deflate_claim(png_ptr, png_IDAT, png_image_size(png_ptr)) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); + + /* The output state is maintained in png_ptr->zstream, so it must be + * initialized here after the claim. + */ + png_ptr->zstream.next_out = png_ptr->zbuffer_list->output; + png_ptr->zstream.avail_out = png_ptr->zbuffer_size; + } - /* Optimize the CMF field in the zlib stream. */ - /* This hack of the zlib stream is compliant to the stream specification. */ - if (!(png_ptr->mode & PNG_HAVE_IDAT) && - png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) + /* Now loop reading and writing until all the input is consumed or an error + * terminates the operation. The _out values are maintained across calls to + * this function, but the input must be reset each time. + */ + png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input); + png_ptr->zstream.avail_in = 0; /* set below */ + for (;;) { - unsigned int z_cmf = data[0]; /* zlib compression method and flags */ - if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) + int ret; + + /* INPUT: from the row data */ + uInt avail = ZLIB_IO_MAX; + + if (avail > input_len) + avail = (uInt)input_len; /* safe because of the check */ + + png_ptr->zstream.avail_in = avail; + input_len -= avail; + + ret = deflate(&png_ptr->zstream, input_len > 0 ? Z_NO_FLUSH : flush); + + /* Include as-yet unconsumed input */ + input_len += png_ptr->zstream.avail_in; + png_ptr->zstream.avail_in = 0; + + /* OUTPUT: write complete IDAT chunks when avail_out drops to zero, note + * that these two zstream fields are preserved across the calls, therefore + * there is no need to set these up on entry to the loop. + */ + if (png_ptr->zstream.avail_out == 0) + { + png_bytep data = png_ptr->zbuffer_list->output; + uInt size = png_ptr->zbuffer_size; + + /* Write an IDAT containing the data then reset the buffer. The + * first IDAT may need deflate header optimization. + */ +# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED + if (!(png_ptr->mode & PNG_HAVE_IDAT) && + png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) + optimize_cmf(data, png_image_size(png_ptr)); +# endif + + png_write_complete_chunk(png_ptr, png_IDAT, data, size); + png_ptr->mode |= PNG_HAVE_IDAT; + + png_ptr->zstream.next_out = data; + png_ptr->zstream.avail_out = size; + + /* For SYNC_FLUSH or FINISH it is essential to keep calling zlib with + * the same flush parameter until it has finished output, for NO_FLUSH + * it doesn't matter. + */ + if (ret == Z_OK && flush != Z_NO_FLUSH) + continue; + } + + /* The order of these checks doesn't matter much; it just effect which + * possible error might be detected if multiple things go wrong at once. + */ + if (ret == Z_OK) /* most likely return code! */ { - /* Avoid memory underflows and multiplication overflows. */ - /* The conditions below are practically always satisfied; - however, they still must be checked. */ - if (length >= 2 && - png_ptr->height < 16384 && png_ptr->width < 16384) + /* If all the input has been consumed then just return. If Z_FINISH + * was used as the flush parameter something has gone wrong if we get + * here. + */ + if (input_len == 0) { - png_uint_32 uncompressed_idat_size = png_ptr->height * - ((png_ptr->width * - png_ptr->channels * png_ptr->bit_depth + 15) >> 3); - unsigned int z_cinfo = z_cmf >> 4; - unsigned int half_z_window_size = 1 << (z_cinfo + 7); - while (uncompressed_idat_size <= half_z_window_size && - half_z_window_size >= 256) - { - z_cinfo--; - half_z_window_size >>= 1; - } - z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); - if (data[0] != (png_byte)z_cmf) - { - data[0] = (png_byte)z_cmf; - data[1] &= 0xe0; - data[1] += (png_byte)(0x1f - ((z_cmf << 8) + data[1]) % 0x1f); - } + if (flush == Z_FINISH) + png_error(png_ptr, "Z_OK on Z_FINISH with output space"); + + return; } } + + else if (ret == Z_STREAM_END && flush == Z_FINISH) + { + /* This is the end of the IDAT data; any pending output must be + * flushed. For small PNG files we may still be at the beginning. + */ + png_bytep data = png_ptr->zbuffer_list->output; + uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out; + +# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED + if (!(png_ptr->mode & PNG_HAVE_IDAT) && + png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) + optimize_cmf(data, png_image_size(png_ptr)); +# endif + + png_write_complete_chunk(png_ptr, png_IDAT, data, size); + png_ptr->zstream.avail_out = 0; + png_ptr->zstream.next_out = NULL; + png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT; + + png_ptr->zowner = 0; /* Release the stream */ + return; + } + else - png_error(png_ptr, - "Invalid zlib compression method or flags in IDAT"); + { + /* This is an error condition. */ + png_zstream_error(png_ptr, ret); + png_error(png_ptr, png_ptr->zstream.msg); + } } - - png_write_chunk(png_ptr, png_IDAT, data, length); - png_ptr->mode |= PNG_HAVE_IDAT; } -/* write an IEND chunk */ +/* Write an IEND chunk */ void /* PRIVATE */ -png_write_IEND(png_structp png_ptr) +png_write_IEND(png_structrp png_ptr) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IEND; -#endif - png_debug(1, "in png_write_IEND\n"); - png_write_chunk(png_ptr, png_IEND, png_bytep_NULL, - (png_size_t)0); + png_debug(1, "in png_write_IEND"); + + png_write_complete_chunk(png_ptr, png_IEND, NULL, (png_size_t)0); png_ptr->mode |= PNG_HAVE_IEND; } -#if defined(PNG_WRITE_gAMA_SUPPORTED) -/* write a gAMA chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_WRITE_gAMA_SUPPORTED +/* Write a gAMA chunk */ void /* PRIVATE */ -png_write_gAMA(png_structp png_ptr, double file_gamma) +png_write_gAMA_fixed(png_structrp png_ptr, png_fixed_point file_gamma) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_uint_32 igamma; png_byte buf[4]; - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); - png_save_uint_32(buf, igamma); - png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_byte buf[4]; + png_debug(1, "in png_write_gAMA"); - png_debug(1, "in png_write_gAMA\n"); /* file_gamma is saved in 1/100,000ths */ png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); + png_write_complete_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); } #endif -#endif -#if defined(PNG_WRITE_sRGB_SUPPORTED) -/* write a sRGB chunk */ +#ifdef PNG_WRITE_sRGB_SUPPORTED +/* Write a sRGB chunk */ void /* PRIVATE */ -png_write_sRGB(png_structp png_ptr, int srgb_intent) +png_write_sRGB(png_structrp png_ptr, int srgb_intent) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sRGB; -#endif png_byte buf[1]; - png_debug(1, "in png_write_sRGB\n"); - if(srgb_intent >= PNG_sRGB_INTENT_LAST) - png_warning(png_ptr, - "Invalid sRGB rendering intent specified"); + png_debug(1, "in png_write_sRGB"); + + if (srgb_intent >= PNG_sRGB_INTENT_LAST) + png_warning(png_ptr, + "Invalid sRGB rendering intent specified"); + buf[0]=(png_byte)srgb_intent; - png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1); + png_write_complete_chunk(png_ptr, png_sRGB, buf, (png_size_t)1); } #endif -#if defined(PNG_WRITE_iCCP_SUPPORTED) -/* write an iCCP chunk */ +#ifdef PNG_WRITE_iCCP_SUPPORTED +/* Write an iCCP chunk */ void /* PRIVATE */ -png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, - png_charp profile, int profile_len) +png_write_iCCP(png_structrp png_ptr, png_const_charp name, + png_const_bytep profile) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iCCP; -#endif - png_size_t name_len; - png_charp new_name; + png_uint_32 name_len; + png_uint_32 profile_len; + png_byte new_name[81]; /* 1 byte for the compression byte */ compression_state comp; - int embedded_profile_len = 0; - png_debug(1, "in png_write_iCCP\n"); + png_debug(1, "in png_write_iCCP"); + + /* These are all internal problems: the profile should have been checked + * before when it was stored. + */ + if (profile == NULL) + png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */ + + profile_len = png_get_uint_32(profile); - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - comp.input_len = 0; + if (profile_len < 132) + png_error(png_ptr, "ICC profile too short"); + + if (profile_len & 0x03) + png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)"); - if (name == NULL || (name_len = png_check_keyword(png_ptr, name, - &new_name)) == 0) { - png_warning(png_ptr, "Empty keyword in iCCP chunk"); - return; + png_uint_32 embedded_profile_len = png_get_uint_32(profile); + + if (profile_len != embedded_profile_len) + png_error(png_ptr, "Profile length does not match profile"); } - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_warning(png_ptr, "Unknown compression type in iCCP chunk"); + name_len = png_check_keyword(png_ptr, name, new_name); - if (profile == NULL) - profile_len = 0; - - if (profile_len > 3) - embedded_profile_len = - ((*( (png_bytep)profile ))<<24) | - ((*( (png_bytep)profile+1))<<16) | - ((*( (png_bytep)profile+2))<< 8) | - ((*( (png_bytep)profile+3)) ); - - if (profile_len < embedded_profile_len) - { - png_warning(png_ptr, - "Embedded profile length too large in iCCP chunk"); - return; - } - - if (profile_len > embedded_profile_len) - { - png_warning(png_ptr, - "Truncating profile to actual length in iCCP chunk"); - profile_len = embedded_profile_len; - } - - if (profile_len) - profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, - PNG_COMPRESSION_TYPE_BASE, &comp); - - /* make sure we include the NULL after the name and the compression type */ - png_write_chunk_start(png_ptr, png_iCCP, - (png_uint_32)name_len+profile_len+2); - new_name[name_len+1]=0x00; - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); - - if (profile_len) - png_write_compressed_data_out(png_ptr, &comp); + if (name_len == 0) + png_error(png_ptr, "iCCP: invalid keyword"); + + new_name[++name_len] = PNG_COMPRESSION_TYPE_BASE; + + /* Make sure we include the NULL after the name and the compression type */ + ++name_len; + + png_text_compress_init(&comp, profile, profile_len); + + /* Allow for keyword terminator and compression byte */ + if (png_text_compress(png_ptr, png_iCCP, &comp, name_len) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); + + png_write_chunk_header(png_ptr, png_iCCP, name_len + comp.output_len); + + png_write_chunk_data(png_ptr, new_name, name_len); + + png_write_compressed_data_out(png_ptr, &comp); png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); } #endif -#if defined(PNG_WRITE_sPLT_SUPPORTED) -/* write a sPLT chunk */ +#ifdef PNG_WRITE_sPLT_SUPPORTED +/* Write a sPLT chunk */ void /* PRIVATE */ -png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) +png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sPLT; -#endif - png_size_t name_len; - png_charp new_name; + png_uint_32 name_len; + png_byte new_name[80]; png_byte entrybuf[10]; - int entry_size = (spalette->depth == 8 ? 6 : 10); - int palette_size = entry_size * spalette->nentries; + png_size_t entry_size = (spalette->depth == 8 ? 6 : 10); + png_size_t palette_size = entry_size * spalette->nentries; png_sPLT_entryp ep; -#ifdef PNG_NO_POINTER_INDEXING +#ifndef PNG_POINTER_INDEXING_SUPPORTED int i; #endif - png_debug(1, "in png_write_sPLT\n"); - if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, - spalette->name, &new_name))==0) + png_debug(1, "in png_write_sPLT"); + + name_len = png_check_keyword(png_ptr, spalette->name, new_name); + + if (name_len == 0) + png_error(png_ptr, "sPLT: invalid keyword"); + + /* Make sure we include the NULL after the name */ + png_write_chunk_header(png_ptr, png_sPLT, + (png_uint_32)(name_len + 2 + palette_size)); + + png_write_chunk_data(png_ptr, (png_bytep)new_name, + (png_size_t)(name_len + 1)); + + png_write_chunk_data(png_ptr, &spalette->depth, (png_size_t)1); + + /* Loop through each palette entry, writing appropriately */ +#ifdef PNG_POINTER_INDEXING_SUPPORTED + for (ep = spalette->entries; ep<spalette->entries + spalette->nentries; ep++) { - png_warning(png_ptr, "Empty keyword in sPLT chunk"); - return; - } + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep->red; + entrybuf[1] = (png_byte)ep->green; + entrybuf[2] = (png_byte)ep->blue; + entrybuf[3] = (png_byte)ep->alpha; + png_save_uint_16(entrybuf + 4, ep->frequency); + } + + else + { + png_save_uint_16(entrybuf + 0, ep->red); + png_save_uint_16(entrybuf + 2, ep->green); + png_save_uint_16(entrybuf + 4, ep->blue); + png_save_uint_16(entrybuf + 6, ep->alpha); + png_save_uint_16(entrybuf + 8, ep->frequency); + } - /* make sure we include the NULL after the name */ - png_write_chunk_start(png_ptr, png_sPLT, - (png_uint_32)(name_len + 2 + palette_size)); - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); - png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); - - /* loop through each palette entry, writing appropriately */ -#ifndef PNG_NO_POINTER_INDEXING - for (ep = spalette->entries; ep<spalette->entries+spalette->nentries; ep++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep->red; - entrybuf[1] = (png_byte)ep->green; - entrybuf[2] = (png_byte)ep->blue; - entrybuf[3] = (png_byte)ep->alpha; - png_save_uint_16(entrybuf + 4, ep->frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep->red); - png_save_uint_16(entrybuf + 2, ep->green); - png_save_uint_16(entrybuf + 4, ep->blue); - png_save_uint_16(entrybuf + 6, ep->alpha); - png_save_uint_16(entrybuf + 8, ep->frequency); - } - png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); + png_write_chunk_data(png_ptr, entrybuf, entry_size); } #else ep=spalette->entries; - for (i=0; i>spalette->nentries; i++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep[i].red; - entrybuf[1] = (png_byte)ep[i].green; - entrybuf[2] = (png_byte)ep[i].blue; - entrybuf[3] = (png_byte)ep[i].alpha; - png_save_uint_16(entrybuf + 4, ep[i].frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep[i].red); - png_save_uint_16(entrybuf + 2, ep[i].green); - png_save_uint_16(entrybuf + 4, ep[i].blue); - png_save_uint_16(entrybuf + 6, ep[i].alpha); - png_save_uint_16(entrybuf + 8, ep[i].frequency); - } - png_write_chunk_data(png_ptr, entrybuf, entry_size); + for (i = 0; i>spalette->nentries; i++) + { + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep[i].red; + entrybuf[1] = (png_byte)ep[i].green; + entrybuf[2] = (png_byte)ep[i].blue; + entrybuf[3] = (png_byte)ep[i].alpha; + png_save_uint_16(entrybuf + 4, ep[i].frequency); + } + + else + { + png_save_uint_16(entrybuf + 0, ep[i].red); + png_save_uint_16(entrybuf + 2, ep[i].green); + png_save_uint_16(entrybuf + 4, ep[i].blue); + png_save_uint_16(entrybuf + 6, ep[i].alpha); + png_save_uint_16(entrybuf + 8, ep[i].frequency); + } + + png_write_chunk_data(png_ptr, entrybuf, entry_size); } #endif png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); } #endif -#if defined(PNG_WRITE_sBIT_SUPPORTED) -/* write the sBIT chunk */ +#ifdef PNG_WRITE_sBIT_SUPPORTED +/* Write the sBIT chunk */ void /* PRIVATE */ -png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) +png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sBIT; -#endif png_byte buf[4]; png_size_t size; - png_debug(1, "in png_write_sBIT\n"); - /* make sure we don't depend upon the order of PNG_COLOR_8 */ + png_debug(1, "in png_write_sBIT"); + + /* Make sure we don't depend upon the order of PNG_COLOR_8 */ if (color_type & PNG_COLOR_MASK_COLOR) { png_byte maxbits; maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : - png_ptr->usr_bit_depth); + png_ptr->usr_bit_depth); + if (sbit->red == 0 || sbit->red > maxbits || sbit->green == 0 || sbit->green > maxbits || sbit->blue == 0 || sbit->blue > maxbits) @@ -905,11 +1353,13 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) png_warning(png_ptr, "Invalid sBIT depth specified"); return; } + buf[0] = sbit->red; buf[1] = sbit->green; buf[2] = sbit->blue; size = 3; } + else { if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) @@ -917,6 +1367,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) png_warning(png_ptr, "Invalid sBIT depth specified"); return; } + buf[0] = sbit->gray; size = 1; } @@ -928,600 +1379,401 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) png_warning(png_ptr, "Invalid sBIT depth specified"); return; } + buf[size++] = sbit->alpha; } - png_write_chunk(png_ptr, png_sBIT, buf, size); + png_write_complete_chunk(png_ptr, png_sBIT, buf, size); } #endif -#if defined(PNG_WRITE_cHRM_SUPPORTED) -/* write the cHRM chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_WRITE_cHRM_SUPPORTED +/* Write the cHRM chunk */ void /* PRIVATE */ -png_write_cHRM(png_structp png_ptr, double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y) +png_write_cHRM_fixed(png_structrp png_ptr, const png_xy *xy) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif png_byte buf[32]; - png_uint_32 itemp; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || - white_x + white_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y); -#endif - return; - } - itemp = (png_uint_32)(white_x * 100000.0 + 0.5); - png_save_uint_32(buf, itemp); - itemp = (png_uint_32)(white_y * 100000.0 + 0.5); - png_save_uint_32(buf + 4, itemp); - - if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM red point specified"); - return; - } - itemp = (png_uint_32)(red_x * 100000.0 + 0.5); - png_save_uint_32(buf + 8, itemp); - itemp = (png_uint_32)(red_y * 100000.0 + 0.5); - png_save_uint_32(buf + 12, itemp); - - if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM green point specified"); - return; - } - itemp = (png_uint_32)(green_x * 100000.0 + 0.5); - png_save_uint_32(buf + 16, itemp); - itemp = (png_uint_32)(green_y * 100000.0 + 0.5); - png_save_uint_32(buf + 20, itemp); - - if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM blue point specified"); - return; - } - itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); - png_save_uint_32(buf + 24, itemp); - itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); - png_save_uint_32(buf + 28, itemp); - png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, - png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, - png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, - png_fixed_point blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; + png_debug(1, "in png_write_cHRM"); - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); -#endif - return; - } - png_save_uint_32(buf, (png_uint_32)white_x); - png_save_uint_32(buf + 4, (png_uint_32)white_y); + /* Each value is saved in 1/100,000ths */ + png_save_int_32(buf, xy->whitex); + png_save_int_32(buf + 4, xy->whitey); - if (red_x + red_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM fixed red point specified"); - return; - } - png_save_uint_32(buf + 8, (png_uint_32)red_x); - png_save_uint_32(buf + 12, (png_uint_32)red_y); + png_save_int_32(buf + 8, xy->redx); + png_save_int_32(buf + 12, xy->redy); - if (green_x + green_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM green point specified"); - return; - } - png_save_uint_32(buf + 16, (png_uint_32)green_x); - png_save_uint_32(buf + 20, (png_uint_32)green_y); + png_save_int_32(buf + 16, xy->greenx); + png_save_int_32(buf + 20, xy->greeny); - if (blue_x + blue_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); - return; - } - png_save_uint_32(buf + 24, (png_uint_32)blue_x); - png_save_uint_32(buf + 28, (png_uint_32)blue_y); + png_save_int_32(buf + 24, xy->bluex); + png_save_int_32(buf + 28, xy->bluey); - png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32); + png_write_complete_chunk(png_ptr, png_cHRM, buf, 32); } #endif -#endif -#if defined(PNG_WRITE_tRNS_SUPPORTED) -/* write the tRNS chunk */ +#ifdef PNG_WRITE_tRNS_SUPPORTED +/* Write the tRNS chunk */ void /* PRIVATE */ -png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, - int num_trans, int color_type) +png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, + png_const_color_16p tran, int num_trans, int color_type) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tRNS; -#endif png_byte buf[6]; - png_debug(1, "in png_write_tRNS\n"); + png_debug(1, "in png_write_tRNS"); + if (color_type == PNG_COLOR_TYPE_PALETTE) { if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) { - png_warning(png_ptr,"Invalid number of transparent colors specified"); + png_app_warning(png_ptr, + "Invalid number of transparent colors specified"); return; } - /* write the chunk out as it is */ - png_write_chunk(png_ptr, png_tRNS, trans, (png_size_t)num_trans); + + /* Write the chunk out as it is */ + png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, + (png_size_t)num_trans); } + else if (color_type == PNG_COLOR_TYPE_GRAY) { - /* one 16 bit value */ - if(tran->gray >= (1 << png_ptr->bit_depth)) + /* One 16 bit value */ + if (tran->gray >= (1 << png_ptr->bit_depth)) { - png_warning(png_ptr, - "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); + png_app_warning(png_ptr, + "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); + return; } + png_save_uint_16(buf, tran->gray); - png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2); + png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)2); } + else if (color_type == PNG_COLOR_TYPE_RGB) { - /* three 16 bit values */ + /* Three 16 bit values */ png_save_uint_16(buf, tran->red); png_save_uint_16(buf + 2, tran->green); png_save_uint_16(buf + 4, tran->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6); +#ifdef PNG_WRITE_16BIT_SUPPORTED + if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) +#else + if (buf[0] | buf[2] | buf[4]) +#endif + { + png_app_warning(png_ptr, + "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); + return; + } + + png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)6); } + else { - png_warning(png_ptr, "Can't write tRNS with an alpha channel"); + png_app_warning(png_ptr, "Can't write tRNS with an alpha channel"); } } #endif -#if defined(PNG_WRITE_bKGD_SUPPORTED) -/* write the background chunk */ +#ifdef PNG_WRITE_bKGD_SUPPORTED +/* Write the background chunk */ void /* PRIVATE */ -png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) +png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_bKGD; -#endif png_byte buf[6]; - png_debug(1, "in png_write_bKGD\n"); + png_debug(1, "in png_write_bKGD"); + if (color_type == PNG_COLOR_TYPE_PALETTE) { if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED (png_ptr->num_palette || (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && #endif - back->index > png_ptr->num_palette) + back->index >= png_ptr->num_palette) { png_warning(png_ptr, "Invalid background palette index"); return; } - buf[0] = back->index; - png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1); - } - else if (color_type & PNG_COLOR_MASK_COLOR) - { - png_save_uint_16(buf, back->red); - png_save_uint_16(buf + 2, back->green); - png_save_uint_16(buf + 4, back->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6); - } - else - { - if(back->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); - return; - } - png_save_uint_16(buf, back->gray); - png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2); - } -} -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -/* write the histogram */ -void /* PRIVATE */ -png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_hIST; -#endif - int i; - png_byte buf[3]; - - png_debug(1, "in png_write_hIST\n"); - if (num_hist > (int)png_ptr->num_palette) - { - png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, - png_ptr->num_palette); - png_warning(png_ptr, "Invalid number of histogram entries specified"); - return; - } - - png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2)); - for (i = 0; i < num_hist; i++) - { - png_save_uint_16(buf, hist[i]); - png_write_chunk_data(png_ptr, buf, (png_size_t)2); - } - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The new_key is allocated to hold the corrected keyword and must be freed - * by the calling routine. This avoids problems with trying to write to - * static keywords without having to have duplicate copies of the strings. - */ -png_size_t /* PRIVATE */ -png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) -{ - png_size_t key_len; - png_charp kp, dp; - int kflag; - int kwarn=0; - - png_debug(1, "in png_check_keyword\n"); - *new_key = NULL; - - if (key == NULL || (key_len = png_strlen(key)) == 0) - { - png_warning(png_ptr, "zero length keyword"); - return ((png_size_t)0); - } - - png_debug1(2, "Keyword to be checked is '%s'\n", key); - *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2)); - if (*new_key == NULL) - { - png_warning(png_ptr, "Out of memory while procesing keyword"); - return ((png_size_t)0); + buf[0] = back->index; + png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1); } - /* Replace non-printing characters with a blank and print a warning */ - for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) + else if (color_type & PNG_COLOR_MASK_COLOR) { - if ((png_byte)*kp < 0x20 || - ((png_byte)*kp > 0x7E && (png_byte)*kp < 0xA1)) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[40]; - - png_snprintf(msg, 40, - "invalid keyword character 0x%02X", (png_byte)*kp); - png_warning(png_ptr, msg); + png_save_uint_16(buf, back->red); + png_save_uint_16(buf + 2, back->green); + png_save_uint_16(buf + 4, back->blue); +#ifdef PNG_WRITE_16BIT_SUPPORTED + if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) #else - png_warning(png_ptr, "invalid character in keyword"); + if (buf[0] | buf[2] | buf[4]) #endif - *dp = ' '; - } - else { - *dp = *kp; - } - } - *dp = '\0'; - - /* Remove any trailing white space. */ - kp = *new_key + key_len - 1; - if (*kp == ' ') - { - png_warning(png_ptr, "trailing spaces removed from keyword"); + png_warning(png_ptr, + "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); - while (*kp == ' ') - { - *(kp--) = '\0'; - key_len--; + return; } + + png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)6); } - /* Remove any leading white space. */ - kp = *new_key; - if (*kp == ' ') + else { - png_warning(png_ptr, "leading spaces removed from keyword"); - - while (*kp == ' ') + if (back->gray >= (1 << png_ptr->bit_depth)) { - kp++; - key_len--; + png_warning(png_ptr, + "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); + + return; } + + png_save_uint_16(buf, back->gray); + png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)2); } +} +#endif + +#ifdef PNG_WRITE_hIST_SUPPORTED +/* Write the histogram */ +void /* PRIVATE */ +png_write_hIST(png_structrp png_ptr, png_const_uint_16p hist, int num_hist) +{ + int i; + png_byte buf[3]; - png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); + png_debug(1, "in png_write_hIST"); - /* Remove multiple internal spaces. */ - for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) + if (num_hist > (int)png_ptr->num_palette) { - if (*kp == ' ' && kflag == 0) - { - *(dp++) = *kp; - kflag = 1; - } - else if (*kp == ' ') - { - key_len--; - kwarn=1; - } - else - { - *(dp++) = *kp; - kflag = 0; - } - } - *dp = '\0'; - if(kwarn) - png_warning(png_ptr, "extra interior spaces removed from keyword"); + png_debug2(3, "num_hist = %d, num_palette = %d", num_hist, + png_ptr->num_palette); - if (key_len == 0) - { - png_free(png_ptr, *new_key); - *new_key=NULL; - png_warning(png_ptr, "Zero length keyword"); + png_warning(png_ptr, "Invalid number of histogram entries specified"); + return; } - if (key_len > 79) + png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2)); + + for (i = 0; i < num_hist; i++) { - png_warning(png_ptr, "keyword length must be 1 - 79 characters"); - (*new_key)[79] = '\0'; - key_len = 79; + png_save_uint_16(buf, hist[i]); + png_write_chunk_data(png_ptr, buf, (png_size_t)2); } - return (key_len); + png_write_chunk_end(png_ptr); } #endif -#if defined(PNG_WRITE_tEXt_SUPPORTED) -/* write a tEXt chunk */ +#ifdef PNG_WRITE_tEXt_SUPPORTED +/* Write a tEXt chunk */ void /* PRIVATE */ -png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len) +png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, + png_size_t text_len) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tEXt; -#endif - png_size_t key_len; - png_charp new_key; + png_uint_32 key_len; + png_byte new_key[80]; - png_debug(1, "in png_write_tEXt\n"); - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in tEXt chunk"); - return; - } + png_debug(1, "in png_write_tEXt"); + + key_len = png_check_keyword(png_ptr, key, new_key); + + if (key_len == 0) + png_error(png_ptr, "tEXt: invalid keyword"); if (text == NULL || *text == '\0') text_len = 0; + else - text_len = png_strlen(text); + text_len = strlen(text); + + if (text_len > PNG_UINT_31_MAX - (key_len+1)) + png_error(png_ptr, "tEXt: text too long"); - /* make sure we include the 0 after the key */ - png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)key_len+text_len+1); + /* Make sure we include the 0 after the key */ + png_write_chunk_header(png_ptr, png_tEXt, + (png_uint_32)/*checked above*/(key_len + text_len + 1)); /* * We leave it to the application to meet PNG-1.0 requirements on the * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); + png_write_chunk_data(png_ptr, new_key, key_len + 1); + if (text_len) - png_write_chunk_data(png_ptr, (png_bytep)text, text_len); + png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len); png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); } #endif -#if defined(PNG_WRITE_zTXt_SUPPORTED) -/* write a compressed text chunk */ +#ifdef PNG_WRITE_zTXt_SUPPORTED +/* Write a compressed text chunk */ void /* PRIVATE */ -png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len, int compression) +png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, + png_size_t text_len, int compression) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_zTXt; -#endif - png_size_t key_len; - char buf[1]; - png_charp new_key; + png_uint_32 key_len; + png_byte new_key[81]; compression_state comp; - png_debug(1, "in png_write_zTXt\n"); + png_debug(1, "in png_write_zTXt"); + PNG_UNUSED(text_len) /* Always use strlen */ - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; - comp.input_len = 0; - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) + if (compression == PNG_TEXT_COMPRESSION_NONE) { - png_warning(png_ptr, "Empty keyword in zTXt chunk"); + png_write_tEXt(png_ptr, key, text, 0); return; } - if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE) - { - png_write_tEXt(png_ptr, new_key, text, (png_size_t)0); - png_free(png_ptr, new_key); - return; - } + if (compression != PNG_TEXT_COMPRESSION_zTXt) + png_error(png_ptr, "zTXt: invalid compression type"); + + key_len = png_check_keyword(png_ptr, key, new_key); + + if (key_len == 0) + png_error(png_ptr, "zTXt: invalid keyword"); + + /* Add the compression method and 1 for the keyword separator. */ + new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE; + ++key_len; + + /* Compute the compressed data; do it now for the length */ + png_text_compress_init(&comp, (png_const_bytep)text, + text == NULL ? 0 : strlen(text)); - text_len = png_strlen(text); + if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression, - &comp); + /* Write start of chunk */ + png_write_chunk_header(png_ptr, png_zTXt, key_len + comp.output_len); - /* write start of chunk */ - png_write_chunk_start(png_ptr, png_zTXt, (png_uint_32) - (key_len+text_len+2)); - /* write key */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - png_free(png_ptr, new_key); + /* Write key */ + png_write_chunk_data(png_ptr, new_key, key_len); - buf[0] = (png_byte)compression; - /* write compression */ - png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); - /* write the compressed data */ + /* Write the compressed data */ png_write_compressed_data_out(png_ptr, &comp); - /* close the chunk */ + /* Close the chunk */ png_write_chunk_end(png_ptr); } #endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) -/* write an iTXt chunk */ +#ifdef PNG_WRITE_iTXt_SUPPORTED +/* Write an iTXt chunk */ void /* PRIVATE */ -png_write_iTXt(png_structp png_ptr, int compression, png_charp key, - png_charp lang, png_charp lang_key, png_charp text) +png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, + png_const_charp lang, png_const_charp lang_key, png_const_charp text) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iTXt; -#endif - png_size_t lang_len, key_len, lang_key_len, text_len; - png_charp new_lang, new_key; - png_byte cbuf[2]; + png_uint_32 key_len, prefix_len; + png_size_t lang_len, lang_key_len; + png_byte new_key[82]; compression_state comp; - png_debug(1, "in png_write_iTXt\n"); + png_debug(1, "in png_write_iTXt"); + + key_len = png_check_keyword(png_ptr, key, new_key); - comp.num_output_ptr = 0; - comp.max_output_ptr = 0; - comp.output_ptr = NULL; - comp.input = NULL; + if (key_len == 0) + png_error(png_ptr, "iTXt: invalid keyword"); - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) + /* Set the compression flag */ + switch (compression) { - png_warning(png_ptr, "Empty keyword in iTXt chunk"); - return; + case PNG_ITXT_COMPRESSION_NONE: + case PNG_TEXT_COMPRESSION_NONE: + compression = new_key[++key_len] = 0; /* no compression */ + break; + + case PNG_TEXT_COMPRESSION_zTXt: + case PNG_ITXT_COMPRESSION_zTXt: + compression = new_key[++key_len] = 1; /* compressed */ + break; + + default: + png_error(png_ptr, "iTXt: invalid compression"); } - if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0) + + new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE; + ++key_len; /* for the keywod separator */ + + /* We leave it to the application to meet PNG-1.0 requirements on the + * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of + * any non-Latin-1 characters except for NEWLINE. ISO PNG, however, + * specifies that the text is UTF-8 and this really doesn't require any + * checking. + * + * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. + * + * TODO: validate the language tag correctly (see the spec.) + */ + if (lang == NULL) lang = ""; /* empty language is valid */ + lang_len = strlen(lang)+1; + if (lang_key == NULL) lang_key = ""; /* may be empty */ + lang_key_len = strlen(lang_key)+1; + if (text == NULL) text = ""; /* may be empty */ + + prefix_len = key_len; + if (lang_len > PNG_UINT_31_MAX-prefix_len) + prefix_len = PNG_UINT_31_MAX; + else + prefix_len = (png_uint_32)(prefix_len + lang_len); + + if (lang_key_len > PNG_UINT_31_MAX-prefix_len) + prefix_len = PNG_UINT_31_MAX; + else + prefix_len = (png_uint_32)(prefix_len + lang_key_len); + + png_text_compress_init(&comp, (png_const_bytep)text, strlen(text)); + + if (compression) { - png_warning(png_ptr, "Empty language field in iTXt chunk"); - new_lang = NULL; - lang_len = 0; + if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg); } - if (lang_key == NULL) - lang_key_len = 0; else - lang_key_len = png_strlen(lang_key); + { + if (comp.input_len > PNG_UINT_31_MAX-prefix_len) + png_error(png_ptr, "iTXt: uncompressed text too long"); + } - if (text == NULL) - text_len = 0; - else - text_len = png_strlen(text); + png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len); - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression-2, - &comp); + png_write_chunk_data(png_ptr, new_key, key_len); + png_write_chunk_data(png_ptr, (png_const_bytep)lang, lang_len); - /* make sure we include the compression flag, the compression byte, - * and the NULs after the key, lang, and lang_key parts */ + png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len); - png_write_chunk_start(png_ptr, png_iTXt, - (png_uint_32)( - 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ - + key_len - + lang_len - + lang_key_len - + text_len)); + if (compression) + png_write_compressed_data_out(png_ptr, &comp); - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - - /* set the compression flag */ - if (compression == PNG_ITXT_COMPRESSION_NONE || \ - compression == PNG_TEXT_COMPRESSION_NONE) - cbuf[0] = 0; - else /* compression == PNG_ITXT_COMPRESSION_zTXt */ - cbuf[0] = 1; - /* set the compression method */ - cbuf[1] = 0; - png_write_chunk_data(png_ptr, cbuf, 2); - - cbuf[0] = 0; - png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1); - png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1); - png_write_compressed_data_out(png_ptr, &comp); + else + png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.input_len); png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); - if (new_lang) - png_free(png_ptr, new_lang); } #endif -#if defined(PNG_WRITE_oFFs_SUPPORTED) -/* write the oFFs chunk */ +#ifdef PNG_WRITE_oFFs_SUPPORTED +/* Write the oFFs chunk */ void /* PRIVATE */ -png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, - int unit_type) +png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset, + int unit_type) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_oFFs; -#endif png_byte buf[9]; - png_debug(1, "in png_write_oFFs\n"); + png_debug(1, "in png_write_oFFs"); + if (unit_type >= PNG_OFFSET_LAST) png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); @@ -1529,62 +1781,67 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, png_save_int_32(buf + 4, y_offset); buf[8] = (png_byte)unit_type; - png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9); + png_write_complete_chunk(png_ptr, png_oFFs, buf, (png_size_t)9); } #endif -#if defined(PNG_WRITE_pCAL_SUPPORTED) -/* write the pCAL chunk (described in the PNG extensions document) */ +#ifdef PNG_WRITE_pCAL_SUPPORTED +/* Write the pCAL chunk (described in the PNG extensions document) */ void /* PRIVATE */ -png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, - png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) +png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0, + png_int_32 X1, int type, int nparams, png_const_charp units, + png_charpp params) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pCAL; -#endif - png_size_t purpose_len, units_len, total_len; - png_uint_32p params_len; + png_uint_32 purpose_len; + png_size_t units_len, total_len; + png_size_tp params_len; png_byte buf[10]; - png_charp new_purpose; + png_byte new_purpose[80]; int i; - png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); + png_debug1(1, "in png_write_pCAL (%d parameters)", nparams); + if (type >= PNG_EQUATION_LAST) - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); + png_error(png_ptr, "Unrecognized equation type for pCAL chunk"); + + purpose_len = png_check_keyword(png_ptr, purpose, new_purpose); + + if (purpose_len == 0) + png_error(png_ptr, "pCAL: invalid keyword"); - purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; - png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); - units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d\n", (int)units_len); + ++purpose_len; /* terminator */ + + png_debug1(3, "pCAL purpose length = %d", (int)purpose_len); + units_len = strlen(units) + (nparams == 0 ? 0 : 1); + png_debug1(3, "pCAL units length = %d", (int)units_len); total_len = purpose_len + units_len + 10; - params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_uint_32))); + params_len = (png_size_tp)png_malloc(png_ptr, + (png_alloc_size_t)(nparams * (sizeof (png_size_t)))); /* Find the length of each parameter, making sure we don't count the - null terminator for the last parameter. */ + * null terminator for the last parameter. + */ for (i = 0; i < nparams; i++) { - params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); - total_len += (png_size_t)params_len[i]; + params_len[i] = strlen(params[i]) + (i == nparams - 1 ? 0 : 1); + png_debug2(3, "pCAL parameter %d length = %lu", i, + (unsigned long)params_len[i]); + total_len += params_len[i]; } - png_debug1(3, "pCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); + png_debug1(3, "pCAL total length = %d", (int)total_len); + png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len); + png_write_chunk_data(png_ptr, new_purpose, purpose_len); png_save_int_32(buf, X0); png_save_int_32(buf + 4, X1); buf[8] = (png_byte)type; buf[9] = (png_byte)nparams; png_write_chunk_data(png_ptr, buf, (png_size_t)10); - png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len); - - png_free(png_ptr, new_purpose); + png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len); for (i = 0; i < nparams; i++) { - png_write_chunk_data(png_ptr, (png_bytep)params[i], - (png_size_t)params_len[i]); + png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]); } png_free(png_ptr, params_len); @@ -1592,63 +1849,21 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, } #endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) -/* write the sCAL chunk */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -void /* PRIVATE */ -png_write_sCAL(png_structp png_ptr, int unit, double width, double height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - char buf[64]; - png_size_t total_len; - - png_debug(1, "in png_write_sCAL\n"); - - buf[0] = (char)unit; -#if defined(_WIN32_WCE) -/* sprintf() function is not supported on WindowsCE */ - { - wchar_t wc_buf[32]; - size_t wc_len; - swprintf(wc_buf, TEXT("%12.12e"), width); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + 1, wc_len, NULL, NULL); - total_len = wc_len + 2; - swprintf(wc_buf, TEXT("%12.12e"), height); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + total_len, wc_len, - NULL, NULL); - total_len += wc_len; - } -#else - png_snprintf(buf + 1, 63, "%12.12e", width); - total_len = 1 + png_strlen(buf + 1) + 1; - png_snprintf(buf + total_len, 64-total_len, "%12.12e", height); - total_len += png_strlen(buf + total_len); -#endif - - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, png_sCAL, (png_bytep)buf, total_len); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED +#ifdef PNG_WRITE_sCAL_SUPPORTED +/* Write the sCAL chunk */ void /* PRIVATE */ -png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, - png_charp height) +png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width, + png_const_charp height) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif png_byte buf[64]; png_size_t wlen, hlen, total_len; - png_debug(1, "in png_write_sCAL_s\n"); + png_debug(1, "in png_write_sCAL_s"); - wlen = png_strlen(width); - hlen = png_strlen(height); + wlen = strlen(width); + hlen = strlen(height); total_len = wlen + hlen + 2; + if (total_len > 64) { png_warning(png_ptr, "Can't write sCAL (buffer too small)"); @@ -1656,29 +1871,25 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, } buf[0] = (png_byte)unit; - png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */ - png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */ + memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */ + memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */ - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, png_sCAL, buf, total_len); + png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); + png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len); } #endif -#endif -#endif -#if defined(PNG_WRITE_pHYs_SUPPORTED) -/* write the pHYs chunk */ +#ifdef PNG_WRITE_pHYs_SUPPORTED +/* Write the pHYs chunk */ void /* PRIVATE */ -png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, - png_uint_32 y_pixels_per_unit, - int unit_type) +png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit, + png_uint_32 y_pixels_per_unit, + int unit_type) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pHYs; -#endif png_byte buf[9]; - png_debug(1, "in png_write_pHYs\n"); + png_debug(1, "in png_write_pHYs"); + if (unit_type >= PNG_RESOLUTION_LAST) png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); @@ -1686,23 +1897,21 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, png_save_uint_32(buf + 4, y_pixels_per_unit); buf[8] = (png_byte)unit_type; - png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9); + png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9); } #endif -#if defined(PNG_WRITE_tIME_SUPPORTED) +#ifdef PNG_WRITE_tIME_SUPPORTED /* Write the tIME chunk. Use either png_convert_from_struct_tm() * or png_convert_from_time_t(), or fill in the structure yourself. */ void /* PRIVATE */ -png_write_tIME(png_structp png_ptr, png_timep mod_time) +png_write_tIME(png_structrp png_ptr, png_const_timep mod_time) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tIME; -#endif png_byte buf[7]; - png_debug(1, "in png_write_tIME\n"); + png_debug(1, "in png_write_tIME"); + if (mod_time->month > 12 || mod_time->month < 1 || mod_time->day > 31 || mod_time->day < 1 || mod_time->hour > 23 || mod_time->second > 60) @@ -1718,142 +1927,147 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time) buf[5] = mod_time->minute; buf[6] = mod_time->second; - png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7); + png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7); } #endif -/* initializes the row writing capability of libpng */ +/* Initializes the row writing capability of libpng */ void /* PRIVATE */ -png_write_start_row(png_structp png_ptr) +png_write_start_row(png_structrp png_ptr) { #ifdef PNG_WRITE_INTERLACING_SUPPORTED -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif - png_size_t buf_size; + png_alloc_size_t buf_size; + int usr_pixel_depth; + + png_debug(1, "in png_write_start_row"); + + usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth; + buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1; + + /* 1.5.6: added to allow checking in the row write code. */ + png_ptr->transformed_pixel_depth = png_ptr->pixel_depth; + png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth; - png_debug(1, "in png_write_start_row\n"); - buf_size = (png_size_t)(PNG_ROWBYTES( - png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1); + /* Set up row buffer */ + png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size); - /* set up row buffer */ - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; -#ifndef PNG_NO_WRITE_FILTERING - /* set up filtering buffer, if using this filter */ +#ifdef PNG_WRITE_FILTER_SUPPORTED + /* Set up filtering buffer, if using this filter */ if (png_ptr->do_filter & PNG_FILTER_SUB) { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1); + png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; } /* We only need to keep the previous row if we are using one of these. */ if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) { - /* set up previous row buffer */ - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_memset(png_ptr->prev_row, 0, buf_size); + /* Set up previous row buffer */ + png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size); if (png_ptr->do_filter & PNG_FILTER_UP) { png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + png_ptr->rowbytes + 1); + png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; } if (png_ptr->do_filter & PNG_FILTER_AVG) { png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + png_ptr->rowbytes + 1); + png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; } if (png_ptr->do_filter & PNG_FILTER_PAETH) { png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + png_ptr->rowbytes + 1); + png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; } -#endif /* PNG_NO_WRITE_FILTERING */ } +#endif /* PNG_WRITE_FILTER_SUPPORTED */ #ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, we need to set up width and height of pass */ + /* If interlaced, we need to set up width and height of pass */ if (png_ptr->interlaced) { if (!(png_ptr->transformations & PNG_INTERLACE)) { png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; + png_pass_ystart[0]) / png_pass_yinc[0]; + png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - - png_pass_start[0]) / png_pass_inc[0]; + png_pass_start[0]) / png_pass_inc[0]; } + else { png_ptr->num_rows = png_ptr->height; png_ptr->usr_width = png_ptr->width; } } + else #endif { png_ptr->num_rows = png_ptr->height; png_ptr->usr_width = png_ptr->width; } - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; } /* Internal use only. Called when finished processing a row of data. */ void /* PRIVATE */ -png_write_finish_row(png_structp png_ptr) +png_write_finish_row(png_structrp png_ptr) { #ifdef PNG_WRITE_INTERLACING_SUPPORTED -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + /* Start of interlace block in the y direction */ + static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif + /* Offset to next interlace block in the y direction */ + static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif - int ret; + png_debug(1, "in png_write_finish_row"); - png_debug(1, "in png_write_finish_row\n"); - /* next row */ + /* Next row */ png_ptr->row_number++; - /* see if we are done */ + /* See if we are done */ if (png_ptr->row_number < png_ptr->num_rows) return; #ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, go to next pass */ + /* If interlaced, go to next pass */ if (png_ptr->interlaced) { png_ptr->row_number = 0; @@ -1861,78 +2075,53 @@ png_write_finish_row(png_structp png_ptr) { png_ptr->pass++; } + else { - /* loop until we find a non-zero width or height pass */ + /* Loop until we find a non-zero width or height pass */ do { png_ptr->pass++; + if (png_ptr->pass >= 7) break; + png_ptr->usr_width = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + if (png_ptr->transformations & PNG_INTERLACE) break; + } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); } - /* reset the row above the image for the next pass */ + /* Reset the row above the image for the next pass */ if (png_ptr->pass < 7) { if (png_ptr->prev_row != NULL) - png_memset(png_ptr->prev_row, 0, - (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* - png_ptr->usr_bit_depth,png_ptr->width))+1); + memset(png_ptr->prev_row, 0, + (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* + png_ptr->usr_bit_depth, png_ptr->width)) + 1); + return; } } #endif - /* if we get here, we've just written the last row, so we need + /* If we get here, we've just written the last row, so we need to flush the compressor */ - do - { - /* tell the compressor we are done */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - /* check for an error */ - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else if (ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* write any extra space */ - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - - png_ptr->zstream.avail_out); - } - - deflateReset(&png_ptr->zstream); - png_ptr->zstream.data_type = Z_BINARY; + png_compress_IDAT(png_ptr, NULL, 0, Z_FINISH); } -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +#ifdef PNG_WRITE_INTERLACING_SUPPORTED /* Pick out the correct pixels for the interlace pass. * The basic idea here is to go through the row with a source * pointer and a destination pointer (sp and dp), and copy the @@ -1943,25 +2132,20 @@ png_write_finish_row(png_structp png_ptr) void /* PRIVATE */ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) { -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + /* Start of interlace block */ + static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif + /* Offset to next interlace block */ + static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - png_debug(1, "in png_do_write_interlace\n"); - /* we don't have to do anything on the last pass (6) */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && pass < 6) -#else + png_debug(1, "in png_do_write_interlace"); + + /* We don't have to do anything on the last pass (6) */ if (pass < 6) -#endif { - /* each pixel depth is handled separately */ + /* Each pixel depth is handled separately */ switch (row_info->pixel_depth) { case 1: @@ -1977,6 +2161,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) dp = row; d = 0; shift = 7; + for (i = png_pass_start[pass]; i < row_width; i += png_pass_inc[pass]) { @@ -1990,14 +2175,17 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) *dp++ = (png_byte)d; d = 0; } + else shift--; } if (shift != 7) *dp = (png_byte)d; + break; } + case 2: { png_bytep sp; @@ -2011,6 +2199,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) dp = row; shift = 6; d = 0; + for (i = png_pass_start[pass]; i < row_width; i += png_pass_inc[pass]) { @@ -2024,13 +2213,16 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) *dp++ = (png_byte)d; d = 0; } + else shift -= 2; } if (shift != 6) - *dp = (png_byte)d; + *dp = (png_byte)d; + break; } + case 4: { png_bytep sp; @@ -2045,7 +2237,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) shift = 4; d = 0; for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) + i += png_pass_inc[pass]) { sp = row + (png_size_t)(i >> 1); value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; @@ -2057,13 +2249,16 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) *dp++ = (png_byte)d; d = 0; } + else shift -= 4; } if (shift != 4) *dp = (png_byte)d; + break; } + default: { png_bytep sp; @@ -2072,33 +2267,37 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) png_uint_32 row_width = row_info->width; png_size_t pixel_bytes; - /* start at the beginning */ + /* Start at the beginning */ dp = row; - /* find out how many bytes each pixel takes up */ + + /* Find out how many bytes each pixel takes up */ pixel_bytes = (row_info->pixel_depth >> 3); - /* loop through the row, only looking at the pixels that - matter */ + + /* Loop through the row, only looking at the pixels that matter */ for (i = png_pass_start[pass]; i < row_width; i += png_pass_inc[pass]) { - /* find out where the original pixel is */ + /* Find out where the original pixel is */ sp = row + (png_size_t)i * pixel_bytes; - /* move the pixel */ + + /* Move the pixel */ if (dp != sp) - png_memcpy(dp, sp, pixel_bytes); - /* next pixel */ + memcpy(dp, sp, pixel_bytes); + + /* Next pixel */ dp += pixel_bytes; } break; } } - /* set new row width */ + /* Set new row width */ row_info->width = (row_info->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); + png_pass_inc[pass] - 1 - + png_pass_start[pass]) / + png_pass_inc[pass]; + + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, + row_info->width); } } #endif @@ -2107,31 +2306,43 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) * been specified by the application, and then writes the row out with the * chosen filter. */ +static void png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, + png_size_t row_bytes); + #define PNG_MAXSUM (((png_uint_32)(-1)) >> 1) #define PNG_HISHIFT 10 #define PNG_LOMASK ((png_uint_32)0xffffL) #define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) void /* PRIVATE */ -png_write_find_filter(png_structp png_ptr, png_row_infop row_info) +png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) { png_bytep best_row; -#ifndef PNG_NO_WRITE_FILTER +#ifdef PNG_WRITE_FILTER_SUPPORTED png_bytep prev_row, row_buf; png_uint_32 mins, bpp; png_byte filter_to_do = png_ptr->do_filter; - png_uint_32 row_bytes = row_info->rowbytes; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - int num_p_filters = (int)png_ptr->num_prev_filters; + png_size_t row_bytes = row_info->rowbytes; +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED + int num_p_filters = png_ptr->num_prev_filters; +#endif + + png_debug(1, "in png_write_find_filter"); + +#ifndef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED + if (png_ptr->row_number == 0 && filter_to_do == PNG_ALL_FILTERS) + { + /* These will never be selected so we need not test them. */ + filter_to_do &= ~(PNG_FILTER_UP | PNG_FILTER_PAETH); + } #endif - png_debug(1, "in png_write_find_filter\n"); - /* find out how many bytes offset each pixel is */ + /* Find out how many bytes offset each pixel is */ bpp = (row_info->pixel_depth + 7) >> 3; prev_row = png_ptr->prev_row; #endif best_row = png_ptr->row_buf; -#ifndef PNG_NO_WRITE_FILTER +#ifdef PNG_WRITE_FILTER_SUPPORTED row_buf = best_row; mins = PNG_MAXSUM; @@ -2147,11 +2358,14 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) * computationally expensive). * * GRR 980525: consider also + * * (1) minimum sum of absolute differences from running average (i.e., * keep running sum of non-absolute differences & count of bytes) * [track dispersion, too? restart average if dispersion too large?] + * * (1b) minimum sum of absolute differences from sliding average, probably * with window size <= deflate window (usually 32K) + * * (2) minimum sum of squared differences from zero or running average * (i.e., ~ root-mean-square approach) */ @@ -2160,12 +2374,11 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) /* We don't need to test the 'no filter' case if this is the only filter * that has been chosen, as it doesn't actually do anything to the data. */ - if ((filter_to_do & PNG_FILTER_NONE) && - filter_to_do != PNG_FILTER_NONE) + if ((filter_to_do & PNG_FILTER_NONE) && filter_to_do != PNG_FILTER_NONE) { png_bytep rp; png_uint_32 sum = 0; - png_uint_32 i; + png_size_t i; int v; for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) @@ -2174,7 +2387,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) sum += (v < 128) ? v : 256 - v; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { png_uint_32 sumhi, sumlo; @@ -2188,9 +2401,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) { sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } @@ -2199,12 +2413,14 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) * it has the minimum possible computational cost - none). */ sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; + else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2212,22 +2428,25 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) mins = sum; } - /* sub filter */ + /* Sub filter */ if (filter_to_do == PNG_FILTER_SUB) - /* it's the only filter so no testing is needed */ + /* It's the only filter so no testing is needed */ { png_bytep rp, lp, dp; - png_uint_32 i; + png_size_t i; + for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; i++, rp++, dp++) { *dp = *rp; } + for (lp = row_buf + 1; i < row_bytes; i++, rp++, lp++, dp++) { *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); } + best_row = png_ptr->sub_row; } @@ -2235,10 +2454,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) { png_bytep rp, dp, lp; png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; + png_size_t i; int v; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* We temporarily increase the "minimum sum" by the factor we * would reduce the sum of this filter, so that we can do the * early exit comparison without scaling the sum each time. @@ -2255,19 +2474,22 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) { lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (lmhi > PNG_HIMASK) lmins = PNG_MAXSUM; + else lmins = (lmhi << PNG_HISHIFT) + lmlo; } @@ -2280,6 +2502,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) sum += (v < 128) ? v : 256 - v; } + for (lp = row_buf + 1; i < row_bytes; i++, rp++, lp++, dp++) { @@ -2291,7 +2514,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) break; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2304,19 +2527,22 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) { sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; + else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2329,18 +2555,19 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) } } - /* up filter */ + /* Up filter */ if (filter_to_do == PNG_FILTER_UP) { png_bytep rp, dp, pp; - png_uint_32 i; + png_size_t i; for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; - i++, rp++, pp++, dp++) + pp = prev_row + 1; i < row_bytes; + i++, rp++, pp++, dp++) { *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); } + best_row = png_ptr->up_row; } @@ -2348,11 +2575,11 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) { png_bytep rp, dp, pp; png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; + png_size_t i; int v; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2365,26 +2592,29 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) { lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (lmhi > PNG_HIMASK) lmins = PNG_MAXSUM; + else lmins = (lmhi << PNG_HISHIFT) + lmlo; } #endif for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; i++) + pp = prev_row + 1; i < row_bytes; i++) { v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); @@ -2394,7 +2624,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) break; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2407,19 +2637,22 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) { sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; + else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2432,16 +2665,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) } } - /* avg filter */ + /* Avg filter */ if (filter_to_do == PNG_FILTER_AVG) { png_bytep rp, dp, pp, lp; png_uint_32 i; + for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, pp = prev_row + 1; i < bpp; i++) { *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); } + for (lp = row_buf + 1; i < row_bytes; i++) { *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) @@ -2454,10 +2689,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) { png_bytep rp, dp, pp, lp; png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; + png_size_t i; int v; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2470,19 +2705,22 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG) { lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (lmhi > PNG_HIMASK) lmins = PNG_MAXSUM; + else lmins = (lmhi << PNG_HISHIFT) + lmlo; } @@ -2495,10 +2733,11 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) sum += (v < 128) ? v : 256 - v; } + for (lp = row_buf + 1; i < row_bytes; i++) { v = *dp++ = - (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); + (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); sum += (v < 128) ? v : 256 - v; @@ -2506,7 +2745,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) break; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2519,19 +2758,22 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) { sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; + else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2548,9 +2790,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (filter_to_do == PNG_FILTER_PAETH) { png_bytep rp, dp, pp, cp, lp; - png_uint_32 i; + png_size_t i; + for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) + pp = prev_row + 1; i < bpp; i++) { *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); } @@ -2587,10 +2830,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) { png_bytep rp, dp, pp, cp, lp; png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; + png_size_t i; int v; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2603,26 +2846,29 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) { lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; + lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (lmhi > PNG_HIMASK) lmins = PNG_MAXSUM; + else lmins = (lmhi << PNG_HISHIFT) + lmlo; } #endif for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) + pp = prev_row + 1; i < bpp; i++) { v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); @@ -2655,10 +2901,13 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) pa = abs(p - a); pb = abs(p - b); pc = abs(p - c); + if (pa <= pb && pa <= pc) p = a; + else if (pb <= pc) p = b; + else p = c; #endif /* PNG_SLOW_PAETH */ @@ -2671,7 +2920,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) break; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; @@ -2684,19 +2933,22 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) { sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; + sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; + PNG_WEIGHT_SHIFT; } } sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; + sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; + PNG_COST_SHIFT; if (sumhi > PNG_HIMASK) sum = PNG_MAXSUM; + else sum = (sumhi << PNG_HISHIFT) + sumlo; } @@ -2707,66 +2959,42 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) best_row = png_ptr->paeth_row; } } -#endif /* PNG_NO_WRITE_FILTER */ - /* Do the actual writing of the filtered row data from the chosen filter. */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ - png_write_filtered_row(png_ptr, best_row); + /* Do the actual writing of the filtered row data from the chosen filter. */ + png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1); -#ifndef PNG_NO_WRITE_FILTER -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_FILTER_SUPPORTED +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* Save the type of filter we picked this time for future calculations */ if (png_ptr->num_prev_filters > 0) { int j; + for (j = 1; j < num_p_filters; j++) { png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1]; } + png_ptr->prev_filters[j] = best_row[0]; } #endif -#endif /* PNG_NO_WRITE_FILTER */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ } /* Do the actual writing of a previously filtered row. */ -void /* PRIVATE */ -png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) +static void +png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, + png_size_t full_row_length/*includes filter byte*/) { - png_debug(1, "in png_write_filtered_row\n"); - png_debug1(2, "filter = %d\n", filtered_row[0]); - /* set up the zlib input buffer */ - - png_ptr->zstream.next_in = filtered_row; - png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; - /* repeat until we have compressed all the data */ - do - { - int ret; /* return of zlib */ + png_debug(1, "in png_write_filtered_row"); - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } + png_debug1(2, "filter = %d", filtered_row[0]); - /* see if it is time to write another IDAT */ - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - /* repeat until all data has been compressed */ - } while (png_ptr->zstream.avail_in); + png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH); - /* swap the current and previous rows */ + /* Swap the current and previous rows */ if (png_ptr->prev_row != NULL) { png_bytep tptr; @@ -2776,10 +3004,10 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) png_ptr->row_buf = tptr; } - /* finish row - updates counters and flushes zlib if last row */ + /* Finish row - updates counters and flushes zlib if last row */ png_write_finish_row(png_ptr); -#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#ifdef PNG_WRITE_FLUSH_SUPPORTED png_ptr->flush_rows++; if (png_ptr->flush_dist > 0 && diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_Image.cpp b/JuceLibraryCode/modules/juce_graphics/images/juce_Image.cpp index 8d7bba1e7..54a996c93 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_Image.cpp +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_Image.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -392,7 +391,7 @@ Colour Image::BitmapData::getPixelColour (const int x, const int y) const noexce return Colour(); } -void Image::BitmapData::setPixelColour (const int x, const int y, const Colour& colour) const noexcept +void Image::BitmapData::setPixelColour (const int x, const int y, Colour colour) const noexcept { jassert (isPositiveAndBelow (x, width) && isPositiveAndBelow (y, height)); @@ -409,7 +408,7 @@ void Image::BitmapData::setPixelColour (const int x, const int y, const Colour& } //============================================================================== -void Image::clear (const Rectangle<int>& area, const Colour& colourToClearTo) +void Image::clear (const Rectangle<int>& area, Colour colourToClearTo) { const ScopedPointer<LowLevelGraphicsContext> g (image->createLowLevelContext()); g->setFill (colourToClearTo); @@ -428,7 +427,7 @@ Colour Image::getPixelAt (const int x, const int y) const return Colour(); } -void Image::setPixelAt (const int x, const int y, const Colour& colour) +void Image::setPixelAt (const int x, const int y, Colour colour) { if (isPositiveAndBelow (x, getWidth()) && isPositiveAndBelow (y, getHeight())) { diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_Image.h b/JuceLibraryCode/modules/juce_graphics/images/juce_Image.h index 82afa25b0..898750460 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_Image.h +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_Image.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -188,7 +187,7 @@ public: This won't do any alpha-blending - it just sets all pixels in the image to the given colour (which may be non-opaque if the image has an alpha channel). */ - void clear (const Rectangle<int>& area, const Colour& colourToClearTo = Colour (0x00000000)); + void clear (const Rectangle<int>& area, Colour colourToClearTo = Colour (0x00000000)); /** Returns a rescaled version of this image. @@ -262,7 +261,7 @@ public: @see getPixelAt, Image::BitmapData::setPixelColour */ - void setPixelAt (int x, int y, const Colour& colour); + void setPixelAt (int x, int y, Colour colour); /** Changes the opacity of a pixel. @@ -344,7 +343,7 @@ public: For performance reasons, this won't do any bounds-checking on the coordinates, so it's the caller's repsonsibility to make sure they're within the image's size. */ - void setPixelColour (int x, int y, const Colour& colour) const noexcept; + void setPixelColour (int x, int y, Colour colour) const noexcept; /** Returns the size of the bitmap. */ Rectangle<int> getBounds() const noexcept { return Rectangle<int> (width, height); } diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.cpp b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.cpp index 7c513f01c..c964513ac 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.cpp +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -27,8 +26,7 @@ class ImageCache::Pimpl : private Timer, private DeletedAtShutdown { public: - Pimpl() - : cacheTimeout (5000) + Pimpl() : cacheTimeout (5000) { } @@ -43,7 +41,7 @@ public: for (int i = images.size(); --i >= 0;) { - Item* const item = images.getUnchecked(i); + const Item* const item = images.getUnchecked(i); if (item->hashCode == hashCode) return item->image; @@ -94,6 +92,15 @@ public: stopTimer(); } + void releaseUnusedImages() + { + const ScopedLock sl (lock); + + for (int i = images.size(); --i >= 0;) + if (images.getUnchecked(i)->image.getReferenceCount() <= 1) + images.remove (i); + } + struct Item { Image image; @@ -162,3 +169,8 @@ void ImageCache::setCacheTimeout (const int millisecs) jassert (millisecs >= 0); Pimpl::getInstance()->cacheTimeout = (unsigned int) millisecs; } + +void ImageCache::releaseUnusedImages() +{ + Pimpl::getInstance()->releaseUnusedImages(); +} diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.h b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.h index b45d218c4..7bf9b7d47 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.h +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -109,6 +108,10 @@ public: */ static void setCacheTimeout (int millisecs); + /** Releases any images in the cache that aren't being referenced by active + Image objects. + */ + static void releaseUnusedImages(); private: //============================================================================== diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp index 3d5a15049..78e4fb8d6 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageConvolutionKernel.h b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageConvolutionKernel.h index 2c45177bf..25bf29863 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageConvolutionKernel.h +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageConvolutionKernel.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageFileFormat.cpp b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageFileFormat.cpp index 97a063747..a1cfd6a44 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageFileFormat.cpp +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageFileFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageFileFormat.h b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageFileFormat.h index 720a06d47..1ab4ddf05 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageFileFormat.h +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageFileFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -62,6 +61,9 @@ public: The format class should only read the first few bytes of the stream and sniff for header bytes that it understands. + Note that this will advance the stream and leave it in a new position, so if you're + planning on re-using it, you may want to rewind it after calling this method. + @see decodeImage */ virtual bool canUnderstand (InputStream& input) = 0; @@ -151,11 +153,11 @@ public: ~PNGImageFormat(); //============================================================================== - String getFormatName(); - bool usesFileExtension (const File& possibleFile); - bool canUnderstand (InputStream& input); - Image decodeImage (InputStream& input); - bool writeImageToStream (const Image& sourceImage, OutputStream& destStream); + String getFormatName() override; + bool usesFileExtension (const File&) override; + bool canUnderstand (InputStream&) override; + Image decodeImage (InputStream&) override; + bool writeImageToStream (const Image&, OutputStream&) override; }; @@ -181,11 +183,11 @@ public: void setQuality (float newQuality); //============================================================================== - String getFormatName(); - bool usesFileExtension (const File& possibleFile); - bool canUnderstand (InputStream& input); - Image decodeImage (InputStream& input); - bool writeImageToStream (const Image& sourceImage, OutputStream& destStream); + String getFormatName() override; + bool usesFileExtension (const File&) override; + bool canUnderstand (InputStream&) override; + Image decodeImage (InputStream&) override; + bool writeImageToStream (const Image&, OutputStream&) override; private: float quality; @@ -205,11 +207,11 @@ public: ~GIFImageFormat(); //============================================================================== - String getFormatName(); - bool usesFileExtension (const File& possibleFile); - bool canUnderstand (InputStream& input); - Image decodeImage (InputStream& input); - bool writeImageToStream (const Image& sourceImage, OutputStream& destStream); + String getFormatName() override; + bool usesFileExtension (const File&) override; + bool canUnderstand (InputStream&) override; + Image decodeImage (InputStream&) override; + bool writeImageToStream (const Image&, OutputStream&) override; }; diff --git a/JuceLibraryCode/modules/juce_graphics/juce_graphics.cpp b/JuceLibraryCode/modules/juce_graphics/juce_graphics.cpp index c05e75e0e..7dc52527f 100644 --- a/JuceLibraryCode/modules/juce_graphics/juce_graphics.cpp +++ b/JuceLibraryCode/modules/juce_graphics/juce_graphics.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -44,6 +43,11 @@ #import <QuartzCore/QuartzCore.h> #elif JUCE_WINDOWS + #if JUCE_MINGW && JUCE_USE_DIRECTWRITE + #warning "DirectWrite not currently implemented with mingw..." + #undef JUCE_USE_DIRECTWRITE + #endif + #if JUCE_USE_DIRECTWRITE /* If you hit a compile error trying to include these files, you may need to update your version of the Windows SDK to the latest one. The DirectWrite and Direct2D @@ -53,6 +57,10 @@ #include <dwrite.h> #endif + #if JUCE_MINGW + #include <malloc.h> + #endif + #elif JUCE_IOS #import <QuartzCore/QuartzCore.h> #import <CoreText/CoreText.h> @@ -62,11 +70,22 @@ #endif #elif JUCE_LINUX - #include <ft2build.h> - #include FT_FREETYPE_H - #undef SIZEOF + #ifndef JUCE_USE_FREETYPE + #define JUCE_USE_FREETYPE 1 + #endif + + #if ! JUCE_USE_FREETYPE_AMALGAMATED + #include <ft2build.h> + #include FT_FREETYPE_H + #endif +#endif + +#if JUCE_USE_FREETYPE && JUCE_USE_FREETYPE_AMALGAMATED + #include "native/freetype/FreeTypeAmalgam.h" #endif +#undef SIZEOF + #if (JUCE_MAC || JUCE_IOS) && USE_COREGRAPHICS_RENDERING && JUCE_USE_COREIMAGE_LOADER #define JUCE_USING_COREIMAGE_LOADER 1 #else @@ -108,6 +127,10 @@ namespace juce #include "effects/juce_DropShadowEffect.cpp" #include "effects/juce_GlowEffect.cpp" +#if JUCE_USE_FREETYPE + #include "native/juce_freetype_Fonts.cpp" +#endif + //============================================================================== #if JUCE_MAC || JUCE_IOS #include "../juce_core/native/juce_osx_ObjCHelpers.h" @@ -133,5 +156,18 @@ namespace juce #include "native/juce_android_Fonts.cpp" #endif - } + +//============================================================================== +#if JUCE_USE_FREETYPE && JUCE_USE_FREETYPE_AMALGAMATED + #undef PIXEL_MASK + #undef ZLIB_VERSION + #undef Z_ASCII + #undef ZEXTERN + #undef ZEXPORT + + extern "C" + { + #include "native/freetype/FreeTypeAmalgam.c" + } +#endif diff --git a/JuceLibraryCode/modules/juce_graphics/juce_graphics.h b/JuceLibraryCode/modules/juce_graphics/juce_graphics.h index cd08b4c1b..646ee7183 100644 --- a/JuceLibraryCode/modules/juce_graphics/juce_graphics.h +++ b/JuceLibraryCode/modules/juce_graphics/juce_graphics.h @@ -1,29 +1,28 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ -#ifndef __JUCE_GRAPHICS_MODULE_JUCEHEADER__ // %% +#ifndef __JUCE_GRAPHICS_MODULE_JUCEHEADER__ #define __JUCE_GRAPHICS_MODULE_JUCEHEADER__ #include "../juce_core/juce_core.h" diff --git a/JuceLibraryCode/modules/juce_graphics/juce_graphics.mm b/JuceLibraryCode/modules/juce_graphics/juce_graphics.mm index 22772e4cb..b36b0edce 100644 --- a/JuceLibraryCode/modules/juce_graphics/juce_graphics.mm +++ b/JuceLibraryCode/modules/juce_graphics/juce_graphics.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/juce_module_info b/JuceLibraryCode/modules/juce_graphics/juce_module_info index 9b7a494be..d3da20211 100644 --- a/JuceLibraryCode/modules/juce_graphics/juce_module_info +++ b/JuceLibraryCode/modules/juce_graphics/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_graphics", "name": "JUCE graphics classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for 2D vector graphics, image loading/saving, font handling, etc.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_RenderingHelpers.h b/JuceLibraryCode/modules/juce_graphics/native/juce_RenderingHelpers.h index 5d591076f..5ee19f074 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -581,7 +580,7 @@ namespace EdgeTableFillers class SolidColour { public: - SolidColour (const Image::BitmapData& image, const PixelARGB& colour) + SolidColour (const Image::BitmapData& image, const PixelARGB colour) : destData (image), sourceColour (colour) { if (sizeof (PixelType) == 3 && destData.pixelStride == sizeof (PixelType)) @@ -651,12 +650,12 @@ namespace EdgeTableFillers return addBytesToPointer (linePixels, x * destData.pixelStride); } - inline void blendLine (PixelType* dest, const PixelARGB& colour, int width) const noexcept + inline void blendLine (PixelType* dest, const PixelARGB colour, int width) const noexcept { JUCE_PERFORM_PIXEL_OP_LOOP (blend (colour)) } - forcedinline void replaceLine (PixelRGB* dest, const PixelARGB& colour, int width) const noexcept + forcedinline void replaceLine (PixelRGB* dest, const PixelARGB colour, int width) const noexcept { if (destData.pixelStride == sizeof (*dest)) { @@ -701,7 +700,7 @@ namespace EdgeTableFillers } } - forcedinline void replaceLine (PixelAlpha* dest, const PixelARGB& colour, int width) const noexcept + forcedinline void replaceLine (PixelAlpha* dest, const PixelARGB colour, int width) const noexcept { if (destData.pixelStride == sizeof (*dest)) memset (dest, colour.getAlpha(), (size_t) width); @@ -709,7 +708,7 @@ namespace EdgeTableFillers JUCE_PERFORM_PIXEL_OP_LOOP (setAlpha (colour.getAlpha())) } - forcedinline void replaceLine (PixelARGB* dest, const PixelARGB& colour, int width) const noexcept + forcedinline void replaceLine (PixelARGB* dest, const PixelARGB colour, int width) const noexcept { JUCE_PERFORM_PIXEL_OP_LOOP (set (colour)) } @@ -916,14 +915,14 @@ namespace EdgeTableFillers { public: TransformedImageFill (const Image::BitmapData& dest, const Image::BitmapData& src, - const AffineTransform& transform, const int alpha, const bool higherQuality) + const AffineTransform& transform, const int alpha, const Graphics::ResamplingQuality q) : interpolator (transform, - higherQuality ? 0.5f : 0.0f, - higherQuality ? -128 : 0), + q != Graphics::lowResamplingQuality ? 0.5f : 0.0f, + q != Graphics::lowResamplingQuality ? -128 : 0), destData (dest), srcData (src), extraAlpha (alpha + 1), - betterQuality (higherQuality), + quality (q), maxX (src.width - 1), maxY (src.height - 1), scratchSize (2048) @@ -1021,7 +1020,7 @@ namespace EdgeTableFillers loResY = negativeAwareModulo (loResY, srcData.height); } - if (betterQuality) + if (quality != Graphics::lowResamplingQuality) { if (isPositiveAndBelow (loResX, maxX)) { @@ -1361,7 +1360,7 @@ namespace EdgeTableFillers const Image::BitmapData& destData; const Image::BitmapData& srcData; const int extraAlpha; - const bool betterQuality; + const Graphics::ResamplingQuality quality; const int maxX, maxY; int y; DestPixelType* linePixels; @@ -1375,7 +1374,7 @@ namespace EdgeTableFillers //============================================================================== template <class Iterator> void renderImageTransformed (Iterator& iter, const Image::BitmapData& destData, const Image::BitmapData& srcData, - const int alpha, const AffineTransform& transform, bool betterQuality, bool tiledFill) + const int alpha, const AffineTransform& transform, Graphics::ResamplingQuality quality, bool tiledFill) { switch (destData.pixelFormat) { @@ -1383,16 +1382,16 @@ namespace EdgeTableFillers switch (srcData.pixelFormat) { case Image::ARGB: - if (tiledFill) { TransformedImageFill <PixelARGB, PixelARGB, true> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } - else { TransformedImageFill <PixelARGB, PixelARGB, false> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } + if (tiledFill) { TransformedImageFill <PixelARGB, PixelARGB, true> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } + else { TransformedImageFill <PixelARGB, PixelARGB, false> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } break; case Image::RGB: - if (tiledFill) { TransformedImageFill <PixelARGB, PixelRGB, true> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } - else { TransformedImageFill <PixelARGB, PixelRGB, false> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } + if (tiledFill) { TransformedImageFill <PixelARGB, PixelRGB, true> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } + else { TransformedImageFill <PixelARGB, PixelRGB, false> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } break; default: - if (tiledFill) { TransformedImageFill <PixelARGB, PixelAlpha, true> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } - else { TransformedImageFill <PixelARGB, PixelAlpha, false> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } + if (tiledFill) { TransformedImageFill <PixelARGB, PixelAlpha, true> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } + else { TransformedImageFill <PixelARGB, PixelAlpha, false> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } break; } break; @@ -1401,16 +1400,16 @@ namespace EdgeTableFillers switch (srcData.pixelFormat) { case Image::ARGB: - if (tiledFill) { TransformedImageFill <PixelRGB, PixelARGB, true> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } - else { TransformedImageFill <PixelRGB, PixelARGB, false> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } + if (tiledFill) { TransformedImageFill <PixelRGB, PixelARGB, true> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } + else { TransformedImageFill <PixelRGB, PixelARGB, false> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } break; case Image::RGB: - if (tiledFill) { TransformedImageFill <PixelRGB, PixelRGB, true> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } - else { TransformedImageFill <PixelRGB, PixelRGB, false> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } + if (tiledFill) { TransformedImageFill <PixelRGB, PixelRGB, true> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } + else { TransformedImageFill <PixelRGB, PixelRGB, false> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } break; default: - if (tiledFill) { TransformedImageFill <PixelRGB, PixelAlpha, true> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } - else { TransformedImageFill <PixelRGB, PixelAlpha, false> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } + if (tiledFill) { TransformedImageFill <PixelRGB, PixelAlpha, true> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } + else { TransformedImageFill <PixelRGB, PixelAlpha, false> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } break; } break; @@ -1419,16 +1418,16 @@ namespace EdgeTableFillers switch (srcData.pixelFormat) { case Image::ARGB: - if (tiledFill) { TransformedImageFill <PixelAlpha, PixelARGB, true> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } - else { TransformedImageFill <PixelAlpha, PixelARGB, false> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } + if (tiledFill) { TransformedImageFill <PixelAlpha, PixelARGB, true> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } + else { TransformedImageFill <PixelAlpha, PixelARGB, false> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } break; case Image::RGB: - if (tiledFill) { TransformedImageFill <PixelAlpha, PixelRGB, true> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } - else { TransformedImageFill <PixelAlpha, PixelRGB, false> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } + if (tiledFill) { TransformedImageFill <PixelAlpha, PixelRGB, true> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } + else { TransformedImageFill <PixelAlpha, PixelRGB, false> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } break; default: - if (tiledFill) { TransformedImageFill <PixelAlpha, PixelAlpha, true> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } - else { TransformedImageFill <PixelAlpha, PixelAlpha, false> r (destData, srcData, transform, alpha, betterQuality); iter.iterate (r); } + if (tiledFill) { TransformedImageFill <PixelAlpha, PixelAlpha, true> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } + else { TransformedImageFill <PixelAlpha, PixelAlpha, false> r (destData, srcData, transform, alpha, quality); iter.iterate (r); } break; } break; @@ -1497,7 +1496,7 @@ namespace EdgeTableFillers } template <class Iterator, class DestPixelType> - void renderSolidFill (Iterator& iter, const Image::BitmapData& destData, const PixelARGB& fillColour, const bool replaceContents, DestPixelType*) + void renderSolidFill (Iterator& iter, const Image::BitmapData& destData, const PixelARGB fillColour, const bool replaceContents, DestPixelType*) { if (replaceContents) { @@ -1555,17 +1554,17 @@ namespace ClipRegions virtual Ptr excludeClipRectangle (const Rectangle<int>&) = 0; virtual Ptr clipToPath (const Path&, const AffineTransform&) = 0; virtual Ptr clipToEdgeTable (const EdgeTable& et) = 0; - virtual Ptr clipToImageAlpha (const Image&, const AffineTransform&, const bool betterQuality) = 0; - virtual void translate (const Point<int>& delta) = 0; + virtual Ptr clipToImageAlpha (const Image&, const AffineTransform&, const Graphics::ResamplingQuality quality) = 0; + virtual void translate (Point<int> delta) = 0; virtual bool clipRegionIntersects (const Rectangle<int>&) const = 0; virtual Rectangle<int> getClipBounds() const = 0; - virtual void fillRectWithColour (Image::BitmapData& destData, const Rectangle<int>&, const PixelARGB& colour, bool replaceContents) const = 0; - virtual void fillRectWithColour (Image::BitmapData& destData, const Rectangle<float>&, const PixelARGB& colour) const = 0; - virtual void fillAllWithColour (Image::BitmapData& destData, const PixelARGB& colour, bool replaceContents) const = 0; + virtual void fillRectWithColour (Image::BitmapData& destData, const Rectangle<int>&, const PixelARGB colour, bool replaceContents) const = 0; + virtual void fillRectWithColour (Image::BitmapData& destData, const Rectangle<float>&, const PixelARGB colour) const = 0; + virtual void fillAllWithColour (Image::BitmapData& destData, const PixelARGB colour, bool replaceContents) const = 0; virtual void fillAllWithGradient (Image::BitmapData& destData, ColourGradient&, const AffineTransform&, bool isIdentity) const = 0; - virtual void renderImageTransformed (const Image::BitmapData& destData, const Image::BitmapData& srcData, const int alpha, const AffineTransform&, bool betterQuality, bool tiledFill) const = 0; + virtual void renderImageTransformed (const Image::BitmapData& destData, const Image::BitmapData& srcData, const int alpha, const AffineTransform&, Graphics::ResamplingQuality, bool tiledFill) const = 0; virtual void renderImageUntransformed (const Image::BitmapData& destData, const Image::BitmapData& srcData, const int alpha, int x, int y, bool tiledFill) const = 0; }; @@ -1619,7 +1618,7 @@ namespace ClipRegions return edgeTable.isEmpty() ? nullptr : this; } - Ptr clipToImageAlpha (const Image& image, const AffineTransform& transform, const bool betterQuality) + Ptr clipToImageAlpha (const Image& image, const AffineTransform& transform, const Graphics::ResamplingQuality quality) { const Image::BitmapData srcData (image, Image::BitmapData::readOnly); @@ -1629,7 +1628,7 @@ namespace ClipRegions const int tx = (int) (transform.getTranslationX() * 256.0f); const int ty = (int) (transform.getTranslationY() * 256.0f); - if ((! betterQuality) || ((tx | ty) & 224) == 0) + if (quality == Graphics::lowResamplingQuality || ((tx | ty) & 224) == 0) { const int imageX = ((tx + 128) >> 8); const int imageY = ((ty + 128) >> 8); @@ -1656,15 +1655,15 @@ namespace ClipRegions if (! edgeTable.isEmpty()) { if (image.getFormat() == Image::ARGB) - transformedClipImage (srcData, transform, betterQuality, (PixelARGB*) 0); + transformedClipImage (srcData, transform, quality, (PixelARGB*) 0); else - transformedClipImage (srcData, transform, betterQuality, (PixelAlpha*) 0); + transformedClipImage (srcData, transform, quality, (PixelAlpha*) 0); } return edgeTable.isEmpty() ? nullptr : this; } - void translate (const Point<int>& delta) + void translate (Point<int> delta) { edgeTable.translate ((float) delta.x, delta.y); } @@ -1679,7 +1678,7 @@ namespace ClipRegions return edgeTable.getMaximumBounds(); } - void fillRectWithColour (Image::BitmapData& destData, const Rectangle<int>& area, const PixelARGB& colour, bool replaceContents) const + void fillRectWithColour (Image::BitmapData& destData, const Rectangle<int>& area, const PixelARGB colour, bool replaceContents) const { const Rectangle<int> totalClip (edgeTable.getMaximumBounds()); const Rectangle<int> clipped (totalClip.getIntersection (area)); @@ -1692,7 +1691,7 @@ namespace ClipRegions } } - void fillRectWithColour (Image::BitmapData& destData, const Rectangle<float>& area, const PixelARGB& colour) const + void fillRectWithColour (Image::BitmapData& destData, const Rectangle<float>& area, const PixelARGB colour) const { const Rectangle<float> totalClip (edgeTable.getMaximumBounds().toFloat()); const Rectangle<float> clipped (totalClip.getIntersection (area)); @@ -1705,7 +1704,7 @@ namespace ClipRegions } } - void fillAllWithColour (Image::BitmapData& destData, const PixelARGB& colour, bool replaceContents) const + void fillAllWithColour (Image::BitmapData& destData, const PixelARGB colour, bool replaceContents) const { switch (destData.pixelFormat) { @@ -1729,9 +1728,9 @@ namespace ClipRegions } } - void renderImageTransformed (const Image::BitmapData& destData, const Image::BitmapData& srcData, const int alpha, const AffineTransform& transform, bool betterQuality, bool tiledFill) const + void renderImageTransformed (const Image::BitmapData& destData, const Image::BitmapData& srcData, const int alpha, const AffineTransform& transform, Graphics::ResamplingQuality quality, bool tiledFill) const { - EdgeTableFillers::renderImageTransformed (edgeTable, destData, srcData, alpha, transform, betterQuality, tiledFill); + EdgeTableFillers::renderImageTransformed (edgeTable, destData, srcData, alpha, transform, quality, tiledFill); } void renderImageUntransformed (const Image::BitmapData& destData, const Image::BitmapData& srcData, const int alpha, int x, int y, bool tiledFill) const @@ -1744,9 +1743,9 @@ namespace ClipRegions private: //============================================================================== template <class SrcPixelType> - void transformedClipImage (const Image::BitmapData& srcData, const AffineTransform& transform, const bool betterQuality, const SrcPixelType*) + void transformedClipImage (const Image::BitmapData& srcData, const AffineTransform& transform, const Graphics::ResamplingQuality quality, const SrcPixelType*) { - EdgeTableFillers::TransformedImageFill <SrcPixelType, SrcPixelType, false> renderer (srcData, srcData, transform, 255, betterQuality); + EdgeTableFillers::TransformedImageFill <SrcPixelType, SrcPixelType, false> renderer (srcData, srcData, transform, 255, quality); for (int y = 0; y < edgeTable.getMaximumBounds().getHeight(); ++y) renderer.clipEdgeTableLine (edgeTable, edgeTable.getMaximumBounds().getX(), y + edgeTable.getMaximumBounds().getY(), @@ -1800,12 +1799,12 @@ namespace ClipRegions Ptr clipToPath (const Path& p, const AffineTransform& transform) { return toEdgeTable()->clipToPath (p, transform); } Ptr clipToEdgeTable (const EdgeTable& et) { return toEdgeTable()->clipToEdgeTable (et); } - Ptr clipToImageAlpha (const Image& image, const AffineTransform& transform, const bool betterQuality) + Ptr clipToImageAlpha (const Image& image, const AffineTransform& transform, const Graphics::ResamplingQuality quality) { - return toEdgeTable()->clipToImageAlpha (image, transform, betterQuality); + return toEdgeTable()->clipToImageAlpha (image, transform, quality); } - void translate (const Point<int>& delta) + void translate (Point<int> delta) { clip.offsetAll (delta.x, delta.y); } @@ -1813,7 +1812,7 @@ namespace ClipRegions bool clipRegionIntersects (const Rectangle<int>& r) const { return clip.intersects (r); } Rectangle<int> getClipBounds() const { return clip.getBounds(); } - void fillRectWithColour (Image::BitmapData& destData, const Rectangle<int>& area, const PixelARGB& colour, bool replaceContents) const + void fillRectWithColour (Image::BitmapData& destData, const Rectangle<int>& area, const PixelARGB colour, bool replaceContents) const { SubRectangleIterator iter (clip, area); @@ -1825,7 +1824,7 @@ namespace ClipRegions } } - void fillRectWithColour (Image::BitmapData& destData, const Rectangle<float>& area, const PixelARGB& colour) const + void fillRectWithColour (Image::BitmapData& destData, const Rectangle<float>& area, const PixelARGB colour) const { SubRectangleIteratorFloat iter (clip, area); @@ -1837,7 +1836,7 @@ namespace ClipRegions } } - void fillAllWithColour (Image::BitmapData& destData, const PixelARGB& colour, bool replaceContents) const + void fillAllWithColour (Image::BitmapData& destData, const PixelARGB colour, bool replaceContents) const { switch (destData.pixelFormat) { @@ -1861,9 +1860,9 @@ namespace ClipRegions } } - void renderImageTransformed (const Image::BitmapData& destData, const Image::BitmapData& srcData, const int alpha, const AffineTransform& transform, bool betterQuality, bool tiledFill) const + void renderImageTransformed (const Image::BitmapData& destData, const Image::BitmapData& srcData, const int alpha, const AffineTransform& transform, Graphics::ResamplingQuality quality, bool tiledFill) const { - EdgeTableFillers::renderImageTransformed (*this, destData, srcData, alpha, transform, betterQuality, tiledFill); + EdgeTableFillers::renderImageTransformed (*this, destData, srcData, alpha, transform, quality, tiledFill); } void renderImageUntransformed (const Image::BitmapData& destData, const Image::BitmapData& srcData, const int alpha, int x, int y, bool tiledFill) const @@ -2153,8 +2152,7 @@ public: if (sourceImage.hasAlphaChannel()) { cloneClipIfMultiplyReferenced(); - clip = clip->clipToImageAlpha (sourceImage, transform.getTransformWith (t), - interpolationQuality != Graphics::lowResamplingQuality); + clip = clip->clipToImageAlpha (sourceImage, transform.getTransformWith (t), interpolationQuality); } else { @@ -2363,7 +2361,6 @@ public: const Image::BitmapData destData (image, Image::BitmapData::readWrite); const Image::BitmapData srcData (sourceImage, Image::BitmapData::readOnly); const int alpha = fillType.colour.getAlpha(); - const bool betterQuality = (interpolationQuality != Graphics::lowResamplingQuality); if (t.isOnlyTranslation()) { @@ -2371,7 +2368,7 @@ public: int tx = (int) (t.getTranslationX() * 256.0f); int ty = (int) (t.getTranslationY() * 256.0f); - if ((! betterQuality) || ((tx | ty) & 224) == 0) + if (interpolationQuality == Graphics::lowResamplingQuality || ((tx | ty) & 224) == 0) { tx = ((tx + 128) >> 8); ty = ((ty + 128) >> 8); @@ -2402,7 +2399,7 @@ public: { if (tiledFillClipRegion != nullptr) { - tiledFillClipRegion->renderImageTransformed (destData, srcData, alpha, t, betterQuality, true); + tiledFillClipRegion->renderImageTransformed (destData, srcData, alpha, t, interpolationQuality, true); } else { @@ -2413,7 +2410,7 @@ public: c = c->clipToPath (p, t); if (c != nullptr) - c->renderImageTransformed (destData, srcData, alpha, t, betterQuality, false); + c->renderImageTransformed (destData, srcData, alpha, t, interpolationQuality, false); } } } diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_android_Fonts.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_android_Fonts.cpp index 47f081c3f..cbd311942 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_android_Fonts.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_android_Fonts.cpp @@ -1,28 +1,93 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ +struct DefaultFontNames +{ + DefaultFontNames() + : defaultSans ("sans"), + defaultSerif ("serif"), + defaultFixed ("monospace"), + defaultFallback ("sans") + { + } + + String getRealFontName (const String& faceName) const + { + if (faceName == Font::getDefaultSansSerifFontName()) return defaultSans; + if (faceName == Font::getDefaultSerifFontName()) return defaultSerif; + if (faceName == Font::getDefaultMonospacedFontName()) return defaultFixed; + + return faceName; + } + + String defaultSans, defaultSerif, defaultFixed, defaultFallback; +}; + +Typeface::Ptr Font::getDefaultTypefaceForFont (const Font& font) +{ + static DefaultFontNames defaultNames; + + Font f (font); + f.setTypefaceName (defaultNames.getRealFontName (font.getTypefaceName())); + return Typeface::createSystemTypefaceFor (f); +} + +//============================================================================== +#if JUCE_USE_FREETYPE + +StringArray FTTypefaceList::getDefaultFontDirectories() +{ + return StringArray ("/system/fonts"); +} + +Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) +{ + return new FreeTypeTypeface (font); +} + +void Typeface::scanFolderForFonts (const File& folder) +{ + FTTypefaceList::getInstance()->scanFontPaths (StringArray (folder.getFullPathName())); +} + +StringArray Font::findAllTypefaceNames() +{ + return FTTypefaceList::getInstance()->findAllFamilyNames(); +} + +StringArray Font::findAllTypefaceStyles (const String& family) +{ + return FTTypefaceList::getInstance()->findAllTypefaceStyles (family); +} + +bool TextLayout::createNativeLayout (const AttributedString&) +{ + return false; +} + +#else + //============================================================================== #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ STATICMETHOD (create, "create", "(Ljava/lang/String;I)Landroid/graphics/Typeface;") \ @@ -31,7 +96,6 @@ DECLARE_JNI_CLASS (TypefaceClass, "android/graphics/Typeface"); #undef JNI_CLASS_MEMBERS - //============================================================================== StringArray Font::findAllTypefaceNames() { @@ -61,34 +125,6 @@ StringArray Font::findAllTypefaceStyles (const String& family) return results; } -struct DefaultFontNames -{ - DefaultFontNames() - : defaultSans ("sans"), - defaultSerif ("serif"), - defaultFixed ("monospace"), - defaultFallback ("sans") - { - } - - String defaultSans, defaultSerif, defaultFixed, defaultFallback; -}; - -Typeface::Ptr Font::getDefaultTypefaceForFont (const Font& font) -{ - static DefaultFontNames defaultNames; - - String faceName (font.getTypefaceName()); - - if (faceName == Font::getDefaultSansSerifFontName()) faceName = defaultNames.defaultSans; - else if (faceName == Font::getDefaultSerifFontName()) faceName = defaultNames.defaultSerif; - else if (faceName == Font::getDefaultMonospacedFontName()) faceName = defaultNames.defaultFixed; - - Font f (font); - f.setTypefaceName (faceName); - return Typeface::createSystemTypefaceFor (f); -} - const float referenceFontSize = 256.0f; const float referenceFontToUnits = 1.0f / referenceFontSize; @@ -279,7 +315,14 @@ Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) return new AndroidTypeface (font); } +void Typeface::scanFolderForFonts (const File&) +{ + jassertfalse; // not available unless using FreeType +} + bool TextLayout::createNativeLayout (const AttributedString&) { return false; } + +#endif diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_android_GraphicsContext.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_android_GraphicsContext.cpp index c69d89b9f..9382c1db6 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_android_GraphicsContext.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_android_GraphicsContext.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_freetype_Fonts.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_freetype_Fonts.cpp new file mode 100644 index 000000000..a77fe2eb0 --- /dev/null +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_freetype_Fonts.cpp @@ -0,0 +1,412 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +struct FTLibWrapper : public ReferenceCountedObject +{ + FTLibWrapper() : library (0) + { + if (FT_Init_FreeType (&library) != 0) + { + library = 0; + DBG ("Failed to initialize FreeType"); + } + } + + ~FTLibWrapper() + { + if (library != 0) + FT_Done_FreeType (library); + } + + FT_Library library; + + typedef ReferenceCountedObjectPtr <FTLibWrapper> Ptr; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTLibWrapper) +}; + +//============================================================================== +struct FTFaceWrapper : public ReferenceCountedObject +{ + FTFaceWrapper (const FTLibWrapper::Ptr& ftLib, const File& file, int faceIndex) + : face (0), library (ftLib) + { + if (FT_New_Face (ftLib->library, file.getFullPathName().toUTF8(), faceIndex, &face) != 0) + face = 0; + } + + ~FTFaceWrapper() + { + if (face != 0) + FT_Done_Face (face); + } + + FT_Face face; + FTLibWrapper::Ptr library; + + typedef ReferenceCountedObjectPtr <FTFaceWrapper> Ptr; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTFaceWrapper) +}; + +//============================================================================== +class FTTypefaceList : private DeletedAtShutdown +{ +public: + FTTypefaceList() : library (new FTLibWrapper()) + { + scanFontPaths (getDefaultFontDirectories()); + } + + ~FTTypefaceList() + { + clearSingletonInstance(); + } + + //============================================================================== + struct KnownTypeface + { + KnownTypeface (const File& f, const int index, const FTFaceWrapper& face) + : file (f), + family (face.face->family_name), + style (face.face->style_name), + faceIndex (index), + isMonospaced ((face.face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0), + isSansSerif (isFaceSansSerif (family)) + { + } + + const File file; + const String family, style; + const int faceIndex; + const bool isMonospaced, isSansSerif; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KnownTypeface) + }; + + //============================================================================== + FTFaceWrapper::Ptr createFace (const String& fontName, const String& fontStyle) + { + const KnownTypeface* ftFace = matchTypeface (fontName, fontStyle); + + if (ftFace == nullptr) ftFace = matchTypeface (fontName, "Regular"); + if (ftFace == nullptr) ftFace = matchTypeface (fontName, String::empty); + + if (ftFace != nullptr) + { + if (FTFaceWrapper::Ptr face = new FTFaceWrapper (library, ftFace->file, ftFace->faceIndex)) + { + // If there isn't a unicode charmap then select the first one. + if (FT_Select_Charmap (face->face, ft_encoding_unicode) != 0) + FT_Set_Charmap (face->face, face->face->charmaps[0]); + + return face; + } + } + + return nullptr; + } + + //============================================================================== + StringArray findAllFamilyNames() const + { + StringArray s; + + for (int i = 0; i < faces.size(); i++) + s.addIfNotAlreadyThere (faces.getUnchecked(i)->family); + + return s; + } + + StringArray findAllTypefaceStyles (const String& family) const + { + StringArray s; + + for (int i = 0; i < faces.size(); i++) + { + const KnownTypeface* const face = faces.getUnchecked(i); + + if (face->family == family) + s.addIfNotAlreadyThere (face->style); + } + + return s; + } + + void scanFontPaths (const StringArray& paths) + { + for (int i = 0; i < paths.size(); ++i) + { + DirectoryIterator iter (File::getCurrentWorkingDirectory() + .getChildFile (paths[i]), true); + + while (iter.next()) + if (iter.getFile().hasFileExtension ("ttf;pfb;pcf;otf")) + scanFont (iter.getFile()); + } + } + + void getMonospacedNames (StringArray& monoSpaced) const + { + for (int i = 0; i < faces.size(); i++) + if (faces.getUnchecked(i)->isMonospaced) + monoSpaced.addIfNotAlreadyThere (faces.getUnchecked(i)->family); + } + + void getSerifNames (StringArray& serif) const + { + for (int i = 0; i < faces.size(); i++) + if (! faces.getUnchecked(i)->isSansSerif) + serif.addIfNotAlreadyThere (faces.getUnchecked(i)->family); + } + + void getSansSerifNames (StringArray& sansSerif) const + { + for (int i = 0; i < faces.size(); i++) + if (faces.getUnchecked(i)->isSansSerif) + sansSerif.addIfNotAlreadyThere (faces.getUnchecked(i)->family); + } + + juce_DeclareSingleton_SingleThreaded_Minimal (FTTypefaceList); + +private: + FTLibWrapper::Ptr library; + OwnedArray<KnownTypeface> faces; + + static StringArray getDefaultFontDirectories(); + + void scanFont (const File& file) + { + int faceIndex = 0; + int numFaces = 0; + + do + { + FTFaceWrapper face (library, file, faceIndex); + + if (face.face != 0) + { + if (faceIndex == 0) + numFaces = face.face->num_faces; + + if ((face.face->face_flags & FT_FACE_FLAG_SCALABLE) != 0) + faces.add (new KnownTypeface (file, faceIndex, face)); + } + + ++faceIndex; + } + while (faceIndex < numFaces); + } + + const KnownTypeface* matchTypeface (const String& familyName, const String& style) const noexcept + { + for (int i = 0; i < faces.size(); ++i) + { + const KnownTypeface* const face = faces.getUnchecked(i); + + if (face->family == familyName + && (face->style.equalsIgnoreCase (style) || style.isEmpty())) + return face; + } + + return nullptr; + } + + static bool isFaceSansSerif (const String& family) + { + const char* sansNames[] = { "Sans", "Verdana", "Arial", "Ubuntu" }; + + for (int i = 0; i < numElementsInArray (sansNames); ++i) + if (family.containsIgnoreCase (sansNames[i])) + return true; + + return false; + } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTTypefaceList) +}; + +juce_ImplementSingleton_SingleThreaded (FTTypefaceList) + + +//============================================================================== +class FreeTypeTypeface : public CustomTypeface +{ +public: + FreeTypeTypeface (const Font& font) + : faceWrapper (FTTypefaceList::getInstance() + ->createFace (font.getTypefaceName(), font.getTypefaceStyle())) + { + if (faceWrapper != nullptr) + { + setCharacteristics (font.getTypefaceName(), + font.getTypefaceStyle(), + faceWrapper->face->ascender / (float) (faceWrapper->face->ascender - faceWrapper->face->descender), + L' '); + } + else + { + DBG ("Failed to create typeface: " << font.toString()); + } + } + + bool loadGlyphIfPossible (const juce_wchar character) + { + if (faceWrapper != nullptr) + { + FT_Face face = faceWrapper->face; + const unsigned int glyphIndex = FT_Get_Char_Index (face, character); + + if (FT_Load_Glyph (face, glyphIndex, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM) == 0 + && face->glyph->format == ft_glyph_format_outline) + { + const float scale = 1.0f / (float) (face->ascender - face->descender); + Path destShape; + + if (getGlyphShape (destShape, face->glyph->outline, scale)) + { + addGlyph (character, destShape, face->glyph->metrics.horiAdvance * scale); + + if ((face->face_flags & FT_FACE_FLAG_KERNING) != 0) + addKerning (face, character, glyphIndex); + + return true; + } + } + } + + return false; + } + +private: + FTFaceWrapper::Ptr faceWrapper; + + bool getGlyphShape (Path& destShape, const FT_Outline& outline, const float scaleX) + { + const float scaleY = -scaleX; + const short* const contours = outline.contours; + const char* const tags = outline.tags; + const FT_Vector* const points = outline.points; + + for (int c = 0; c < outline.n_contours; ++c) + { + const int startPoint = (c == 0) ? 0 : contours [c - 1] + 1; + const int endPoint = contours[c]; + + for (int p = startPoint; p <= endPoint; ++p) + { + const float x = scaleX * points[p].x; + const float y = scaleY * points[p].y; + + if (p == startPoint) + { + if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Conic) + { + float x2 = scaleX * points [endPoint].x; + float y2 = scaleY * points [endPoint].y; + + if (FT_CURVE_TAG (tags[endPoint]) != FT_Curve_Tag_On) + { + x2 = (x + x2) * 0.5f; + y2 = (y + y2) * 0.5f; + } + + destShape.startNewSubPath (x2, y2); + } + else + { + destShape.startNewSubPath (x, y); + } + } + + if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_On) + { + if (p != startPoint) + destShape.lineTo (x, y); + } + else if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Conic) + { + const int nextIndex = (p == endPoint) ? startPoint : p + 1; + float x2 = scaleX * points [nextIndex].x; + float y2 = scaleY * points [nextIndex].y; + + if (FT_CURVE_TAG (tags [nextIndex]) == FT_Curve_Tag_Conic) + { + x2 = (x + x2) * 0.5f; + y2 = (y + y2) * 0.5f; + } + else + { + ++p; + } + + destShape.quadraticTo (x, y, x2, y2); + } + else if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Cubic) + { + const int next1 = p + 1; + const int next2 = (p == (endPoint - 1)) ? startPoint : (p + 2); + + if (p >= endPoint + || FT_CURVE_TAG (tags[next1]) != FT_Curve_Tag_Cubic + || FT_CURVE_TAG (tags[next2]) != FT_Curve_Tag_On) + return false; + + const float x2 = scaleX * points [next1].x; + const float y2 = scaleY * points [next1].y; + const float x3 = scaleX * points [next2].x; + const float y3 = scaleY * points [next2].y; + + destShape.cubicTo (x, y, x2, y2, x3, y3); + p += 2; + } + } + + destShape.closeSubPath(); + } + + return true; + } + + void addKerning (FT_Face face, const uint32 character, const uint32 glyphIndex) + { + const float height = (float) (face->ascender - face->descender); + + uint32 rightGlyphIndex; + uint32 rightCharCode = FT_Get_First_Char (face, &rightGlyphIndex); + + while (rightGlyphIndex != 0) + { + FT_Vector kerning; + + if (FT_Get_Kerning (face, glyphIndex, rightGlyphIndex, ft_kerning_unscaled, &kerning) == 0 + && kerning.x != 0) + addKerningPair (character, rightCharCode, kerning.x / height); + + rightCharCode = FT_Get_Next_Char (face, rightCharCode, &rightGlyphIndex); + } + } + + JUCE_DECLARE_NON_COPYABLE (FreeTypeTypeface) +}; diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_linux_Fonts.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_linux_Fonts.cpp index 5eb91ab66..5dc91f04d 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_linux_Fonts.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_linux_Fonts.cpp @@ -1,480 +1,79 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ -struct FTLibWrapper : public ReferenceCountedObject +StringArray FTTypefaceList::getDefaultFontDirectories() { - FTLibWrapper() : library (0) - { - if (FT_Init_FreeType (&library) != 0) - { - library = 0; - DBG ("Failed to initialize FreeType"); - } - } - - ~FTLibWrapper() - { - if (library != 0) - FT_Done_FreeType (library); - } - - FT_Library library; - - typedef ReferenceCountedObjectPtr <FTLibWrapper> Ptr; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTLibWrapper) -}; - -//============================================================================== -struct FTFaceWrapper : public ReferenceCountedObject -{ - FTFaceWrapper (const FTLibWrapper::Ptr& ftLib, const File& file, int faceIndex) - : face (0), library (ftLib) - { - if (FT_New_Face (ftLib->library, file.getFullPathName().toUTF8(), faceIndex, &face) != 0) - face = 0; - } - - ~FTFaceWrapper() - { - if (face != 0) - FT_Done_Face (face); - } - - FT_Face face; - FTLibWrapper::Ptr library; - - typedef ReferenceCountedObjectPtr <FTFaceWrapper> Ptr; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTFaceWrapper) -}; - -//============================================================================== -class LinuxFontFileIterator -{ -public: - LinuxFontFileIterator() - : index (0) - { - fontDirs.addTokens (CharPointer_UTF8 (getenv ("JUCE_FONT_PATH")), ";,", String::empty); - fontDirs.removeEmptyStrings (true); - - if (fontDirs.size() == 0) - { - const ScopedPointer<XmlElement> fontsInfo (XmlDocument::parse (File ("/etc/fonts/fonts.conf"))); - - if (fontsInfo != nullptr) - { - forEachXmlChildElementWithTagName (*fontsInfo, e, "dir") - { - String fontPath (e->getAllSubText().trim()); - - if (fontPath.isNotEmpty()) - { - if (e->getStringAttribute ("prefix") == "xdg") - { - String xdgDataHome (SystemStats::getEnvironmentVariable ("XDG_DATA_HOME", String::empty)); - - if (xdgDataHome.trimStart().isEmpty()) - xdgDataHome = "~/.local/share"; - - fontPath = File (xdgDataHome).getChildFile (fontPath).getFullPathName(); - } - - fontDirs.add (fontPath); - } - } - } - } - - if (fontDirs.size() == 0) - fontDirs.add ("/usr/X11R6/lib/X11/fonts"); - - fontDirs.removeDuplicates (false); - } - - bool next() - { - if (iter != nullptr) - { - while (iter->next()) - if (getFile().hasFileExtension ("ttf;pfb;pcf;otf")) - return true; - } - - if (index >= fontDirs.size()) - return false; - - iter = new DirectoryIterator (File::getCurrentWorkingDirectory() - .getChildFile (fontDirs [index++]), true); - return next(); - } - - File getFile() const { jassert (iter != nullptr); return iter->getFile(); } - -private: StringArray fontDirs; - int index; - ScopedPointer<DirectoryIterator> iter; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LinuxFontFileIterator) -}; + fontDirs.addTokens (CharPointer_UTF8 (getenv ("JUCE_FONT_PATH")), ";,", String::empty); + fontDirs.removeEmptyStrings (true); -//============================================================================== -class FTTypefaceList : private DeletedAtShutdown -{ -public: - FTTypefaceList() - : library (new FTLibWrapper()) + if (fontDirs.size() == 0) { - LinuxFontFileIterator fontFileIterator; + const ScopedPointer<XmlElement> fontsInfo (XmlDocument::parse (File ("/etc/fonts/fonts.conf"))); - while (fontFileIterator.next()) + if (fontsInfo != nullptr) { - int faceIndex = 0; - int numFaces = 0; - - do + forEachXmlChildElementWithTagName (*fontsInfo, e, "dir") { - FTFaceWrapper face (library, fontFileIterator.getFile(), faceIndex); + String fontPath (e->getAllSubText().trim()); - if (face.face != 0) + if (fontPath.isNotEmpty()) { - if (faceIndex == 0) - numFaces = face.face->num_faces; - - if ((face.face->face_flags & FT_FACE_FLAG_SCALABLE) != 0) - faces.add (new KnownTypeface (fontFileIterator.getFile(), faceIndex, face)); - } - - ++faceIndex; - } - while (faceIndex < numFaces); - } - } - - ~FTTypefaceList() - { - clearSingletonInstance(); - } - - //============================================================================== - struct KnownTypeface - { - KnownTypeface (const File& f, const int index, const FTFaceWrapper& face) - : file (f), - family (face.face->family_name), - style (face.face->style_name), - faceIndex (index), - isMonospaced ((face.face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0), - isSansSerif (isFaceSansSerif (family)) - { - } - - const File file; - const String family, style; - const int faceIndex; - const bool isMonospaced, isSansSerif; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KnownTypeface) - }; - - //============================================================================== - FTFaceWrapper::Ptr createFace (const String& fontName, const String& fontStyle) - { - const KnownTypeface* ftFace = matchTypeface (fontName, fontStyle); - - if (ftFace == nullptr) ftFace = matchTypeface (fontName, "Regular"); - if (ftFace == nullptr) ftFace = matchTypeface (fontName, String::empty); - - if (ftFace != nullptr) - { - if (FTFaceWrapper::Ptr face = new FTFaceWrapper (library, ftFace->file, ftFace->faceIndex)) - { - // If there isn't a unicode charmap then select the first one. - if (FT_Select_Charmap (face->face, ft_encoding_unicode) != 0) - FT_Set_Charmap (face->face, face->face->charmaps[0]); - - return face; - } - } - - return nullptr; - } - - //============================================================================== - StringArray findAllFamilyNames() const - { - StringArray s; - - for (int i = 0; i < faces.size(); i++) - s.addIfNotAlreadyThere (faces.getUnchecked(i)->family); - - return s; - } - - StringArray findAllTypefaceStyles (const String& family) const - { - StringArray s; - - for (int i = 0; i < faces.size(); i++) - { - const KnownTypeface* const face = faces.getUnchecked(i); - - if (face->family == family) - s.addIfNotAlreadyThere (face->style); - } - - return s; - } - - void getMonospacedNames (StringArray& monoSpaced) const - { - for (int i = 0; i < faces.size(); i++) - if (faces.getUnchecked(i)->isMonospaced) - monoSpaced.addIfNotAlreadyThere (faces.getUnchecked(i)->family); - } - - void getSerifNames (StringArray& serif) const - { - for (int i = 0; i < faces.size(); i++) - if (! faces.getUnchecked(i)->isSansSerif) - serif.addIfNotAlreadyThere (faces.getUnchecked(i)->family); - } - - void getSansSerifNames (StringArray& sansSerif) const - { - for (int i = 0; i < faces.size(); i++) - if (faces.getUnchecked(i)->isSansSerif) - sansSerif.addIfNotAlreadyThere (faces.getUnchecked(i)->family); - } - - juce_DeclareSingleton_SingleThreaded_Minimal (FTTypefaceList); - -private: - FTLibWrapper::Ptr library; - OwnedArray<KnownTypeface> faces; - - const KnownTypeface* matchTypeface (const String& familyName, const String& style) const noexcept - { - for (int i = 0; i < faces.size(); ++i) - { - const KnownTypeface* const face = faces.getUnchecked(i); - - if (face->family == familyName - && (face->style.equalsIgnoreCase (style) || style.isEmpty())) - return face; - } - - return nullptr; - } - - static bool isFaceSansSerif (const String& family) - { - const char* sansNames[] = { "Sans", "Verdana", "Arial", "Ubuntu" }; - - for (int i = 0; i < numElementsInArray (sansNames); ++i) - if (family.containsIgnoreCase (sansNames[i])) - return true; - - return false; - } - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTTypefaceList) -}; - -juce_ImplementSingleton_SingleThreaded (FTTypefaceList) - - -//============================================================================== -class FreeTypeTypeface : public CustomTypeface -{ -public: - FreeTypeTypeface (const Font& font) - : faceWrapper (FTTypefaceList::getInstance() - ->createFace (font.getTypefaceName(), font.getTypefaceStyle())) - { - if (faceWrapper != nullptr) - { - setCharacteristics (font.getTypefaceName(), - font.getTypefaceStyle(), - faceWrapper->face->ascender / (float) (faceWrapper->face->ascender - faceWrapper->face->descender), - L' '); - } - else - { - DBG ("Failed to create typeface: " << font.toString()); - } - } - - bool loadGlyphIfPossible (const juce_wchar character) - { - if (faceWrapper != nullptr) - { - FT_Face face = faceWrapper->face; - const unsigned int glyphIndex = FT_Get_Char_Index (face, character); - - if (FT_Load_Glyph (face, glyphIndex, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM) == 0 - && face->glyph->format == ft_glyph_format_outline) - { - const float scale = 1.0f / (float) (face->ascender - face->descender); - Path destShape; - - if (getGlyphShape (destShape, face->glyph->outline, scale)) - { - addGlyph (character, destShape, face->glyph->metrics.horiAdvance * scale); - - if ((face->face_flags & FT_FACE_FLAG_KERNING) != 0) - addKerning (face, character, glyphIndex); - - return true; - } - } - } - - return false; - } - -private: - FTFaceWrapper::Ptr faceWrapper; - - bool getGlyphShape (Path& destShape, const FT_Outline& outline, const float scaleX) - { - const float scaleY = -scaleX; - const short* const contours = outline.contours; - const char* const tags = outline.tags; - const FT_Vector* const points = outline.points; - - for (int c = 0; c < outline.n_contours; ++c) - { - const int startPoint = (c == 0) ? 0 : contours [c - 1] + 1; - const int endPoint = contours[c]; - - for (int p = startPoint; p <= endPoint; ++p) - { - const float x = scaleX * points[p].x; - const float y = scaleY * points[p].y; - - if (p == startPoint) - { - if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Conic) + if (e->getStringAttribute ("prefix") == "xdg") { - float x2 = scaleX * points [endPoint].x; - float y2 = scaleY * points [endPoint].y; + String xdgDataHome (SystemStats::getEnvironmentVariable ("XDG_DATA_HOME", String::empty)); - if (FT_CURVE_TAG (tags[endPoint]) != FT_Curve_Tag_On) - { - x2 = (x + x2) * 0.5f; - y2 = (y + y2) * 0.5f; - } - - destShape.startNewSubPath (x2, y2); - } - else - { - destShape.startNewSubPath (x, y); - } - } + if (xdgDataHome.trimStart().isEmpty()) + xdgDataHome = "~/.local/share"; - if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_On) - { - if (p != startPoint) - destShape.lineTo (x, y); - } - else if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Conic) - { - const int nextIndex = (p == endPoint) ? startPoint : p + 1; - float x2 = scaleX * points [nextIndex].x; - float y2 = scaleY * points [nextIndex].y; - - if (FT_CURVE_TAG (tags [nextIndex]) == FT_Curve_Tag_Conic) - { - x2 = (x + x2) * 0.5f; - y2 = (y + y2) * 0.5f; - } - else - { - ++p; + fontPath = File (xdgDataHome).getChildFile (fontPath).getFullPathName(); } - destShape.quadraticTo (x, y, x2, y2); - } - else if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Cubic) - { - const int next1 = p + 1; - const int next2 = (p == (endPoint - 1)) ? startPoint : (p + 2); - - if (p >= endPoint - || FT_CURVE_TAG (tags[next1]) != FT_Curve_Tag_Cubic - || FT_CURVE_TAG (tags[next2]) != FT_Curve_Tag_On) - return false; - - const float x2 = scaleX * points [next1].x; - const float y2 = scaleY * points [next1].y; - const float x3 = scaleX * points [next2].x; - const float y3 = scaleY * points [next2].y; - - destShape.cubicTo (x, y, x2, y2, x3, y3); - p += 2; + fontDirs.add (fontPath); } } - - destShape.closeSubPath(); } - - return true; } - void addKerning (FT_Face face, const uint32 character, const uint32 glyphIndex) - { - const float height = (float) (face->ascender - face->descender); - - uint32 rightGlyphIndex; - uint32 rightCharCode = FT_Get_First_Char (face, &rightGlyphIndex); - - while (rightGlyphIndex != 0) - { - FT_Vector kerning; - - if (FT_Get_Kerning (face, glyphIndex, rightGlyphIndex, ft_kerning_unscaled, &kerning) == 0 - && kerning.x != 0) - addKerningPair (character, rightCharCode, kerning.x / height); + if (fontDirs.size() == 0) + fontDirs.add ("/usr/X11R6/lib/X11/fonts"); - rightCharCode = FT_Get_Next_Char (face, rightCharCode, &rightGlyphIndex); - } - } - - JUCE_DECLARE_NON_COPYABLE (FreeTypeTypeface) -}; + fontDirs.removeDuplicates (false); + return fontDirs; +} -//============================================================================== Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) { return new FreeTypeTypeface (font); } +void Typeface::scanFolderForFonts (const File& folder) +{ + FTTypefaceList::getInstance()->scanFontPaths (StringArray (folder.getFullPathName())); +} + StringArray Font::findAllTypefaceNames() { return FTTypefaceList::getInstance()->findAllFamilyNames(); @@ -485,6 +84,11 @@ StringArray Font::findAllTypefaceStyles (const String& family) return FTTypefaceList::getInstance()->findAllTypefaceStyles (family); } +bool TextLayout::createNativeLayout (const AttributedString&) +{ + return false; +} + //============================================================================== struct DefaultFontNames { @@ -495,6 +99,15 @@ struct DefaultFontNames { } + String getRealFontName (const String& faceName) const + { + if (faceName == Font::getDefaultSansSerifFontName()) return defaultSans; + if (faceName == Font::getDefaultSerifFontName()) return defaultSerif; + if (faceName == Font::getDefaultMonospacedFontName()) return defaultFixed; + + return faceName; + } + String defaultSans, defaultSerif, defaultFixed; private: @@ -525,7 +138,7 @@ private: FTTypefaceList::getInstance()->getSansSerifNames (allFonts); const char* targets[] = { "Verdana", "Bitstream Vera Sans", "Luxi Sans", - "Liberation Sans", "DejaVu Sans", "Sans", 0 }; + "Liberation Sans", "DejaVu Sans", "Sans", nullptr }; return pickBestFont (allFonts, targets); } @@ -535,7 +148,7 @@ private: FTTypefaceList::getInstance()->getSerifNames (allFonts); const char* targets[] = { "Bitstream Vera Serif", "Times", "Nimbus Roman", - "Liberation Serif", "DejaVu Serif", "Serif", 0 }; + "Liberation Serif", "DejaVu Serif", "Serif", nullptr }; return pickBestFont (allFonts, targets); } @@ -545,7 +158,7 @@ private: FTTypefaceList::getInstance()->getMonospacedNames (allFonts); const char* targets[] = { "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Sans Mono", - "Liberation Mono", "Courier", "DejaVu Mono", "Mono", 0 }; + "Liberation Mono", "Courier", "DejaVu Mono", "Mono", nullptr }; return pickBestFont (allFonts, targets); } @@ -556,18 +169,7 @@ Typeface::Ptr Font::getDefaultTypefaceForFont (const Font& font) { static DefaultFontNames defaultNames; - String faceName (font.getTypefaceName()); - - if (faceName == getDefaultSansSerifFontName()) faceName = defaultNames.defaultSans; - else if (faceName == getDefaultSerifFontName()) faceName = defaultNames.defaultSerif; - else if (faceName == getDefaultMonospacedFontName()) faceName = defaultNames.defaultFixed; - Font f (font); - f.setTypefaceName (faceName); + f.setTypefaceName (defaultNames.getRealFontName (font.getTypefaceName())); return Typeface::createSystemTypefaceFor (f); } - -bool TextLayout::createNativeLayout (const AttributedString&) -{ - return false; -} diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h b/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h index 492f151c3..e0e5d4471 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index 341533ae8..e96de5f14 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -74,8 +73,8 @@ public: ImageType* createType() const { return new NativeImageType(); } //============================================================================== - static CGImageRef createImage (const Image& juceImage, const bool /*forAlpha*/, - CGColorSpaceRef colourSpace, const bool mustOutliveSource) + static CGImageRef createImage (const Image& juceImage, CGColorSpaceRef colourSpace, + const bool mustOutliveSource) { const Image::BitmapData srcData (juceImage, Image::BitmapData::readOnly); CGDataProviderRef provider; @@ -245,7 +244,7 @@ void CoreGraphicsContext::clipToImageAlpha (const Image& sourceImage, const Affi if (sourceImage.getFormat() != Image::SingleChannel) singleChannelImage = sourceImage.convertedToFormat (Image::SingleChannel); - CGImageRef image = CoreGraphicsImage::createImage (singleChannelImage, true, greyColourSpace, true); + CGImageRef image = CoreGraphicsImage::createImage (singleChannelImage, greyColourSpace, true); flip(); AffineTransform t (AffineTransform::verticalFlip (sourceImage.getHeight()).followedBy (transform)); @@ -439,7 +438,7 @@ void CoreGraphicsContext::drawImage (const Image& sourceImage, const AffineTrans { const int iw = sourceImage.getWidth(); const int ih = sourceImage.getHeight(); - CGImageRef image = CoreGraphicsImage::createImage (sourceImage, false, rgbColourSpace, false); + CGImageRef image = CoreGraphicsImage::createImage (sourceImage, rgbColourSpace, false); CGContextSaveGState (context); CGContextSetAlpha (context, state->fillType.getOpacity()); @@ -787,51 +786,55 @@ Image juce_loadWithCoreImage (InputStream& input) MemoryBlock data; input.readIntoMemoryBlock (data, -1); - #if JUCE_IOS + #if JUCE_IOS JUCE_AUTORELEASEPOOL - if (UIImage* uiImage = [UIImage imageWithData: [NSData dataWithBytesNoCopy: data.getData() - length: data.getSize() - freeWhenDone: NO]]) + #endif { - CGImageRef loadedImage = uiImage.CGImage; - - #else - CGDataProviderRef provider = CGDataProviderCreateWithData (0, data.getData(), data.getSize(), 0); - CGImageSourceRef imageSource = CGImageSourceCreateWithDataProvider (provider, 0); - CGDataProviderRelease (provider); + #if JUCE_IOS + if (UIImage* uiImage = [UIImage imageWithData: [NSData dataWithBytesNoCopy: data.getData() + length: data.getSize() + freeWhenDone: NO]]) + { + CGImageRef loadedImage = uiImage.CGImage; - if (imageSource != 0) - { - CGImageRef loadedImage = CGImageSourceCreateImageAtIndex (imageSource, 0, 0); - CFRelease (imageSource); - #endif + #else + CGDataProviderRef provider = CGDataProviderCreateWithData (0, data.getData(), data.getSize(), 0); + CGImageSourceRef imageSource = CGImageSourceCreateWithDataProvider (provider, 0); + CGDataProviderRelease (provider); - if (loadedImage != 0) + if (imageSource != 0) { - CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo (loadedImage); - const bool hasAlphaChan = (alphaInfo != kCGImageAlphaNone - && alphaInfo != kCGImageAlphaNoneSkipLast - && alphaInfo != kCGImageAlphaNoneSkipFirst); - - Image image (NativeImageType().create (Image::ARGB, // (CoreImage doesn't work with 24-bit images) - (int) CGImageGetWidth (loadedImage), - (int) CGImageGetHeight (loadedImage), - hasAlphaChan)); - - CoreGraphicsImage* const cgImage = dynamic_cast<CoreGraphicsImage*> (image.getPixelData()); - jassert (cgImage != nullptr); // if USE_COREGRAPHICS_RENDERING is set, the CoreGraphicsImage class should have been used. - - CGContextDrawImage (cgImage->context, convertToCGRect (image.getBounds()), loadedImage); - CGContextFlush (cgImage->context); - - #if ! JUCE_IOS - CFRelease (loadedImage); - #endif - - // Because it's impossible to create a truly 24-bit CG image, this flag allows a user - // to find out whether the file they just loaded the image from had an alpha channel or not. - image.getProperties()->set ("originalImageHadAlpha", hasAlphaChan); - return image; + CGImageRef loadedImage = CGImageSourceCreateImageAtIndex (imageSource, 0, 0); + CFRelease (imageSource); + #endif + + if (loadedImage != 0) + { + CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo (loadedImage); + const bool hasAlphaChan = (alphaInfo != kCGImageAlphaNone + && alphaInfo != kCGImageAlphaNoneSkipLast + && alphaInfo != kCGImageAlphaNoneSkipFirst); + + Image image (NativeImageType().create (Image::ARGB, // (CoreImage doesn't work with 24-bit images) + (int) CGImageGetWidth (loadedImage), + (int) CGImageGetHeight (loadedImage), + hasAlphaChan)); + + CoreGraphicsImage* const cgImage = dynamic_cast<CoreGraphicsImage*> (image.getPixelData()); + jassert (cgImage != nullptr); // if USE_COREGRAPHICS_RENDERING is set, the CoreGraphicsImage class should have been used. + + CGContextDrawImage (cgImage->context, convertToCGRect (image.getBounds()), loadedImage); + CGContextFlush (cgImage->context); + + #if ! JUCE_IOS + CFRelease (loadedImage); + #endif + + // Because it's impossible to create a truly 24-bit CG image, this flag allows a user + // to find out whether the file they just loaded the image from had an alpha channel or not. + image.getProperties()->set ("originalImageHadAlpha", hasAlphaChan); + return image; + } } } @@ -852,10 +855,10 @@ Image juce_createImageFromCIImage (CIImage* im, int w, int h) return Image (cgImage); } -CGImageRef juce_createCoreGraphicsImage (const Image& juceImage, const bool forAlpha, - CGColorSpaceRef colourSpace, const bool mustOutliveSource) +CGImageRef juce_createCoreGraphicsImage (const Image& juceImage, CGColorSpaceRef colourSpace, + const bool mustOutliveSource) { - return CoreGraphicsImage::createImage (juceImage, forAlpha, colourSpace, mustOutliveSource); + return CoreGraphicsImage::createImage (juceImage, colourSpace, mustOutliveSource); } CGContextRef juce_getImageContext (const Image& image) diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h b/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h index 4455a9599..e0d07aad3 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -55,7 +54,7 @@ namespace } } -extern CGImageRef juce_createCoreGraphicsImage (const Image&, const bool forAlpha, CGColorSpaceRef, const bool mustOutliveSource); +extern CGImageRef juce_createCoreGraphicsImage (const Image&, CGColorSpaceRef, bool mustOutliveSource); extern CGContextRef juce_getImageContext (const Image&); #endif // __JUCE_MAC_COREGRAPHICSHELPERS_JUCEHEADER__ diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_mac_Fonts.mm b/JuceLibraryCode/modules/juce_graphics/native/juce_mac_Fonts.mm index 051a56f66..6aa44d66f 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -40,6 +39,8 @@ extern "C" } #endif +static CTFontRef getCTFontFromTypeface (const Font& f); + namespace CoreTextTypeLayout { static String findBestAvailableStyle (const Font& font, CGAffineTransform& requiredTransform) @@ -188,6 +189,18 @@ namespace CoreTextTypeLayout HeapBlock<CGPoint> local; }; + static CTFontRef getOrCreateFont (const Font& f) + { + if (CTFontRef ctf = getCTFontFromTypeface (f)) + { + CFRetain (ctf); + return ctf; + } + + CGAffineTransform transform; + return createCTFont (f, referenceFontSize, transform); + } + //============================================================================== static CFAttributedStringRef createCFAttributedString (const AttributedString& text) { @@ -214,13 +227,14 @@ namespace CoreTextTypeLayout if (const Font* const f = attr->getFont()) { - CGAffineTransform transform; - CTFontRef ctFontRef = createCTFont (*f, referenceFontSize, transform); - ctFontRef = getFontWithPointSize (ctFontRef, f->getHeight() * getHeightToPointsFactor (ctFontRef)); + if (CTFontRef ctFontRef = getOrCreateFont (*f)) + { + ctFontRef = getFontWithPointSize (ctFontRef, f->getHeight() * getHeightToPointsFactor (ctFontRef)); - CFAttributedStringSetAttribute (attribString, CFRangeMake (range.getStart(), range.getLength()), - kCTFontAttributeName, ctFontRef); - CFRelease (ctFontRef); + CFAttributedStringSetAttribute (attribString, CFRangeMake (range.getStart(), range.getLength()), + kCTFontAttributeName, ctFontRef); + CFRelease (ctFontRef); + } } if (const Colour* const col = attr->getColour()) @@ -417,11 +431,11 @@ class OSXTypeface : public Typeface public: OSXTypeface (const Font& font) : Typeface (font.getTypefaceName(), - font.getTypefaceStyle()), + font.getTypefaceStyle()), fontRef (nullptr), + ctFontRef (nullptr), fontHeightToPointsFactor (1.0f), renderingTransform (CGAffineTransformIdentity), - ctFontRef (nullptr), attributedStringAtts (nullptr), ascent (0.0f), unitsToHeightScaleFactor (0.0f) @@ -567,12 +581,12 @@ public: //============================================================================== CGFontRef fontRef; + CTFontRef ctFontRef; float fontHeightToPointsFactor; CGAffineTransform renderingTransform; private: - CTFontRef ctFontRef; CFDictionaryRef attributedStringAtts; float ascent, unitsToHeightScaleFactor; AffineTransform pathTransform; @@ -599,6 +613,15 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSXTypeface) }; +CTFontRef getCTFontFromTypeface (const Font& f) +{ + if (OSXTypeface* tf = dynamic_cast <OSXTypeface*> (f.getTypeface())) + return tf->ctFontRef; + + return 0; +} + + StringArray Font::findAllTypefaceNames() { StringArray names; @@ -713,44 +736,46 @@ public: : Typeface (font.getTypefaceName(), font.getTypefaceStyle()) { JUCE_AUTORELEASEPOOL - renderingTransform = CGAffineTransformIdentity; + { + renderingTransform = CGAffineTransformIdentity; - NSDictionary* nsDict = [NSDictionary dictionaryWithObjectsAndKeys: - juceStringToNS (name), NSFontFamilyAttribute, - juceStringToNS (style), NSFontFaceAttribute, nil]; + NSDictionary* nsDict = [NSDictionary dictionaryWithObjectsAndKeys: + juceStringToNS (name), NSFontFamilyAttribute, + juceStringToNS (style), NSFontFaceAttribute, nil]; - NSFontDescriptor* nsFontDesc = [NSFontDescriptor fontDescriptorWithFontAttributes: nsDict]; - nsFont = [NSFont fontWithDescriptor: nsFontDesc size: referenceFontSize]; + NSFontDescriptor* nsFontDesc = [NSFontDescriptor fontDescriptorWithFontAttributes: nsDict]; + nsFont = [NSFont fontWithDescriptor: nsFontDesc size: referenceFontSize]; - [nsFont retain]; + [nsFont retain]; - #if SUPPORT_ONLY_10_4_FONTS - initWithATSFont(); - #else - #if SUPPORT_10_4_FONTS - if (NEW_CGFONT_FUNCTIONS_UNAVAILABLE) - { + #if SUPPORT_ONLY_10_4_FONTS initWithATSFont(); - } - else - #endif - { - fontRef = CGFontCreateWithFontName ((CFStringRef) [nsFont fontName]); + #else + #if SUPPORT_10_4_FONTS + if (NEW_CGFONT_FUNCTIONS_UNAVAILABLE) + { + initWithATSFont(); + } + else + #endif + { + fontRef = CGFontCreateWithFontName ((CFStringRef) [nsFont fontName]); - const float absAscent = std::abs ((float) CGFontGetAscent (fontRef)); - const float totalHeight = absAscent + std::abs ((float) CGFontGetDescent (fontRef)); + const float absAscent = std::abs ((float) CGFontGetAscent (fontRef)); + const float totalHeight = absAscent + std::abs ((float) CGFontGetDescent (fontRef)); - ascent = absAscent / totalHeight; - unitsToHeightScaleFactor = 1.0f / totalHeight; + ascent = absAscent / totalHeight; + unitsToHeightScaleFactor = 1.0f / totalHeight; - const float nsFontAscent = std::abs ([nsFont ascender]); - const float nsFontDescent = std::abs ([nsFont descender]); + const float nsFontAscent = std::abs ([nsFont ascender]); + const float nsFontDescent = std::abs ([nsFont descender]); - fontHeightToPointsFactor = referenceFontSize / (nsFontAscent + nsFontDescent); - } - #endif + fontHeightToPointsFactor = referenceFontSize / (nsFontAscent + nsFontDescent); + } + #endif - pathTransform = AffineTransform::identity.scale (unitsToHeightScaleFactor); + pathTransform = AffineTransform::identity.scale (unitsToHeightScaleFactor); + } } ~OSXTypeface() @@ -910,28 +935,29 @@ public: jassert (path.isEmpty()); JUCE_AUTORELEASEPOOL - - NSBezierPath* bez = [NSBezierPath bezierPath]; - [bez moveToPoint: NSMakePoint (0, 0)]; - [bez appendBezierPathWithGlyph: (NSGlyph) glyphNumber - inFont: nsFont]; - - for (int i = 0; i < [bez elementCount]; ++i) { - NSPoint p[3]; - switch ([bez elementAtIndex: i associatedPoints: p]) + NSBezierPath* bez = [NSBezierPath bezierPath]; + [bez moveToPoint: NSMakePoint (0, 0)]; + [bez appendBezierPathWithGlyph: (NSGlyph) glyphNumber + inFont: nsFont]; + + for (int i = 0; i < [bez elementCount]; ++i) { - case NSMoveToBezierPathElement: path.startNewSubPath ((float) p[0].x, (float) -p[0].y); break; - case NSLineToBezierPathElement: path.lineTo ((float) p[0].x, (float) -p[0].y); break; - case NSCurveToBezierPathElement: path.cubicTo ((float) p[0].x, (float) -p[0].y, - (float) p[1].x, (float) -p[1].y, - (float) p[2].x, (float) -p[2].y); break; - case NSClosePathBezierPathElement: path.closeSubPath(); break; - default: jassertfalse; break; + NSPoint p[3]; + switch ([bez elementAtIndex: i associatedPoints: p]) + { + case NSMoveToBezierPathElement: path.startNewSubPath ((float) p[0].x, (float) -p[0].y); break; + case NSLineToBezierPathElement: path.lineTo ((float) p[0].x, (float) -p[0].y); break; + case NSCurveToBezierPathElement: path.cubicTo ((float) p[0].x, (float) -p[0].y, + (float) p[1].x, (float) -p[1].y, + (float) p[2].x, (float) -p[2].y); break; + case NSClosePathBezierPathElement: path.closeSubPath(); break; + default: jassertfalse; break; + } } - } - path.applyTransform (pathTransform); + path.applyTransform (pathTransform); + } return true; #endif } @@ -1084,18 +1110,21 @@ private: StringArray Font::findAllTypefaceNames() { StringArray names; + JUCE_AUTORELEASEPOOL + { + #if JUCE_IOS + NSArray* fonts = [UIFont familyNames]; + #else + NSArray* fonts = [[NSFontManager sharedFontManager] availableFontFamilies]; + #endif - #if JUCE_IOS - NSArray* fonts = [UIFont familyNames]; - #else - NSArray* fonts = [[NSFontManager sharedFontManager] availableFontFamilies]; - #endif + for (unsigned int i = 0; i < [fonts count]; ++i) + names.add (nsStringToJuce ((NSString*) [fonts objectAtIndex: i])); - for (unsigned int i = 0; i < [fonts count]; ++i) - names.add (nsStringToJuce ((NSString*) [fonts objectAtIndex: i])); + names.sort (true); + } - names.sort (true); return names; } @@ -1105,14 +1134,16 @@ StringArray Font::findAllTypefaceStyles (const String& family) return findAllTypefaceStyles (FontStyleHelpers::getConcreteFamilyNameFromPlaceholder (family)); StringArray results; - JUCE_AUTORELEASEPOOL - - NSArray* styles = [[NSFontManager sharedFontManager] availableMembersOfFontFamily: juceStringToNS (family)]; - for (unsigned int i = 0; i < [styles count]; ++i) + JUCE_AUTORELEASEPOOL { - NSArray* style = [styles objectAtIndex: i]; - results.add (nsStringToJuce ((NSString*) [style objectAtIndex: 1])); + NSArray* styles = [[NSFontManager sharedFontManager] availableMembersOfFontFamily: juceStringToNS (family)]; + + for (unsigned int i = 0; i < [styles count]; ++i) + { + NSArray* style = [styles objectAtIndex: i]; + results.add (nsStringToJuce ((NSString*) [style objectAtIndex: 1])); + } } return results; @@ -1126,6 +1157,11 @@ Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) return new OSXTypeface (font); } +void Typeface::scanFolderForFonts (const File&) +{ + jassertfalse; // not implemented on this platform +} + struct DefaultFontNames { DefaultFontNames() diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp index 3d9a1e8c1..4e44b9f45 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -629,8 +628,8 @@ public: { radialGradient = 0; - const Point<float>& p1 = fillType.gradient->point1; - const Point<float>& p2 = fillType.gradient->point2; + const Point<float> p1 = fillType.gradient->point1; + const Point<float> p2 = fillType.gradient->point2; float r = p1.getDistanceFrom (p2); D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES props = @@ -645,8 +644,8 @@ public: { linearGradient = 0; - const Point<float>& p1 = fillType.gradient->point1; - const Point<float>& p2 = fillType.gradient->point2; + const Point<float> p1 = fillType.gradient->point1; + const Point<float> p2 = fillType.gradient->point2; D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES props = D2D1::LinearGradientBrushProperties (D2D1::Point2F (p1.x, p1.y), diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp index 02ad1106a..a511aa87f 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -222,9 +221,11 @@ namespace DirectWriteTypeLayout if (const Font* const font = attr.getFont()) { + const String familyName (FontStyleHelpers::getConcreteFamilyName (*font)); + BOOL fontFound = false; uint32 fontIndex; - fontCollection->FindFamilyName (FontStyleHelpers::getConcreteFamilyName (*font).toWideCharPointer(), + fontCollection->FindFamilyName (familyName.toWideCharPointer(), &fontIndex, &fontFound); if (! fontFound) @@ -245,7 +246,7 @@ namespace DirectWriteTypeLayout break; } - textLayout->SetFontFamilyName (attr.getFont()->getTypefaceName().toWideCharPointer(), range); + textLayout->SetFontFamilyName (familyName.toWideCharPointer(), range); textLayout->SetFontWeight (dwFont->GetWeight(), range); textLayout->SetFontStretch (dwFont->GetStretch(), range); textLayout->SetFontStyle (dwFont->GetStyle(), range); diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp index 366e4f07a..3d9263447 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -154,10 +153,13 @@ public: { hr = dwFontFamily->GetFont (i, dwFont.resetAndGetPointerAddress()); + if (i == 0) + break; + ComSmartPtr<IDWriteLocalizedStrings> faceNames; hr = dwFont->GetFaceNames (faceNames.resetAndGetPointerAddress()); - if (i == 0 || font.getTypefaceStyle() == getLocalisedName (faceNames)) + if (font.getTypefaceStyle() == getLocalisedName (faceNames)) break; } diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_win32_Fonts.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_win32_Fonts.cpp index ef6f773f5..01fd94ff0 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_win32_Fonts.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_win32_Fonts.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -499,3 +498,8 @@ Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) return new WindowsTypeface (font); } + +void Typeface::scanFolderForFonts (const File&) +{ + jassertfalse; // not implemented on this platform +} diff --git a/JuceLibraryCode/modules/juce_graphics/placement/juce_Justification.cpp b/JuceLibraryCode/modules/juce_graphics/placement/juce_Justification.cpp index 7692f2475..f006e1b4e 100644 --- a/JuceLibraryCode/modules/juce_graphics/placement/juce_Justification.cpp +++ b/JuceLibraryCode/modules/juce_graphics/placement/juce_Justification.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/placement/juce_Justification.h b/JuceLibraryCode/modules/juce_graphics/placement/juce_Justification.h index eac13926b..1373e31c5 100644 --- a/JuceLibraryCode/modules/juce_graphics/placement/juce_Justification.h +++ b/JuceLibraryCode/modules/juce_graphics/placement/juce_Justification.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/placement/juce_RectanglePlacement.cpp b/JuceLibraryCode/modules/juce_graphics/placement/juce_RectanglePlacement.cpp index 016a50906..031048e30 100644 --- a/JuceLibraryCode/modules/juce_graphics/placement/juce_RectanglePlacement.cpp +++ b/JuceLibraryCode/modules/juce_graphics/placement/juce_RectanglePlacement.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_graphics/placement/juce_RectanglePlacement.h b/JuceLibraryCode/modules/juce_graphics/placement/juce_RectanglePlacement.h index c8f22b423..b35606754 100644 --- a/JuceLibraryCode/modules/juce_graphics/placement/juce_RectanglePlacement.h +++ b/JuceLibraryCode/modules/juce_graphics/placement/juce_RectanglePlacement.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.cpp b/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.cpp index e643268ac..d8566ffbe 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -283,19 +282,20 @@ String JUCEApplication::getCommandLineParameters() int JUCEApplication::main (int argc, const char* argv[]) { JUCE_AUTORELEASEPOOL + { + juce_argc = argc; + juce_argv = argv; - juce_argc = argc; - juce_argv = argv; - - #if JUCE_MAC - initialiseNSApplication(); - #endif + #if JUCE_MAC + initialiseNSApplication(); + #endif - #if JUCE_IOS - return juce_iOSMain (argc, argv); - #else - return JUCEApplication::main(); - #endif + #if JUCE_IOS + return juce_iOSMain (argc, argv); + #else + return JUCEApplication::main(); + #endif + } } #endif diff --git a/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.h b/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.h index 40e71fe50..530123ab2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.h +++ b/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/application/juce_Initialisation.h b/JuceLibraryCode/modules/juce_gui_basics/application/juce_Initialisation.h index 3eaea3db1..3621d2dde 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/application/juce_Initialisation.h +++ b/JuceLibraryCode/modules/juce_gui_basics/application/juce_Initialisation.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp index 0d2f87b90..75f8590c6 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp @@ -1,29 +1,28 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ -ArrowButton::ArrowButton (const String& name, float arrowDirectionInRadians, const Colour& arrowColour) +ArrowButton::ArrowButton (const String& name, float arrowDirectionInRadians, Colour arrowColour) : Button (name), colour (arrowColour) { path.addTriangle (0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f); diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ArrowButton.h b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ArrowButton.h index b5f6e2227..610dec4b7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ArrowButton.h +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ArrowButton.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -48,7 +47,7 @@ public: */ ArrowButton (const String& buttonName, float arrowDirection, - const Colour& arrowColour); + Colour arrowColour); /** Destructor. */ ~ArrowButton(); diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.cpp index 3a1876a09..f1012d86a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.h b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.h index 10a4662bc..edabc05e9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.h +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp index fda20519f..3a3ec96ce 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_DrawableButton.h b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_DrawableButton.h index 68b9a3604..4df7c25fc 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_DrawableButton.h +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_DrawableButton.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp index c15b658f1..46d4746de 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h index 7c811b98d..4563f3250 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ImageButton.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ImageButton.cpp index bda145e8a..3170d05f6 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ImageButton.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ImageButton.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -40,13 +39,13 @@ void ImageButton::setImages (const bool resizeButtonNowToFitThisImage, const bool preserveImageProportions, const Image& normalImage_, const float imageOpacityWhenNormal, - const Colour& overlayColourWhenNormal, + Colour overlayColourWhenNormal, const Image& overImage_, const float imageOpacityWhenOver, - const Colour& overlayColourWhenOver, + Colour overlayColourWhenOver, const Image& downImage_, const float imageOpacityWhenDown, - const Colour& overlayColourWhenDown, + Colour overlayColourWhenDown, const float hitTestAlphaThreshold) { normalImage = normalImage_; diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ImageButton.h b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ImageButton.h index 4189c6717..b2b726087 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ImageButton.h +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ImageButton.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -45,7 +44,7 @@ public: /** Creates an ImageButton. Use setImage() to specify the image to use. The colours and opacities that - are specified here can be changed later using setDrawingOptions(). + are specified here can be changed later using setImages(). @param name the name to give the component */ @@ -101,13 +100,13 @@ public: bool preserveImageProportions, const Image& normalImage, float imageOpacityWhenNormal, - const Colour& overlayColourWhenNormal, + Colour overlayColourWhenNormal, const Image& overImage, float imageOpacityWhenOver, - const Colour& overlayColourWhenOver, + Colour overlayColourWhenOver, const Image& downImage, float imageOpacityWhenDown, - const Colour& overlayColourWhenDown, + Colour overlayColourWhenDown, float hitTestAlphaThreshold = 0.0f); /** Returns the currently set 'normal' image. */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp index f3ee2e15c..65b11af12 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.h b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.h index 8e195410f..991ca85b3 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.h +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_TextButton.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_TextButton.cpp index 2faabfb71..eafffd416 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_TextButton.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_TextButton.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_TextButton.h b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_TextButton.h index e95068f85..0e362244c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_TextButton.h +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_TextButton.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp index de3bfc78a..edaf7ab0a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToggleButton.h b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToggleButton.h index b152d531d..224ed3de9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToggleButton.h +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToggleButton.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp index 788f6573e..f7ef1b096 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToolbarButton.h b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToolbarButton.h index 339ec1e65..007f8489f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToolbarButton.h +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ToolbarButton.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h index 9c3d8c989..dd864656e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp index 93751b4cf..28b4b28cd 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -56,7 +55,7 @@ void ApplicationCommandInfo::setTicked (const bool b) noexcept flags &= ~isTicked; } -void ApplicationCommandInfo::addDefaultKeypress (const int keyCode, const ModifierKeys& modifiers) noexcept +void ApplicationCommandInfo::addDefaultKeypress (const int keyCode, ModifierKeys modifiers) noexcept { defaultKeypresses.add (KeyPress (keyCode, modifiers, 0)); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h index c1bac5cca..2b66db22f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -82,7 +81,7 @@ struct JUCE_API ApplicationCommandInfo @endcode */ void addDefaultKeypress (int keyCode, - const ModifierKeys& modifiers) noexcept; + ModifierKeys modifiers) noexcept; //============================================================================== /** The command's unique ID number. diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index 51e82c58b..d75c5388c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h index 268744cec..a40dda4bc 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp index a803e6b76..245cb25b4 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h index 00bc0988c..4fe2c2cdf 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp index 19131390d..b7334b028 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h index 8f06d6759..842c28e33 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_CachedComponentImage.h b/JuceLibraryCode/modules/juce_gui_basics/components/juce_CachedComponentImage.h index dbe7845ad..112dc175d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_CachedComponentImage.h +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_CachedComponentImage.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.cpp b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.cpp index 789763add..92eb3facc 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -194,14 +193,14 @@ struct Component::ComponentHelpers } //============================================================================== - static inline bool hitTest (Component& comp, const Point<int>& localPoint) + static inline bool hitTest (Component& comp, Point<int> localPoint) { return isPositiveAndBelow (localPoint.x, comp.getWidth()) && isPositiveAndBelow (localPoint.y, comp.getHeight()) && comp.hitTest (localPoint.x, localPoint.y); } - static Point<int> convertFromParentSpace (const Component& comp, const Point<int>& pointInParentSpace) + static Point<int> convertFromParentSpace (const Component& comp, Point<int> pointInParentSpace) { if (comp.affineTransform == nullptr) return pointInParentSpace - comp.getPosition(); @@ -217,7 +216,7 @@ struct Component::ComponentHelpers return areaInParentSpace.toFloat().transformed (comp.affineTransform->inverted()).getSmallestIntegerContainer() - comp.getPosition(); } - static Point<int> convertToParentSpace (const Component& comp, const Point<int>& pointInLocalSpace) + static Point<int> convertToParentSpace (const Component& comp, Point<int> pointInLocalSpace) { if (comp.affineTransform == nullptr) return pointInLocalSpace + comp.getPosition(); @@ -295,7 +294,7 @@ struct Component::ComponentHelpers return r; } - static bool clipObscuredRegions (const Component& comp, Graphics& g, const Rectangle<int>& clipRect, const Point<int>& delta) + static bool clipObscuredRegions (const Component& comp, Graphics& g, const Rectangle<int>& clipRect, Point<int> delta) { bool nothingChanged = true; @@ -328,7 +327,7 @@ struct Component::ComponentHelpers } static void subtractObscuredRegions (const Component& comp, RectangleList& result, - const Point<int>& delta, const Rectangle<int>& clipRect, + Point<int> delta, const Rectangle<int>& clipRect, const Component* const compToAvoid) { for (int i = comp.childComponentList.size(); --i >= 0;) @@ -584,7 +583,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) Desktop::getInstance().addDesktopComponent (this); bounds.setPosition (topLeft); - peer->setBounds (topLeft.x, topLeft.y, getWidth(), getHeight(), false); + peer->setBounds (bounds, false); if (oldRenderingEngine >= 0) peer->setCurrentRenderingEngine (oldRenderingEngine); @@ -644,7 +643,8 @@ ComponentPeer* Component::getPeer() const { if (flags.hasHeavyweightPeerFlag) return ComponentPeer::getPeerFor (this); - else if (parentComponent == nullptr) + + if (parentComponent == nullptr) return nullptr; return parentComponent->getPeer(); @@ -965,7 +965,7 @@ Rectangle<int> Component::getParentMonitorArea() const return Desktop::getInstance().getDisplays().getDisplayContaining (getScreenBounds().getCentre()).userArea; } -Point<int> Component::getLocalPoint (const Component* source, const Point<int>& point) const +Point<int> Component::getLocalPoint (const Component* source, Point<int> point) const { return ComponentHelpers::convertCoordinate (this, source, point); } @@ -975,7 +975,7 @@ Rectangle<int> Component::getLocalArea (const Component* source, const Rectangle return ComponentHelpers::convertCoordinate (this, source, area); } -Point<int> Component::localPointToGlobal (const Point<int>& point) const +Point<int> Component::localPointToGlobal (Point<int> point) const { return ComponentHelpers::convertCoordinate (nullptr, this, point); } @@ -986,17 +986,17 @@ Rectangle<int> Component::localAreaToGlobal (const Rectangle<int>& area) const } // Deprecated methods... -Point<int> Component::relativePositionToGlobal (const Point<int>& relativePosition) const +Point<int> Component::relativePositionToGlobal (Point<int> relativePosition) const { return localPointToGlobal (relativePosition); } -Point<int> Component::globalPositionToRelative (const Point<int>& screenPosition) const +Point<int> Component::globalPositionToRelative (Point<int> screenPosition) const { return getLocalPoint (nullptr, screenPosition); } -Point<int> Component::relativePositionToOtherComponent (const Component* const targetComponent, const Point<int>& positionRelativeToThis) const +Point<int> Component::relativePositionToOtherComponent (const Component* const targetComponent, Point<int> positionRelativeToThis) const { return targetComponent == nullptr ? localPointToGlobal (positionRelativeToThis) : targetComponent->getLocalPoint (this, positionRelativeToThis); @@ -1048,17 +1048,8 @@ void Component::setBounds (const int x, const int y, int w, int h) } if (flags.hasHeavyweightPeerFlag) - { if (ComponentPeer* const peer = getPeer()) - { - if (wasMoved && wasResized) - peer->setBounds (getX(), getY(), getWidth(), getHeight(), false); - else if (wasMoved) - peer->setPosition (getX(), getY()); - else if (wasResized) - peer->setSize (getWidth(), getHeight()); - } - } + peer->setBounds (getBounds(), false); sendMovedResizedMessages (wasMoved, wasResized); } @@ -1112,7 +1103,7 @@ void Component::setTopLeftPosition (const int x, const int y) setBounds (x, y, getWidth(), getHeight()); } -void Component::setTopLeftPosition (const Point<int>& pos) +void Component::setTopLeftPosition (Point<int> pos) { setBounds (pos.x, pos.y, getWidth(), getHeight()); } @@ -1295,7 +1286,7 @@ void Component::getInterceptsMouseClicks (bool& allowsClicksOnThisComponent, allowsClicksOnChildComponents = flags.allowChildMouseClicksFlag; } -bool Component::contains (const Point<int>& point) +bool Component::contains (Point<int> point) { if (ComponentHelpers::hitTest (*this, point)) { @@ -1310,7 +1301,7 @@ bool Component::contains (const Point<int>& point) return false; } -bool Component::reallyContains (const Point<int>& point, const bool returnTrueIfWithinAChild) +bool Component::reallyContains (Point<int> point, const bool returnTrueIfWithinAChild) { if (! contains (point)) return false; @@ -1321,7 +1312,7 @@ bool Component::reallyContains (const Point<int>& point, const bool returnTrueIf return (compAtPosition == this) || (returnTrueIfWithinAChild && isParentOf (compAtPosition)); } -Component* Component::getComponentAt (const Point<int>& position) +Component* Component::getComponentAt (Point<int> position) { if (flags.visibleFlag && ComponentHelpers::hitTest (*this, position)) { @@ -2054,7 +2045,7 @@ void Component::removeColour (const int colourId) colourChanged(); } -void Component::setColour (const int colourId, const Colour& colour) +void Component::setColour (const int colourId, Colour colour) { if (properties.set (ComponentHelpers::getColourPropertyId (colourId), (int) colour.getARGB())) colourChanged(); @@ -2151,6 +2142,12 @@ void Component::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wh parentComponent->mouseWheelMove (e.getEventRelativeTo (parentComponent), wheel); } +void Component::mouseMagnify (const MouseEvent& e, float magnifyAmount) +{ + // the base class just passes this event up to its parent.. + if (parentComponent != nullptr) + parentComponent->mouseMagnify (e.getEventRelativeTo (parentComponent), magnifyAmount); +} //============================================================================== void Component::resized() {} @@ -2247,7 +2244,7 @@ void Component::removeMouseListener (MouseListener* const listenerToRemove) } //============================================================================== -void Component::internalMouseEnter (MouseInputSource& source, const Point<int>& relativePos, const Time& time) +void Component::internalMouseEnter (MouseInputSource& source, Point<int> relativePos, Time time) { if (isCurrentlyBlockedByAnotherModalComponent()) { @@ -2273,7 +2270,7 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>& MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseEnter, me); } -void Component::internalMouseExit (MouseInputSource& source, const Point<int>& relativePos, const Time& time) +void Component::internalMouseExit (MouseInputSource& source, Point<int> relativePos, Time time) { if (flags.repaintOnMouseActivityFlag) repaint(); @@ -2293,7 +2290,7 @@ void Component::internalMouseExit (MouseInputSource& source, const Point<int>& r MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseExit, me); } -void Component::internalMouseDown (MouseInputSource& source, const Point<int>& relativePos, const Time& time) +void Component::internalMouseDown (MouseInputSource& source, Point<int> relativePos, Time time) { Desktop& desktop = Desktop::getInstance(); BailOutChecker checker (this); @@ -2357,8 +2354,8 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDown, me); } -void Component::internalMouseUp (MouseInputSource& source, const Point<int>& relativePos, - const Time& time, const ModifierKeys& oldModifiers) +void Component::internalMouseUp (MouseInputSource& source, Point<int> relativePos, + Time time, const ModifierKeys oldModifiers) { if (flags.mouseDownWasBlocked && isCurrentlyBlockedByAnotherModalComponent()) return; @@ -2400,7 +2397,7 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel } } -void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& relativePos, const Time& time) +void Component::internalMouseDrag (MouseInputSource& source, Point<int> relativePos, Time time) { if (! isCurrentlyBlockedByAnotherModalComponent()) { @@ -2423,7 +2420,7 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r } } -void Component::internalMouseMove (MouseInputSource& source, const Point<int>& relativePos, const Time& time) +void Component::internalMouseMove (MouseInputSource& source, Point<int> relativePos, Time time) { Desktop& desktop = Desktop::getInstance(); @@ -2449,8 +2446,8 @@ void Component::internalMouseMove (MouseInputSource& source, const Point<int>& r } } -void Component::internalMouseWheel (MouseInputSource& source, const Point<int>& relativePos, - const Time& time, const MouseWheelDetails& wheel) +void Component::internalMouseWheel (MouseInputSource& source, Point<int> relativePos, + Time time, const MouseWheelDetails& wheel) { Desktop& desktop = Desktop::getInstance(); BailOutChecker checker (this); @@ -2477,6 +2474,18 @@ void Component::internalMouseWheel (MouseInputSource& source, const Point<int>& } } +void Component::internalMagnifyGesture (MouseInputSource& source, Point<int> relativePos, + Time time, float amount) +{ + if (! isCurrentlyBlockedByAnotherModalComponent()) + { + const MouseEvent me (source, relativePos, source.getCurrentModifiers(), + this, this, time, relativePos, time, 0, false); + + mouseMagnify (me, amount); + } +} + void Component::sendFakeMouseMove() const { MouseInputSource& mainMouse = Desktop::getInstance().getMainMouseSource(); diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.h b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.h index fb29e1342..5e0736ca1 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.h +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -136,7 +135,7 @@ public: */ bool isVisible() const noexcept { return flags.visibleFlag; } - /** Called when this component's visiblility changes. + /** Called when this component's visibility changes. @see setVisible, isVisible */ virtual void visibilityChanged(); @@ -288,7 +287,7 @@ public: int getRight() const noexcept { return bounds.getRight(); } /** Returns the component's top-left position as a Point. */ - const Point<int>& getPosition() const noexcept { return bounds.getPosition(); } + Point<int> getPosition() const noexcept { return bounds.getPosition(); } /** Returns the y coordinate of the bottom edge of this component. This is a distance in pixels from the top edge of the component's parent. @@ -361,7 +360,7 @@ public: screen coordinate. */ Point<int> getLocalPoint (const Component* sourceComponent, - const Point<int>& pointRelativeToSourceComponent) const; + Point<int> pointRelativeToSourceComponent) const; /** Converts a rectangle to be relative to this component's coordinate space. @@ -379,7 +378,7 @@ public: /** Converts a point relative to this component's top-left into a screen coordinate. @see getLocalPoint, localAreaToGlobal */ - Point<int> localPointToGlobal (const Point<int>& localPoint) const; + Point<int> localPointToGlobal (Point<int> localPoint) const; /** Converts a rectangle from this component's coordinate space to a screen coordinate. @@ -419,7 +418,7 @@ public: @see setBounds, ComponentListener::componentMovedOrResized */ - void setTopLeftPosition (const Point<int>& newTopLeftPosition); + void setTopLeftPosition (Point<int> newTopLeftPosition); /** Moves the component to a new position. @@ -897,7 +896,7 @@ public: which might be in the way - for that, see reallyContains() @see hitTest, reallyContains, getComponentAt */ - bool contains (const Point<int>& localPoint); + bool contains (Point<int> localPoint); /** Returns true if a given point lies in this component, taking any overlapping siblings into account. @@ -907,7 +906,7 @@ public: this determines whether that is counted as a hit. @see contains, getComponentAt */ - bool reallyContains (const Point<int>& localPoint, bool returnTrueIfWithinAChild); + bool reallyContains (Point<int> localPoint, bool returnTrueIfWithinAChild); /** Returns the component at a certain point within this one. @@ -930,7 +929,7 @@ public: instead call getComponentAt on the top-level parent of this component. @see hitTest, contains, reallyContains */ - Component* getComponentAt (const Point<int>& position); + Component* getComponentAt (Point<int> position); //============================================================================== /** Marks the whole component as needing to be redrawn. @@ -1559,6 +1558,19 @@ public: virtual void mouseWheelMove (const MouseEvent& event, const MouseWheelDetails& wheel); + /** Called when a pinch-to-zoom mouse-gesture is used. + + If not overridden, a component will forward this message to its parent, so + that parent components can collect gesture messages that are unused by child + components. + + @param event details about the mouse event + @param scaleFactor a multiplier to indicate by how much the size of the target + should be changed. A value of 1.0 would indicate no change, + values greater than 1.0 mean it should be enlarged. + */ + virtual void mouseMagnify (const MouseEvent& event, float scaleFactor); + //============================================================================== /** Ensures that a non-stop stream of mouse-drag events will be sent during the current mouse-drag operation. @@ -2030,7 +2042,7 @@ public: @see findColour, isColourSpecified, colourChanged, LookAndFeel::findColour, LookAndFeel::setColour */ - void setColour (int colourId, const Colour& colour); + void setColour (int colourId, Colour newColour); /** If a colour has been set with setColour(), this will remove it. This allows you to make a colour revert to its default state. @@ -2204,9 +2216,9 @@ public: //============================================================================== #ifndef DOXYGEN // These methods are deprecated - use localPointToGlobal, getLocalPoint, getLocalPoint, etc instead. - JUCE_DEPRECATED (Point<int> relativePositionToGlobal (const Point<int>&) const); - JUCE_DEPRECATED (Point<int> globalPositionToRelative (const Point<int>&) const); - JUCE_DEPRECATED (Point<int> relativePositionToOtherComponent (const Component*, const Point<int>&) const); + JUCE_DEPRECATED (Point<int> relativePositionToGlobal (Point<int>) const); + JUCE_DEPRECATED (Point<int> globalPositionToRelative (Point<int>) const); + JUCE_DEPRECATED (Point<int> relativePositionToOtherComponent (const Component*, Point<int>) const); #endif private: @@ -2274,13 +2286,14 @@ private: uint8 componentTransparency; //============================================================================== - void internalMouseEnter (MouseInputSource&, const Point<int>&, const Time&); - void internalMouseExit (MouseInputSource&, const Point<int>&, const Time&); - void internalMouseDown (MouseInputSource&, const Point<int>&, const Time&); - void internalMouseUp (MouseInputSource&, const Point<int>&, const Time&, const ModifierKeys& oldModifiers); - void internalMouseDrag (MouseInputSource&, const Point<int>&, const Time&); - void internalMouseMove (MouseInputSource&, const Point<int>&, const Time&); - void internalMouseWheel (MouseInputSource&, const Point<int>&, const Time&, const MouseWheelDetails&); + void internalMouseEnter (MouseInputSource&, Point<int>, Time); + void internalMouseExit (MouseInputSource&, Point<int>, Time); + void internalMouseDown (MouseInputSource&, Point<int>, Time); + void internalMouseUp (MouseInputSource&, Point<int>, Time, const ModifierKeys oldModifiers); + void internalMouseDrag (MouseInputSource&, Point<int>, Time); + void internalMouseMove (MouseInputSource&, Point<int>, Time); + void internalMouseWheel (MouseInputSource&, Point<int>, Time, const MouseWheelDetails&); + void internalMagnifyGesture (MouseInputSource&, Point<int>, Time, float); void internalBroughtToFront(); void internalFocusGain (const FocusChangeType, const WeakReference<Component>&); void internalFocusGain (const FocusChangeType); @@ -2322,7 +2335,7 @@ private: virtual void filesDropped (const StringArray&, int, int) {} // This is included here to cause an error if you use or overload it - it has been deprecated in - // favour of contains (const Point<int>&) + // favour of contains (Point<int>) void contains (int, int); #endif diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ComponentListener.cpp b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ComponentListener.cpp index 169d50eb1..3e5cd35eb 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ComponentListener.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ComponentListener.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ComponentListener.h b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ComponentListener.h index c109250a6..abdf1122f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ComponentListener.h +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ComponentListener.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Desktop.cpp b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Desktop.cpp index 602f94334..72b701ed8 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -64,7 +63,7 @@ Component* Desktop::getComponent (const int index) const noexcept return desktopComponents [index]; } -Component* Desktop::findComponentAt (const Point<int>& screenPosition) const +Component* Desktop::findComponentAt (Point<int> screenPosition) const { for (int i = desktopComponents.size(); --i >= 0;) { @@ -328,7 +327,7 @@ const Desktop::Displays::Display& Desktop::Displays::getMainDisplay() const noex return displays.getReference(0); } -const Desktop::Displays::Display& Desktop::Displays::getDisplayContaining (const Point<int>& position) const noexcept +const Desktop::Displays::Display& Desktop::Displays::getDisplayContaining (Point<int> position) const noexcept { const Display* best = &displays.getReference(0); double bestDistance = 1.0e10; diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Desktop.h b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Desktop.h index 22503e3c7..e3e12737d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Desktop.h +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Desktop.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -80,7 +79,7 @@ public: /** Makes the mouse pointer jump to a given location. The co-ordinates are relative to the top-left of the main monitor. */ - static void setMousePosition (const Point<int>& newPosition); + static void setMousePosition (Point<int> newPosition); /** Returns the last position at which a mouse button was pressed. @@ -203,7 +202,7 @@ public: Returns nullptr if the co-ordinates are inside a non-Juce window. */ - Component* findComponentAt (const Point<int>& screenPosition) const; + Component* findComponentAt (Point<int> screenPosition) const; /** The Desktop object has a ComponentAnimator instance which can be used for performing your animations. @@ -343,7 +342,7 @@ public: /** Returns the display which contains a particular point. If the point lies outside all the displays, the nearest one will be returned. */ - const Display& getDisplayContaining (const Point<int>& position) const noexcept; + const Display& getDisplayContaining (Point<int> position) const noexcept; /** Returns a RectangleList made up of all the displays. */ RectangleList getRectangleList (bool userAreasOnly) const; diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp index 10c2a5e78..fefe0f19f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.h b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.h index 5448cdb5e..bb1383953 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.h +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.cpp index 6520b5eec..847d822e1 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -109,7 +108,7 @@ void Drawable::setBoundsToEnclose (const Rectangle<float>& area) } //============================================================================== -void Drawable::setOriginWithOriginalSize (const Point<float>& originWithinParent) +void Drawable::setOriginWithOriginalSize (Point<float> originWithinParent) { setTransform (AffineTransform::translation (originWithinParent.x, originWithinParent.y)); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.h b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.h index f7ad85cc7..86757e009 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.h +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -113,7 +112,7 @@ public: /** Resets any transformations on this drawable, and positions its origin within its parent component. */ - void setOriginWithOriginalSize (const Point<float>& originWithinParent); + void setOriginWithOriginalSize (Point<float> originWithinParent); /** Sets a transform for this drawable that will position it within the specified area of its parent component. @@ -156,6 +155,9 @@ public: */ static Drawable* createFromSVG (const XmlElement& svgDocument); + /** Parses an SVG path string and returns it. */ + static Path parseSVGPath (const String& svgPath); + //============================================================================== /** Tries to create a Drawable from a previously-saved ValueTree. The ValueTree must have been created by the createValueTree() method. diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp index f0736cd51..8fc71a978 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableComposite.h b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableComposite.h index f4789f619..b9851c5fd 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableComposite.h +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableComposite.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp index c0a18eb79..17d0fc456 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableImage.h b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableImage.h index 2d5bf385d..8f7b032cd 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableImage.h +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableImage.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp index 3679debe9..6dc46ba64 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -78,9 +77,9 @@ void DrawablePath::applyRelativePath (const RelativePointPath& newRelativePath, class DrawablePath::RelativePositioner : public RelativeCoordinatePositionerBase { public: - RelativePositioner (DrawablePath& component_) - : RelativeCoordinatePositionerBase (component_), - owner (component_) + RelativePositioner (DrawablePath& comp) + : RelativeCoordinatePositionerBase (comp), + owner (comp) { } @@ -403,7 +402,7 @@ namespace DrawablePathHelpers } } -float DrawablePath::ValueTreeWrapper::Element::findProportionAlongLine (const Point<float>& targetPoint, Expression::Scope* scope) const +float DrawablePath::ValueTreeWrapper::Element::findProportionAlongLine (Point<float> targetPoint, Expression::Scope* scope) const { using namespace DrawablePathHelpers; const Identifier pointType (state.getType()); @@ -460,7 +459,7 @@ float DrawablePath::ValueTreeWrapper::Element::findProportionAlongLine (const Po return bestProp; } -ValueTree DrawablePath::ValueTreeWrapper::Element::insertPoint (const Point<float>& targetPoint, Expression::Scope* scope, UndoManager* undoManager) +ValueTree DrawablePath::ValueTreeWrapper::Element::insertPoint (Point<float> targetPoint, Expression::Scope* scope, UndoManager* undoManager) { ValueTree newTree; const Identifier pointType (state.getType()); diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawablePath.h b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawablePath.h index 391c31c96..8a22830f0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawablePath.h +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawablePath.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -112,9 +111,9 @@ public: void convertToLine (UndoManager*); void convertToCubic (Expression::Scope*, UndoManager*); void convertToPathBreak (UndoManager* undoManager); - ValueTree insertPoint (const Point<float>& targetPoint, Expression::Scope*, UndoManager*); + ValueTree insertPoint (Point<float> targetPoint, Expression::Scope*, UndoManager*); void removePoint (UndoManager* undoManager); - float findProportionAlongLine (const Point<float>& targetPoint, Expression::Scope*) const; + float findProportionAlongLine (Point<float> targetPoint, Expression::Scope*) const; static const Identifier mode, startSubPathElement, closeSubPathElement, lineToElement, quadraticToElement, cubicToElement; diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp index 47becf9e8..5a8c1c85e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h index d4a3b39e3..7a9dfd038 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp index 90905a7dc..308ac1cbb 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -46,11 +45,11 @@ DrawableShape::~DrawableShape() class DrawableShape::RelativePositioner : public RelativeCoordinatePositionerBase { public: - RelativePositioner (DrawableShape& component_, const DrawableShape::RelativeFillType& fill_, bool isMainFill_) - : RelativeCoordinatePositionerBase (component_), - owner (component_), - fill (fill_), - isMainFill (isMainFill_) + RelativePositioner (DrawableShape& comp, const DrawableShape::RelativeFillType& f, bool isMain) + : RelativeCoordinatePositionerBase (comp), + owner (comp), + fill (f), + isMainFill (isMain) { } diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableShape.h b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableShape.h index 64099ab11..b6fe6ac41 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableShape.h +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableShape.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.cpp index e2b3ee173..1edc6cccc 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -59,7 +58,7 @@ void DrawableText::setText (const String& newText) } } -void DrawableText::setColour (const Colour& newColour) +void DrawableText::setColour (Colour newColour) { if (colour != newColour) { @@ -159,28 +158,21 @@ void DrawableText::recalculateCoordinates (Expression::Scope* scope) repaint(); } -const AffineTransform DrawableText::getArrangementAndTransform (GlyphArrangement& glyphs) const -{ - const float w = Line<float> (resolvedPoints[0], resolvedPoints[1]).getLength(); - const float h = Line<float> (resolvedPoints[0], resolvedPoints[2]).getLength(); - - glyphs.addFittedText (scaledFont, text, 0, 0, w, h, justification, 0x100000); - - return AffineTransform::fromTargetPoints (0, 0, resolvedPoints[0].x, resolvedPoints[0].y, - w, 0, resolvedPoints[1].x, resolvedPoints[1].y, - 0, h, resolvedPoints[2].x, resolvedPoints[2].y); -} - //============================================================================== void DrawableText::paint (Graphics& g) { transformContextToCorrectOrigin (g); + const float w = Line<float> (resolvedPoints[0], resolvedPoints[1]).getLength(); + const float h = Line<float> (resolvedPoints[0], resolvedPoints[2]).getLength(); + + g.addTransform (AffineTransform::fromTargetPoints (0, 0, resolvedPoints[0].x, resolvedPoints[0].y, + w, 0, resolvedPoints[1].x, resolvedPoints[1].y, + 0, h, resolvedPoints[2].x, resolvedPoints[2].y)); + g.setFont (scaledFont); g.setColour (colour); - GlyphArrangement ga; - const AffineTransform transform (getArrangementAndTransform (ga)); - ga.draw (g, transform); + g.drawFittedText (text, Rectangle<float> (w, h).getSmallestIntegerContainer(), justification, 0x100000); } Rectangle<float> DrawableText::getDrawableBounds() const @@ -233,7 +225,7 @@ Colour DrawableText::ValueTreeWrapper::getColour() const return Colour::fromString (state [colour].toString()); } -void DrawableText::ValueTreeWrapper::setColour (const Colour& newColour, UndoManager* undoManager) +void DrawableText::ValueTreeWrapper::setColour (Colour newColour, UndoManager* undoManager) { state.setProperty (colour, newColour.toString(), undoManager); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.h b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.h index 440ada928..8fb002fea 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.h +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -55,10 +54,10 @@ public: const String& getText() const noexcept { return text;} /** Sets the colour of the text. */ - void setColour (const Colour& newColour); + void setColour (Colour newColour); /** Returns the current text colour. */ - const Colour& getColour() const noexcept { return colour; } + Colour getColour() const noexcept { return colour; } /** Sets the font to use. Note that the font height and horizontal scale are set as RelativeCoordinates using @@ -115,7 +114,7 @@ public: Value getTextValue (UndoManager* undoManager); Colour getColour() const; - void setColour (const Colour& newColour, UndoManager* undoManager); + void setColour (Colour newColour, UndoManager* undoManager); Justification getJustification() const; void setJustification (const Justification& newJustification, UndoManager* undoManager); @@ -150,7 +149,6 @@ private: bool registerCoordinates (RelativeCoordinatePositionerBase&); void recalculateCoordinates (Expression::Scope*); void refreshBounds(); - const AffineTransform getArrangementAndTransform (GlyphArrangement& glyphs) const; DrawableText& operator= (const DrawableText&); JUCE_LEAK_DETECTOR (DrawableText) diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index 728e34394..1fe3205df 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_SVGParser.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -27,7 +26,7 @@ class SVGState { public: //============================================================================== - SVGState (const XmlElement* const topLevel) + explicit SVGState (const XmlElement* const topLevel) : topLevelXml (topLevel), elementX (0), elementY (0), width (512), height (512), @@ -38,7 +37,7 @@ public: //============================================================================== Drawable* parseSVGElement (const XmlElement& xml) { - if (! xml.hasTagName ("svg")) + if (! xml.hasTagNameIgnoringNamespace ("svg")) return nullptr; DrawableComposite* const drawable = new DrawableComposite(); @@ -105,7 +104,7 @@ public: if (viewBoxH == 0) newState.viewBoxH = newState.height; } - newState.parseSubElements (xml, drawable); + newState.parseSubElements (xml, *drawable); drawable->setContentArea (RelativeRectangle (Rectangle<float> (newState.viewBoxW, newState.viewBoxH))); drawable->resetBoundingBoxToContentArea(); @@ -113,76 +112,10 @@ public: return drawable; } -private: - //============================================================================== - const XmlElement* const topLevelXml; - float elementX, elementY, width, height, viewBoxW, viewBoxH; - AffineTransform transform; - String cssStyleText; - //============================================================================== - void parseSubElements (const XmlElement& xml, DrawableComposite* const parentDrawable) - { - forEachXmlChildElement (xml, e) - { - Drawable* d = nullptr; - - if (e->hasTagName ("g")) d = parseGroupElement (*e); - else if (e->hasTagName ("svg")) d = parseSVGElement (*e); - else if (e->hasTagName ("path")) d = parsePath (*e); - else if (e->hasTagName ("rect")) d = parseRect (*e); - else if (e->hasTagName ("circle")) d = parseCircle (*e); - else if (e->hasTagName ("ellipse")) d = parseEllipse (*e); - else if (e->hasTagName ("line")) d = parseLine (*e); - else if (e->hasTagName ("polyline")) d = parsePolygon (*e, true); - else if (e->hasTagName ("polygon")) d = parsePolygon (*e, false); - else if (e->hasTagName ("text")) d = parseText (*e); - else if (e->hasTagName ("switch")) d = parseSwitch (*e); - else if (e->hasTagName ("style")) parseCSSStyle (*e); - - parentDrawable->addAndMakeVisible (d); - } - } - - DrawableComposite* parseSwitch (const XmlElement& xml) - { - if (const XmlElement* const group = xml.getChildByName ("g")) - return parseGroupElement (*group); - - return nullptr; - } - - DrawableComposite* parseGroupElement (const XmlElement& xml) + void parsePathString (Path& path, const String& pathString) const { - DrawableComposite* const drawable = new DrawableComposite(); - - drawable->setName (xml.getStringAttribute ("id")); - - if (xml.hasAttribute ("transform")) - { - SVGState newState (*this); - newState.addTransform (xml); - - newState.parseSubElements (xml, drawable); - } - else - { - parseSubElements (xml, drawable); - } - - drawable->resetContentAreaAndBoundingBoxToFitChildren(); - return drawable; - } - - //============================================================================== - Drawable* parsePath (const XmlElement& xml) const - { - const String dAttribute (xml.getStringAttribute ("d").trimStart()); - String::CharPointerType d (dAttribute.getCharPointer()); - Path path; - - if (getStyleAttribute (&xml, "fill-rule").trim().equalsIgnoreCase ("evenodd")) - path.setUsingNonZeroWinding (false); + String::CharPointerType d (pathString.getCharPointer().findEndOfWhitespace()); Point<float> subpathStart, last, last2, p1, p2, p3; juce_wchar lastCommandChar = 0; @@ -399,6 +332,80 @@ private: if (! carryOn) break; } + } + +private: + //============================================================================== + const XmlElement* const topLevelXml; + float elementX, elementY, width, height, viewBoxW, viewBoxH; + AffineTransform transform; + String cssStyleText; + + //============================================================================== + void parseSubElements (const XmlElement& xml, DrawableComposite& parentDrawable) + { + forEachXmlChildElement (xml, e) + parentDrawable.addAndMakeVisible (parseSubElement (*e)); + } + + Drawable* parseSubElement (const XmlElement& xml) + { + const String tag (xml.getTagNameWithoutNamespace()); + + if (tag == "g") return parseGroupElement (xml); + if (tag == "svg") return parseSVGElement (xml); + if (tag == "path") return parsePath (xml); + if (tag == "rect") return parseRect (xml); + if (tag == "circle") return parseCircle (xml); + if (tag == "ellipse") return parseEllipse (xml); + if (tag == "line") return parseLine (xml); + if (tag == "polyline") return parsePolygon (xml, true); + if (tag == "polygon") return parsePolygon (xml, false); + if (tag == "text") return parseText (xml); + if (tag == "switch") return parseSwitch (xml); + if (tag == "style") parseCSSStyle (xml); + + return nullptr; + } + + DrawableComposite* parseSwitch (const XmlElement& xml) + { + if (const XmlElement* const group = xml.getChildByName ("g")) + return parseGroupElement (*group); + + return nullptr; + } + + DrawableComposite* parseGroupElement (const XmlElement& xml) + { + DrawableComposite* const drawable = new DrawableComposite(); + + drawable->setName (xml.getStringAttribute ("id")); + + if (xml.hasAttribute ("transform")) + { + SVGState newState (*this); + newState.addTransform (xml); + + newState.parseSubElements (xml, *drawable); + } + else + { + parseSubElements (xml, *drawable); + } + + drawable->resetContentAreaAndBoundingBoxToFitChildren(); + return drawable; + } + + //============================================================================== + Drawable* parsePath (const XmlElement& xml) const + { + Path path; + parsePathString (path, xml.getStringAttribute ("d")); + + if (getStyleAttribute (&xml, "fill-rule").trim().equalsIgnoreCase ("evenodd")) + path.setUsingNonZeroWinding (false); return parseShape (xml, path); } @@ -412,26 +419,26 @@ private: if (hasRX || hasRY) { - float rx = getCoordLength (xml.getStringAttribute ("rx"), viewBoxW); - float ry = getCoordLength (xml.getStringAttribute ("ry"), viewBoxH); + float rx = getCoordLength (xml, "rx", viewBoxW); + float ry = getCoordLength (xml, "ry", viewBoxH); if (! hasRX) rx = ry; else if (! hasRY) ry = rx; - rect.addRoundedRectangle (getCoordLength (xml.getStringAttribute ("x"), viewBoxW), - getCoordLength (xml.getStringAttribute ("y"), viewBoxH), - getCoordLength (xml.getStringAttribute ("width"), viewBoxW), - getCoordLength (xml.getStringAttribute ("height"), viewBoxH), + rect.addRoundedRectangle (getCoordLength (xml, "x", viewBoxW), + getCoordLength (xml, "y", viewBoxH), + getCoordLength (xml, "width", viewBoxW), + getCoordLength (xml, "height", viewBoxH), rx, ry); } else { - rect.addRectangle (getCoordLength (xml.getStringAttribute ("x"), viewBoxW), - getCoordLength (xml.getStringAttribute ("y"), viewBoxH), - getCoordLength (xml.getStringAttribute ("width"), viewBoxW), - getCoordLength (xml.getStringAttribute ("height"), viewBoxH)); + rect.addRectangle (getCoordLength (xml, "x", viewBoxW), + getCoordLength (xml, "y", viewBoxH), + getCoordLength (xml, "width", viewBoxW), + getCoordLength (xml, "height", viewBoxH)); } return parseShape (xml, rect); @@ -441,9 +448,9 @@ private: { Path circle; - const float cx = getCoordLength (xml.getStringAttribute ("cx"), viewBoxW); - const float cy = getCoordLength (xml.getStringAttribute ("cy"), viewBoxH); - const float radius = getCoordLength (xml.getStringAttribute ("r"), viewBoxW); + const float cx = getCoordLength (xml, "cx", viewBoxW); + const float cy = getCoordLength (xml, "cy", viewBoxH); + const float radius = getCoordLength (xml, "r", viewBoxW); circle.addEllipse (cx - radius, cy - radius, radius * 2.0f, radius * 2.0f); @@ -454,10 +461,10 @@ private: { Path ellipse; - const float cx = getCoordLength (xml.getStringAttribute ("cx"), viewBoxW); - const float cy = getCoordLength (xml.getStringAttribute ("cy"), viewBoxH); - const float radiusX = getCoordLength (xml.getStringAttribute ("rx"), viewBoxW); - const float radiusY = getCoordLength (xml.getStringAttribute ("ry"), viewBoxH); + const float cx = getCoordLength (xml, "cx", viewBoxW); + const float cy = getCoordLength (xml, "cy", viewBoxH); + const float radiusX = getCoordLength (xml, "rx", viewBoxW); + const float radiusY = getCoordLength (xml, "ry", viewBoxH); ellipse.addEllipse (cx - radiusX, cy - radiusY, radiusX * 2.0f, radiusY * 2.0f); @@ -468,10 +475,10 @@ private: { Path line; - const float x1 = getCoordLength (xml.getStringAttribute ("x1"), viewBoxW); - const float y1 = getCoordLength (xml.getStringAttribute ("y1"), viewBoxH); - const float x2 = getCoordLength (xml.getStringAttribute ("x2"), viewBoxW); - const float y2 = getCoordLength (xml.getStringAttribute ("y2"), viewBoxH); + const float x1 = getCoordLength (xml, "x1", viewBoxW); + const float y1 = getCoordLength (xml, "y1", viewBoxH); + const float x2 = getCoordLength (xml, "x2", viewBoxW); + const float y2 = getCoordLength (xml, "y2", viewBoxH); line.startNewSubPath (x1, y1); line.lineTo (x2, y2); @@ -615,7 +622,7 @@ private: jassert (gradient.getNumColours() > 0); - gradient.isRadial = fillXml->hasTagName ("radialGradient"); + gradient.isRadial = fillXml->hasTagNameIgnoringNamespace ("radialGradient"); float gradientWidth = viewBoxW; float gradientHeight = viewBoxH; @@ -659,10 +666,10 @@ private: } else { - gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x1", "0%"), 1.0f), + gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x1", "0%"), 1.0f), dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y1", "0%"), 1.0f)); - gradient.point2.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x2", "100%"), 1.0f), + gradient.point2.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x2", "100%"), 1.0f), dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y2", "0%"), 1.0f)); } @@ -671,8 +678,34 @@ private: } FillType type (gradient); - type.transform = parseTransform (fillXml->getStringAttribute ("gradientTransform")) - .followedBy (transform); + + const AffineTransform gradientTransform (parseTransform (fillXml->getStringAttribute ("gradientTransform")) + .followedBy (transform)); + + if (gradient.isRadial) + { + type.transform = gradientTransform; + } + else + { + // Transform the perpendicular vector into the new coordinate space for the gradient. + // This vector is now the slope of the linear gradient as it should appear in the new coord space + const Point<float> perpendicular (Point<float> (gradient.point2.y - gradient.point1.y, + gradient.point1.x - gradient.point2.x) + .transformedBy (gradientTransform.withAbsoluteTranslation (0, 0))); + + const Point<float> newGradPoint1 (gradient.point1.transformedBy (gradientTransform)); + const Point<float> newGradPoint2 (gradient.point2.transformedBy (gradientTransform)); + + // Project the transformed gradient vector onto the transformed slope of the linear + // gradient as it should appear in the new coordinate space + const float scale = perpendicular.getDotProduct (newGradPoint2 - newGradPoint1) + / perpendicular.getDotProduct (perpendicular); + + type.gradient->point1 = newGradPoint1; + type.gradient->point2 = newGradPoint2 - perpendicular * scale; + } + return type; } @@ -680,7 +713,7 @@ private: const String& fill, const String& fillOpacity, const String& overallOpacity, - const Colour& defaultColour) const + const Colour defaultColour) const { float opacity = 1.0f; @@ -696,7 +729,8 @@ private: .upToLastOccurrenceOf (")", false, false).trim()); if (const XmlElement* const fillXml = findElementForId (topLevelXml, id)) - if (fillXml->hasTagName ("linearGradient") || fillXml->hasTagName ("radialGradient")) + if (fillXml->hasTagNameIgnoringNamespace ("linearGradient") + || fillXml->hasTagNameIgnoringNamespace ("radialGradient")) return getGradientFillType (fillXml, path, opacity); } @@ -762,7 +796,7 @@ private: Drawable* s = parseShape (*e, path); delete s; // xxx not finished! } - else if (e->hasTagName ("tspan")) + else if (e->hasTagNameIgnoringNamespace ("tspan")) { Drawable* s = parseText (*e); delete s; // xxx not finished! @@ -831,6 +865,11 @@ private: return n; } + float getCoordLength (const XmlElement& xml, const char* attName, const float sizeForProportions) const + { + return getCoordLength (xml.getStringAttribute (attName), sizeForProportions); + } + void getCoordList (Array <float>& coords, const String& list, const bool allowUnits, const bool isX) const { @@ -1005,7 +1044,7 @@ private: } //============================================================================== - static Colour parseColour (const String& s, int& index, const Colour& defaultColour) + static Colour parseColour (const String& s, int& index, const Colour defaultColour) { if (s [index] == '#') { @@ -1031,9 +1070,10 @@ private: (uint8) ((hex [2] << 4) + hex [3]), (uint8) ((hex [4] << 4) + hex [5])); } - else if (s [index] == 'r' - && s [index + 1] == 'g' - && s [index + 2] == 'b') + + if (s [index] == 'r' + && s [index + 1] == 'g' + && s [index + 2] == 'b') { const int openBracket = s.indexOfChar (index, '('); const int closeBracket = s.indexOfChar (openBracket, ')'); @@ -1228,3 +1268,11 @@ Drawable* Drawable::createFromSVG (const XmlElement& svgDocument) SVGState state (&svgDocument); return state.parseSVGElement (svgDocument); } + +Path Drawable::parseSVGPath (const String& svgPath) +{ + SVGState state (nullptr); + Path p; + state.parsePathString (p, svgPath); + return p; +} diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp index addfcc327..265df8312 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h index 301811232..478d9594c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index 28d3b3164..59545a446 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -232,8 +231,8 @@ int DirectoryContentsList::compareElements (const DirectoryContentsList::FileInf bool DirectoryContentsList::addFile (const File& file, const bool isDir, const int64 fileSize, - const Time& modTime, - const Time& creationTime, + const Time modTime, + const Time creationTime, const bool isReadOnly) { if (fileFilter == nullptr diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h index 9866bcd21..2c12fd61d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -206,8 +205,8 @@ private: void changed(); bool checkNextFile (bool& hasChanged); bool addFile (const File& file, bool isDir, - const int64 fileSize, const Time& modTime, - const Time& creationTime, bool isReadOnly); + const int64 fileSize, const Time modTime, + const Time creationTime, bool isReadOnly); void setTypeFlags (int newFlags); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryContentsList) diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index f2c9f898c..e6667223c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -102,7 +101,7 @@ FileBrowserComponent::FileBrowserComponent (int flags_, addAndMakeVisible (goUpButton = getLookAndFeel().createFileBrowserGoUpButton()); goUpButton->addListener (this); - goUpButton->setTooltip (TRANS ("go up to parent directory")); + goUpButton->setTooltip (TRANS ("Go up to parent directory")); if (previewComp != nullptr) addAndMakeVisible (previewComp); @@ -310,7 +309,7 @@ String FileBrowserComponent::getActionVerb() const void FileBrowserComponent::setFilenameBoxLabel (const String& name) { - fileLabel.setText (name, false); + fileLabel.setText (name, dontSendNotification); } FilePreviewComponent* FileBrowserComponent::getPreviewComponent() const noexcept @@ -523,7 +522,7 @@ void FileBrowserComponent::getRoots (StringArray& rootNames, StringArray& rootPa } else if (drive.isOnCDRomDrive()) { - name << TRANS(" [CD/DVD drive]"); + name << " [" << TRANS("CD/DVD drive") << ']'; } rootNames.add (name); diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h index aa2aa3a33..10140b715 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -68,7 +67,8 @@ public: conjuction with canSelectFiles). */ canSelectMultipleItems = 16, /**< specifies that the user can select multiple items. */ useTreeView = 32, /**< specifies that a tree-view should be shown instead of a file list. */ - filenameBoxIsReadOnly = 64 /**< specifies that the user can't type directly into the filename box. */ + filenameBoxIsReadOnly = 64, /**< specifies that the user can't type directly into the filename box. */ + warnAboutOverwriting = 128 /**< specifies that the dialog should warn about overwriting existing files (if possible). */ }; //============================================================================== diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h index ad26be4fb..1c83fbb63 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp index 64e531f13..01c8b32d2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -26,81 +25,88 @@ FileChooser::FileChooser (const String& chooserBoxTitle, const File& currentFileOrDirectory, const String& fileFilters, - const bool useNativeDialogBox_) + const bool useNativeBox) : title (chooserBoxTitle), filters (fileFilters), startingFile (currentFileOrDirectory), - useNativeDialogBox (useNativeDialogBox_) + useNativeDialogBox (useNativeBox && isPlatformDialogAvailable()) { - if (useNativeDialogBox) - { - static bool canUseNativeBox = isPlatformDialogAvailable(); - if (! canUseNativeBox) - useNativeDialogBox = false; - } - if (! fileFilters.containsNonWhitespaceChars()) filters = "*"; } -FileChooser::~FileChooser() -{ -} +FileChooser::~FileChooser() {} #if JUCE_MODAL_LOOPS_PERMITTED -bool FileChooser::browseForFileToOpen (FilePreviewComponent* previewComponent) +bool FileChooser::browseForFileToOpen (FilePreviewComponent* previewComp) { - return showDialog (false, true, false, false, false, previewComponent); + return showDialog (FileBrowserComponent::openMode + | FileBrowserComponent::canSelectFiles, + previewComp); } -bool FileChooser::browseForMultipleFilesToOpen (FilePreviewComponent* previewComponent) +bool FileChooser::browseForMultipleFilesToOpen (FilePreviewComponent* previewComp) { - return showDialog (false, true, false, false, true, previewComponent); + return showDialog (FileBrowserComponent::openMode + | FileBrowserComponent::canSelectFiles + | FileBrowserComponent::canSelectMultipleItems, + previewComp); } -bool FileChooser::browseForMultipleFilesOrDirectories (FilePreviewComponent* previewComponent) +bool FileChooser::browseForMultipleFilesOrDirectories (FilePreviewComponent* previewComp) { - return showDialog (true, true, false, false, true, previewComponent); + return showDialog (FileBrowserComponent::openMode + | FileBrowserComponent::canSelectFiles + | FileBrowserComponent::canSelectDirectories + | FileBrowserComponent::canSelectMultipleItems, + previewComp); } -bool FileChooser::browseForFileToSave (const bool warnAboutOverwritingExistingFiles) +bool FileChooser::browseForFileToSave (const bool warnAboutOverwrite) { - return showDialog (false, true, true, warnAboutOverwritingExistingFiles, false, nullptr); + return showDialog (FileBrowserComponent::saveMode + | FileBrowserComponent::canSelectFiles + | (warnAboutOverwrite ? FileBrowserComponent::warnAboutOverwriting : 0), + nullptr); } bool FileChooser::browseForDirectory() { - return showDialog (true, false, false, false, false, nullptr); + return showDialog (FileBrowserComponent::openMode + | FileBrowserComponent::canSelectDirectories, + nullptr); } -bool FileChooser::showDialog (const bool selectsDirectories, - const bool selectsFiles, - const bool isSave, - const bool warnAboutOverwritingExistingFiles, - const bool selectMultipleFiles, - FilePreviewComponent* const previewComponent) +bool FileChooser::showDialog (const int flags, FilePreviewComponent* const previewComp) { WeakReference<Component> previouslyFocused (Component::getCurrentlyFocusedComponent()); results.clear(); // the preview component needs to be the right size before you pass it in here.. - jassert (previewComponent == nullptr || (previewComponent->getWidth() > 10 - && previewComponent->getHeight() > 10)); + jassert (previewComp == nullptr || (previewComp->getWidth() > 10 + && previewComp->getHeight() > 10)); + + const bool selectsDirectories = (flags & FileBrowserComponent::canSelectDirectories) != 0; + const bool selectsFiles = (flags & FileBrowserComponent::canSelectFiles) != 0; + const bool isSave = (flags & FileBrowserComponent::saveMode) != 0; + const bool warnAboutOverwrite = (flags & FileBrowserComponent::warnAboutOverwriting) != 0; + const bool selectMultiple = (flags & FileBrowserComponent::canSelectMultipleItems) != 0; + + // You've set the flags for both saveMode and openMode! + jassert (! (isSave && (flags & FileBrowserComponent::openMode) != 0)); #if JUCE_WINDOWS if (useNativeDialogBox && ! (selectsFiles && selectsDirectories)) #elif JUCE_MAC || JUCE_LINUX - if (useNativeDialogBox && (previewComponent == nullptr)) + if (useNativeDialogBox && (previewComp == nullptr)) #else if (false) #endif { showPlatformDialog (results, title, startingFile, filters, selectsDirectories, selectsFiles, isSave, - warnAboutOverwritingExistingFiles, - selectMultipleFiles, - previewComponent); + warnAboutOverwrite, selectMultiple, previewComp); } else { @@ -108,28 +114,10 @@ bool FileChooser::showDialog (const bool selectsDirectories, selectsDirectories ? "*" : String::empty, String::empty); - int flags = isSave ? FileBrowserComponent::saveMode - : FileBrowserComponent::openMode; - - if (selectsFiles) - flags |= FileBrowserComponent::canSelectFiles; - - if (selectsDirectories) - { - flags |= FileBrowserComponent::canSelectDirectories; - - if (! isSave) - flags |= FileBrowserComponent::filenameBoxIsReadOnly; - } - - if (selectMultipleFiles) - flags |= FileBrowserComponent::canSelectMultipleItems; - - FileBrowserComponent browserComponent (flags, startingFile, &wildcard, previewComponent); + FileBrowserComponent browserComponent (flags, startingFile, &wildcard, previewComp); FileChooserDialogBox box (title, String::empty, - browserComponent, - warnAboutOverwritingExistingFiles, + browserComponent, warnAboutOverwrite, browserComponent.findColour (AlertWindow::backgroundColourId)); if (box.show()) @@ -155,16 +143,6 @@ File FileChooser::getResult() const return results.getFirst(); } -const Array<File>& FileChooser::getResults() const -{ - return results; -} - //============================================================================== -FilePreviewComponent::FilePreviewComponent() -{ -} - -FilePreviewComponent::~FilePreviewComponent() -{ -} +FilePreviewComponent::FilePreviewComponent() {} +FilePreviewComponent::~FilePreviewComponent() {} diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.h index 474360789..0078f3af0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -143,6 +142,17 @@ public: */ bool browseForMultipleFilesOrDirectories (FilePreviewComponent* previewComponent = nullptr); + //============================================================================== + /** Runs a dialog box for the given set of option flags. + The flag values used are those in FileBrowserComponent::FileChooserFlags. + + @returns true if the user chose a directory and pressed 'ok', in which case, use + the getResult() method to find out what they chose. Returns false + if they cancelled instead. + @see FileBrowserComponent::FileChooserFlags + */ + bool showDialog (int flags, FilePreviewComponent* previewComponent); + //============================================================================== /** Returns the last file that was chosen by one of the browseFor methods. @@ -167,18 +177,14 @@ public: @see getResult */ - const Array<File>& getResults() const; + const Array<File>& getResults() const noexcept { return results; } private: //============================================================================== String title, filters; - File startingFile; + const File startingFile; Array<File> results; - bool useNativeDialogBox; - - bool showDialog (bool selectsDirectories, bool selectsFiles, bool isSave, - bool warnAboutOverwritingExistingFiles, bool selectMultipleFiles, - FilePreviewComponent* previewComponent); + const bool useNativeDialogBox; static void showPlatformDialog (Array<File>& results, const String& title, const File& file, const String& filters, bool selectsDirectories, bool selectsFiles, @@ -186,7 +192,7 @@ private: FilePreviewComponent* previewComponent); static bool isPlatformDialogAvailable(); - JUCE_LEAK_DETECTOR (FileChooser) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileChooser) }; diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp index 892d5b3e1..c1448135d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -26,14 +25,13 @@ class FileChooserDialogBox::ContentComponent : public Component { public: - //============================================================================== - ContentComponent (const String& name, const String& instructions_, FileBrowserComponent& chooserComponent_) + ContentComponent (const String& name, const String& desc, FileBrowserComponent& chooser) : Component (name), - chooserComponent (chooserComponent_), - okButton (chooserComponent_.getActionVerb()), + chooserComponent (chooser), + okButton (chooser.getActionVerb()), cancelButton (TRANS ("Cancel")), newFolderButton (TRANS ("New Folder")), - instructions (instructions_) + instructions (desc) { addAndMakeVisible (&chooserComponent); @@ -50,8 +48,8 @@ public: void paint (Graphics& g) { - g.setColour (getLookAndFeel().findColour (FileChooserDialogBox::titleTextColourId)); - text.draw (g); + text.draw (g, getLocalBounds().reduced (6) + .removeFromTop ((int) text.getHeight()).toFloat()); } void resized() @@ -60,9 +58,10 @@ public: Rectangle<int> area (getLocalBounds()); - getLookAndFeel().createFileChooserHeaderText (getName(), instructions, text, getWidth()); - const Rectangle<float> bb (text.getBoundingBox (0, text.getNumGlyphs(), false)); - area.removeFromTop (roundToInt (bb.getBottom()) + 10); + text.createLayout (getLookAndFeel().createFileChooserHeaderText (getName(), instructions), + getWidth() - 12.0f); + + area.removeFromTop (roundToInt (text.getHeight()) + 10); chooserComponent.setBounds (area.removeFromTop (area.getHeight() - buttonHeight - 20)); Rectangle<int> buttonArea (area.reduced (16, 10)); @@ -84,7 +83,7 @@ public: private: String instructions; - GlyphArrangement text; + TextLayout text; }; //============================================================================== @@ -209,12 +208,13 @@ void FileChooserDialogBox::okButtonPressed() && content->chooserComponent.getSelectedFile(0).exists()) { AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, - TRANS("File already exists"), - TRANS("There's already a file called:") - + "\n\n" + content->chooserComponent.getSelectedFile(0).getFullPathName() - + "\n\n" + TRANS("Are you sure you want to overwrite it?"), - TRANS("overwrite"), - TRANS("cancel"), + TRANS("File already exists"), + TRANS("There's already a file called: FLMN") + .replace ("FLNM", content->chooserComponent.getSelectedFile(0).getFullPathName()) + + "\n\n" + + TRANS("Are you sure you want to overwrite it?"), + TRANS("Overwrite"), + TRANS("Cancel"), this, ModalCallbackFunction::forComponent (okToOverwriteFileCallback, this)); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h index 50f51865f..2969ff22f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileFilter.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileFilter.cpp index 25a5486d2..d72309b8d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileFilter.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileFilter.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileFilter.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileFilter.h index 6a80af58a..65a65c008 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileFilter.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileFilter.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp index afa08a651..f5d3dc648 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h index 68558cdd5..7a7d34666 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h index 52917e2fd..5525d732b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp index 2232c3f4a..2840480dd 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h index 3d88846c8..2ec505a05 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index cd32ae796..98c6b6c41 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -32,22 +31,22 @@ class FileListTreeItem : public TreeViewItem, private ChangeListener { public: - FileListTreeItem (FileTreeComponent& owner_, - DirectoryContentsList* const parentContentsList_, - const int indexInContentsList_, - const File& file_, - TimeSliceThread& thread_) - : file (file_), - owner (owner_), - parentContentsList (parentContentsList_), - indexInContentsList (indexInContentsList_), + FileListTreeItem (FileTreeComponent& treeComp, + DirectoryContentsList* const parentContents, + const int indexInContents, + const File& f, + TimeSliceThread& t) + : file (f), + owner (treeComp), + parentContentsList (parentContents), + indexInContentsList (indexInContents), subContentsList (nullptr, false), - thread (thread_) + thread (t) { DirectoryContentsList::FileInfo fileInfo; - if (parentContentsList_ != nullptr - && parentContentsList_->getFileInfo (indexInContentsList_, fileInfo)) + if (parentContents != nullptr + && parentContents->getFileInfo (indexInContents, fileInfo)) { fileSize = File::descriptionOfSizeInBytes (fileInfo.fileSize); modTime = fileInfo.modificationTime.formatted ("%d %b '%y %H:%M"); @@ -63,6 +62,7 @@ public: { thread.removeTimeSliceClient (this); clearSubItems(); + removeSubContentsList(); } //============================================================================== @@ -97,8 +97,19 @@ public: } } + void removeSubContentsList() + { + if (subContentsList != nullptr) + { + subContentsList->removeChangeListener (this); + subContentsList.clear(); + } + } + void setSubContentsList (DirectoryContentsList* newList, const bool canDeleteList) { + removeSubContentsList(); + OptionalScopedPointer<DirectoryContentsList> newPointer (newList, canDeleteList); subContentsList = newPointer; newList->addChangeListener (this); diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h index a706b6cb7..69f61c376 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp index a38c4a6fd..c2eec28a9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -60,7 +59,7 @@ void FilenameComponent::paintOverChildren (Graphics& g) if (isFileDragOver) { g.setColour (Colours::red.withAlpha (0.2f)); - g.drawRect (0, 0, getWidth(), getHeight(), 3); + g.drawRect (getLocalBounds(), 3); } } diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h index 4b1ca94e9..8ac09c455 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -111,6 +110,7 @@ public: /** Changes the current filename. + @param newFile the new filename to use @param addToRecentlyUsedList if true, the filename will also be added to the drop-down list of recent files. @param notification whether to send a notification of the change to listeners diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp index 4a664d61e..808968397 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -62,13 +61,11 @@ void ImagePreviewComponent::timerCallback() currentDetails = String::empty; repaint(); - ScopedPointer <FileInputStream> in (fileToLoad.createInputStream()); + ScopedPointer<FileInputStream> in (fileToLoad.createInputStream()); if (in != nullptr) { - ImageFileFormat* const format = ImageFileFormat::findImageFormatForStream (*in); - - if (format != nullptr) + if (ImageFileFormat* const format = ImageFileFormat::findImageFormatForStream (*in)) { currentThumbnail = format->decodeImage (*in); diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h index 793093676..10b643aec 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_WildcardFileFilter.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_WildcardFileFilter.cpp index fa3c220f5..a28850706 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_WildcardFileFilter.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_WildcardFileFilter.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_WildcardFileFilter.h b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_WildcardFileFilter.h index 28336c281..b51f84acc 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_WildcardFileFilter.h +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_WildcardFileFilter.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.cpp b/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.cpp index e774594b1..e583c7213 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h b/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h index d5e2cd073..cc9d698ad 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h +++ b/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.mm b/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.mm index 4c918c7b5..fd6808c65 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/juce_module_info b/JuceLibraryCode/modules/juce_gui_basics/juce_module_info index 2ec4d00ee..c7591f972 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/juce_module_info +++ b/JuceLibraryCode/modules/juce_gui_basics/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_gui_basics", "name": "JUCE GUI core classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Basic user-interface components and related classes.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp index 26c0faec8..03c5c56c2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_CaretComponent.h b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_CaretComponent.h index 114911a23..05b98c97b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_CaretComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_CaretComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp index 08cd4b1c1..76ea68661 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyListener.h b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyListener.h index 5974b285b..25e4d614c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyListener.h +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyListener.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp index b918da235..98b9b12f1 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -29,17 +28,16 @@ KeyPress::KeyPress() noexcept { } -KeyPress::KeyPress (const int keyCode_, - const ModifierKeys& mods_, - const juce_wchar textCharacter_) noexcept - : keyCode (keyCode_), - mods (mods_), - textCharacter (textCharacter_) +KeyPress::KeyPress (const int code, ModifierKeys m, + const juce_wchar textChar) noexcept + : keyCode (code), + mods (m), + textCharacter (textChar) { } -KeyPress::KeyPress (const int keyCode_) noexcept - : keyCode (keyCode_), +KeyPress::KeyPress (const int code) noexcept + : keyCode (code), textCharacter (0) { } diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyPress.h b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyPress.h index 532fe9f00..91c6c954b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyPress.h +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyPress.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -67,7 +66,7 @@ public: @see getKeyCode, isKeyCode, getModifiers */ KeyPress (int keyCode, - const ModifierKeys& modifiers, + ModifierKeys modifiers, juce_wchar textCharacter) noexcept; /** Creates a keypress with a keyCode but no modifiers or text character. */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp index 0ba366d09..b84e9038c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h index 32446c51f..e477ab01b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp index 476a6fde1..827860b3e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -38,7 +37,7 @@ ModifierKeys::ModifierKeys (const ModifierKeys& other) noexcept { } -ModifierKeys& ModifierKeys::operator= (const ModifierKeys& other) noexcept +ModifierKeys& ModifierKeys::operator= (const ModifierKeys other) noexcept { flags = other.flags; return *this; diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h index 23cc8831a..c7b21fb9c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -55,7 +54,7 @@ public: ModifierKeys (const ModifierKeys& other) noexcept; /** Copies this object from another one. */ - ModifierKeys& operator= (const ModifierKeys& other) noexcept; + ModifierKeys& operator= (const ModifierKeys other) noexcept; //============================================================================== /** Checks whether the 'command' key flag is set (or 'ctrl' on Windows/Linux). @@ -167,8 +166,8 @@ public: /** Returns a copy of only the non-mouse flags */ ModifierKeys withoutMouseButtons() const noexcept { return ModifierKeys (flags & ~allMouseButtonModifiers); } - bool operator== (const ModifierKeys& other) const noexcept { return flags == other.flags; } - bool operator!= (const ModifierKeys& other) const noexcept { return flags != other.flags; } + bool operator== (const ModifierKeys other) const noexcept { return flags == other.flags; } + bool operator!= (const ModifierKeys other) const noexcept { return flags != other.flags; } //============================================================================== /** Returns the raw flags for direct testing. */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h index ae7192b60..aa6e006a5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h index e2f6d5492..fad5bac61 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h index 192368cbd..b277d45f2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index dad6fd06b..4ad50cdd7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.h index 8a9bb9436..ea00ca92f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp index 4ecfd3b42..4f1fd4a52 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h index 5c8c04c2e..4317e7ff9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp index 9ef37913a..b91a10ca7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.h index 79b78c171..7f8ab5dea 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp index fc0e658bb..97c20a149 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp @@ -1,33 +1,32 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ -ComponentMovementWatcher::ComponentMovementWatcher (Component* const component_) - : component (component_), +ComponentMovementWatcher::ComponentMovementWatcher (Component* const comp) + : component (comp), lastPeerID (0), reentrant (false), - wasShowing (component_->isShowing()) + wasShowing (comp->isShowing()) { jassert (component != nullptr); // can't use this with a null pointer.. diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h index f4ff70653..35eed40c9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp index 5d082d67d..b5440029d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h index 598728bc9..626e7861a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_GroupComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_GroupComponent.cpp index da6077023..481a071e3 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_GroupComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_GroupComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_GroupComponent.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_GroupComponent.h index 7f0674a17..fae94748a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_GroupComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_GroupComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp index c19f34b8a..434c82d43 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h index e84c8495f..fdaf50be6 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp index 3755ed7a1..ea05c3a7b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -46,7 +45,7 @@ bool ResizableBorderComponent::Zone::operator!= (const ResizableBorderComponent: ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBorder (const Rectangle<int>& totalSize, const BorderSize<int>& border, - const Point<int>& position) + Point<int> position) { int z = 0; diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h index c1e6627de..8129147a1 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -121,7 +120,7 @@ public: */ static Zone fromPositionOnBorder (const Rectangle<int>& totalSize, const BorderSize<int>& border, - const Point<int>& position); + Point<int> position); /** Returns an appropriate mouse-cursor for this resize zone. */ MouseCursor getMouseCursor() const noexcept; diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp index 57ee61b02..1e04c481a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h index 2791153c3..a18eac423 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp index 7c1683ad3..739c25cfd 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h index bff56d5e9..c8cdfa224 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index 49d90bc98..534ff9bfa 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -79,7 +78,7 @@ ScrollBar::~ScrollBar() } //============================================================================== -void ScrollBar::setRangeLimits (const Range<double>& newRangeLimit, NotificationType notification) +void ScrollBar::setRangeLimits (Range<double> newRangeLimit, NotificationType notification) { if (totalRange != newRangeLimit) { @@ -95,7 +94,7 @@ void ScrollBar::setRangeLimits (const double newMinimum, const double newMaximum setRangeLimits (Range<double> (newMinimum, newMaximum), notification); } -bool ScrollBar::setCurrentRange (const Range<double>& newRange, +bool ScrollBar::setCurrentRange (Range<double> newRange, const NotificationType notification) { const Range<double> constrainedRange (totalRange.constrainRange (newRange)); diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.h index 8c3fab1b3..1e875c611 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -99,7 +98,7 @@ public: @see setCurrentRange */ - void setRangeLimits (const Range<double>& newRangeLimit, + void setRangeLimits (Range<double> newRangeLimit, NotificationType notification = sendNotificationAsync); /** Sets the minimum and maximum values that the bar will move between. @@ -145,7 +144,7 @@ public: @returns true if the range was changed, or false if nothing was changed. @see getCurrentRange. setCurrentRangeStart */ - bool setCurrentRange (const Range<double>& newRange, + bool setCurrentRange (Range<double> newRange, NotificationType notification = sendNotificationAsync); /** Changes the position of the scrollbar's 'thumb'. diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp index 934dca24b..ee7ff1478 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h index 82a09fe17..862256ead 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp index fb26d0dcc..10bd717af 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h index 507b4198b..cf500aab5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp index ca1fc47d8..08d04df22 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h index cf46ce766..e8bcb864a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index cfd9c880f..78da7c5d7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h index e9d3c66b5..5cfb4d405 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp index 208fda1c1..4e1a065a2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.h index 0937912e4..11ac0da25 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.cpp index 889f558fb..4a42a9d92 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -98,7 +97,7 @@ void Viewport::setViewedComponent (Component* const newViewedComponent, const bo int Viewport::getMaximumVisibleWidth() const { return contentHolder.getWidth(); } int Viewport::getMaximumVisibleHeight() const { return contentHolder.getHeight(); } -Point<int> Viewport::viewportPosToCompPos (const Point<int>& pos) const +Point<int> Viewport::viewportPosToCompPos (Point<int> pos) const { jassert (contentComp != nullptr); return Point<int> (jmax (jmin (0, contentHolder.getWidth() - contentComp->getWidth()), jmin (0, -(pos.x))), @@ -110,7 +109,7 @@ void Viewport::setViewPosition (const int xPixelsOffset, const int yPixelsOffset setViewPosition (Point<int> (xPixelsOffset, yPixelsOffset)); } -void Viewport::setViewPosition (const Point<int>& newPosition) +void Viewport::setViewPosition (Point<int> newPosition) { if (contentComp != nullptr) contentComp->setTopLeftPosition (viewportPosToCompPos (newPosition)); @@ -350,7 +349,7 @@ void Viewport::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whe bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, const MouseWheelDetails& wheel) { - if (! (e.mods.isAltDown() || e.mods.isCtrlDown())) + if (! (e.mods.isAltDown() || e.mods.isCtrlDown() || e.mods.isCommandDown())) { const bool hasVertBar = verticalScrollBar.isVisible(); const bool hasHorzBar = horizontalScrollBar.isVisible(); diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.h index 21b6f1434..146cf05fc 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -106,7 +105,7 @@ public: @see getViewPositionX, getViewPositionY, setViewPositionProportionately */ - void setViewPosition (const Point<int>& newPosition); + void setViewPosition (Point<int> newPosition); /** Changes the view position as a proportion of the distance it can move. @@ -136,7 +135,7 @@ public: /** Returns the position within the child component of the top-left of its visible area. */ - const Point<int>& getViewPosition() const noexcept { return lastVisibleArea.getPosition(); } + Point<int> getViewPosition() const noexcept { return lastVisibleArea.getPosition(); } /** Returns the position within the child component of the top-left of its visible area. @see getViewWidth, setViewPosition @@ -240,7 +239,7 @@ public: /** @internal */ void resized(); /** @internal */ - void scrollBarMoved (ScrollBar* scrollBarThatHasMoved, double newRangeStart); + void scrollBarMoved (ScrollBar*, double newRangeStart); /** @internal */ void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); /** @internal */ @@ -260,7 +259,7 @@ private: Component contentHolder; ScrollBar verticalScrollBar; ScrollBar horizontalScrollBar; - Point<int> viewportPosToCompPos (const Point<int>&) const; + Point<int> viewportPosToCompPos (Point<int>) const; void updateVisibleArea(); void deleteContentComp(); diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index 74478f00f..d0e0c8058 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -1603,6 +1602,19 @@ ImageEffectFilter* LookAndFeel::getSliderEffect() return nullptr; } +Font LookAndFeel::getSliderPopupFont() +{ + return Font (15.0f, Font::bold); +} + +int LookAndFeel::getSliderPopupPlacement() +{ + return BubbleComponent::above + | BubbleComponent::below + | BubbleComponent::left + | BubbleComponent::right; +} + //============================================================================== void LookAndFeel::getTooltipSize (const String& tipText, int& width, int& height) { @@ -2179,12 +2191,6 @@ void LookAndFeel::drawTabButtonText (TabBarButton& button, Graphics& g, bool isM Font font (depth * 0.6f); font.setUnderline (button.hasKeyboardFocus (false)); - GlyphArrangement textLayout; - textLayout.addFittedText (font, button.getButtonText().trim(), - 0.0f, 0.0f, (float) length, (float) depth, - Justification::centred, - jmax (1, ((int) depth) / 12)); - AffineTransform t; switch (button.getTabbedButtonBar().getOrientation()) @@ -2210,7 +2216,13 @@ void LookAndFeel::drawTabButtonText (TabBarButton& button, Graphics& g, bool isM const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f; g.setColour (col.withMultipliedAlpha (alpha)); - textLayout.draw (g, t); + g.setFont (font); + g.addTransform (t); + + g.drawFittedText (button.getButtonText().trim(), + 0, 0, (int) length, (int) depth, + Justification::centred, + jmax (1, ((int) depth) / 12)); } void LookAndFeel::drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) @@ -2491,20 +2503,17 @@ void LookAndFeel::drawCallOutBoxBackground (CallOutBox& box, Graphics& g, //============================================================================== -void LookAndFeel::createFileChooserHeaderText (const String& title, - const String& instructions, - GlyphArrangement& text, - int width) +AttributedString LookAndFeel::createFileChooserHeaderText (const String& title, + const String& instructions) { - text.clear(); + AttributedString s; + s.setJustification (Justification::centred); - text.addJustifiedText (Font (17.0f, Font::bold), title, - 8.0f, 22.0f, width - 16.0f, - Justification::centred); + const Colour colour (findColour (FileChooserDialogBox::titleTextColourId)); + s.append (title + "\n\n", Font (17.0f, Font::bold), colour); + s.append (instructions, Font (14.0f), colour); - text.addJustifiedText (Font (14.0f), instructions, - 8.0f, 24.0f + 16.0f, width - 16.0f, - Justification::centred); + return s; } void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height, @@ -2514,10 +2523,13 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height, const bool isDirectory, const bool isItemSelected, const int /*itemIndex*/, - DirectoryContentsDisplayComponent&) + DirectoryContentsDisplayComponent& dcc) { + Component* const fileListComp = dynamic_cast<Component*> (&dcc); + if (isItemSelected) - g.fillAll (findColour (DirectoryContentsDisplayComponent::highlightColourId)); + g.fillAll (fileListComp != nullptr ? fileListComp->findColour (DirectoryContentsDisplayComponent::highlightColourId) + : findColour (DirectoryContentsDisplayComponent::highlightColourId)); const int x = 32; g.setColour (Colours::black); @@ -2536,7 +2548,8 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height, RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); } - g.setColour (findColour (DirectoryContentsDisplayComponent::textColourId)); + g.setColour (fileListComp != nullptr ? fileListComp->findColour (DirectoryContentsDisplayComponent::textColourId) + : findColour (DirectoryContentsDisplayComponent::textColourId)); g.setFont (height * 0.7f); if (width > 450 && ! isDirectory) @@ -2616,10 +2629,12 @@ void LookAndFeel::layoutFileBrowserComponent (FileBrowserComponent& browserComp, y += controlsHeight + 4; - Component* const listAsComp = dynamic_cast <Component*> (fileListComponent); - listAsComp->setBounds (x, y, w, browserComp.getHeight() - y - bottomSectionHeight); + if (Component* const listAsComp = dynamic_cast <Component*> (fileListComponent)) + { + listAsComp->setBounds (x, y, w, browserComp.getHeight() - y - bottomSectionHeight); + y = listAsComp->getBottom() + 4; + } - y = listAsComp->getBottom() + 4; filenameBox->setBounds (x + 50, y, w - 50, controlsHeight); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h index 9e10e6f24..a2b793ef6 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -312,10 +311,8 @@ public: virtual const Drawable* getDefaultFolderImage(); virtual const Drawable* getDefaultDocumentFileImage(); - virtual void createFileChooserHeaderText (const String& title, - const String& instructions, - GlyphArrangement& destArrangement, - int width); + virtual AttributedString createFileChooserHeaderText (const String& title, + const String& instructions); virtual void drawFileBrowserRow (Graphics& g, int width, int height, const String& filename, Image* icon, @@ -453,6 +450,9 @@ public: virtual ImageEffectFilter* getSliderEffect(); + virtual Font getSliderPopupFont(); + virtual int getSliderPopupPlacement(); + //============================================================================== virtual void getTooltipSize (const String& tipText, int& width, int& height); @@ -674,6 +674,7 @@ private: virtual int getTabButtonBestWidth (int, const String&, int, Button&) { return 0; } virtual int drawBubble (Graphics&, float, float, float, float, float, float) { return 0; } virtual int getFontForTextButton (TextButton&) { return 0; } + virtual int createFileChooserHeaderText (const String&, const String&, GlyphArrangement&, int) { return 0; } #endif class GlassWindowButton; diff --git a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp index faa044c9d..5a22fc7a4 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -110,7 +109,7 @@ void MenuBarComponent::resized() } } -int MenuBarComponent::getItemAt (const Point<int>& p) +int MenuBarComponent::getItemAt (Point<int> p) { for (int i = 0; i < xPositions.size(); ++i) if (p.x >= xPositions[i] && p.x < xPositions[i + 1]) @@ -157,7 +156,7 @@ void MenuBarComponent::setOpenItem (int index) } } -void MenuBarComponent::updateItemUnderMouse (const Point<int>& p) +void MenuBarComponent::updateItemUnderMouse (Point<int> p) { setItemUnderMouse (getItemAt (p)); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.h b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.h index e40a2aba3..d8ca2a42d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -108,10 +107,10 @@ private: Point<int> lastMousePos; int itemUnderMouse, currentPopupIndex, topLevelIndexClicked; - int getItemAt (const Point<int>&); + int getItemAt (Point<int>); void setItemUnderMouse (int index); void setOpenItem (int index); - void updateItemUnderMouse (const Point<int>&); + void updateItemUnderMouse (Point<int>); void timerCallback(); void repaintMenuItem (int index); void menuDismissed (int topLevelIndex, int itemId); diff --git a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp index 599ebd67e..c72de960b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarModel.h b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarModel.h index a8c19267e..68846db4e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarModel.h +++ b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarModel.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 5aa0443e4..5a5621863 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -1,28 +1,39 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ +//============================================================================== +namespace PopupMenuSettings +{ + const int scrollZone = 24; + const int borderSize = 2; + const int timerInterval = 50; + const int dismissCommandId = 0x6287345f; + const int sectionHeaderID = 0x4734a34f; + + static bool menuWasHiddenBecauseOfAppChange = false; +} + class PopupMenu::Item { public: @@ -35,7 +46,7 @@ public: const bool active, const bool ticked, const Image& im, - const Colour& colour, + const Colour colour, const bool useColour, CustomComponent* const custom, const PopupMenu* const sub, @@ -87,7 +98,7 @@ public: commandManager (other.commandManager) {} - bool canBeTriggered() const noexcept { return isActive && itemID != 0; } + bool canBeTriggered() const noexcept { return isActive && itemID != 0 && itemID != PopupMenuSettings::sectionHeaderID; } bool hasActiveSubMenu() const noexcept { return isActive && subMenu != nullptr && subMenu->items.size() > 0; } //============================================================================== @@ -199,17 +210,6 @@ private: }; -//============================================================================== -namespace PopupMenuSettings -{ - const int scrollZone = 24; - const int borderSize = 2; - const int timerInterval = 50; - const int dismissCommandId = 0x6287345f; - - static bool menuWasHiddenBecauseOfAppChange = false; -} - //============================================================================== class PopupMenu::Window : public Component, private Timer @@ -563,7 +563,7 @@ private: && (isOver || (activeSubMenu != nullptr && activeSubMenu->isOverChildren())); } - void updateMouseOverStatus (const Point<int>& globalMousePos) + void updateMouseOverStatus (Point<int> globalMousePos) { isOver = reallyContains (getLocalPoint (nullptr, globalMousePos), true); @@ -738,12 +738,12 @@ private: for (int col = 0; col < numColumns; ++col) { - int i, colW = options.standardHeight, colH = 0; + int colW = options.standardHeight, colH = 0; const int numChildren = jmin (items.size() - childNum, (items.size() + numColumns - 1) / numColumns); - for (i = numChildren; --i >= 0;) + for (int i = numChildren; --i >= 0;) { colW = jmax (colW, items.getUnchecked (childNum + i)->getWidth()); colH += items.getUnchecked (childNum + i)->getHeight(); @@ -929,7 +929,7 @@ private: return false; } - void highlightItemUnderMouse (const Point<int>& globalMousePos, const Point<int>& localMousePos, const uint32 timeNow) + void highlightItemUnderMouse (Point<int> globalMousePos, Point<int> localMousePos, const uint32 timeNow) { if (globalMousePos != lastMousePos || timeNow > lastMouseMoveTime + 350) { @@ -1005,7 +1005,7 @@ private: } } - void checkButtonState (const Point<int>& localMousePos, const uint32 timeNow, + void checkButtonState (Point<int> localMousePos, const uint32 timeNow, const bool wasDown, const bool overScrollArea, const bool isOverAny) { isDown = hasBeenOver @@ -1053,26 +1053,22 @@ private: void selectNextItem (const int delta) { disableTimerUntilMouseMoves(); - PopupMenu::ItemComponent* mic = nullptr; - bool wasLastOne = (currentChild == nullptr); - const int numItems = items.size(); - - for (int i = 0; i < numItems + 1; ++i) - { - int index = (delta > 0) ? i : (numItems - 1 - i); - index = (index + numItems) % numItems; - mic = items.getUnchecked (index); + int start = jmax (0, items.indexOf (currentChild)); - if (mic != nullptr && (mic->itemInfo.canBeTriggered() || mic->itemInfo.hasActiveSubMenu()) - && wasLastOne) - break; + for (int i = items.size(); --i >= 0;) + { + start += delta; - if (mic == currentChild) - wasLastOne = true; + if (PopupMenu::ItemComponent* mic = items.getUnchecked ((start + items.size()) % items.size())) + { + if (mic->itemInfo.canBeTriggered() || mic->itemInfo.hasActiveSubMenu()) + { + setCurrentlyHighlightedChild (mic); + break; + } + } } - - setCurrentlyHighlightedChild (mic); } void disableTimerUntilMouseMoves() @@ -1087,7 +1083,7 @@ private: bool isTopScrollZoneActive() const noexcept { return canScroll() && childYOffset > 0; } bool isBottomScrollZoneActive() const noexcept { return canScroll() && childYOffset < contentHeight - windowPos.getHeight(); } - bool scrollIfNecessary (const Point<int>& localMousePos, const uint32 timeNow) + bool scrollIfNecessary (Point<int> localMousePos, const uint32 timeNow) { if (canScroll() && (isOver || (isDown && isPositiveAndBelow (localMousePos.x, getWidth())))) @@ -1213,7 +1209,7 @@ void PopupMenu::addCommandItem (ApplicationCommandManager* commandManager, void PopupMenu::addColouredItem (const int itemResultID, const String& itemText, - const Colour& itemTextColour, + Colour itemTextColour, const bool isActive, const bool isTicked, const Image& iconToUse) @@ -1330,7 +1326,7 @@ private: void PopupMenu::addSectionHeader (const String& title) { - addCustomItem (0X4734a34f, new HeaderItemComponent (title)); + addCustomItem (PopupMenuSettings::sectionHeaderID, new HeaderItemComponent (title)); } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.h b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.h index 4458f9444..60dda320b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.h +++ b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -146,20 +145,18 @@ public: */ void addColouredItem (int itemResultID, const String& itemText, - const Colour& itemTextColour, + Colour itemTextColour, bool isEnabled = true, bool isTicked = false, const Image& iconToUse = Image::null); /** Appends a custom menu item that can't be used to trigger a result. - This will add a user-defined component to use as a menu item. Unlike the - addCustomItem() method that takes a PopupMenu::CustomComponent, this version - can't trigger a result from it, so doesn't take a menu ID. It also doesn't - delete the component when it's finished, so it's the caller's responsibility - to manage the component that is passed-in. + This will add a user-defined component to use as a menu item. + It's the caller's responsibility to delete the component that is passed-in + when it's no longer needed after the menu has been hidden. - if triggerMenuItemAutomaticallyWhenClicked is true, the menu itself will handle + If triggerMenuItemAutomaticallyWhenClicked is true, the menu itself will handle detection of a mouse-click on your component, and use that to trigger the menu ID specified in itemResultID. If this is false, the menu item can't be triggered, so itemResultID is not used. diff --git a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp index f3a5a44b4..e0bddd44f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -60,7 +59,7 @@ void BubbleComponent::setPosition (Component* componentToPointTo) setPosition (componentToPointTo->getScreenBounds()); } -void BubbleComponent::setPosition (const Point<int>& pos) +void BubbleComponent::setPosition (Point<int> pos) { setPosition (Rectangle<int> (pos.x, pos.y, 1, 1)); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_BubbleComponent.h b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_BubbleComponent.h index 8fbb19c37..d38ddceb5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_BubbleComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_BubbleComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -108,7 +107,7 @@ public: on where there's the most space, honouring any restrictions that were set with setAllowedPlacement(). */ - void setPosition (const Point<int>& arrowTipPosition); + void setPosition (Point<int> arrowTipPosition); /** Moves and resizes the bubble to point at a given rectangle. diff --git a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.cpp b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.cpp index 8a779513c..eff3a0f79 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -95,9 +94,7 @@ void DropShadower::setOwner (Component* componentToFollow) jassert (componentToFollow != nullptr); owner = componentToFollow; - jassert (owner != nullptr); - jassert (owner->isOpaque()); // doesn't work properly for semi-transparent comps! updateParent(); owner->addComponentListener (this); @@ -175,7 +172,7 @@ void DropShadower::updateShadows() const int w = owner->getWidth(); const int h = owner->getHeight() + shadowEdge + shadowEdge; - for (int i = shadowWindows.size(); --i >= 0;) + for (int i = 4; --i >= 0;) { // there seem to be rare situations where the dropshadower may be deleted by // callbacks during this loop, so use a weak ref to watch out for this.. @@ -197,7 +194,7 @@ void DropShadower::updateShadows() } if (sw != nullptr) - sw->toBehind (owner); + sw->toBehind (i == 3 ? owner : shadowWindows.getUnchecked (i + 1)); if (sw == nullptr) return; diff --git a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.h b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.h index 077d74e86..e68b0649e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.h +++ b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp index fa11b8834..2cdb26e03 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_ComponentDragger.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_ComponentDragger.h index ed8d1d222..006182def 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_ComponentDragger.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_ComponentDragger.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp index 8c155abf9..5ea9865c6 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -37,7 +36,7 @@ public: Component* const sourceComponent, Component* const mouseDragSource_, DragAndDropContainer& owner_, - const Point<int>& imageOffset_) + Point<int> imageOffset_) : sourceDetails (desc, sourceComponent, Point<int>()), image (im), owner (owner_), @@ -121,7 +120,7 @@ public: updateLocation (true, e.getScreenPosition()); } - void updateLocation (const bool canDoExternalDrag, const Point<int>& screenPos) + void updateLocation (const bool canDoExternalDrag, Point<int> screenPos) { DragAndDropTarget::SourceDetails details (sourceDetails); @@ -187,7 +186,7 @@ private: return dynamic_cast <DragAndDropTarget*> (currentlyOverComp.get()); } - DragAndDropTarget* findTarget (const Point<int>& screenPos, Point<int>& relativePos, + DragAndDropTarget* findTarget (Point<int> screenPos, Point<int>& relativePos, Component*& resultComponent) const { Component* hit = getParentComponent(); @@ -220,7 +219,7 @@ private: return nullptr; } - void setNewScreenPos (const Point<int>& screenPos) + void setNewScreenPos (Point<int> screenPos) { Point<int> newPos (screenPos - imageOffset); @@ -253,7 +252,7 @@ private: bool canMoveFiles; }; - void checkForExternalDrag (DragAndDropTarget::SourceDetails& details, const Point<int>& screenPos) + void checkForExternalDrag (DragAndDropTarget::SourceDetails& details, Point<int> screenPos) { if (! hasCheckedForExternalDrag) { @@ -435,10 +434,10 @@ bool DragAndDropContainer::shouldDropFilesWhenDraggedExternally (const DragAndDr } //============================================================================== -DragAndDropTarget::SourceDetails::SourceDetails (const var& description_, Component* sourceComponent_, const Point<int>& localPosition_) noexcept - : description (description_), - sourceComponent (sourceComponent_), - localPosition (localPosition_) +DragAndDropTarget::SourceDetails::SourceDetails (const var& desc, Component* comp, Point<int> pos) noexcept + : description (desc), + sourceComponent (comp), + localPosition (pos) { } diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h index cd5a01bff..cd10fcc83 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h index ee70cf0a4..1409126a5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -59,7 +58,7 @@ public: /** Creates a SourceDetails object from its various settings. */ SourceDetails (const var& description, Component* sourceComponent, - const Point<int>& localPosition) noexcept; + Point<int> localPosition) noexcept; /** A descriptor for the drag - this is set DragAndDropContainer::startDragging(). */ var description; diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h index 200775aac..9beda95d3 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_LassoComponent.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_LassoComponent.h index 2f660d5f8..7bfc3a4cb 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_LassoComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_LassoComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp index 89664b007..7aef739f3 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -29,7 +28,7 @@ struct CustomMouseCursorInfo : image (im), hotspot (hsX, hsY), scaleFactor (1.0f) {} - CustomMouseCursorInfo (const Image& im, const Point<int>& hs, float scale) noexcept + CustomMouseCursorInfo (const Image& im, Point<int> hs, float scale) noexcept : image (im), hotspot (hs), scaleFactor (scale) {} @@ -54,7 +53,7 @@ public: { } - SharedCursorHandle (const Image& image, const Point<int>& hotSpot, const float scaleFactor) + SharedCursorHandle (const Image& image, Point<int> hotSpot, const float scaleFactor) : handle (CustomMouseCursorInfo (image, hotSpot, scaleFactor).create()), refCount (1), standardType (MouseCursor::NormalCursor), diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseCursor.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseCursor.h index 46592f29f..95eb30e9f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseCursor.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseCursor.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp index dfd0a63ec..03919e465 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp @@ -1,36 +1,35 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ MouseEvent::MouseEvent (MouseInputSource& inputSource, - const Point<int>& position, - const ModifierKeys& modKeys, + Point<int> position, + ModifierKeys modKeys, Component* const eventComp, Component* const originator, - const Time& time, - const Point<int>& downPos, - const Time& downTime, + Time time, + Point<int> downPos, + Time downTime, const int numClicks, const bool mouseWasDragged) noexcept : x (position.x), @@ -62,7 +61,7 @@ MouseEvent MouseEvent::getEventRelativeTo (Component* const otherComponent) cons mouseDownTime, numberOfClicks, wasMovedSinceMouseDown != 0); } -MouseEvent MouseEvent::withNewPosition (const Point<int>& newPosition) const noexcept +MouseEvent MouseEvent::withNewPosition (Point<int> newPosition) const noexcept { return MouseEvent (source, newPosition, mods, eventComponent, originalComponent, eventTime, mouseDownPos, mouseDownTime, diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseEvent.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseEvent.h index d66e56a50..4b5e829ab 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseEvent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseEvent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -62,13 +61,13 @@ public: @param mouseWasDragged whether the mouse has been dragged significantly since the previous mouse-down */ MouseEvent (MouseInputSource& source, - const Point<int>& position, - const ModifierKeys& modifiers, + Point<int> position, + ModifierKeys modifiers, Component* eventComponent, Component* originator, - const Time& eventTime, - const Point<int>& mouseDownPos, - const Time& mouseDownTime, + Time eventTime, + Point<int> mouseDownPos, + Time mouseDownTime, int numberOfClicks, bool mouseWasDragged) noexcept; @@ -290,7 +289,7 @@ public: All other members of the event object are the same, but the x and y are replaced with these new values. */ - MouseEvent withNewPosition (const Point<int>& newPosition) const noexcept; + MouseEvent withNewPosition (Point<int> newPosition) const noexcept; //============================================================================== /** Changes the application-wide setting for the double-click time limit. diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index 3faaa1717..56f7e8b82 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -42,7 +41,7 @@ public: Component* getComponentUnderMouse() const { - return static_cast <Component*> (componentUnderMouse); + return componentUnderMouse.get(); } ModifierKeys getCurrentModifiers() const @@ -58,7 +57,7 @@ public: return lastPeer; } - Component* findComponentAt (const Point<int>& screenPos) + Component* findComponentAt (Point<int> screenPos) { if (ComponentPeer* const peer = getPeer()) { @@ -82,51 +81,65 @@ public: } //============================================================================== - void sendMouseEnter (Component* const comp, const Point<int>& screenPos, const Time& time) + #if JUCE_DUMP_MOUSE_EVENTS + #define JUCE_MOUSE_EVENT_DBG(desc) DBG ("Mouse " desc << " #" << source.getIndex() \ + << ": " << comp->getLocalPoint (nullptr, screenPos).toString() \ + << " - Comp: " << String::toHexString ((int) comp)); + #else + #define JUCE_MOUSE_EVENT_DBG(desc) + #endif + + void sendMouseEnter (Component* const comp, Point<int> screenPos, Time time) { - //DBG ("Mouse " + String (source.getIndex()) + " enter: " + comp->getLocalPoint (nullptr, screenPos).toString() + " - Comp: " + String::toHexString ((int) comp)); + JUCE_MOUSE_EVENT_DBG ("enter") comp->internalMouseEnter (source, comp->getLocalPoint (nullptr, screenPos), time); } - void sendMouseExit (Component* const comp, const Point<int>& screenPos, const Time& time) + void sendMouseExit (Component* const comp, Point<int> screenPos, Time time) { - //DBG ("Mouse " + String (source.getIndex()) + " exit: " + comp->getLocalPoint (nullptr, screenPos).toString() + " - Comp: " + String::toHexString ((int) comp)); + JUCE_MOUSE_EVENT_DBG ("exit") comp->internalMouseExit (source, comp->getLocalPoint (nullptr, screenPos), time); } - void sendMouseMove (Component* const comp, const Point<int>& screenPos, const Time& time) + void sendMouseMove (Component* const comp, Point<int> screenPos, Time time) { - //DBG ("Mouse " + String (source.getIndex()) + " move: " + comp->getLocalPoint (nullptr, screenPos).toString() + " - Comp: " + String::toHexString ((int) comp)); + JUCE_MOUSE_EVENT_DBG ("move") comp->internalMouseMove (source, comp->getLocalPoint (nullptr, screenPos), time); } - void sendMouseDown (Component* const comp, const Point<int>& screenPos, const Time& time) + void sendMouseDown (Component* const comp, Point<int> screenPos, Time time) { - //DBG ("Mouse " + String (source.getIndex()) + " down: " + comp->getLocalPoint (nullptr, screenPos).toString() + " - Comp: " + String::toHexString ((int) comp)); + JUCE_MOUSE_EVENT_DBG ("down") comp->internalMouseDown (source, comp->getLocalPoint (nullptr, screenPos), time); } - void sendMouseDrag (Component* const comp, const Point<int>& screenPos, const Time& time) + void sendMouseDrag (Component* const comp, Point<int> screenPos, Time time) { - //DBG ("Mouse " + String (source.getIndex()) + " drag: " + comp->getLocalPoint (nullptr, screenPos).toString() + " - Comp: " + String::toHexString ((int) comp)); + JUCE_MOUSE_EVENT_DBG ("drag") comp->internalMouseDrag (source, comp->getLocalPoint (nullptr, screenPos), time); } - void sendMouseUp (Component* const comp, const Point<int>& screenPos, const Time& time, const ModifierKeys& oldMods) + void sendMouseUp (Component* const comp, Point<int> screenPos, Time time, const ModifierKeys oldMods) { - //DBG ("Mouse " + String (source.getIndex()) + " up: " + comp->getLocalPoint (nullptr, screenPos).toString() + " - Comp: " + String::toHexString ((int) comp)); + JUCE_MOUSE_EVENT_DBG ("up") comp->internalMouseUp (source, comp->getLocalPoint (nullptr, screenPos), time, oldMods); } - void sendMouseWheel (Component* const comp, const Point<int>& screenPos, const Time& time, const MouseWheelDetails& wheel) + void sendMouseWheel (Component* const comp, Point<int> screenPos, Time time, const MouseWheelDetails& wheel) { - //DBG ("Mouse " + String (source.getIndex()) + " wheel: " + comp->getLocalPoint (nullptr, screenPos).toString() + " - Comp: " + String::toHexString ((int) comp)); + JUCE_MOUSE_EVENT_DBG ("wheel") comp->internalMouseWheel (source, comp->getLocalPoint (nullptr, screenPos), time, wheel); } + void sendMagnifyGesture (Component* const comp, Point<int> screenPos, Time time, const float amount) + { + JUCE_MOUSE_EVENT_DBG ("magnify") + comp->internalMagnifyGesture (source, comp->getLocalPoint (nullptr, screenPos), time, amount); + } + //============================================================================== // (returns true if the button change caused a modal event loop) - bool setButtons (const Point<int>& screenPos, const Time& time, const ModifierKeys& newButtonState) + bool setButtons (Point<int> screenPos, Time time, const ModifierKeys newButtonState) { if (buttonState == newButtonState) return false; @@ -152,6 +165,9 @@ public: buttonState = newButtonState; // must change this before calling sendMouseUp, in case it runs a modal loop sendMouseUp (current, screenPos + unboundedMouseOffset, time, oldMods); + + if (lastCounter != mouseEventCounter) + return true; // if a modal loop happened, then newButtonState is no longer valid. } enableUnboundedMouseMovement (false, false); @@ -173,7 +189,7 @@ public: return lastCounter != mouseEventCounter; } - void setComponentUnderMouse (Component* const newComponent, const Point<int>& screenPos, const Time& time) + void setComponentUnderMouse (Component* const newComponent, Point<int> screenPos, Time time) { Component* current = getComponentUnderMouse(); @@ -206,7 +222,7 @@ public: } } - void setPeer (ComponentPeer* const newPeer, const Point<int>& screenPos, const Time& time) + void setPeer (ComponentPeer* const newPeer, Point<int> screenPos, Time time) { ModifierKeys::updateCurrentModifiers(); @@ -218,7 +234,7 @@ public: } } - void setScreenPos (const Point<int>& newScreenPos, const Time& time, const bool forceUpdate) + void setScreenPos (Point<int> newScreenPos, Time time, const bool forceUpdate) { if (! isDragging()) setComponentUnderMouse (findComponentAt (newScreenPos), newScreenPos, time); @@ -249,7 +265,7 @@ public: } //============================================================================== - void handleEvent (ComponentPeer* const newPeer, const Point<int>& positionWithinPeer, const Time& time, const ModifierKeys& newMods) + void handleEvent (ComponentPeer* const newPeer, Point<int> positionWithinPeer, Time time, const ModifierKeys newMods) { jassert (newPeer != nullptr); lastTime = time; @@ -276,29 +292,42 @@ public: } } - void handleWheel (ComponentPeer* const peer, const Point<int>& positionWithinPeer, - const Time& time, const MouseWheelDetails& wheel) + Component* getTargetForGesture (ComponentPeer* const peer, Point<int> positionWithinPeer, + Time time, Point<int>& screenPos) { jassert (peer != nullptr); lastTime = time; ++mouseEventCounter; - Desktop::getInstance().incrementMouseWheelCounter(); - const Point<int> screenPos (peer->localToGlobal (positionWithinPeer)); + screenPos = peer->localToGlobal (positionWithinPeer); setPeer (peer, screenPos, time); setScreenPos (screenPos, time, false); triggerFakeMove(); - if (! isDragging()) - { - if (Component* current = getComponentUnderMouse()) - sendMouseWheel (current, screenPos, time, wheel); - } + return isDragging() ? nullptr : getComponentUnderMouse(); + } + + void handleWheel (ComponentPeer* const peer, Point<int> positionWithinPeer, + Time time, const MouseWheelDetails& wheel) + { + Desktop::getInstance().incrementMouseWheelCounter(); + + Point<int> screenPos; + if (Component* current = getTargetForGesture (peer, positionWithinPeer, time, screenPos)) + sendMouseWheel (current, screenPos, time, wheel); + } + + void handleMagnifyGesture (ComponentPeer* const peer, Point<int> positionWithinPeer, + Time time, const float scaleFactor) + { + Point<int> screenPos; + if (Component* current = getTargetForGesture (peer, positionWithinPeer, time, screenPos)) + sendMagnifyGesture (current, screenPos, time, scaleFactor); } //============================================================================== - const Time& getLastMouseDownTime() const noexcept { return mouseDowns[0].time; } - const Point<int>& getLastMouseDownPosition() const noexcept { return mouseDowns[0].position; } + Time getLastMouseDownTime() const noexcept { return mouseDowns[0].time; } + Point<int> getLastMouseDownPosition() const noexcept { return mouseDowns[0].position; } int getNumberOfMultipleClicks() const noexcept { @@ -450,8 +479,8 @@ private: Time lastTime; bool mouseMovedSignificantlySincePressed; - void registerMouseDown (const Point<int>& screenPos, const Time& time, - Component& component, const ModifierKeys& modifiers) noexcept + void registerMouseDown (Point<int> screenPos, Time time, + Component& component, const ModifierKeys modifiers) noexcept { for (int i = numElementsInArray (mouseDowns); --i > 0;) mouseDowns[i] = mouseDowns[i - 1]; @@ -468,7 +497,7 @@ private: mouseMovedSignificantlySincePressed = false; } - void registerMouseDrag (const Point<int>& screenPos) noexcept + void registerMouseDrag (Point<int> screenPos) noexcept { mouseMovedSignificantlySincePressed = mouseMovedSignificantlySincePressed || mouseDowns[0].position.getDistanceFrom (screenPos) >= 4; @@ -507,14 +536,20 @@ void MouseInputSource::hideCursor() { pimpl- void MouseInputSource::revealCursor() { pimpl->revealCursor (false); } void MouseInputSource::forceMouseCursorUpdate() { pimpl->revealCursor (true); } -void MouseInputSource::handleEvent (ComponentPeer* peer, const Point<int>& positionWithinPeer, - const int64 time, const ModifierKeys& mods) +void MouseInputSource::handleEvent (ComponentPeer* peer, Point<int> positionWithinPeer, + const int64 time, const ModifierKeys mods) { pimpl->handleEvent (peer, positionWithinPeer, Time (time), mods.withOnlyMouseButtons()); } -void MouseInputSource::handleWheel (ComponentPeer* const peer, const Point<int>& positionWithinPeer, +void MouseInputSource::handleWheel (ComponentPeer* const peer, Point<int> positionWithinPeer, const int64 time, const MouseWheelDetails& wheel) { pimpl->handleWheel (peer, positionWithinPeer, Time (time), wheel); } + +void MouseInputSource::handleMagnifyGesture (ComponentPeer* const peer, Point<int> positionWithinPeer, + const int64 time, const float scaleFactor) +{ + pimpl->handleMagnifyGesture (peer, positionWithinPeer, Time (time), scaleFactor); +} diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseInputSource.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseInputSource.h index d6c2cb679..6a77cde24 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseInputSource.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseInputSource.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -166,9 +165,11 @@ public: //============================================================================== /** @internal */ - void handleEvent (ComponentPeer*, const Point<int>& positionWithinPeer, int64 time, const ModifierKeys&); + void handleEvent (ComponentPeer*, Point<int>, int64 time, const ModifierKeys); /** @internal */ - void handleWheel (ComponentPeer*, const Point<int>& positionWithinPeer, int64 time, const MouseWheelDetails&); + void handleWheel (ComponentPeer*, Point<int>, int64 time, const MouseWheelDetails&); + /** @internal */ + void handleMagnifyGesture (ComponentPeer*, Point<int>, int64 time, float scaleFactor); private: //============================================================================== diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseListener.cpp b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseListener.cpp index d2233068f..f1ad12242 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseListener.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseListener.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseListener.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseListener.h index b1d9d6a06..cecefc621 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseListener.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_MouseListener.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h index e169bbe6b..f254d331d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -148,7 +147,7 @@ public: @see selectOnly, addToSelection, addToSelectionOnMouseDown, addToSelectionOnMouseUp */ void addToSelectionBasedOnModifiers (ParameterType item, - const ModifierKeys& modifiers) + ModifierKeys modifiers) { if (modifiers.isShiftDown()) { @@ -185,7 +184,7 @@ public: @see addToSelectionOnMouseUp, addToSelectionBasedOnModifiers */ bool addToSelectionOnMouseDown (ParameterType item, - const ModifierKeys& modifiers) + ModifierKeys modifiers) { if (isSelected (item)) return ! modifiers.isPopupMenu(); @@ -209,7 +208,7 @@ public: should have made during the matching mouseDown event */ void addToSelectionOnMouseUp (ParameterType item, - const ModifierKeys& modifiers, + ModifierKeys modifiers, const bool wasItemDragged, const bool resultOfMouseDownSelectMethod) { diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h index 4cf779a94..33d0ee2b9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_TooltipClient.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_TooltipClient.h index 88ff4f613..5bafd362d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_TooltipClient.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_TooltipClient.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_MultiTouchMapper.h b/JuceLibraryCode/modules/juce_gui_basics/native/juce_MultiTouchMapper.h index 3be571086..1b3e1d6e7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_MultiTouchMapper.h +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_MultiTouchMapper.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_android_FileChooser.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_android_FileChooser.cpp index 92a139c1e..78f157e84 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_android_FileChooser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_android_FileChooser.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_android_Windowing.cpp index 2af79ab89..8c163bede 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -183,50 +182,33 @@ public: view.callVoidMethod (ComponentPeerView.setViewName, javaString (title).get()); } - void setPosition (int x, int y) - { - const Rectangle<int> pos (getBounds()); - setBounds (x, y, pos.getWidth(), pos.getHeight(), false); - } - - void setSize (int w, int h) - { - const Rectangle<int> pos (getBounds()); - setBounds (pos.getX(), pos.getY(), w, h, false); - } - - void setBounds (int x, int y, int w, int h, bool isNowFullScreen) + void setBounds (const Rectangle<int>& r, bool isNowFullScreen) { if (MessageManager::getInstance()->isThisTheMessageThread()) { fullScreen = isNowFullScreen; - w = jmax (0, w); - h = jmax (0, h); - - view.callVoidMethod (ComponentPeerView.layout, x, y, x + w, y + h); + view.callVoidMethod (ComponentPeerView.layout, + r.getX(), r.getY(), r.getRight(), r.getBottom()); } else { class ViewMover : public CallbackMessage { public: - ViewMover (const GlobalRef& view_, int x_, int y_, int w_, int h_) - : view (view_), x (x_), y (y_), w (w_), h (h_) - { - post(); - } + ViewMover (const GlobalRef& v, const Rectangle<int>& r) : view (v), bounds (r) {} void messageCallback() { - view.callVoidMethod (ComponentPeerView.layout, x, y, x + w, y + h); + view.callVoidMethod (ComponentPeerView.layout, + bounds.getX(), bounds.getY(), bounds.getRight(), bounds.getBottom()); } private: GlobalRef view; - int x, y, w, h; + Rectangle<int> bounds; }; - new ViewMover (view, x, y, w, h); + (new ViewMover (view, r))->post(); } } @@ -282,7 +264,7 @@ public: // (can't call the component's setBounds method because that'll reset our fullscreen flag) if (! r.isEmpty()) - setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); + setBounds (r, shouldBeFullScreen); component.repaint(); } @@ -607,7 +589,7 @@ Point<int> MouseInputSource::getCurrentMousePosition() return AndroidComponentPeer::lastMousePos; } -void Desktop::setMousePosition (const Point<int>& newPosition) +void Desktop::setMousePosition (Point<int> newPosition) { // not needed } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index 71f44d6fe..99d568d22 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -133,13 +132,10 @@ public: void* getNativeHandle() const; void setVisible (bool shouldBeVisible); void setTitle (const String& title); - void setPosition (int x, int y); - void setSize (int w, int h); - void setBounds (int x, int y, int w, int h, bool isNowFullScreen); + void setBounds (const Rectangle<int>&, bool isNowFullScreen); Rectangle<int> getBounds() const; Rectangle<int> getBounds (const bool global) const; - Point<int> getScreenPosition() const; Point<int> localToGlobal (const Point<int>& relativePosition); Point<int> globalToLocal (const Point<int>& screenPosition); void setAlpha (float newAlpha); @@ -530,37 +526,23 @@ void UIViewComponentPeer::setTitle (const String& title) // xxx is this possible? } -void UIViewComponentPeer::setPosition (int x, int y) -{ - setBounds (x, y, component.getWidth(), component.getHeight(), false); -} - -void UIViewComponentPeer::setSize (int w, int h) -{ - setBounds (component.getX(), component.getY(), w, h, false); -} - -void UIViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNowFullScreen) +void UIViewComponentPeer::setBounds (const Rectangle<int>& newBounds, const bool isNowFullScreen) { fullScreen = isNowFullScreen; - w = jmax (0, w); - h = jmax (0, h); if (isSharedWindow) { - CGRect r = CGRectMake ((CGFloat) x, (CGFloat) y, (CGFloat) w, (CGFloat) h); + CGRect r = convertToCGRect (newBounds); - if (view.frame.size.width != r.size.width - || view.frame.size.height != r.size.height) + if (view.frame.size.width != r.size.width || view.frame.size.height != r.size.height) [view setNeedsDisplay]; view.frame = r; } else { - const Rectangle<int> bounds (rotatedScreenPosToReal (Rectangle<int> (x, y, w, h))); - window.frame = convertToCGRect (bounds); - view.frame = CGRectMake (0, 0, (CGFloat) w, (CGFloat) h); + window.frame = convertToCGRect (rotatedScreenPosToReal (newBounds)); + view.frame = CGRectMake (0, 0, (CGFloat) newBounds.getWidth(), (CGFloat) newBounds.getHeight()); handleMovedOrResized(); } @@ -586,19 +568,14 @@ Rectangle<int> UIViewComponentPeer::getBounds() const return getBounds (! isSharedWindow); } -Point<int> UIViewComponentPeer::getScreenPosition() const -{ - return getBounds (true).getPosition(); -} - Point<int> UIViewComponentPeer::localToGlobal (const Point<int>& relativePosition) { - return relativePosition + getScreenPosition(); + return relativePosition + getBounds (true).getPosition(); } Point<int> UIViewComponentPeer::globalToLocal (const Point<int>& screenPosition) { - return screenPosition - getScreenPosition(); + return screenPosition - getBounds (true).getPosition(); } CGRect UIViewComponentPeer::constrainRect (CGRect r) @@ -657,7 +634,7 @@ void UIViewComponentPeer::setFullScreen (bool shouldBeFullScreen) // (can't call the component's setBounds method because that'll reset our fullscreen flag) if (! r.isEmpty()) - setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); + setBounds (r, shouldBeFullScreen); component.repaint(); } @@ -695,7 +672,7 @@ void UIViewComponentPeer::updateTransformAndScreenBounds() const int x = ((int) (newDesktop.getWidth() * centreRelX)) - (oldArea.getWidth() / 2); const int y = ((int) (newDesktop.getHeight() * centreRelY)) - (oldArea.getHeight() / 2); - setBounds (x, y, oldArea.getWidth(), oldArea.getHeight(), false); + setBounds (oldArea.withPosition (x, y), false); } [view setNeedsDisplay]; @@ -774,7 +751,7 @@ void UIViewComponentPeer::handleTouches (UIEvent* event, const bool isDown, cons CGPoint p = [touch locationInView: view]; const Point<int> pos ((int) p.x, (int) p.y); - juce_lastMousePos = pos + getScreenPosition(); + juce_lastMousePos = pos + getBounds (true).getPosition(); const int64 time = getMouseTime (event); const int touchIndex = currentTouches.getIndexOfTouch (touch); diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_ios_Windowing.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_ios_Windowing.mm index 1980de6e0..6b4551db0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_ios_Windowing.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_ios_Windowing.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -131,10 +130,12 @@ public: int getResult() { jassert (callback == nullptr); - JUCE_AUTORELEASEPOOL - while (! alert.hidden && alert.superview != nil) - [[NSRunLoop mainRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.01]]; + JUCE_AUTORELEASEPOOL + { + while (! alert.hidden && alert.superview != nil) + [[NSRunLoop mainRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.01]]; + } return result; } @@ -181,8 +182,10 @@ void JUCE_CALLTYPE NativeMessageBox::showMessageBox (AlertWindow::AlertIconType Component* associatedComponent) { JUCE_AUTORELEASEPOOL - iOSMessageBox mb (title, message, @"OK", nil, nil, nullptr, false); - (void) mb.getResult(); + { + iOSMessageBox mb (title, message, @"OK", nil, nil, nullptr, false); + (void) mb.getResult(); + } } void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (AlertWindow::AlertIconType iconType, @@ -290,7 +293,7 @@ Point<int> MouseInputSource::getCurrentMousePosition() return juce_lastMousePos; } -void Desktop::setMousePosition (const Point<int>&) +void Desktop::setMousePosition (Point<int>) { } @@ -302,18 +305,19 @@ Desktop::DisplayOrientation Desktop::getCurrentOrientation() const void Desktop::Displays::findDisplays() { JUCE_AUTORELEASEPOOL + { + UIScreen* s = [UIScreen mainScreen]; - UIScreen* s = [UIScreen mainScreen]; - - Display d; - d.userArea = UIViewComponentPeer::realScreenPosToRotated (convertToRectInt ([s applicationFrame])); - d.totalArea = UIViewComponentPeer::realScreenPosToRotated (convertToRectInt ([s bounds])); - d.isMain = true; + Display d; + d.userArea = UIViewComponentPeer::realScreenPosToRotated (convertToRectInt ([s applicationFrame])); + d.totalArea = UIViewComponentPeer::realScreenPosToRotated (convertToRectInt ([s bounds])); + d.isMain = true; - if ([s respondsToSelector: @selector (scale)]) - d.scale = s.scale; - else - d.scale = 1.0; + if ([s respondsToSelector: @selector (scale)]) + d.scale = s.scale; + else + d.scale = 1.0; - displays.add (d); + displays.add (d); + } } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_Clipboard.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_Clipboard.cpp index 846ef0a69..b64c85c25 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_Clipboard.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_Clipboard.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp index 5bd789a90..8de2d9445 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -35,7 +34,8 @@ static bool exeIsAvailable (const char* const executable) bool FileChooser::isPlatformDialogAvailable() { - return exeIsAvailable ("zenity") || exeIsAvailable ("kdialog"); + static bool canUseNativeBox = exeIsAvailable ("zenity") || exeIsAvailable ("kdialog"); + return canUseNativeBox; } void FileChooser::showPlatformDialog (Array<File>& results, diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_Windowing.cpp index 6c573ce6b..4977eccd5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -792,6 +791,14 @@ static void* createDraggingHandCursor() return CustomMouseCursorInfo (ImageFileFormat::loadFrom (dragHandData, dragHandDataSize), 8, 7).create(); } +//============================================================================== +static int numAlwaysOnTopPeers = 0; + +bool juce_areThereAnyAlwaysOnTopWindows() +{ + return numAlwaysOnTopPeers > 0; +} + //============================================================================== class LinuxComponentPeer : public ComponentPeer { @@ -800,13 +807,17 @@ public: : ComponentPeer (comp, windowStyleFlags), windowH (0), parentWindow (0), fullScreen (false), mapped (false), - visual (nullptr), depth (0) + visual (nullptr), depth (0), + isAlwaysOnTop (comp.isAlwaysOnTop()) { // it's dangerous to create a window on a thread other than the message thread.. jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); dispatchWindowMessage = windowMessageReceive; - repainter = new LinuxRepaintManager (this); + repainter = new LinuxRepaintManager (*this); + + if (isAlwaysOnTop) + ++numAlwaysOnTopPeers; createWindow (parentToAddTo); @@ -821,6 +832,9 @@ public: deleteIconPixmaps(); destroyWindow(); windowH = 0; + + if (isAlwaysOnTop) + --numAlwaysOnTopPeers; } // (this callback is hooked up in the messaging code) @@ -868,7 +882,7 @@ public: void setTitle (const String& title) { XTextProperty nameProperty; - char* strings[] = { const_cast <char*> (title.toUTF8().getAddress()) }; + char* strings[] = { const_cast <char*> (title.toRawUTF8()) }; ScopedXLock xlock; if (XStringListToTextProperty (strings, 1, &nameProperty)) @@ -880,7 +894,7 @@ public: } } - void setBounds (int x, int y, int w, int h, bool isNowFullScreen) + void setBounds (const Rectangle<int>& newBounds, bool isNowFullScreen) { if (fullScreen && ! isNowFullScreen) { @@ -914,7 +928,8 @@ public: if (windowH != 0) { - bounds.setBounds (x, y, jmax (1, w), jmax (1, h)); + bounds = newBounds.withSize (jmax (1, newBounds.getWidth()), + jmax (1, newBounds.getHeight())); WeakReference<Component> deletionChecker (&component); ScopedXLock xlock; @@ -950,19 +965,16 @@ public: } } - void setPosition (int x, int y) { setBounds (x, y, bounds.getWidth(), bounds.getHeight(), false); } - void setSize (int w, int h) { setBounds (bounds.getX(), bounds.getY(), w, h, false); } Rectangle<int> getBounds() const { return bounds; } - Point<int> getScreenPosition() const { return bounds.getPosition(); } Point<int> localToGlobal (const Point<int>& relativePosition) { - return relativePosition + getScreenPosition(); + return relativePosition + bounds.getPosition(); } Point<int> globalToLocal (const Point<int>& screenPosition) { - return screenPosition - getScreenPosition(); + return screenPosition - bounds.getPosition(); } void setAlpha (float /* newAlpha */) @@ -1018,7 +1030,7 @@ public: r = Desktop::getInstance().getDisplays().getMainDisplay().userArea; if (! r.isEmpty()) - setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); + setBounds (r, shouldBeFullScreen); component.repaint(); } @@ -1500,6 +1512,9 @@ public: { updateKeyModifiers (buttonRelEvent.state); + if (parentWindow != 0) + updateBounds(); + switch (pointerMap [buttonRelEvent.button - Button1]) { case Keys::LeftButton: currentModifiers = currentModifiers.withoutFlags (ModifierKeys::leftButtonModifier); break; @@ -1514,9 +1529,6 @@ public: handleMouseEvent (0, getMousePos (buttonRelEvent), currentModifiers, getEventTime (buttonRelEvent)); clearLastMousePos(); - - if (parentWindow != 0) - updateBounds(); } void handleMotionNotifyEvent (const XPointerMovedEvent& movedEvent) @@ -1612,9 +1624,7 @@ public: if ((styleFlags & windowHasTitleBar) != 0 && component.isCurrentlyBlockedByAnotherModalComponent()) { - Component* const currentModalComp = Component::getCurrentlyModalComponent(); - - if (currentModalComp != 0) + if (Component* const currentModalComp = Component::getCurrentlyModalComponent()) currentModalComp->inputAttemptWhenModal(); } @@ -1769,15 +1779,14 @@ public: private: //============================================================================== - class LinuxRepaintManager : public Timer + class LinuxRepaintManager : public Timer { public: - LinuxRepaintManager (LinuxComponentPeer* const peer_) - : peer (peer_), - lastTimeImageUsed (0) + LinuxRepaintManager (LinuxComponentPeer& p) + : peer (p), lastTimeImageUsed (0) { #if JUCE_USE_XSHM - shmCompletedDrawing = true; + shmPaintsPending = 0; useARGBImagesForRendering = XSHMHelpers::isShmAvailable(); @@ -1799,9 +1808,10 @@ private: void timerCallback() { #if JUCE_USE_XSHM - if (! shmCompletedDrawing) + if (shmPaintsPending != 0) return; #endif + if (! regionsNeedingRepaint.isEmpty()) { stopTimer(); @@ -1825,14 +1835,14 @@ private: void performAnyPendingRepaintsNow() { #if JUCE_USE_XSHM - if (! shmCompletedDrawing) + if (shmPaintsPending != 0) { startTimer (repaintTimerPeriod); return; } #endif - peer->clearMaskedRegion(); + peer.clearMaskedRegion(); RectangleList originalRepaintRegion (regionsNeedingRepaint); regionsNeedingRepaint.clear(); @@ -1849,9 +1859,9 @@ private: #else image = Image (new XBitmapImage (Image::RGB, #endif - (totalArea.getWidth() + 31) & ~31, + (totalArea.getWidth() + 31) & ~31, (totalArea.getHeight() + 31) & ~31, - false, peer->depth, peer->visual)); + false, peer.depth, peer.visual)); } startTimer (repaintTimerPeriod); @@ -1859,29 +1869,27 @@ private: RectangleList adjustedList (originalRepaintRegion); adjustedList.offsetAll (-totalArea.getX(), -totalArea.getY()); - if (peer->depth == 32) - { + if (peer.depth == 32) for (const Rectangle<int>* i = originalRepaintRegion.begin(), * const e = originalRepaintRegion.end(); i != e; ++i) image.clear (*i - totalArea.getPosition()); - } { - ScopedPointer<LowLevelGraphicsContext> context (peer->getComponent().getLookAndFeel() + ScopedPointer<LowLevelGraphicsContext> context (peer.getComponent().getLookAndFeel() .createGraphicsContext (image, -totalArea.getPosition(), adjustedList)); - peer->handlePaint (*context); + peer.handlePaint (*context); } - if (! peer->maskedRegion.isEmpty()) - originalRepaintRegion.subtract (peer->maskedRegion); + if (! peer.maskedRegion.isEmpty()) + originalRepaintRegion.subtract (peer.maskedRegion); for (const Rectangle<int>* i = originalRepaintRegion.begin(), * const e = originalRepaintRegion.end(); i != e; ++i) { #if JUCE_USE_XSHM - shmCompletedDrawing = false; + ++shmPaintsPending; #endif static_cast<XBitmapImage*> (image.getPixelData()) - ->blitToWindow (peer->windowH, + ->blitToWindow (peer.windowH, i->getX(), i->getY(), i->getWidth(), i->getHeight(), i->getX() - totalArea.getX(), i->getY() - totalArea.getY()); } @@ -1892,19 +1900,20 @@ private: } #if JUCE_USE_XSHM - void notifyPaintCompleted() { shmCompletedDrawing = true; } + void notifyPaintCompleted() noexcept { --shmPaintsPending; } #endif private: enum { repaintTimerPeriod = 1000 / 100 }; - LinuxComponentPeer* const peer; + LinuxComponentPeer& peer; Image image; uint32 lastTimeImageUsed; RectangleList regionsNeedingRepaint; #if JUCE_USE_XSHM - bool useARGBImagesForRendering, shmCompletedDrawing; + bool useARGBImagesForRendering; + int shmPaintsPending; #endif JUCE_DECLARE_NON_COPYABLE (LinuxRepaintManager) }; @@ -1919,6 +1928,7 @@ private: Visual* visual; int depth; BorderSize<int> windowBorder; + bool isAlwaysOnTop; enum { KeyPressEventType = 2 }; struct MotifWmHints @@ -2514,7 +2524,7 @@ private: xchangeProperty (evt.xselectionrequest.requestor, evt.xselectionrequest.property, targetType, 8, - dragState.textOrFiles.toUTF8().getAddress(), + dragState.textOrFiles.toRawUTF8(), dragState.textOrFiles.getNumBytesAsUTF8()); } @@ -2608,7 +2618,7 @@ private: Point<int> dropPos ((int) clientMsg.data.l[2] >> 16, (int) clientMsg.data.l[2] & 0xffff); - dropPos -= getScreenPosition(); + dropPos -= bounds.getPosition(); const Atoms& atoms = Atoms::get(); Atom targetAction = atoms.XdndActionCopy; @@ -2948,7 +2958,7 @@ ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool /* allowMenusAndBars */) { if (enableOrDisable) - kioskModeComponent->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea); + kioskModeComponent->setBounds (getDisplays().getMainDisplay().totalArea); } //============================================================================== @@ -3104,7 +3114,7 @@ Point<int> MouseInputSource::getCurrentMousePosition() return Point<int> (x, y); } -void Desktop::setMousePosition (const Point<int>& newPosition) +void Desktop::setMousePosition (Point<int> newPosition) { ScopedXLock xlock; Window root = RootWindow (display, DefaultScreen (display)); @@ -3143,12 +3153,6 @@ bool Desktop::isScreenSaverEnabled() return screenSaverAllowed; } -//============================================================================== -bool juce_areThereAnyAlwaysOnTopWindows() -{ - return false; // XXX should be implemented -} - //============================================================================== void* CustomMouseCursorInfo::create() const { diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_FileChooser.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_FileChooser.mm index 5c53f0de8..d1663d8ed 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_FileChooser.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_FileChooser.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -117,83 +116,84 @@ void FileChooser::showPlatformDialog (Array<File>& results, FilePreviewComponent* /*extraInfoComponent*/) { JUCE_AUTORELEASEPOOL + { + ScopedPointer<TemporaryMainMenuWithStandardCommands> tempMenu; + if (JUCEApplication::isStandaloneApp()) + tempMenu = new TemporaryMainMenuWithStandardCommands(); - ScopedPointer<TemporaryMainMenuWithStandardCommands> tempMenu; - if (JUCEApplication::isStandaloneApp()) - tempMenu = new TemporaryMainMenuWithStandardCommands(); - - StringArray* filters = new StringArray(); - filters->addTokens (filter.replaceCharacters (",:", ";;"), ";", String::empty); - filters->trim(); - filters->removeEmptyStrings(); + StringArray* filters = new StringArray(); + filters->addTokens (filter.replaceCharacters (",:", ";;"), ";", String::empty); + filters->trim(); + filters->removeEmptyStrings(); - #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 - typedef NSObject<NSOpenSavePanelDelegate> DelegateType; - #else - typedef NSObject DelegateType; - #endif + #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + typedef NSObject<NSOpenSavePanelDelegate> DelegateType; + #else + typedef NSObject DelegateType; + #endif - static FileChooserDelegateClass cls; - DelegateType* delegate = (DelegateType*) [[cls.createInstance() init] autorelease]; - FileChooserDelegateClass::setFilters (delegate, filters); + static FileChooserDelegateClass cls; + DelegateType* delegate = (DelegateType*) [[cls.createInstance() init] autorelease]; + FileChooserDelegateClass::setFilters (delegate, filters); - NSSavePanel* panel = isSaveDialogue ? [NSSavePanel savePanel] - : [NSOpenPanel openPanel]; + NSSavePanel* panel = isSaveDialogue ? [NSSavePanel savePanel] + : [NSOpenPanel openPanel]; - [panel setTitle: juceStringToNS (title)]; - [panel setAllowedFileTypes: createAllowedTypesArray (*filters)]; + [panel setTitle: juceStringToNS (title)]; + [panel setAllowedFileTypes: createAllowedTypesArray (*filters)]; - if (! isSaveDialogue) - { - NSOpenPanel* openPanel = (NSOpenPanel*) panel; - [openPanel setCanChooseDirectories: selectsDirectory]; - [openPanel setCanChooseFiles: selectsFiles]; - [openPanel setAllowsMultipleSelection: selectMultipleFiles]; - [openPanel setResolvesAliases: YES]; - } + if (! isSaveDialogue) + { + NSOpenPanel* openPanel = (NSOpenPanel*) panel; + [openPanel setCanChooseDirectories: selectsDirectory]; + [openPanel setCanChooseFiles: selectsFiles]; + [openPanel setAllowsMultipleSelection: selectMultipleFiles]; + [openPanel setResolvesAliases: YES]; + } - [panel setDelegate: delegate]; + [panel setDelegate: delegate]; - if (isSaveDialogue || selectsDirectory) - [panel setCanCreateDirectories: YES]; + if (isSaveDialogue || selectsDirectory) + [panel setCanCreateDirectories: YES]; - String directory, filename; + String directory, filename; - if (currentFileOrDirectory.isDirectory()) - { - directory = currentFileOrDirectory.getFullPathName(); - } - else - { - directory = currentFileOrDirectory.getParentDirectory().getFullPathName(); - filename = currentFileOrDirectory.getFileName(); - } - - #if defined (MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) - [panel setDirectoryURL: [NSURL fileURLWithPath: juceStringToNS (directory)]]; - [panel setNameFieldStringValue: juceStringToNS (filename)]; - - if ([panel runModal] == NSOKButton) - #else - if ([panel runModalForDirectory: juceStringToNS (directory) - file: juceStringToNS (filename)] == NSOKButton) - #endif - { - if (isSaveDialogue) + if (currentFileOrDirectory.isDirectory()) { - results.add (File (nsStringToJuce ([[panel URL] path]))); + directory = currentFileOrDirectory.getFullPathName(); } else { - NSOpenPanel* openPanel = (NSOpenPanel*) panel; - NSArray* urls = [openPanel URLs]; + directory = currentFileOrDirectory.getParentDirectory().getFullPathName(); + filename = currentFileOrDirectory.getFileName(); + } + + #if defined (MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) + [panel setDirectoryURL: [NSURL fileURLWithPath: juceStringToNS (directory)]]; + [panel setNameFieldStringValue: juceStringToNS (filename)]; - for (unsigned int i = 0; i < [urls count]; ++i) - results.add (File (nsStringToJuce ([[urls objectAtIndex: i] path]))); + if ([panel runModal] == NSOKButton) + #else + if ([panel runModalForDirectory: juceStringToNS (directory) + file: juceStringToNS (filename)] == NSOKButton) + #endif + { + if (isSaveDialogue) + { + results.add (File (nsStringToJuce ([[panel URL] path]))); + } + else + { + NSOpenPanel* openPanel = (NSOpenPanel*) panel; + NSArray* urls = [openPanel URLs]; + + for (unsigned int i = 0; i < [urls count]; ++i) + results.add (File (nsStringToJuce ([[urls objectAtIndex: i] path]))); + } } - } - [panel setDelegate: nil]; + [panel setDelegate: nil]; + } } bool FileChooser::isPlatformDialogAvailable() @@ -220,8 +220,6 @@ void FileChooser::showPlatformDialog (Array<File>& results, bool selectMultipleFiles, FilePreviewComponent* extraInfoComponent) { - JUCE_AUTORELEASEPOOL - jassertfalse; //there's no such thing in iOS } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_MainMenu.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_MainMenu.mm index 23abaa64d..3387b5a1a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_MainMenu.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_MainMenu.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -423,7 +422,7 @@ private: [menu release]; } - static unsigned int juceModsToNSMods (const ModifierKeys& mods) + static unsigned int juceModsToNSMods (const ModifierKeys mods) { unsigned int m = 0; if (mods.isShiftDown()) m |= NSShiftKeyMask; @@ -658,20 +657,21 @@ namespace MainMenuHelpers if (JUCEApplication* app = JUCEApplication::getInstance()) { JUCE_AUTORELEASEPOOL + { + NSMenu* mainMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("MainMenu")]; + NSMenuItem* item = [mainMenu addItemWithTitle: nsStringLiteral ("Apple") action: nil keyEquivalent: nsEmptyString()]; - NSMenu* mainMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("MainMenu")]; - NSMenuItem* item = [mainMenu addItemWithTitle: nsStringLiteral ("Apple") action: nil keyEquivalent: nsEmptyString()]; - - NSMenu* appMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("Apple")]; + NSMenu* appMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("Apple")]; - [NSApp performSelector: @selector (setAppleMenu:) withObject: appMenu]; - [mainMenu setSubmenu: appMenu forItem: item]; + [NSApp performSelector: @selector (setAppleMenu:) withObject: appMenu]; + [mainMenu setSubmenu: appMenu forItem: item]; - [NSApp setMainMenu: mainMenu]; - MainMenuHelpers::createStandardAppMenu (appMenu, app->getApplicationName(), extraItems); + [NSApp setMainMenu: mainMenu]; + MainMenuHelpers::createStandardAppMenu (appMenu, app->getApplicationName(), extraItems); - [appMenu release]; - [mainMenu release]; + [appMenu release]; + [mainMenu release]; + } } } } @@ -683,21 +683,22 @@ void MenuBarModel::setMacMainMenu (MenuBarModel* newMenuBarModel, if (getMacMainMenu() != newMenuBarModel) { JUCE_AUTORELEASEPOOL - - if (newMenuBarModel == nullptr) { - delete JuceMainMenuHandler::instance; - jassert (JuceMainMenuHandler::instance == nullptr); // should be zeroed in the destructor - jassert (extraAppleMenuItems == nullptr); // you can't specify some extra items without also supplying a model + if (newMenuBarModel == nullptr) + { + delete JuceMainMenuHandler::instance; + jassert (JuceMainMenuHandler::instance == nullptr); // should be zeroed in the destructor + jassert (extraAppleMenuItems == nullptr); // you can't specify some extra items without also supplying a model - extraAppleMenuItems = nullptr; - } - else - { - if (JuceMainMenuHandler::instance == nullptr) - JuceMainMenuHandler::instance = new JuceMainMenuHandler(); + extraAppleMenuItems = nullptr; + } + else + { + if (JuceMainMenuHandler::instance == nullptr) + JuceMainMenuHandler::instance = new JuceMainMenuHandler(); - JuceMainMenuHandler::instance->setMenu (newMenuBarModel, extraAppleMenuItems, recentItemsMenuName); + JuceMainMenuHandler::instance->setMenu (newMenuBarModel, extraAppleMenuItems, recentItemsMenuName); + } } } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm index 526520cb9..43a6e72d5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -28,25 +27,26 @@ //============================================================================== namespace MouseCursorHelpers { - static NSImage* createNSImage (const Image& image) + NSImage* createNSImage (const Image& image) { JUCE_AUTORELEASEPOOL + { + NSImage* im = [[NSImage alloc] init]; + [im setSize: NSMakeSize (image.getWidth(), image.getHeight())]; + [im lockFocus]; - NSImage* im = [[NSImage alloc] init]; - [im setSize: NSMakeSize (image.getWidth(), image.getHeight())]; - [im lockFocus]; + CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); + CGImageRef imageRef = juce_createCoreGraphicsImage (image, colourSpace, false); + CGColorSpaceRelease (colourSpace); - CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); - CGImageRef imageRef = juce_createCoreGraphicsImage (image, false, colourSpace, false); - CGColorSpaceRelease (colourSpace); + CGContextRef cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; + CGContextDrawImage (cg, convertToCGRect (image.getBounds()), imageRef); - CGContextRef cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; - CGContextDrawImage (cg, convertToCGRect (image.getBounds()), imageRef); + CGImageRelease (imageRef); + [im unlockFocus]; - CGImageRelease (imageRef); - [im unlockFocus]; - - return im; + return im; + } } static void* fromWebKitFile (const char* filename, float hx, float hy) @@ -78,46 +78,48 @@ void* CustomMouseCursorInfo::create() const void* MouseCursor::createStandardMouseCursor (MouseCursor::StandardCursorType type) { JUCE_AUTORELEASEPOOL - NSCursor* c = nil; - - switch (type) { - case NormalCursor: - case ParentCursor: c = [NSCursor arrowCursor]; break; - case NoCursor: return CustomMouseCursorInfo (Image (Image::ARGB, 8, 8, true), 0, 0).create(); - case DraggingHandCursor: c = [NSCursor openHandCursor]; break; - case WaitCursor: c = [NSCursor arrowCursor]; break; // avoid this on the mac, let the OS provide the beachball - case IBeamCursor: c = [NSCursor IBeamCursor]; break; - case PointingHandCursor: c = [NSCursor pointingHandCursor]; break; - case LeftRightResizeCursor: c = [NSCursor resizeLeftRightCursor]; break; - case LeftEdgeResizeCursor: c = [NSCursor resizeLeftCursor]; break; - case RightEdgeResizeCursor: c = [NSCursor resizeRightCursor]; break; - case CrosshairCursor: c = [NSCursor crosshairCursor]; break; - case CopyingCursor: return MouseCursorHelpers::fromWebKitFile ("copyCursor.png", 0, 0); - - case UpDownResizeCursor: - case TopEdgeResizeCursor: - case BottomEdgeResizeCursor: - return MouseCursorHelpers::fromWebKitFile ("northSouthResizeCursor.png", 0.5f, 0.5f); - - case TopLeftCornerResizeCursor: - case BottomRightCornerResizeCursor: - return MouseCursorHelpers::fromWebKitFile ("northWestSouthEastResizeCursor.png", 0.5f, 0.5f); - - case TopRightCornerResizeCursor: - case BottomLeftCornerResizeCursor: - return MouseCursorHelpers::fromWebKitFile ("northEastSouthWestResizeCursor.png", 0.5f, 0.5f); - - case UpDownLeftRightResizeCursor: - return MouseCursorHelpers::fromWebKitFile ("moveCursor.png", 0.5f, 0.5f); - - default: - jassertfalse; - break; + NSCursor* c = nil; + + switch (type) + { + case NormalCursor: + case ParentCursor: c = [NSCursor arrowCursor]; break; + case NoCursor: return CustomMouseCursorInfo (Image (Image::ARGB, 8, 8, true), 0, 0).create(); + case DraggingHandCursor: c = [NSCursor openHandCursor]; break; + case WaitCursor: c = [NSCursor arrowCursor]; break; // avoid this on the mac, let the OS provide the beachball + case IBeamCursor: c = [NSCursor IBeamCursor]; break; + case PointingHandCursor: c = [NSCursor pointingHandCursor]; break; + case LeftRightResizeCursor: c = [NSCursor resizeLeftRightCursor]; break; + case LeftEdgeResizeCursor: c = [NSCursor resizeLeftCursor]; break; + case RightEdgeResizeCursor: c = [NSCursor resizeRightCursor]; break; + case CrosshairCursor: c = [NSCursor crosshairCursor]; break; + case CopyingCursor: return MouseCursorHelpers::fromWebKitFile ("copyCursor.png", 0, 0); + + case UpDownResizeCursor: + case TopEdgeResizeCursor: + case BottomEdgeResizeCursor: + return MouseCursorHelpers::fromWebKitFile ("northSouthResizeCursor.png", 0.5f, 0.5f); + + case TopLeftCornerResizeCursor: + case BottomRightCornerResizeCursor: + return MouseCursorHelpers::fromWebKitFile ("northWestSouthEastResizeCursor.png", 0.5f, 0.5f); + + case TopRightCornerResizeCursor: + case BottomLeftCornerResizeCursor: + return MouseCursorHelpers::fromWebKitFile ("northEastSouthWestResizeCursor.png", 0.5f, 0.5f); + + case UpDownLeftRightResizeCursor: + return MouseCursorHelpers::fromWebKitFile ("moveCursor.png", 0.5f, 0.5f); + + default: + jassertfalse; + break; + } + + [c retain]; + return c; } - - [c retain]; - return c; } void MouseCursor::deleteMouseCursor (void* const cursorHandle, const bool /*isStandard*/) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 320272a8b..3e70f88a9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -199,9 +198,10 @@ public: void setTitle (const String& title) { JUCE_AUTORELEASEPOOL - - if (! isSharedWindow) - [window setTitle: juceStringToNS (title)]; + { + if (! isSharedWindow) + [window setTitle: juceStringToNS (title)]; + } } bool setDocumentEditedStatus (bool edited) @@ -221,21 +221,12 @@ public: : String::empty)]; } - void setPosition (int x, int y) - { - setBounds (x, y, component.getWidth(), component.getHeight(), false); - } - - void setSize (int w, int h) - { - setBounds (component.getX(), component.getY(), w, h, false); - } - - void setBounds (int x, int y, int w, int h, bool isNowFullScreen) + void setBounds (const Rectangle<int>& newBounds, bool isNowFullScreen) { fullScreen = isNowFullScreen; - NSRect r = NSMakeRect ((CGFloat) x, (CGFloat) y, (CGFloat) jmax (0, w), (CGFloat) jmax (0, h)); + NSRect r = NSMakeRect ((CGFloat) newBounds.getX(), (CGFloat) newBounds.getY(), + (CGFloat) jmax (0, newBounds.getWidth()), (CGFloat) jmax (0, newBounds.getHeight())); if (isSharedWindow) { @@ -288,19 +279,14 @@ public: return getBounds (! isSharedWindow); } - Point<int> getScreenPosition() const - { - return getBounds (true).getPosition(); - } - Point<int> localToGlobal (const Point<int>& relativePosition) { - return relativePosition + getScreenPosition(); + return relativePosition + getBounds (true).getPosition(); } Point<int> globalToLocal (const Point<int>& screenPosition) { - return screenPosition - getScreenPosition(); + return screenPosition - getBounds (true).getPosition(); } void setAlpha (float newAlpha) @@ -367,7 +353,7 @@ public: // (can't call the component's setBounds method because that'll reset our fullscreen flag) if (r != component.getBounds() && ! r.isEmpty()) - setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); + setBounds (r, shouldBeFullScreen); } } } @@ -625,6 +611,17 @@ public: handleMouseWheel (0, getMousePos (ev, view), getMouseTime (ev), wheel); } + void redirectMagnify (NSEvent* ev) + { + #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + const float invScale = 1.0f - [ev magnification]; + + if (invScale != 0.0f) + handleMagnifyGesture (0, getMousePos (ev, view), getMouseTime (ev), 1.0f / invScale); + #endif + (void) ev; + } + void sendMouseEvent (NSEvent* ev) { updateModifiers (ev); @@ -805,7 +802,7 @@ public: } CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); - CGImageRef image = juce_createCoreGraphicsImage (temp, false, colourSpace, false); + CGImageRef image = juce_createCoreGraphicsImage (temp, colourSpace, false); CGColorSpaceRelease (colourSpace); CGContextDrawImage (cg, CGRectMake (r.origin.x, r.origin.y, clipW, clipH), image); CGImageRelease (image); @@ -1149,8 +1146,8 @@ public: class AsyncRepaintMessage : public CallbackMessage { public: - AsyncRepaintMessage (NSViewComponentPeer* const peer_, const Rectangle<int>& rect_) - : peer (peer_), rect (rect_) + AsyncRepaintMessage (NSViewComponentPeer* const p, const Rectangle<int>& r) + : peer (p), rect (r) {} void messageCallback() @@ -1346,6 +1343,7 @@ struct JuceNSViewClass : public ObjCClass <NSView> addMethod (@selector (otherMouseDragged:), mouseDragged, "v@:@"); addMethod (@selector (otherMouseUp:), mouseUp, "v@:@"); addMethod (@selector (scrollWheel:), scrollWheel, "v@:@"); + addMethod (@selector (magnifyWithEvent:), magnify, "v@:@"); addMethod (@selector (acceptsFirstMouse:), acceptsFirstMouse, "v@:@"); addMethod (@selector (frameChanged:), frameChanged, "v@:@"); addMethod (@selector (viewDidMoveToWindow), viewDidMoveToWindow, "v@:"); @@ -1424,6 +1422,7 @@ private: static void mouseEntered (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseEnter (ev); } static void mouseExited (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseExit (ev); } static void scrollWheel (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseWheel (ev); } + static void magnify (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMagnify (ev); } static BOOL acceptsFirstMouse (id, SEL, NSEvent*) { return YES; } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_Windowing.mm index 917874747..0af0b84cf 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_mac_Windowing.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -163,35 +162,36 @@ bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& fi } JUCE_AUTORELEASEPOOL - - NSView* view = (NSView*) sourceComp->getWindowHandle(); - - if (view == nil) - return false; - - NSPasteboard* pboard = [NSPasteboard pasteboardWithName: NSDragPboard]; - [pboard declareTypes: [NSArray arrayWithObject: NSFilenamesPboardType] - owner: nil]; - - NSMutableArray* filesArray = [NSMutableArray arrayWithCapacity: 4]; - for (int i = 0; i < files.size(); ++i) - [filesArray addObject: juceStringToNS (files[i])]; - - [pboard setPropertyList: filesArray - forType: NSFilenamesPboardType]; - - NSPoint dragPosition = [view convertPoint: [[[view window] currentEvent] locationInWindow] - fromView: nil]; - dragPosition.x -= 16; - dragPosition.y -= 16; - - [view dragImage: [[NSWorkspace sharedWorkspace] iconForFile: juceStringToNS (files[0])] - at: dragPosition - offset: NSMakeSize (0, 0) - event: [[view window] currentEvent] - pasteboard: pboard - source: view - slideBack: YES]; + { + NSView* view = (NSView*) sourceComp->getWindowHandle(); + + if (view == nil) + return false; + + NSPasteboard* pboard = [NSPasteboard pasteboardWithName: NSDragPboard]; + [pboard declareTypes: [NSArray arrayWithObject: NSFilenamesPboardType] + owner: nil]; + + NSMutableArray* filesArray = [NSMutableArray arrayWithCapacity: 4]; + for (int i = 0; i < files.size(); ++i) + [filesArray addObject: juceStringToNS (files[i])]; + + [pboard setPropertyList: filesArray + forType: NSFilenamesPboardType]; + + NSPoint dragPosition = [view convertPoint: [[[view window] currentEvent] locationInWindow] + fromView: nil]; + dragPosition.x -= 16; + dragPosition.y -= 16; + + [view dragImage: [[NSWorkspace sharedWorkspace] iconForFile: juceStringToNS (files[0])] + at: dragPosition + offset: NSMakeSize (0, 0) + event: [[view window] currentEvent] + pasteboard: pboard + source: view + slideBack: YES]; + } return true; } @@ -211,11 +211,13 @@ bool Desktop::canUseSemiTransparentWindows() noexcept Point<int> MouseInputSource::getCurrentMousePosition() { JUCE_AUTORELEASEPOOL - const NSPoint p ([NSEvent mouseLocation]); - return Point<int> (roundToInt (p.x), roundToInt ([[[NSScreen screens] objectAtIndex: 0] frame].size.height - p.y)); + { + const NSPoint p ([NSEvent mouseLocation]); + return Point<int> (roundToInt (p.x), roundToInt ([[[NSScreen screens] objectAtIndex: 0] frame].size.height - p.y)); + } } -void Desktop::setMousePosition (const Point<int>& newPosition) +void Desktop::setMousePosition (Point<int> newPosition) { // this rubbish needs to be done around the warp call, to avoid causing a // bizarre glitch.. @@ -349,29 +351,30 @@ static Rectangle<int> convertDisplayRect (NSRect r, CGFloat mainScreenBottom) void Desktop::Displays::findDisplays() { JUCE_AUTORELEASEPOOL + { + DisplaySettingsChangeCallback::getInstance(); - DisplaySettingsChangeCallback::getInstance(); - - NSArray* screens = [NSScreen screens]; - const CGFloat mainScreenBottom = [[screens objectAtIndex: 0] frame].size.height; + NSArray* screens = [NSScreen screens]; + const CGFloat mainScreenBottom = [[screens objectAtIndex: 0] frame].size.height; - for (unsigned int i = 0; i < [screens count]; ++i) - { - NSScreen* s = (NSScreen*) [screens objectAtIndex: i]; + for (unsigned int i = 0; i < [screens count]; ++i) + { + NSScreen* s = (NSScreen*) [screens objectAtIndex: i]; - Display d; - d.userArea = convertDisplayRect ([s visibleFrame], mainScreenBottom); - d.totalArea = convertDisplayRect ([s frame], mainScreenBottom); - d.isMain = (i == 0); + Display d; + d.userArea = convertDisplayRect ([s visibleFrame], mainScreenBottom); + d.totalArea = convertDisplayRect ([s frame], mainScreenBottom); + d.isMain = (i == 0); - #if defined (MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) - if ([s respondsToSelector: @selector (backingScaleFactor)]) - d.scale = s.backingScaleFactor; - else - #endif - d.scale = 1.0; + #if defined (MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) + if ([s respondsToSelector: @selector (backingScaleFactor)]) + d.scale = s.backingScaleFactor; + else + #endif + d.scale = 1.0; - displays.add (d); + displays.add (d); + } } } @@ -397,22 +400,23 @@ bool juce_areThereAnyAlwaysOnTopWindows() Image juce_createIconForFile (const File& file) { JUCE_AUTORELEASEPOOL + { + NSImage* image = [[NSWorkspace sharedWorkspace] iconForFile: juceStringToNS (file.getFullPathName())]; - NSImage* image = [[NSWorkspace sharedWorkspace] iconForFile: juceStringToNS (file.getFullPathName())]; - - Image result (Image::ARGB, (int) [image size].width, (int) [image size].height, true); + Image result (Image::ARGB, (int) [image size].width, (int) [image size].height, true); - [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: juce_getImageContext (result) flipped: false]]; + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: juce_getImageContext (result) flipped: false]]; - [image drawAtPoint: NSMakePoint (0, 0) - fromRect: NSMakeRect (0, 0, [image size].width, [image size].height) - operation: NSCompositeSourceOver fraction: 1.0f]; + [image drawAtPoint: NSMakePoint (0, 0) + fromRect: NSMakeRect (0, 0, [image size].width, [image size].height) + operation: NSCompositeSourceOver fraction: 1.0f]; - [[NSGraphicsContext currentContext] flushGraphics]; - [NSGraphicsContext restoreGraphicsState]; + [[NSGraphicsContext currentContext] flushGraphics]; + [NSGraphicsContext restoreGraphicsState]; - return result; + return result; + } } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp index b66be5d8a..51def834d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index 300f56feb..a3b97aee8 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -77,9 +76,8 @@ namespace FileChooserHelpers if (ofn->hdr.code == CDN_SELCHANGE) { FileChooserCallbackInfo* info = (FileChooserCallbackInfo*) ofn->lpOFN->lCustData; - FilePreviewComponent* comp = dynamic_cast<FilePreviewComponent*> (info->customComponent->getChildComponent(0)); - if (comp != nullptr) + if (FilePreviewComponent* comp = dynamic_cast<FilePreviewComponent*> (info->customComponent->getChildComponent(0))) { WCHAR path [MAX_PATH * 2] = { 0 }; CommDlg_OpenSave_GetFilePath (GetParent (hdlg), (LPARAM) &path, MAX_PATH); @@ -110,8 +108,7 @@ namespace FileChooserHelpers void resized() { - Component* const c = getChildComponent(0); - if (c != nullptr) + if (Component* const c = getChildComponent(0)) c->setBounds (getLocalBounds()); } @@ -134,6 +131,8 @@ void FileChooser::showPlatformDialog (Array<File>& results, const String& title_ using namespace FileChooserHelpers; const String title (title_); + String defaultExtension; // scope of these strings must extend beyond dialog's lifetime. + HeapBlock<WCHAR> files; const size_t charsAvailableForResult = 32768; files.calloc (charsAvailableForResult + 1); @@ -188,7 +187,7 @@ void FileChooser::showPlatformDialog (Array<File>& results, const String& title_ } LPMALLOC al; - if (list != 0 && SUCCEEDED (SHGetMalloc (&al))) + if (list != nullptr && SUCCEEDED (SHGetMalloc (&al))) al->Free (list); if (info.returnedString.isNotEmpty()) @@ -243,9 +242,27 @@ void FileChooser::showPlatformDialog (Array<File>& results, const String& title_ if (extraInfoComponent != nullptr) of.lpfnHook = &openCallback; - if (! (isSaveDialogue ? GetSaveFileName (&of) - : GetOpenFileName (&of))) - return; + if (isSaveDialogue) + { + StringArray tokens; + tokens.addTokens (filter, ";,", "\"'"); + tokens.trim(); + tokens.removeEmptyStrings(); + + if (tokens.size() == 1 && tokens[0].removeCharacters ("*.").isNotEmpty()) + { + defaultExtension = tokens[0].fromFirstOccurrenceOf (".", false, false); + of.lpstrDefExt = defaultExtension.toWideCharPointer(); + } + + if (! GetSaveFileName (&of)) + return; + } + else + { + if (! GetOpenFileName (&of)) + return; + } filenameOffset = of.nFileOffset; } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 1e6aa93da..d34295ee5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -77,8 +76,9 @@ bool Desktop::canUseSemiTransparentWindows() noexcept #define TOUCHEVENTF_DOWN 0x0002 #define TOUCHEVENTF_UP 0x0004 DECLARE_HANDLE (HTOUCHINPUT); + DECLARE_HANDLE (HGESTUREINFO); - typedef struct tagTOUCHINPUT + struct TOUCHINPUT { LONG x; LONG y; @@ -90,16 +90,34 @@ bool Desktop::canUseSemiTransparentWindows() noexcept ULONG_PTR dwExtraInfo; DWORD cxContact; DWORD cyContact; - } TOUCHINPUT, *PTOUCHINPUT; + }; + + struct GESTUREINFO + { + UINT cbSize; + DWORD dwFlags; + DWORD dwID; + HWND hwndTarget; + POINTS ptsLocation; + DWORD dwInstanceID; + DWORD dwSequenceID; + ULONGLONG ullArguments; + UINT cbExtraArgs; + }; + #endif typedef BOOL (WINAPI* RegisterTouchWindowFunc) (HWND, ULONG); -typedef BOOL (WINAPI* GetTouchInputInfoFunc) (HTOUCHINPUT, UINT, PTOUCHINPUT, int); +typedef BOOL (WINAPI* GetTouchInputInfoFunc) (HTOUCHINPUT, UINT, TOUCHINPUT*, int); typedef BOOL (WINAPI* CloseTouchInputHandleFunc) (HTOUCHINPUT); +typedef BOOL (WINAPI* GetGestureInfoFunc) (HGESTUREINFO, GESTUREINFO*); +typedef BOOL (WINAPI* SetProcessDPIAwareFunc)(); static RegisterTouchWindowFunc registerTouchWindow = nullptr; static GetTouchInputInfoFunc getTouchInputInfo = nullptr; static CloseTouchInputHandleFunc closeTouchInputHandle = nullptr; +static GetGestureInfoFunc getGestureInfo = nullptr; +static SetProcessDPIAwareFunc setProcessDPIAware = nullptr; static bool hasCheckedForMultiTouch = false; @@ -112,6 +130,7 @@ static bool canUseMultiTouch() registerTouchWindow = (RegisterTouchWindowFunc) getUser32Function ("RegisterTouchWindow"); getTouchInputInfo = (GetTouchInputInfoFunc) getUser32Function ("GetTouchInputInfo"); closeTouchInputHandle = (CloseTouchInputHandleFunc) getUser32Function ("CloseTouchInputHandle"); + getGestureInfo = (GetGestureInfoFunc) getUser32Function ("GetGestureInfo"); } return registerTouchWindow != nullptr; @@ -122,6 +141,27 @@ static inline Rectangle<int> rectangleFromRECT (const RECT& r) noexcept return Rectangle<int>::leftTopRightBottom ((int) r.left, (int) r.top, (int) r.right, (int) r.bottom); } +static void setDPIAwareness() +{ + if (JUCEApplication::isStandaloneApp()) + { + if (setProcessDPIAware == nullptr) + setProcessDPIAware = (SetProcessDPIAwareFunc) getUser32Function ("SetProcessDPIAware"); + + if (setProcessDPIAware != nullptr) + setProcessDPIAware(); + } +} + +inline float getDisplayScale() +{ + HDC dc = GetDC (0); + const float scale = (GetDeviceCaps (dc, LOGPIXELSX) + + GetDeviceCaps (dc, LOGPIXELSY)) / (2.0f * 96.0f); + ReleaseDC (0, dc); + return scale; +} + //============================================================================== Desktop::DisplayOrientation Desktop::getCurrentOrientation() const { @@ -470,8 +510,10 @@ public: HWNDComponentPeer (Component& comp, const int windowStyleFlags, HWND parent, bool nonRepainting) : ComponentPeer (comp, windowStyleFlags), dontRepaint (nonRepainting), + parentToAddTo (parent), currentRenderingEngine (softwareRenderingEngine), lastPaintTime (0), + lastMagnifySize (0), fullScreen (false), isDragging (false), isMouseOver (false), @@ -479,7 +521,6 @@ public: constrainerIsResizing (false), currentWindowIcon (0), dropTarget (nullptr), - parentToAddTo (parent), updateLayeredWindowAlpha (255) { callFunctionIfNotLocked (&createWindowCallback, this); @@ -542,16 +583,6 @@ public: SetWindowText (hwnd, title.toWideCharPointer()); } - void setPosition (int x, int y) - { - offsetWithinParent (x, y); - SetWindowPos (hwnd, 0, - x - windowBorder.getLeft(), - y - windowBorder.getTop(), - 0, 0, - SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); - } - void repaintNowIfTransparent() { if (isUsingUpdateLayeredWindow() && lastPaintTime > 0 && Time::getMillisecondCounter() > lastPaintTime + 30) @@ -577,33 +608,41 @@ public: #endif } - void setSize (int w, int h) + void setBounds (const Rectangle<int>& bounds, bool isNowFullScreen) { - SetWindowPos (hwnd, 0, 0, 0, - w + windowBorder.getLeftAndRight(), - h + windowBorder.getTopAndBottom(), - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER); + fullScreen = isNowFullScreen; - updateBorderSize(); + Rectangle<int> newBounds (windowBorder.addedTo (bounds)); - repaintNowIfTransparent(); - } + if (isUsingUpdateLayeredWindow()) + { + if (HWND parentHwnd = GetParent (hwnd)) + { + RECT parentRect; + GetWindowRect (parentHwnd, &parentRect); + newBounds.translate (parentRect.left, parentRect.top); + } + } - void setBounds (int x, int y, int w, int h, bool isNowFullScreen) - { - fullScreen = isNowFullScreen; - offsetWithinParent (x, y); + const Rectangle<int> oldBounds (getBounds()); + const bool hasMoved = (oldBounds.getPosition() != bounds.getPosition()); + const bool hasResized = (oldBounds.getWidth() != bounds.getWidth() + || oldBounds.getHeight() != bounds.getHeight()); - SetWindowPos (hwnd, 0, - x - windowBorder.getLeft(), - y - windowBorder.getTop(), - w + windowBorder.getLeftAndRight(), - h + windowBorder.getTopAndBottom(), - SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER); + DWORD flags = SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER; + if (! hasMoved) flags |= SWP_NOMOVE; + if (! hasResized) flags |= SWP_NOSIZE; - updateBorderSize(); + SetWindowPos (hwnd, 0, + newBounds.getX(), newBounds.getY(), + newBounds.getWidth(), newBounds.getHeight(), + flags); - repaintNowIfTransparent(); + if (hasResized && isValidPeer (this)) + { + updateBorderSize(); + repaintNowIfTransparent(); + } } Rectangle<int> getBounds() const @@ -612,8 +651,7 @@ public: GetWindowRect (hwnd, &r); Rectangle<int> bounds (rectangleFromRECT (r)); - HWND parentH = GetParent (hwnd); - if (parentH != 0) + if (HWND parentH = GetParent (hwnd)) { GetWindowRect (parentH, &r); bounds.translate (-r.left, -r.top); @@ -696,13 +734,7 @@ public: ShowWindow (hwnd, SW_SHOWNORMAL); if (! boundsCopy.isEmpty()) - { - setBounds (boundsCopy.getX(), - boundsCopy.getY(), - boundsCopy.getWidth(), - boundsCopy.getHeight(), - false); - } + setBounds (boundsCopy, false); } else { @@ -1066,6 +1098,7 @@ private: ScopedPointer<Direct2DLowLevelGraphicsContext> direct2DContext; #endif uint32 lastPaintTime; + ULONGLONG lastMagnifySize; bool fullScreen, isDragging, isMouseOver, hasCreatedCaret, constrainerIsResizing; BorderSize<int> windowBorder; HICON currentWindowIcon; @@ -1299,6 +1332,7 @@ private: if (canUseMultiTouch()) registerTouchWindow (hwnd, 0); + setDPIAwareness(); updateBorderSize(); // Calling this function here is (for some reason) necessary to make Windows @@ -1345,20 +1379,6 @@ private: return GetFocus(); } - void offsetWithinParent (int& x, int& y) const - { - if (isUsingUpdateLayeredWindow()) - { - if (HWND parentHwnd = GetParent (hwnd)) - { - RECT parentRect; - GetWindowRect (parentHwnd, &parentRect); - x += parentRect.left; - y += parentRect.top; - } - } - } - bool isUsingUpdateLayeredWindow() const { return ! component.isOpaque(); @@ -1534,7 +1554,7 @@ private: } //============================================================================== - void doMouseEvent (const Point<int>& position) + void doMouseEvent (Point<int> position) { handleMouseEvent (0, position, currentModifiers, getMouseEventTime()); } @@ -1592,7 +1612,7 @@ private: && (flags & 0x80) != 0; // (bit 7 = 0 for pen events, 1 for touch) } - void doMouseMove (const Point<int>& position) + void doMouseMove (Point<int> position) { if (! isCurrentEventFromTouchScreen()) { @@ -1631,7 +1651,7 @@ private: } } - void doMouseDown (const Point<int>& position, const WPARAM wParam) + void doMouseDown (Point<int> position, const WPARAM wParam) { if (! isCurrentEventFromTouchScreen()) { @@ -1647,7 +1667,7 @@ private: } } - void doMouseUp (const Point<int>& position, const WPARAM wParam) + void doMouseUp (Point<int> position, const WPARAM wParam) { if (! isCurrentEventFromTouchScreen()) { @@ -1686,10 +1706,9 @@ private: doMouseEvent (getCurrentMousePos()); } - void doMouseWheel (const Point<int>& globalPos, const WPARAM wParam, const bool isVertical) + ComponentPeer* findPeerUnderMouse (Point<int>& localPos) { - updateKeyModifiers(); - const float amount = jlimit (-1000.0f, 1000.0f, 0.5f * (short) HIWORD (wParam)); + const Point<int> globalPos (getCurrentMousePosGlobal()); // Because Windows stupidly sends all wheel events to the window with the keyboard // focus, we have to redirect them here according to the mouse pos.. @@ -1699,17 +1718,69 @@ private: if (peer == nullptr) peer = this; + localPos = peer->globalToLocal (globalPos); + return peer; + } + + void doMouseWheel (const WPARAM wParam, const bool isVertical) + { + updateKeyModifiers(); + const float amount = jlimit (-1000.0f, 1000.0f, 0.5f * (short) HIWORD (wParam)); + MouseWheelDetails wheel; wheel.deltaX = isVertical ? 0.0f : amount / -256.0f; wheel.deltaY = isVertical ? amount / 256.0f : 0.0f; wheel.isReversed = false; wheel.isSmooth = false; - peer->handleMouseWheel (0, peer->globalToLocal (globalPos), getMouseEventTime(), wheel); + Point<int> localPos; + if (ComponentPeer* const peer = findPeerUnderMouse (localPos)) + peer->handleMouseWheel (0, localPos, getMouseEventTime(), wheel); + } + + bool doGestureEvent (LPARAM lParam) + { + GESTUREINFO gi; + zerostruct (gi); + gi.cbSize = sizeof (gi); + + if (getGestureInfo != nullptr && getGestureInfo ((HGESTUREINFO) lParam, &gi)) + { + updateKeyModifiers(); + Point<int> localPos; + + if (ComponentPeer* const peer = findPeerUnderMouse (localPos)) + { + switch (gi.dwID) + { + case 3: /*GID_ZOOM*/ + if (gi.dwFlags != 1 /*GF_BEGIN*/ && lastMagnifySize > 0) + peer->handleMagnifyGesture (0, localPos, getMouseEventTime(), + (float) (gi.ullArguments / (double) lastMagnifySize)); + + lastMagnifySize = gi.ullArguments; + return true; + + case 4: /*GID_PAN*/ + case 5: /*GID_ROTATE*/ + case 6: /*GID_TWOFINGERTAP*/ + case 7: /*GID_PRESSANDTAP*/ + default: + break; + } + } + } + + return false; } - void doTouchEvent (const int numInputs, HTOUCHINPUT eventHandle) + LRESULT doTouchEvent (const int numInputs, HTOUCHINPUT eventHandle) { + if ((styleFlags & windowIgnoresMouseClicks) != 0) + if (HWNDComponentPeer* const parent = getOwnerOfWindow (GetParent (hwnd))) + if (parent != this) + return parent->doTouchEvent (numInputs, eventHandle); + HeapBlock<TOUCHINPUT> inputInfo (numInputs); if (getTouchInputInfo (eventHandle, numInputs, inputInfo, sizeof (TOUCHINPUT))) @@ -1722,12 +1793,13 @@ private: { if (! handleTouchInput (inputInfo[i], (flags & TOUCHEVENTF_DOWN) != 0, (flags & TOUCHEVENTF_UP) != 0)) - return; // abandon method if this window was deleted by the callback + return 0; // abandon method if this window was deleted by the callback } } } closeTouchInputHandle (eventHandle); + return 0; } bool handleTouchInput (const TOUCHINPUT& touch, const bool isDown, const bool isUp) @@ -2174,7 +2246,8 @@ private: case WM_NCHITTEST: if ((styleFlags & windowIgnoresMouseClicks) != 0) return HTTRANSPARENT; - else if (! hasTitleBar()) + + if (! hasTitleBar()) return HTCLIENT; break; @@ -2222,15 +2295,20 @@ private: case 0x020A: /* WM_MOUSEWHEEL */ case 0x020E: /* WM_MOUSEHWHEEL */ - doMouseWheel (getCurrentMousePosGlobal(), wParam, message == 0x020A); + doMouseWheel (wParam, message == 0x020A); return 0; case WM_TOUCH: - if (getTouchInputInfo == nullptr) - break; + if (getTouchInputInfo != nullptr) + return doTouchEvent ((int) wParam, (HTOUCHINPUT) lParam); - doTouchEvent ((int) wParam, (HTOUCHINPUT) lParam); - return 0; + break; + + case 0x119: /* WM_GESTURE */ + if (doGestureEvent (lParam)) + return 0; + + break; //============================================================================== case WM_SIZING: return handleSizeConstraining (*(RECT*) lParam, wParam); @@ -2278,7 +2356,8 @@ private: if (doAppCommand (lParam)) return TRUE; - break; + case WM_MENUCHAR: // triggered when alt+something is pressed + return MNC_CLOSE << 16; // (avoids making the default system beep) //============================================================================== case WM_SETFOCUS: @@ -2946,7 +3025,7 @@ Point<int> MouseInputSource::getCurrentMousePosition() return Point<int> (mousePos.x, mousePos.y); } -void Desktop::setMousePosition (const Point<int>& newPosition) +void Desktop::setMousePosition (Point<int> newPosition) { SetCursorPos (newPosition.x, newPosition.y); } @@ -3083,6 +3162,8 @@ static BOOL CALLBACK enumMonitorsProc (HMONITOR, HDC, LPRECT r, LPARAM userInfo) void Desktop::Displays::findDisplays() { + setDPIAwareness(); + Array <Rectangle<int> > monitors; EnumDisplayMonitors (0, 0, &enumMonitorsProc, (LPARAM) &monitors); diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.cpp index 9015a1e85..751bcabc3 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.h b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.h index 352f214c1..369534764 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.h +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp index ea3cb965b..7482f57ac 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h index f10666a71..7d74f44b4 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp index 8f7e83ab4..b8de9afda 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -26,7 +25,7 @@ class MarkerListScope : public Expression::Scope { public: - MarkerListScope (Component& component_) : component (component_) {} + MarkerListScope (Component& comp) : component (comp) {} Expression getSymbolValue (const String& symbol) const { @@ -90,8 +89,8 @@ private: }; //============================================================================== -RelativeCoordinatePositionerBase::ComponentScope::ComponentScope (Component& component_) - : component (component_) +RelativeCoordinatePositionerBase::ComponentScope::ComponentScope (Component& comp) + : component (comp) { } @@ -151,8 +150,8 @@ Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponen class RelativeCoordinatePositionerBase::DependencyFinderScope : public ComponentScope { public: - DependencyFinderScope (Component& component_, RelativeCoordinatePositionerBase& positioner_, bool& ok_) - : ComponentScope (component_), positioner (positioner_), ok (ok_) + DependencyFinderScope (Component& comp, RelativeCoordinatePositionerBase& positioner_, bool& ok_) + : ComponentScope (comp), positioner (positioner_), ok (ok_) { } @@ -221,8 +220,8 @@ private: }; //============================================================================== -RelativeCoordinatePositionerBase::RelativeCoordinatePositionerBase (Component& component_) - : Component::Positioner (component_), registeredOk (false) +RelativeCoordinatePositionerBase::RelativeCoordinatePositionerBase (Component& comp) + : Component::Positioner (comp), registeredOk (false) { } diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h index c9eec0285..466b12138 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp index 52e5550d6..0be3594e0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -111,7 +110,7 @@ bool RelativeParallelogram::operator!= (const RelativeParallelogram& other) cons return ! operator== (other); } -const Point<float> RelativeParallelogram::getInternalCoordForPoint (const Point<float>* const corners, Point<float> target) noexcept +Point<float> RelativeParallelogram::getInternalCoordForPoint (const Point<float>* const corners, Point<float> target) noexcept { const Point<float> tr (corners[1] - corners[0]); const Point<float> bl (corners[2] - corners[0]); @@ -121,14 +120,14 @@ const Point<float> RelativeParallelogram::getInternalCoordForPoint (const Point< Line<float> (Point<float>(), bl).getIntersection (Line<float> (target, target - tr)).getDistanceFromOrigin()); } -const Point<float> RelativeParallelogram::getPointForInternalCoord (const Point<float>* const corners, const Point<float>& point) noexcept +Point<float> RelativeParallelogram::getPointForInternalCoord (const Point<float>* const corners, const Point<float> point) noexcept { return corners[0] + Line<float> (Point<float>(), corners[1] - corners[0]).getPointAlongLine (point.x) + Line<float> (Point<float>(), corners[2] - corners[0]).getPointAlongLine (point.y); } -const Rectangle<float> RelativeParallelogram::getBoundingBox (const Point<float>* const p) noexcept +Rectangle<float> RelativeParallelogram::getBoundingBox (const Point<float>* const p) noexcept { const Point<float> points[] = { p[0], p[1], p[2], p[1] + (p[2] - p[0]) }; return Rectangle<float>::findAreaContainingPoints (points, 4); diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h index aa544e27f..f8304d69d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -56,9 +55,9 @@ public: bool operator== (const RelativeParallelogram& other) const noexcept; bool operator!= (const RelativeParallelogram& other) const noexcept; - static const Point<float> getInternalCoordForPoint (const Point<float>* parallelogramCorners, Point<float> point) noexcept; - static const Point<float> getPointForInternalCoord (const Point<float>* parallelogramCorners, const Point<float>& internalPoint) noexcept; - static const Rectangle<float> getBoundingBox (const Point<float>* parallelogramCorners) noexcept; + static Point<float> getInternalCoordForPoint (const Point<float>* parallelogramCorners, Point<float> point) noexcept; + static Point<float> getPointForInternalCoord (const Point<float>* parallelogramCorners, Point<float> internalPoint) noexcept; + static Rectangle<float> getBoundingBox (const Point<float>* parallelogramCorners) noexcept; //============================================================================== RelativePoint topLeft, topRight, bottomLeft; diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp index b2e0f5552..307b2ec72 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -39,7 +38,7 @@ RelativePoint::RelativePoint() { } -RelativePoint::RelativePoint (const Point<float>& absolutePoint) +RelativePoint::RelativePoint (Point<float> absolutePoint) : x (absolutePoint.x), y (absolutePoint.y) { } @@ -72,13 +71,13 @@ bool RelativePoint::operator!= (const RelativePoint& other) const noexcept return ! operator== (other); } -const Point<float> RelativePoint::resolve (const Expression::Scope* scope) const +Point<float> RelativePoint::resolve (const Expression::Scope* scope) const { return Point<float> ((float) x.resolve (scope), (float) y.resolve (scope)); } -void RelativePoint::moveToAbsolute (const Point<float>& newPos, const Expression::Scope* scope) +void RelativePoint::moveToAbsolute (Point<float> newPos, const Expression::Scope* scope) { x.moveToAbsolute (newPos.x, scope); y.moveToAbsolute (newPos.y, scope); diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePoint.h b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePoint.h index 9928ae5f7..e09b531ef 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePoint.h +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePoint.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -42,7 +41,7 @@ public: RelativePoint(); /** Creates an absolute point, relative to the origin. */ - RelativePoint (const Point<float>& absolutePoint); + RelativePoint (Point<float> absolutePoint); /** Creates an absolute point, relative to the origin. */ RelativePoint (float absoluteX, float absoluteY); @@ -65,7 +64,7 @@ public: You'll need to provide a suitable Expression::Scope for looking up any coordinates that may be needed to calculate the result. */ - const Point<float> resolve (const Expression::Scope* evaluationContext) const; + Point<float> resolve (const Expression::Scope* evaluationContext) const; /** Changes the values of this point's coordinates to make it resolve to the specified position. @@ -73,7 +72,7 @@ public: or relative positions to whatever values are necessary to make the resultant position match the position that is provided. */ - void moveToAbsolute (const Point<float>& newPos, const Expression::Scope* evaluationContext); + void moveToAbsolute (Point<float> newPos, const Expression::Scope* evaluationContext); /** Returns a string which represents this point. This returns a comma-separated pair of coordinates. For details of the string syntax used by the diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp index 2b04f430c..87e6ca4cf 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.h b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.h index 8f695fbb7..0c1f5cb09 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.h +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp index 9da6fafef..27f3eb618 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -187,9 +186,9 @@ void RelativeRectangle::renameSymbol (const Expression::Symbol& oldSymbol, const class RelativeRectangleComponentPositioner : public RelativeCoordinatePositionerBase { public: - RelativeRectangleComponentPositioner (Component& component_, const RelativeRectangle& rectangle_) - : RelativeCoordinatePositionerBase (component_), - rectangle (rectangle_) + RelativeRectangleComponentPositioner (Component& comp, const RelativeRectangle& r) + : RelativeCoordinatePositionerBase (comp), + rectangle (r) { } diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h index a48d60122..be88d61b7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp index 2e851256c..2f8e568bc 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h index 612d786bd..398b8f621 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp index bf95af8da..1459dd370 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h index 924ca157d..8e4e2a023 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp index 20ed7717d..367626d73 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h index 6188c9ff2..8a407488c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp index cb1f2a110..96fd868d2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.h b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.h index e2ca12f3a..07cef047f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp index 37b6c76d8..c9b1f7f00 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -181,9 +180,8 @@ private: //============================================================================== PropertyPanel::PropertyPanel() + : messageWhenEmpty (TRANS("(nothing selected)")) { - messageWhenEmpty = TRANS("(nothing selected)"); - addAndMakeVisible (&viewport); viewport.setViewedComponent (propertyHolderComponent = new PropertyHolderComponent()); viewport.setFocusContainer (true); @@ -227,6 +225,11 @@ bool PropertyPanel::isEmpty() const return propertyHolderComponent->getNumSections() == 0; } +int PropertyPanel::getTotalContentHeight() const +{ + return propertyHolderComponent->getHeight(); +} + void PropertyPanel::addProperties (const Array <PropertyComponent*>& newProperties) { if (isEmpty()) diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.h b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.h index 68ca86a6c..68880e9ee 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.h +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -53,8 +52,7 @@ public: ~PropertyPanel(); //============================================================================== - /** Deletes all property components from the panel. - */ + /** Deletes all property components from the panel. */ void clear(); /** Adds a set of properties to the panel. @@ -87,27 +85,28 @@ public: /** Returns true if there no properties have been added. */ bool isEmpty() const; + /** Returns the height that the panel needs in order to display all of its content + without scrolling. + */ + int getTotalContentHeight() const; + //============================================================================== /** Returns a list of all the names of sections in the panel. - These are the sections that have been added with addSection(). */ StringArray getSectionNames() const; /** Returns true if the section at this index is currently open. - The index is from 0 up to the number of items returned by getSectionNames(). */ bool isSectionOpen (int sectionIndex) const; /** Opens or closes one of the sections. - The index is from 0 up to the number of items returned by getSectionNames(). */ void setSectionOpen (int sectionIndex, bool shouldBeOpen); /** Enables or disables one of the sections. - The index is from 0 up to the number of items returned by getSectionNames(). */ void setSectionEnabled (int sectionIndex, bool shouldBeEnabled); @@ -116,7 +115,6 @@ public: /** Saves the current state of open/closed sections so it can be restored later. The caller is responsible for deleting the object that is returned. - To restore this state, use restoreOpennessState(). @see restoreOpennessState @@ -135,7 +133,6 @@ public: //============================================================================== /** Sets a message to be displayed when there are no properties in the panel. - The default message is "nothing selected". */ void setMessageWhenEmpty (const String& newMessage); @@ -147,7 +144,7 @@ public: //============================================================================== /** @internal */ - void paint (Graphics& g); + void paint (Graphics&); /** @internal */ void resized(); diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp index cdfb0257c..def6b12fd 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h index 4310fa602..cab957259 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp index 194c5aab5..35c4f7630 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -47,7 +46,7 @@ public: void filesDropped (const StringArray& files, int, int) { - setText (getText() + files.joinIntoString (isMultiline ? "\n" : ", "), true); + setText (getText() + files.joinIntoString (isMultiline ? "\n" : ", "), sendNotificationSync); showEditor(); } @@ -102,7 +101,7 @@ TextPropertyComponent::~TextPropertyComponent() void TextPropertyComponent::setText (const String& newText) { - textEditor->setText (newText, true); + textEditor->setText (newText, sendNotificationSync); } String TextPropertyComponent::getText() const @@ -123,7 +122,7 @@ void TextPropertyComponent::createEditor (const int maxNumChars, const bool isMu void TextPropertyComponent::refresh() { - textEditor->setText (getText(), false); + textEditor->setText (getText(), dontSendNotification); } void TextPropertyComponent::textWasEdited() diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h index 65e8be522..17bc16f11 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 57115bba0..ea90062af 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -280,7 +279,7 @@ void ComboBox::setSelectedId (const int newItemId, const bool dontSendChangeMess if (! dontSendChangeMessage) triggerAsyncUpdate(); - label->setText (newItemText, false); + label->setText (newItemText, dontSendNotification); lastCurrentId = newItemId; currentId = newItemId; @@ -333,7 +332,7 @@ void ComboBox::setText (const String& newText, const bool dontSendChangeMessage) if (label->getText() != newText) { - label->setText (newText, false); + label->setText (newText, dontSendNotification); if (! dontSendChangeMessage) triggerAsyncUpdate(); @@ -417,7 +416,7 @@ void ComboBox::lookAndFeelChanged() newLabel->setEditable (label->isEditable()); newLabel->setJustificationType (label->getJustificationType()); newLabel->setTooltip (label->getTooltip()); - newLabel->setText (label->getText(), false); + newLabel->setText (label->getText(), dontSendNotification); } label = newLabel; diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.h index 6921a4b3b..fbceb539d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp index c8b78d649..4a6fca537 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.h index 0add8da61..d65ddebd0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.cpp index c081d562b..40d9a00b7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -56,7 +55,7 @@ Label::~Label() //============================================================================== void Label::setText (const String& newText, - const bool broadcastChangeMessage) + const NotificationType notification) { hideEditor (true); @@ -71,7 +70,7 @@ void Label::setText (const String& newText, if (ownerComponent != nullptr) componentMovedOrResized (*ownerComponent, true, true); - if (broadcastChangeMessage) + if (notification != dontSendNotification) callChangeListeners(); } } @@ -86,7 +85,7 @@ String Label::getText (const bool returnActiveEditorContents) const void Label::valueChanged (Value&) { if (lastTextValue != textValue.toString()) - setText (textValue.toString(), true); + setText (textValue.toString(), sendNotification); } //============================================================================== @@ -209,6 +208,10 @@ void Label::showEditor() editor->setText (getText(), false); editor->addListener (this); editor->grabKeyboardFocus(); + + if (editor == nullptr) // may be deleted by a callback + return; + editor->setHighlightedRegion (Range<int> (0, textValue.toString().length())); resized(); @@ -359,16 +362,13 @@ class LabelKeyboardFocusTraverser : public KeyboardFocusTraverser public: LabelKeyboardFocusTraverser() {} - Component* getNextComponent (Component* current) - { - return KeyboardFocusTraverser::getNextComponent (dynamic_cast <TextEditor*> (current) != nullptr - ? current->getParentComponent() : current); - } + Component* getNextComponent (Component* c) { return KeyboardFocusTraverser::getNextComponent (getComp (c)); } + Component* getPreviousComponent (Component* c) { return KeyboardFocusTraverser::getPreviousComponent (getComp (c)); } - Component* getPreviousComponent (Component* current) + static Component* getComp (Component* current) { - return KeyboardFocusTraverser::getPreviousComponent (dynamic_cast <TextEditor*> (current) != nullptr - ? current->getParentComponent() : current); + return dynamic_cast <TextEditor*> (current) != nullptr + ? current->getParentComponent() : current; } }; diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.h index cf968a4f1..1e80c8826 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -56,11 +55,11 @@ public: //============================================================================== /** Changes the label text. - If broadcastChangeMessage is true and the new text is different to the current - text, then the class will broadcast a change message to any Label::Listener objects - that are registered. + The NotificationType parameter indicates whether to send a change message to + any Label::Listener objects if the new text is different. */ - void setText (const String& newText, bool broadcastChangeMessage); + void setText (const String& newText, + NotificationType notification); /** Returns the label's current text. @@ -185,8 +184,7 @@ public: /** Destructor. */ virtual ~Listener() {} - /** Called when a Label's text has changed. - */ + /** Called when a Label's text has changed. */ virtual void labelTextChanged (Label* labelThatHasChanged) = 0; }; @@ -269,10 +267,10 @@ protected: virtual void textWasChanged(); /** Called when the text editor has just appeared, due to a user click or other focus change. */ - virtual void editorShown (TextEditor* editorComponent); + virtual void editorShown (TextEditor*); /** Called when the text editor is going to be deleted, after editing has finished. */ - virtual void editorAboutToBeHidden (TextEditor* editorComponent); + virtual void editorAboutToBeHidden (TextEditor*); //============================================================================== /** @internal */ @@ -309,6 +307,8 @@ protected: void colourChanged(); /** @internal */ void valueChanged (Value&); + /** @internal */ + void callChangeListeners(); private: //============================================================================== @@ -327,7 +327,6 @@ private: bool leftOfOwnerComp : 1; bool updateFromTextEditorContents (TextEditor&); - void callChangeListeners(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Label) }; diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 545357573..30d3d388e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -33,7 +32,7 @@ public: { } - void paint (Graphics& g) + void paint (Graphics& g) override { if (ListBoxModel* m = owner.getModel()) m->paintListBoxItem (row, g, getWidth(), getHeight(), selected); @@ -60,7 +59,7 @@ public: } } - void mouseDown (const MouseEvent& e) + void mouseDown (const MouseEvent& e) override { isDragging = false; selectRowOnMouseUp = false; @@ -81,7 +80,7 @@ public: } } - void mouseUp (const MouseEvent& e) + void mouseUp (const MouseEvent& e) override { if (isEnabled() && selectRowOnMouseUp && ! isDragging) { @@ -92,14 +91,14 @@ public: } } - void mouseDoubleClick (const MouseEvent& e) + void mouseDoubleClick (const MouseEvent& e) override { if (ListBoxModel* m = owner.getModel()) if (isEnabled()) m->listBoxItemDoubleClicked (row, e); } - void mouseDrag (const MouseEvent& e) + void mouseDrag (const MouseEvent& e) override { if (ListBoxModel* m = owner.getModel()) { @@ -121,13 +120,13 @@ public: } } - void resized() + void resized() override { if (customComponent != nullptr) customComponent->setBounds (getLocalBounds()); } - String getTooltip() + String getTooltip() override { if (ListBoxModel* m = owner.getModel()) return m->getTooltipForRow (row); @@ -157,7 +156,6 @@ public: Component* const content = new Component(); setViewedComponent (content); - content->addMouseListener (this, false); content->setWantsKeyboardFocus (false); } @@ -184,7 +182,7 @@ public: return -1; } - void visibleAreaChanged (const Rectangle<int>&) + void visibleAreaChanged (const Rectangle<int>&) override { updateVisibleArea (true); @@ -298,13 +296,13 @@ public: } } - void paint (Graphics& g) + void paint (Graphics& g) override { if (isOpaque()) g.fillAll (owner.findColour (ListBox::backgroundColourId)); } - bool keyPressed (const KeyPress& key) + bool keyPressed (const KeyPress& key) override { if (key.isKeyCode (KeyPress::upKey) || key.isKeyCode (KeyPress::downKey) @@ -335,18 +333,42 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ListViewport) }; -enum { defaultListRowHeight = 22 }; +//============================================================================== +class ListBoxMouseMoveSelector : public MouseListener +{ +public: + ListBoxMouseMoveSelector (ListBox& lb) : owner (lb) + { + owner.addMouseListener (this, true); + } + + void mouseMove (const MouseEvent& e) override + { + const MouseEvent e2 (e.getEventRelativeTo (&owner)); + owner.selectRow (owner.getRowContainingPosition (e2.x, e2.y), true); + } + + void mouseExit (const MouseEvent& e) override + { + mouseMove (e); + } + +private: + ListBox& owner; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ListBoxMouseMoveSelector) +}; + //============================================================================== ListBox::ListBox (const String& name, ListBoxModel* const m) : Component (name), model (m), totalItems (0), - rowHeight (defaultListRowHeight), + rowHeight (22), minimumRowWidth (0), outlineThickness (0), lastRowSelected (-1), - mouseMoveSelects (false), multipleSelection (false), hasDoneInitialUpdate (false) { @@ -379,10 +401,15 @@ void ListBox::setMultipleSelectionEnabled (bool b) void ListBox::setMouseMoveSelectsRows (bool b) { - mouseMoveSelects = b; - if (b) - addMouseListener (this, true); + { + if (mouseMoveSelector == nullptr) + mouseMoveSelector = new ListBoxMouseMoveSelector (*this); + } + else + { + mouseMoveSelector = nullptr; + } } //============================================================================== @@ -399,7 +426,7 @@ void ListBox::paintOverChildren (Graphics& g) if (outlineThickness > 0) { g.setColour (findColour (outlineColourId)); - g.drawRect (0, 0, getWidth(), getHeight(), outlineThickness); + g.drawRect (getLocalBounds(), outlineThickness); } } @@ -528,7 +555,7 @@ void ListBox::selectRangeOfRows (int firstRow, int lastRow) { const int numRows = totalItems - 1; firstRow = jlimit (0, jmax (0, numRows), firstRow); - lastRow = jlimit (0, jmax (0, numRows), lastRow); + lastRow = jlimit (0, jmax (0, numRows), lastRow); selected.addRange (Range <int> (jmin (firstRow, lastRow), jmax (firstRow, lastRow) + 1)); @@ -562,7 +589,7 @@ void ListBox::deselectAllRows() } void ListBox::selectRowsBasedOnModifierKeys (const int row, - const ModifierKeys& mods, + ModifierKeys mods, const bool isMouseUpEvent) { if (multipleSelection && mods.isCommandDown()) @@ -766,13 +793,13 @@ void ListBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whee { bool eventWasUsed = false; - if (viewport->getHorizontalScrollBar()->isVisible() && wheel.deltaX != 0) + if (wheel.deltaX != 0 && viewport->getHorizontalScrollBar()->isVisible()) { eventWasUsed = true; viewport->getHorizontalScrollBar()->mouseWheelMove (e, wheel); } - if (viewport->getVerticalScrollBar()->isVisible() && wheel.deltaY != 0) + if (wheel.deltaY != 0 && viewport->getVerticalScrollBar()->isVisible()) { eventWasUsed = true; viewport->getVerticalScrollBar()->mouseWheelMove (e, wheel); @@ -782,20 +809,6 @@ void ListBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whee Component::mouseWheelMove (e, wheel); } -void ListBox::mouseMove (const MouseEvent& e) -{ - if (mouseMoveSelects) - { - const MouseEvent e2 (e.getEventRelativeTo (this)); - selectRow (getRowContainingPosition (e2.x, e2.y), true); - } -} - -void ListBox::mouseExit (const MouseEvent& e) -{ - mouseMove (e); -} - void ListBox::mouseUp (const MouseEvent& e) { if (e.mouseWasClicked() && model != nullptr) diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.h index e8fb828bb..01c0e9cb7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -333,7 +332,7 @@ public: @see selectRow */ void selectRowsBasedOnModifierKeys (int rowThatWasClickedOn, - const ModifierKeys& modifiers, + ModifierKeys modifiers, bool isMouseUpEvent); //============================================================================== @@ -541,10 +540,6 @@ public: /** @internal */ void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); /** @internal */ - void mouseMove (const MouseEvent&); - /** @internal */ - void mouseExit (const MouseEvent&); - /** @internal */ void mouseUp (const MouseEvent&); /** @internal */ void colourChanged(); @@ -560,10 +555,11 @@ private: ListBoxModel* model; ScopedPointer<ListViewport> viewport; ScopedPointer<Component> headerComponent; + ScopedPointer<MouseListener> mouseMoveSelector; int totalItems, rowHeight, minimumRowWidth; int outlineThickness; int lastRowSelected; - bool mouseMoveSelects, multipleSelection, hasDoneInitialUpdate; + bool multipleSelection, hasDoneInitialUpdate; SparseSet <int> selected; void selectRowInternal (int rowNumber, bool dontScrollToShowThisRow, diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp index 0b957c025..a4bdc3dac 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.h index dcf24c64b..46062fb22 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp index 57c9499f8..57d97e23e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -29,9 +28,9 @@ class Slider::Pimpl : public AsyncUpdater, public ValueListener { public: - Pimpl (Slider& owner_, SliderStyle style_, TextEntryBoxPosition textBoxPosition) - : owner (owner_), - style (style_), + Pimpl (Slider& s, SliderStyle sliderStyle, TextEntryBoxPosition textBoxPosition) + : owner (s), + style (sliderStyle), lastCurrentValue (0), lastValueMin (0), lastValueMax (0), minimum (0), maximum (10), interval (0), doubleClickReturnValue (0), skewFactor (1.0), velocityModeSensitivity (1.0), @@ -359,15 +358,24 @@ public: listeners.callChecked (checker, &SliderListener::sliderDragEnded, slider); } + struct DragInProgress + { + DragInProgress (Pimpl& p) : owner (p) { owner.sendDragStart(); } + ~DragInProgress() { owner.sendDragEnd(); } + + Pimpl& owner; + + JUCE_DECLARE_NON_COPYABLE (DragInProgress) + }; + void buttonClicked (Button* button) { if (style == IncDecButtons) { const double delta = (button == incButton) ? interval : -interval; - sendDragStart(); + DragInProgress drag (*this); setValue (owner.snapValue (getValue() + delta, false), sendNotificationSync); - sendDragEnd(); } } @@ -390,9 +398,8 @@ public: if (newValue != (double) currentValue.getValue()) { - sendDragStart(); + DragInProgress drag (*this); setValue (newValue, sendNotificationSync); - sendDragEnd(); } updateText(); // force a clean-up of the text, needed in case setValue() hasn't done this. @@ -401,7 +408,7 @@ public: void updateText() { if (valueBox != nullptr) - valueBox->setText (owner.getTextFromValue (currentValue.getValue()), false); + valueBox->setText (owner.getTextFromValue (currentValue.getValue()), dontSendNotification); } double constrainedValue (double value) const @@ -564,7 +571,7 @@ public: owner.addAndMakeVisible (valueBox = lf.createSliderTextBox (owner)); valueBox->setWantsKeyboardFocus (false); - valueBox->setText (previousTextBoxContent, false); + valueBox->setText (previousTextBoxContent, dontSendNotification); if (valueBox->isEditable() != editableText) // (avoid overriding the single/double click flags unless we have to) valueBox->setEditable (editableText && owner.isEnabled()); @@ -821,6 +828,7 @@ public: incDecDragged = false; useDragEvents = false; mouseDragStartPos = mousePosWhenLastDragged = e.getPosition(); + currentDrag = nullptr; if (owner.isEnabled()) { @@ -864,7 +872,7 @@ public: popup->setVisible (true); } - sendDragStart(); + currentDrag = new DragInProgress (*this); mouseDrag (e); } } @@ -944,7 +952,7 @@ public: if (sendChangeOnlyOnRelease && valueOnMouseDown != (double) currentValue.getValue()) triggerChangeMessage (sendNotificationAsync); - sendDragEnd(); + currentDrag = nullptr; popupDisplay = nullptr; if (style == IncDecButtons) @@ -957,6 +965,8 @@ public: { popupDisplay->startTimer (2000); } + + currentDrag = nullptr; } bool canDoubleClickToValue() const @@ -971,9 +981,8 @@ public: { if (canDoubleClickToValue()) { - sendDragStart(); + DragInProgress drag (*this); setValue (doubleClickReturnValue, sendNotificationSync); - sendDragEnd(); } } @@ -998,9 +1007,8 @@ public: if (value > newValue) delta = -delta; - sendDragStart(); + DragInProgress drag (*this); setValue (owner.snapValue (value + delta, false), sendNotificationSync); - sendDragEnd(); } return true; @@ -1217,6 +1225,7 @@ public: int sliderBeingDragged; int pixelsForFullDragExtent; Rectangle<int> sliderRect; + ScopedPointer<DragInProgress> currentDrag; TextEntryBoxPosition textBoxPos; String textSuffix; @@ -1247,11 +1256,12 @@ public: public Timer { public: - PopupDisplayComponent (Slider& owner_) - : owner (owner_), - font (15.0f, Font::bold) + PopupDisplayComponent (Slider& s) + : owner (s), + font (s.getLookAndFeel().getSliderPopupFont()) { setAlwaysOnTop (true); + setAllowedPlacement (owner.getLookAndFeel().getSliderPopupPlacement()); } void paintContent (Graphics& g, int w, int h) @@ -1461,9 +1471,9 @@ void Slider::setDoubleClickReturnValue (bool isDoubleClickEnabled, double value pimpl->doubleClickReturnValue = valueToSetOnDoubleClick; } -double Slider::getDoubleClickReturnValue (bool& isEnabled_) const +double Slider::getDoubleClickReturnValue (bool& isEnabledResult) const { - isEnabled_ = pimpl->doubleClickToValue; + isEnabledResult = pimpl->doubleClickToValue; return pimpl->doubleClickReturnValue; } @@ -1537,7 +1547,7 @@ void Slider::stoppedDragging() {} void Slider::valueChanged() {} //============================================================================== -void Slider::setPopupMenuEnabled (const bool menuEnabled_) { pimpl->menuEnabled = menuEnabled_; } +void Slider::setPopupMenuEnabled (const bool menuEnabled) { pimpl->menuEnabled = menuEnabled; } void Slider::setScrollWheelEnabled (const bool enabled) { pimpl->scrollWheelEnabled = enabled; } bool Slider::isHorizontal() const noexcept { return pimpl->isHorizontal(); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.h index af77ea188..8a973dfbe 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index bc85ff54f..8f7e3baff 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h index 7cdaa2198..35d468120 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableListBox.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableListBox.cpp index 62c88d5d7..748cf1331 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableListBox.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableListBox.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableListBox.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableListBox.h index 373f0a1b3..b7ef648f3 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableListBox.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TableListBox.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 18142be1e..84596312f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -61,7 +60,7 @@ struct TextAtom class TextEditor::UniformTextSection { public: - UniformTextSection (const String& text, const Font& f, const Colour& col, const juce_wchar passwordChar) + UniformTextSection (const String& text, const Font& f, const Colour col, const juce_wchar passwordChar) : font (f), colour (col) { initialiseAtoms (text, passwordChar); @@ -175,7 +174,7 @@ public: mo << atoms.getUnchecked(i)->atomText; } - void appendSubstring (MemoryOutputStream& mo, const Range<int>& range) const + void appendSubstring (MemoryOutputStream& mo, const Range<int> range) const { int index = 0; for (int i = 0; i < atoms.size(); ++i) @@ -557,7 +556,7 @@ public: } } - void drawSelection (Graphics& g, const Range<int>& selected) const + void drawSelection (Graphics& g, const Range<int> selected) const { const int startX = roundToInt (indexToX (selected.getStart())); const int endX = roundToInt (indexToX (selected.getEnd())); @@ -568,7 +567,7 @@ public: g.fillRect (startX, y, endX - startX, nextY - y); } - void drawUnderline (Graphics& g, const Range<int>& underline, const Colour& colour) const + void drawUnderline (Graphics& g, const Range<int> underline, const Colour colour) const { const int startX = roundToInt (indexToX (underline.getStart())); const int endX = roundToInt (indexToX (underline.getEnd())); @@ -580,8 +579,8 @@ public: } void drawSelectedText (Graphics& g, - const Range<int>& selected, - const Colour& selectedTextColour) const + const Range<int> selected, + const Colour selectedTextColour) const { if (passwordCharacter != 0 || ! atom->isWhitespace()) { @@ -728,7 +727,7 @@ public: const String& newText, const int insertPos, const Font& newFont, - const Colour& newColour, + const Colour newColour, const int oldCaret, const int newCaret) : owner (ed), @@ -1113,6 +1112,7 @@ void TextEditor::lookAndFeelChanged() { setCaretVisible (false); setCaretVisible (true); + updateCaretPosition(); } } @@ -1281,7 +1281,7 @@ void TextEditor::timerCallbackInt() newTransaction(); } -void TextEditor::repaintText (const Range<int>& range) +void TextEditor::repaintText (const Range<int> range) { if (! range.isEmpty()) { @@ -1653,7 +1653,7 @@ void TextEditor::drawContent (Graphics& g) for (int j = underlinedSections.size(); --j >= 0;) { - const Range<int>& underlinedSection = underlinedSections.getReference (j); + const Range<int> underlinedSection = underlinedSections.getReference (j); Iterator i2 (sections, wordWrapWidth, passwordCharacter); @@ -2093,7 +2093,7 @@ void TextEditor::focusGained (FocusChangeType) if (ComponentPeer* const peer = getPeer()) if (! isReadOnly()) - peer->textInputRequired (getScreenPosition() - peer->getScreenPosition()); + peer->textInputRequired (peer->globalToLocal (getScreenPosition())); } void TextEditor::focusLost (FocusChangeType) @@ -2182,7 +2182,7 @@ void TextEditor::clearInternal (UndoManager* const um) void TextEditor::insert (const String& text, const int insertIndex, const Font& font, - const Colour& colour, + const Colour colour, UndoManager* const um, const int caretPositionToMoveTo) { @@ -2279,7 +2279,7 @@ void TextEditor::reinsert (const int insertIndex, valueTextNeedsUpdating = true; } -void TextEditor::remove (const Range<int>& range, +void TextEditor::remove (Range<int> range, UndoManager* const um, const int caretPositionToMoveTo) { diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TextEditor.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TextEditor.h index 096db1804..1d47485b0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -406,16 +405,16 @@ public: The rectangle returned is relative to the component's top-left corner. @see scrollEditorToPositionCaret */ - Rectangle<int> getCaretRectangle(); + Rectangle<int> getCaretRectangle() override; /** Selects a section of the text. */ - void setHighlightedRegion (const Range<int>& newSelection); + void setHighlightedRegion (const Range<int>& newSelection) override; /** Returns the range of characters that are selected. If nothing is selected, this will return an empty range. @see setHighlightedRegion */ - Range<int> getHighlightedRegion() const { return selection; } + Range<int> getHighlightedRegion() const override { return selection; } /** Returns the section of text that is currently selected. */ String getHighlightedText() const; @@ -699,9 +698,9 @@ private: void coalesceSimilarSections(); void splitSection (int sectionIndex, int charToSplitAt); void clearInternal (UndoManager*); - void insert (const String&, int insertIndex, const Font&, const Colour&, UndoManager*, int newCaretPos); + void insert (const String&, int insertIndex, const Font&, const Colour, UndoManager*, int newCaretPos); void reinsert (int insertIndex, const Array <UniformTextSection*>&); - void remove (const Range<int>& range, UndoManager*, int caretPositionToMoveTo); + void remove (Range<int> range, UndoManager*, int caretPositionToMoveTo); void getCharPosition (int index, float& x, float& y, float& lineHeight) const; void updateCaretPosition(); void updateValueFromText(); @@ -716,7 +715,7 @@ private: void updateTextHolderSize(); float getWordWrapWidth() const; void timerCallbackInt(); - void repaintText (const Range<int>&); + void repaintText (Range<int>); void scrollByLines (int deltaLines); bool undoOrRedo (bool shouldUndo); UndoManager* getUndoManager() noexcept; diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Toolbar.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Toolbar.cpp index 2b445f437..57599aef3 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Toolbar.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Toolbar.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -708,8 +707,9 @@ private: : factory (factory_), toolbar (toolbar_), palette (factory_, toolbar_), - instructions (String::empty, TRANS ("You can drag the items above and drop them onto a toolbar to add them.\n\n" - "Items on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them.")), + instructions (String::empty, TRANS ("You can drag the items above and drop them onto a toolbar to add them.") + + "\n\n" + + TRANS ("Items on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them.")), defaultButton (TRANS ("Restore to default set of items")) { addAndMakeVisible (&palette); diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Toolbar.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Toolbar.h index 23f4de7fe..3aaa3bd09 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Toolbar.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Toolbar.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp index d8c11e2a8..2887a11f5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -51,8 +50,8 @@ public: && tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar) { g.setColour (findColour (Toolbar::editingModeOutlineColourId, true)); - g.drawRect (0, 0, getWidth(), getHeight(), - jmin (2, (getWidth() - 1) / 2, (getHeight() - 1) / 2)); + g.drawRect (getLocalBounds(), jmin (2, (getWidth() - 1) / 2, + (getHeight() - 1) / 2)); } } } diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h index b675cbd73..5a33545f8 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h index 619aff6c1..d519fac73 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp index 9df6ee760..b5c08cb94 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h index ada2cb5f1..9d7451c47 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TreeView.cpp index 5aaf52ad2..b19dbda31 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -31,7 +30,8 @@ public: ContentComponent (TreeView& tree) : owner (tree), buttonUnderMouse (nullptr), - isDragging (false) + isDragging (false), + needSelectionOnMouseUp (false) { } @@ -279,7 +279,7 @@ private: TreeViewItem* buttonUnderMouse; bool isDragging, needSelectionOnMouseUp; - void selectBasedOnModifiers (TreeViewItem* const item, const ModifierKeys& modifiers) + void selectBasedOnModifiers (TreeViewItem* const item, const ModifierKeys modifiers) { TreeViewItem* firstSelected = nullptr; @@ -925,7 +925,7 @@ class TreeView::InsertPointHighlight : public Component { public: InsertPointHighlight() - : lastItem (nullptr) + : lastItem (nullptr), lastIndex (0) { setSize (100, 12); setAlwaysOnTop (true); @@ -1123,6 +1123,8 @@ TreeViewItem::TreeViewItem() y (0), itemHeight (0), totalHeight (0), + itemWidth (0), + totalWidth (0), selected (false), redrawNeeded (true), drawLinesInside (true), @@ -1158,19 +1160,26 @@ TreeViewItem* TreeViewItem::getSubItem (const int index) const noexcept void TreeViewItem::clearSubItems() { - if (subItems.size() > 0) + if (ownerView != nullptr) { - if (ownerView != nullptr) + const ScopedLock sl (ownerView->nodeAlterationLock); + + if (subItems.size() > 0) { - const ScopedLock sl (ownerView->nodeAlterationLock); - subItems.clear(); + removeAllSubItemsFromList(); treeHasChanged(); } - else - { - subItems.clear(); - } } + else + { + removeAllSubItemsFromList(); + } +} + +void TreeViewItem::removeAllSubItemsFromList() +{ + for (int i = subItems.size(); --i >= 0;) + removeSubItemFromList (i, true); } void TreeViewItem::addSubItem (TreeViewItem* const newItem, const int insertPosition) @@ -1204,22 +1213,31 @@ void TreeViewItem::addSubItem (TreeViewItem* const newItem, const int insertPosi } } -void TreeViewItem::removeSubItem (const int index, const bool deleteItem) +void TreeViewItem::removeSubItem (int index, bool deleteItem) { if (ownerView != nullptr) { const ScopedLock sl (ownerView->nodeAlterationLock); - if (isPositiveAndBelow (index, subItems.size())) - { - subItems.remove (index, deleteItem); + if (removeSubItemFromList (index, deleteItem)) treeHasChanged(); - } } else { + removeSubItemFromList (index, deleteItem); + } +} + +bool TreeViewItem::removeSubItemFromList (int index, bool deleteItem) +{ + if (TreeViewItem* child = subItems [index]) + { + child->parentItem = nullptr; subItems.remove (index, deleteItem); + return true; } + + return false; } bool TreeViewItem::isOpen() const noexcept @@ -1371,7 +1389,7 @@ Rectangle<int> TreeViewItem::getItemPosition (const bool relativeToTreeViewTopLe Rectangle<int> r (indentX, y, jmax (0, width), totalHeight); - if (relativeToTreeViewTopLeft) + if (relativeToTreeViewTopLeft && ownerView != nullptr) r -= ownerView->viewport->getViewPosition(); return r; @@ -1708,10 +1726,8 @@ int TreeViewItem::getRowNumberInTree() const noexcept return n; } - else - { - return 0; - } + + return 0; } void TreeViewItem::setLinesDrawnForSubItems (const bool drawLines) noexcept @@ -1840,13 +1856,10 @@ XmlElement* TreeViewItem::getOpennessState (const bool canReturnNull) const e->setAttribute ("id", name); return e; } - else - { - // trying to save the openness for an element that has no name - this won't - // work because it needs the names to identify what to open. - jassertfalse; - } + // trying to save the openness for an element that has no name - this won't + // work because it needs the names to identify what to open. + jassertfalse; return nullptr; } diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TreeView.h b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TreeView.h index e0d7890b6..1de6902e8 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_TreeView.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -551,6 +550,8 @@ private: void restoreToDefaultOpenness(); bool isFullyOpen() const noexcept; XmlElement* getOpennessState (bool canReturnNull) const; + bool removeSubItemFromList (int index, bool deleteItem); + void removeAllSubItemsFromList(); #if JUCE_CATCH_DEPRECATED_CODE_MISUSE // The parameters for these methods have changed - please update your code! @@ -610,7 +611,6 @@ public: TreeViewItem* getRootItem() const noexcept { return rootItem; } /** This will remove and delete the current root item. - It's a convenient way of deleting the item and calling setRootItem (nullptr). */ void deleteRootItem(); diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index dd0dc7250..d4fa9e55d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -632,7 +631,7 @@ void AlertWindow::showMessageBox (AlertIconType iconType, else { AlertWindowInfo info (title, message, associatedComponent, iconType, 1, nullptr, true); - info.button1 = buttonText.isEmpty() ? TRANS("ok") : buttonText; + info.button1 = buttonText.isEmpty() ? TRANS("OK") : buttonText; info.invoke(); } @@ -653,7 +652,7 @@ void AlertWindow::showMessageBoxAsync (AlertIconType iconType, else { AlertWindowInfo info (title, message, associatedComponent, iconType, 1, callback, false); - info.button1 = buttonText.isEmpty() ? TRANS("ok") : buttonText; + info.button1 = buttonText.isEmpty() ? TRANS("OK") : buttonText; info.invoke(); } @@ -671,8 +670,8 @@ bool AlertWindow::showOkCancelBox (AlertIconType iconType, return NativeMessageBox::showOkCancelBox (iconType, title, message, associatedComponent, callback); AlertWindowInfo info (title, message, associatedComponent, iconType, 2, callback, callback == nullptr); - info.button1 = button1Text.isEmpty() ? TRANS("ok") : button1Text; - info.button2 = button2Text.isEmpty() ? TRANS("cancel") : button2Text; + info.button1 = button1Text.isEmpty() ? TRANS("OK") : button1Text; + info.button2 = button2Text.isEmpty() ? TRANS("Cancel") : button2Text; return info.invoke() != 0; } @@ -690,9 +689,9 @@ int AlertWindow::showYesNoCancelBox (AlertIconType iconType, return NativeMessageBox::showYesNoCancelBox (iconType, title, message, associatedComponent, callback); AlertWindowInfo info (title, message, associatedComponent, iconType, 3, callback, callback == nullptr); - info.button1 = button1Text.isEmpty() ? TRANS("yes") : button1Text; - info.button2 = button2Text.isEmpty() ? TRANS("no") : button2Text; - info.button3 = button3Text.isEmpty() ? TRANS("cancel") : button3Text; + info.button1 = button1Text.isEmpty() ? TRANS("Yes") : button1Text; + info.button2 = button2Text.isEmpty() ? TRANS("No") : button2Text; + info.button3 = button3Text.isEmpty() ? TRANS("Cancel") : button3Text; return info.invoke(); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_AlertWindow.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_AlertWindow.h index 9bb375fd5..af0b622d9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_AlertWindow.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_AlertWindow.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_CallOutBox.cpp b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_CallOutBox.cpp index b9bc89785..63d7459d7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_CallOutBox.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_CallOutBox.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_CallOutBox.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_CallOutBox.h index c69e4e73b..56c5af077 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_CallOutBox.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_CallOutBox.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index f545b5263..dcfe1d04e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -27,9 +26,9 @@ static Array <ComponentPeer*> heavyweightPeers; static uint32 lastUniqueID = 1; //============================================================================== -ComponentPeer::ComponentPeer (Component& component_, const int styleFlags_) - : component (component_), - styleFlags (styleFlags_), +ComponentPeer::ComponentPeer (Component& comp, const int flags) + : component (comp), + styleFlags (flags), constrainer (nullptr), lastDragAndDropCompUnderMouse (nullptr), uniqueID (lastUniqueID += 2), // increment by 2 so that this can never hit 0 @@ -99,20 +98,27 @@ MouseInputSource* ComponentPeer::getOrCreateMouseInputSource (int touchIndex) } } -void ComponentPeer::handleMouseEvent (const int touchIndex, const Point<int>& positionWithinPeer, - const ModifierKeys& newMods, const int64 time) +void ComponentPeer::handleMouseEvent (const int touchIndex, const Point<int> positionWithinPeer, + const ModifierKeys newMods, const int64 time) { if (MouseInputSource* mouse = getOrCreateMouseInputSource (touchIndex)) mouse->handleEvent (this, positionWithinPeer, time, newMods); } -void ComponentPeer::handleMouseWheel (const int touchIndex, const Point<int>& positionWithinPeer, +void ComponentPeer::handleMouseWheel (const int touchIndex, const Point<int> positionWithinPeer, const int64 time, const MouseWheelDetails& wheel) { if (MouseInputSource* mouse = getOrCreateMouseInputSource (touchIndex)) mouse->handleWheel (this, positionWithinPeer, time, wheel); } +void ComponentPeer::handleMagnifyGesture (const int touchIndex, const Point<int> positionWithinPeer, + const int64 time, const float scaleFactor) +{ + if (MouseInputSource* mouse = getOrCreateMouseInputSource (touchIndex)) + mouse->handleMagnifyGesture (this, positionWithinPeer, time, scaleFactor); +} + //============================================================================== void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo) { diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ComponentPeer.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ComponentPeer.h index 76898b4e0..0b50b004c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ComponentPeer.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ComponentPeer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -135,20 +134,6 @@ public: virtual void setRepresentedFile (const File&); //============================================================================== - /** Moves the window without changing its size. - - If the native window is contained in another window, then the co-ordinates are - relative to the parent window's origin, not the screen origin. - - This should result in a callback to handleMovedOrResized(). - */ - virtual void setPosition (int x, int y) = 0; - - /** Resizes the window without changing its position. - This should result in a callback to handleMovedOrResized(). - */ - virtual void setSize (int w, int h) = 0; - /** Moves and resizes the window. If the native window is contained in another window, then the co-ordinates are @@ -156,7 +141,7 @@ public: This should result in a callback to handleMovedOrResized(). */ - virtual void setBounds (int x, int y, int w, int h, bool isNowFullScreen) = 0; + virtual void setBounds (const Rectangle<int>& newBounds, bool isNowFullScreen) = 0; /** Returns the current position and size of the window. @@ -165,9 +150,6 @@ public: */ virtual Rectangle<int> getBounds() const = 0; - /** Returns the x-position of this window, relative to the screen's origin. */ - virtual Point<int> getScreenPosition() const = 0; - /** Converts a position relative to the top-left of this component to screen co-ordinates. */ virtual Point<int> localToGlobal (const Point<int>& relativePosition) = 0; @@ -313,8 +295,9 @@ public: virtual void setAlpha (float newAlpha) = 0; //============================================================================== - void handleMouseEvent (int touchIndex, const Point<int>& positionWithinPeer, const ModifierKeys& newMods, int64 time); - void handleMouseWheel (int touchIndex, const Point<int>& positionWithinPeer, int64 time, const MouseWheelDetails&); + void handleMouseEvent (int touchIndex, const Point<int> positionWithinPeer, const ModifierKeys newMods, int64 time); + void handleMouseWheel (int touchIndex, const Point<int> positionWithinPeer, int64 time, const MouseWheelDetails&); + void handleMagnifyGesture (int touchIndex, const Point<int> positionWithinPeer, int64 time, float scaleFactor); void handleUserClosingWindow(); diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DialogWindow.cpp b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DialogWindow.cpp index 0631faee6..7a7a2b382 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DialogWindow.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DialogWindow.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DialogWindow.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DialogWindow.h index 0e52ae4f2..cbbe577ed 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DialogWindow.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DialogWindow.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -119,7 +118,7 @@ public: will be automatically deleted when the modal state is terminated. When the dialog's close button is clicked, it'll automatically terminate its - modal state, but you can also do this programatically by calling + modal state, but you can also do this programmatically by calling exitModalState (returnValue) on the DialogWindow. If your content component needs to find the dialog window that it is @@ -162,7 +161,7 @@ public: you want to block and run a modal loop until the dialog is dismissed, use showModalDialog() instead. - To close the dialog programatically, you should call exitModalState (returnValue) on + To close the dialog programmatically, you should call exitModalState (returnValue) on the DialogWindow that is created. To find a pointer to this window from your contentComponent, you can do something like this: @code @@ -210,7 +209,7 @@ public: It returns the value that was returned by the dialog box's runModalLoop() call. - To close the dialog programatically, you should call exitModalState (returnValue) on + To close the dialog programmatically, you should call exitModalState (returnValue) on the DialogWindow that is created. To find a pointer to this window from your contentComponent, you can do something like this: @code diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index 106492714..42a7bf7e5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DocumentWindow.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DocumentWindow.h index dc3bbe9e3..6b6d63849 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DocumentWindow.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_DocumentWindow.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_NativeMessageBox.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_NativeMessageBox.h index 65dc80983..4243330f0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_NativeMessageBox.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_NativeMessageBox.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index d485f59c1..9f17a6ff4 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ResizableWindow.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ResizableWindow.h index 1024669ae..bb9dae4d5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ResizableWindow.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ResizableWindow.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp index 8beecf53d..9a3a027e7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h index edbfe465b..f4713cca2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp index e1893c07b..514106f2f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TooltipWindow.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TooltipWindow.h index 750de5de8..d2bd70a3d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TooltipWindow.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TooltipWindow.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -35,7 +34,8 @@ A window that displays a pop-up tooltip when the mouse hovers over another component. To enable tooltips in your app, just create a single instance of a TooltipWindow - object. + object. Note that if you instantiate more than one instance of this class, you'll + end up with multiple tooltips being shown! The TooltipWindow object will then stay invisible, waiting until the mouse hovers for the specified length of time - it will then see if it's currently diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp index 2baffb890..3fee0efc2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TopLevelWindow.h b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TopLevelWindow.h index 767ac200f..6383109e0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TopLevelWindow.h +++ b/JuceLibraryCode/modules/juce_gui_basics/windows/juce_TopLevelWindow.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp index 8d2de3c66..10243b395 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h index 8219cc005..352b91819 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h +++ b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h index a51907ac0..86c0fcfc2 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h +++ b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp index 7b71d0d4d..678c0eca2 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -26,14 +25,14 @@ class CodeDocumentLine { public: - CodeDocumentLine (const String::CharPointerType& line_, - const int lineLength_, + CodeDocumentLine (const String::CharPointerType& l, + const int lineLen, const int numNewLineChars, - const int lineStartInFile_) - : line (line_, (size_t) lineLength_), - lineStartInFile (lineStartInFile_), - lineLength (lineLength_), - lineLengthWithoutNewLines (lineLength_ - numNewLineChars) + const int startInFile) + : line (l, (size_t) lineLen), + lineStartInFile (startInFile), + lineLength (lineLen), + lineLengthWithoutNewLines (lineLen - numNewLineChars) { } @@ -123,8 +122,8 @@ public: }; //============================================================================== -CodeDocument::Iterator::Iterator (const CodeDocument& document_) noexcept - : document (&document_), +CodeDocument::Iterator::Iterator (const CodeDocument& doc) noexcept + : document (&doc), charPointer (nullptr), line (0), position (0) @@ -159,12 +158,10 @@ juce_wchar CodeDocument::Iterator::nextChar() noexcept { if (charPointer.getAddress() == nullptr) { - const CodeDocumentLine* const l = document->lines[line]; - - if (l == nullptr) + if (const CodeDocumentLine* const l = document->lines[line]) + charPointer = l->line.getCharPointer(); + else return 0; - - charPointer = l->line.getCharPointer(); } const juce_wchar result = charPointer.getAndAdvance(); @@ -208,12 +205,10 @@ juce_wchar CodeDocument::Iterator::peekNextChar() const noexcept { if (charPointer.getAddress() == nullptr) { - const CodeDocumentLine* const l = document->lines[line]; - - if (l == nullptr) + if (const CodeDocumentLine* const l = document->lines[line]) + charPointer = l->line.getCharPointer(); + else return 0; - - charPointer = l->line.getCharPointer(); } const juce_wchar c = *charPointer; @@ -221,8 +216,10 @@ juce_wchar CodeDocument::Iterator::peekNextChar() const noexcept if (c != 0) return c; - const CodeDocumentLine* const l = document->lines [line + 1]; - return l == nullptr ? 0 : l->line[0]; + if (const CodeDocumentLine* const l = document->lines [line + 1]) + return l->line[0]; + + return 0; } void CodeDocument::Iterator::skipWhitespace() noexcept @@ -426,14 +423,18 @@ CodeDocument::Position CodeDocument::Position::movedByLines (const int deltaLine juce_wchar CodeDocument::Position::getCharacter() const { - const CodeDocumentLine* const l = owner->lines [line]; - return l == nullptr ? 0 : l->line [getIndexInLine()]; + if (const CodeDocumentLine* const l = owner->lines [line]) + return l->line [getIndexInLine()]; + + return 0; } String CodeDocument::Position::getLineText() const { - const CodeDocumentLine* const l = owner->lines [line]; - return l == nullptr ? String::empty : l->line; + if (const CodeDocumentLine* const l = owner->lines [line]) + return l->line; + + return String::empty; } void CodeDocument::Position::setPositionMaintained (const bool isMaintained) @@ -489,8 +490,10 @@ String CodeDocument::getTextBetween (const Position& start, const Position& end) if (startLine == endLine) { - CodeDocumentLine* const line = lines [startLine]; - return (line == nullptr) ? String::empty : line->line.substring (start.getIndexInLine(), end.getIndexInLine()); + if (CodeDocumentLine* const line = lines [startLine]) + return line->line.substring (start.getIndexInLine(), end.getIndexInLine()); + + return String::empty; } MemoryOutputStream mo; @@ -524,14 +527,18 @@ String CodeDocument::getTextBetween (const Position& start, const Position& end) int CodeDocument::getNumCharacters() const noexcept { - const CodeDocumentLine* const lastLine = lines.getLast(); - return (lastLine == nullptr) ? 0 : lastLine->lineStartInFile + lastLine->lineLength; + if (const CodeDocumentLine* const lastLine = lines.getLast()) + return lastLine->lineStartInFile + lastLine->lineLength; + + return 0; } String CodeDocument::getLine (const int lineIndex) const noexcept { - const CodeDocumentLine* const line = lines [lineIndex]; - return (line == nullptr) ? String::empty : line->line; + if (const CodeDocumentLine* const line = lines [lineIndex]) + return line->line; + + return String::empty; } int CodeDocument::getMaximumLineLength() noexcept @@ -576,7 +583,10 @@ void CodeDocument::replaceSection (const int start, const int end, const String& void CodeDocument::applyChanges (const String& newContent) { - TextDiff diff (getAllContent(), newContent); + const String corrected (StringArray::fromLines (newContent) + .joinIntoString (newLineChars)); + + TextDiff diff (getAllContent(), corrected); for (int i = 0; i < diff.changes.size(); ++i) { @@ -618,10 +628,10 @@ bool CodeDocument::writeToStream (OutputStream& stream) return true; } -void CodeDocument::setNewLineCharacters (const String& newLineChars_) noexcept +void CodeDocument::setNewLineCharacters (const String& newChars) noexcept { - jassert (newLineChars_ == "\r\n" || newLineChars_ == "\n" || newLineChars_ == "\r"); - newLineChars = newLineChars_; + jassert (newChars == "\r\n" || newChars == "\n" || newChars == "\r"); + newLineChars = newChars; } void CodeDocument::newTransaction() diff --git a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeDocument.h b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeDocument.h index a089c2533..eaab67a80 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeDocument.h +++ b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeDocument.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index 99ea25cae..d2fb441ef 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -82,10 +81,9 @@ public: } void draw (CodeEditorComponent& owner, Graphics& g, const Font& fontToUse, - const float leftClip, const float rightClip, - const float x, const int y, const int baselineOffset, + const float rightClip, const float x, const int y, const int lineH, const float characterWidth, - const Colour& highlightColour) const + const Colour highlightColour) const { if (highlightColumnStart < highlightColumnEnd) { @@ -94,9 +92,11 @@ public: roundToInt ((highlightColumnEnd - highlightColumnStart) * characterWidth), lineH); } - const float baselineY = (float) (y + baselineOffset); Colour lastColour (0x00000001); - GlyphArrangement ga; + + AttributedString as; + as.setJustification (Justification::centredLeft); + int column = 0; for (int i = 0; i < tokens.size(); ++i) @@ -105,26 +105,12 @@ public: if (tokenX > rightClip) break; - SyntaxToken& token = tokens.getReference(i); - - const Colour newColour (owner.getColourForTokenType (token.tokenType)); - if (lastColour != newColour) - { - ga.draw (g); - ga.clear(); - - lastColour = newColour; - g.setColour (newColour); - } - + const SyntaxToken& token = tokens.getReference(i); + as.append (token.text, fontToUse, owner.getColourForTokenType (token.tokenType)); column += token.length; - - if (x + column * characterWidth >= leftClip) - ga.addCurtailedLineOfText (fontToUse, token.text, tokenX, baselineY, - (rightClip - tokenX) + characterWidth, false); } - ga.draw (g); + as.draw (g, Rectangle<float> (x, (float) y, 10000.0f, (float) lineH)); } private: @@ -485,20 +471,18 @@ void CodeEditorComponent::paint (Graphics& g) g.reduceClipRegion (gutterSize, 0, verticalScrollBar.getX() - gutterSize, horizontalScrollBar.getY()); g.setFont (font); - const int baselineOffset = (int) font.getAscent(); const Colour highlightColour (findColour (CodeEditorComponent::highlightColourId)); const Rectangle<int> clip (g.getClipBounds()); const int firstLineToDraw = jmax (0, clip.getY() / lineHeight); const int lastLineToDraw = jmin (lines.size(), clip.getBottom() / lineHeight + 1); const float x = (float) (gutterSize - xOffset * charWidth); - const float leftClip = (float) clip.getX(); const float rightClip = (float) clip.getRight(); for (int i = firstLineToDraw; i < lastLineToDraw; ++i) - lines.getUnchecked(i)->draw (*this, g, font, leftClip, rightClip, - x, lineHeight * i, baselineOffset, - lineHeight, charWidth, highlightColour); + lines.getUnchecked(i)->draw (*this, g, font, rightClip, + x, lineHeight * i, lineHeight, + charWidth, highlightColour); } void CodeEditorComponent::setScrollbarThickness (const int thickness) @@ -677,6 +661,7 @@ void CodeEditorComponent::scrollToLineInternal (int newFirstLineOnScreen) updateCachedIterators (firstLineOnScreen); rebuildLineTokensAsync(); + pimpl->handleUpdateNowIfNeeded(); } } @@ -709,7 +694,7 @@ void CodeEditorComponent::scrollBy (int deltaLines) scrollToLine (firstLineOnScreen + deltaLines); } -void CodeEditorComponent::scrollToKeepLinesOnScreen (const Range<int>& rangeToShow) +void CodeEditorComponent::scrollToKeepLinesOnScreen (Range<int> rangeToShow) { if (rangeToShow.getStart() < firstLineOnScreen) scrollBy (rangeToShow.getStart() - firstLineOnScreen); @@ -1039,14 +1024,16 @@ bool CodeEditorComponent::moveCaretToStartOfLine (const bool selecting) bool CodeEditorComponent::moveCaretToEnd (const bool selecting) { newTransaction(); - moveCaretTo (CodeDocument::Position (document, std::numeric_limits<int>::max(), std::numeric_limits<int>::max()), selecting); + moveCaretTo (CodeDocument::Position (document, std::numeric_limits<int>::max(), + std::numeric_limits<int>::max()), selecting); return true; } bool CodeEditorComponent::moveCaretToEndOfLine (const bool selecting) { newTransaction(); - moveCaretTo (CodeDocument::Position (document, caretPos.getLineNumber(), std::numeric_limits<int>::max()), selecting); + moveCaretTo (CodeDocument::Position (document, caretPos.getLineNumber(), + std::numeric_limits<int>::max()), selecting); return true; } @@ -1057,13 +1044,9 @@ bool CodeEditorComponent::deleteBackwards (const bool moveInWholeWordSteps) cut(); // in case something is already highlighted moveCaretTo (document.findWordBreakBefore (caretPos), true); } - else + else if (selectionStart == selectionEnd && ! skipBackwardsToPreviousTab()) { - if (selectionStart == selectionEnd) - { - if (! skipBackwardsToPreviousTab()) - selectionStart.moveBy (-1); - } + selectionStart.moveBy (-1); } cut(); @@ -1114,7 +1097,8 @@ bool CodeEditorComponent::deleteForwards (const bool moveInWholeWordSteps) bool CodeEditorComponent::selectAll() { newTransaction(); - selectRegion (CodeDocument::Position (document, std::numeric_limits<int>::max(), std::numeric_limits<int>::max()), + selectRegion (CodeDocument::Position (document, std::numeric_limits<int>::max(), + std::numeric_limits<int>::max()), CodeDocument::Position (document, 0, 0)); return true; } @@ -1484,7 +1468,7 @@ void CodeEditorComponent::setFont (const Font& newFont) resized(); } -void CodeEditorComponent::ColourScheme::set (const String& name, const Colour& colour) +void CodeEditorComponent::ColourScheme::set (const String& name, const Colour colour) { for (int i = 0; i < types.size(); ++i) { diff --git a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h index 774aa36df..3cc9f4e6f 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h +++ b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -143,7 +142,7 @@ public: void scrollBy (int deltaLines); void scrollToColumn (int newFirstColumnOnScreen); void scrollToKeepCaretOnScreen(); - void scrollToKeepLinesOnScreen (const Range<int>& linesToShow); + void scrollToKeepLinesOnScreen (Range<int> linesToShow); void insertTextAtCaret (const String& textToInsert); void insertTabAtCaret(); @@ -152,10 +151,10 @@ public: void unindentSelection(); //============================================================================== - Range<int> getHighlightedRegion() const; + Range<int> getHighlightedRegion() const override; bool isHighlightActive() const noexcept; - void setHighlightedRegion (const Range<int>& newRange); - String getTextInRange (const Range<int>& range) const; + void setHighlightedRegion (const Range<int>& newRange) override; + String getTextInRange (const Range<int>& range) const override; //============================================================================== /** Can be used to save and restore the editor's caret position, selection state, etc. */ @@ -216,7 +215,7 @@ public: Array<TokenType> types; - void set (const String& name, const Colour& colour); + void set (const String& name, const Colour colour); }; /** Changes the syntax highlighting scheme. diff --git a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h index e15d3edf2..339b4a06f 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h +++ b/JuceLibraryCode/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp b/JuceLibraryCode/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp index 46f547aee..1273d1d75 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -98,8 +97,8 @@ bool FileBasedDocument::loadFrom (const File& newFile, { AlertWindow::showMessageBox (AlertWindow::WarningIcon, TRANS("Failed to open file..."), - TRANS("There was an error while trying to load the file:\n\n") - + newFile.getFullPathName() + TRANS("There was an error while trying to load the file: FLNM") + .replace ("FLNM", "\n" + newFile.getFullPathName()) + "\n\n" + result.getErrorMessage()); } @@ -119,6 +118,18 @@ bool FileBasedDocument::loadFromUserSpecifiedFile (const bool showMessageOnFailu return false; } +static bool askToOverwriteFile (const File& newFile) +{ + return AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, + TRANS("File already exists"), + TRANS("There's already a file called: FLMN") + .replace ("FLNM", newFile.getFullPathName()) + + "\n\n" + + TRANS("Are you sure you want to overwrite it?"), + TRANS("Overwrite"), + TRANS("Cancel")); +} + //============================================================================== FileBasedDocument::SaveResult FileBasedDocument::save (const bool askUserForFileIfNotSpecified, const bool showMessageOnFailure) @@ -137,31 +148,18 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAs (const File& newFile, if (newFile == File::nonexistent) { if (askUserForFileIfNotSpecified) - { return saveAsInteractive (true); - } - else - { - // can't save to an unspecified file - jassertfalse; - return failedToWriteToFile; - } - } - if (warnAboutOverwritingExistingFiles && newFile.exists()) - { - if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, - TRANS("File already exists"), - TRANS("There's already a file called:\n\n") - + newFile.getFullPathName() - + TRANS("\n\nAre you sure you want to overwrite it?"), - TRANS("overwrite"), - TRANS("cancel"))) - { - return userCancelledSave; - } + // can't save to an unspecified file + jassertfalse; + return failedToWriteToFile; } + if (warnAboutOverwritingExistingFiles + && newFile.exists() + && ! askToOverwriteFile (newFile)) + return userCancelledSave; + MouseCursor::showWaitCursor(); const File oldFile (documentFile); @@ -184,10 +182,9 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAs (const File& newFile, { AlertWindow::showMessageBox (AlertWindow::WarningIcon, TRANS("Error writing to file..."), - TRANS("An error occurred while trying to save \"") - + getDocumentTitle() - + TRANS("\" to the file:\n\n") - + newFile.getFullPathName() + TRANS("An error occurred while trying to save \"DCNM\" to the file: FLNM") + .replace ("DCNM", getDocumentTitle()) + .replace ("FLNM", "\n" + newFile.getFullPathName()) + "\n\n" + result.getErrorMessage()); } @@ -202,22 +199,17 @@ FileBasedDocument::SaveResult FileBasedDocument::saveIfNeededAndUserAgrees() const int r = AlertWindow::showYesNoCancelBox (AlertWindow::QuestionIcon, TRANS("Closing document..."), - TRANS("Do you want to save the changes to \"") - + getDocumentTitle() + "\"?", - TRANS("save"), - TRANS("discard changes"), - TRANS("cancel")); + TRANS("Do you want to save the changes to \"DCNM\"?") + .replace ("DCNM", getDocumentTitle()), + TRANS("Save"), + TRANS("Discard changes"), + TRANS("Cancel")); - if (r == 1) - { - // save changes + if (r == 1) // save changes return save (true, true); - } - else if (r == 2) - { - // discard changes + + if (r == 2) // discard changes return savedOk; - } return userCancelledSave; } @@ -257,19 +249,8 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAsInteractive (const bool w { chosen = chosen.withFileExtension (fileExtension); - if (chosen.exists()) - { - if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, - TRANS("File already exists"), - TRANS("There's already a file called:") - + "\n\n" + chosen.getFullPathName() - + "\n\n" + TRANS("Are you sure you want to overwrite it?"), - TRANS("overwrite"), - TRANS("cancel"))) - { - return userCancelledSave; - } - } + if (chosen.exists() && ! askToOverwriteFile (chosen)) + return userCancelledSave; } setLastDocumentOpened (chosen); diff --git a/JuceLibraryCode/modules/juce_gui_extra/documents/juce_FileBasedDocument.h b/JuceLibraryCode/modules/juce_gui_extra/documents/juce_FileBasedDocument.h index 0c68a41e3..8c96ed5be 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/documents/juce_FileBasedDocument.h +++ b/JuceLibraryCode/modules/juce_gui_extra/documents/juce_FileBasedDocument.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h b/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h index 8ef8417a3..22c046ee9 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h +++ b/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_NSViewComponent.h b/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_NSViewComponent.h index bb66be8f0..8c267a8fc 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_NSViewComponent.h +++ b/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_NSViewComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_UIViewComponent.h b/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_UIViewComponent.h index 36099e030..406432a1a 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_UIViewComponent.h +++ b/JuceLibraryCode/modules/juce_gui_extra/embedding/juce_UIViewComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.cpp b/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.cpp index c030c12e4..e80e7419d 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -111,6 +110,7 @@ namespace juce #if JUCE_MAC #include "native/juce_mac_NSViewComponent.mm" #include "native/juce_mac_AppleRemote.mm" + #include "native/juce_mac_SystemTrayIcon.cpp" #endif #if JUCE_IOS diff --git a/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.h b/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.h index 875511b25..ee25a9aea 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.h +++ b/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.mm b/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.mm index ac617e05b..7478dd40a 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.mm +++ b/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/juce_module_info b/JuceLibraryCode/modules/juce_gui_extra/juce_module_info index 3e2d05cbb..0b026a618 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/juce_module_info +++ b/JuceLibraryCode/modules/juce_gui_extra/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_gui_extra", "name": "JUCE extended GUI classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Miscellaneous GUI classes for specialised tasks.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_gui_extra/lookandfeel/juce_OldSchoolLookAndFeel.cpp b/JuceLibraryCode/modules/juce_gui_extra/lookandfeel/juce_OldSchoolLookAndFeel.cpp index 06be0abf9..70f66634a 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/lookandfeel/juce_OldSchoolLookAndFeel.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/lookandfeel/juce_OldSchoolLookAndFeel.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/lookandfeel/juce_OldSchoolLookAndFeel.h b/JuceLibraryCode/modules/juce_gui_extra/lookandfeel/juce_OldSchoolLookAndFeel.h index c9257ab40..16fc9cbc5 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/lookandfeel/juce_OldSchoolLookAndFeel.h +++ b/JuceLibraryCode/modules/juce_gui_extra/lookandfeel/juce_OldSchoolLookAndFeel.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_AppleRemote.h b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_AppleRemote.h index bb7c8c98f..6145af3e0 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_AppleRemote.h +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_AppleRemote.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp index 5de027eee..9e3cfb3c2 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp @@ -1,31 +1,30 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ BubbleMessageComponent::BubbleMessageComponent (int fadeOutLengthMs) - : fadeOutLength (fadeOutLengthMs), - deleteAfterUse (false) + : fadeOutLength (fadeOutLengthMs), mouseClickCounter (0), + expiryTime (0), deleteAfterUse (false) { } diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h index 0afe93fc7..229e19546 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.cpp b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.cpp index c44a02fe8..cfdf1dffa 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -351,7 +350,7 @@ Colour ColourSelector::getCurrentColour() const return ((flags & showAlphaChannel) != 0) ? colour : colour.withAlpha ((uint8) 0xff); } -void ColourSelector::setCurrentColour (const Colour& c) +void ColourSelector::setCurrentColour (Colour c) { if (c != colour) { diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.h b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.h index 289e082e2..677912bb4 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.h +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -82,7 +81,7 @@ public: /** Changes the colour that is currently being shown. */ - void setCurrentColour (const Colour& newColour); + void setCurrentColour (Colour newColour); //============================================================================== /** Tells the selector how many preset colour swatches you want to have on the component. diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp index 8245ee1a0..f98c41a00 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -96,7 +95,7 @@ public: AlertWindow::NoIcon), owner (kec) { - addButton (TRANS("Ok"), 1); + addButton (TRANS("OK"), 1); addButton (TRANS("Cancel"), 0); // (avoid return + escape keys getting processed by the buttons..) @@ -110,13 +109,15 @@ public: bool keyPressed (const KeyPress& key) { lastPress = key; - String message (TRANS("Key: ") + owner.getDescriptionForKeyPress (key)); + String message (TRANS("Key") + ": " + owner.getDescriptionForKeyPress (key)); const CommandID previousCommand = owner.getMappings().findCommandForKeyPress (key); if (previousCommand != 0) - message << "\n\n" << TRANS("(Currently assigned to \"") - << owner.getCommandManager().getNameOfCommand (previousCommand) << "\")"; + message << "\n\n(" + << TRANS("Currently assigned to \"CMDN\"") + .replace ("CMDN", owner.getCommandManager().getNameOfCommand (previousCommand)) + << ')'; setMessage (message); return true; @@ -160,9 +161,10 @@ public: { AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, TRANS("Change key-mapping"), - TRANS("This key is already assigned to the command \"") - + owner.getCommandManager().getNameOfCommand (previousCommand) - + TRANS("\"\n\nDo you want to re-assign it to this new command instead?"), + TRANS("This key is already assigned to the command \"CMDN\"") + .replace ("CMDN", owner.getCommandManager().getNameOfCommand (previousCommand)) + + "\n\n" + + TRANS("Do you want to re-assign it to this new command instead?"), TRANS("Re-assign"), TRANS("Cancel"), this, @@ -421,8 +423,8 @@ KeyMappingEditorComponent::~KeyMappingEditorComponent() } //============================================================================== -void KeyMappingEditorComponent::setColours (const Colour& mainBackground, - const Colour& textColour) +void KeyMappingEditorComponent::setColours (Colour mainBackground, + Colour textColour) { setColour (backgroundColourId, mainBackground); setColour (textColourId, textColour); diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h index a6f98636c..656731321 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -57,8 +56,8 @@ public: @param mainBackground colour to use for most of the background @param textColour colour to use for the text */ - void setColours (const Colour& mainBackground, - const Colour& textColour); + void setColours (Colour mainBackground, + Colour textColour); /** Returns the KeyPressMappingSet that this component is acting upon. */ KeyPressMappingSet& getMappings() const noexcept { return mappings; } diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp index 67c7123f1..40c6b0c26 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_PreferencesPanel.h b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_PreferencesPanel.h index c2d688296..4b8a432d1 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_PreferencesPanel.h +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_PreferencesPanel.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp index 5bb0b0df2..60da327a8 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -137,9 +136,10 @@ void RecentlyOpenedFilesList::registerRecentFileNatively (const File& file) { #if JUCE_MAC JUCE_AUTORELEASEPOOL - - [[NSDocumentController sharedDocumentController] - noteNewRecentDocumentURL: [NSURL fileURLWithPath: juceStringToNS (file.getFullPathName())]]; + { + [[NSDocumentController sharedDocumentController] + noteNewRecentDocumentURL: [NSURL fileURLWithPath: juceStringToNS (file.getFullPathName())]]; + } #else (void) file; #endif diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h index c21b42ea4..e97e843d5 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SplashScreen.cpp b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SplashScreen.cpp index 3ae7dfa7a..ffa0ffacf 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SplashScreen.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SplashScreen.cpp @@ -1,29 +1,29 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ SplashScreen::SplashScreen() + : originalClickCounter (0) { setOpaque (true); } diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SplashScreen.h b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SplashScreen.h index 3367f5b2f..87b551221 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SplashScreen.h +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SplashScreen.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp index 615e122c5..f904ac18d 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp @@ -1,29 +1,28 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ -#if JUCE_WINDOWS || JUCE_LINUX +#if JUCE_WINDOWS || JUCE_LINUX || JUCE_MAC SystemTrayIconComponent::SystemTrayIconComponent() { diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h index 2d944027f..f0c3ea73e 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -26,7 +25,7 @@ #ifndef __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ #define __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ -#if JUCE_WINDOWS || JUCE_LINUX || DOXYGEN +#if JUCE_WINDOWS || JUCE_LINUX || JUCE_MAC || DOXYGEN //============================================================================== diff --git a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h index 78145b628..419a82ff2 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h +++ b/JuceLibraryCode/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp b/JuceLibraryCode/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp index 069162497..971715d98 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm b/JuceLibraryCode/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm index 2b39f6ae9..1764b6a1f 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_linux_SystemTrayIcon.cpp b/JuceLibraryCode/modules/juce_gui_extra/native/juce_linux_SystemTrayIcon.cpp index 907453efc..d0c3a8772 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_linux_SystemTrayIcon.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_linux_SystemTrayIcon.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_linux_WebBrowserComponent.cpp b/JuceLibraryCode/modules/juce_gui_extra/native/juce_linux_WebBrowserComponent.cpp index 3eab4c9b5..d9212e6c2 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_linux_WebBrowserComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_linux_WebBrowserComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm index 65ffd44f9..f796bdf30 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h index 20e95316e..e395f90c6 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -41,6 +40,7 @@ class CarbonViewWrapperComponent : public Component, public: CarbonViewWrapperComponent() : ComponentMovementWatcher (this), + keepPluginWindowWhenHidden (false), wrapperWindow (0), carbonWindow (0), embeddedView (0), @@ -48,7 +48,7 @@ public: { } - virtual ~CarbonViewWrapperComponent() + ~CarbonViewWrapperComponent() { jassert (embeddedView == 0); // must call deleteWindow() in the subclass's destructor! } @@ -98,9 +98,7 @@ public: // Check for the plugin creating its own floating window, and if there is one, // we need to reparent it to make it visible.. - NSWindow* floatingChildWindow = [[carbonWindow childWindows] objectAtIndex: 0]; - - if (floatingChildWindow != nil) + if (NSWindow* floatingChildWindow = [[carbonWindow childWindows] objectAtIndex: 0]) [getOwnerWindow() addChildWindow: floatingChildWindow ordered: NSWindowAbove]; @@ -112,7 +110,7 @@ public: { kEventClassMouse, kEventMouseDown }, { kEventClassMouse, kEventMouseMoved }, { kEventClassMouse, kEventMouseDragged }, - { kEventClassMouse, kEventMouseUp}, + { kEventClassMouse, kEventMouseUp }, { kEventClassWindow, kEventWindowDrawContent }, { kEventClassWindow, kEventWindowShown }, { kEventClassWindow, kEventWindowHidden } @@ -201,6 +199,18 @@ public: wr.bottom = (short) (wr.top + getHeight()); SetWindowBounds (wrapperWindow, kWindowContentRgn, &wr); + + // This group stuff is mainly a workaround for Mackie plugins like FinalMix.. + WindowGroupRef group = GetWindowGroup (wrapperWindow); + WindowRef attachedWindow; + + if (GetIndexedWindow (group, 2, kWindowGroupContentsReturnWindows, &attachedWindow) == noErr) + { + SelectWindow (attachedWindow); + ActivateWindow (attachedWindow, TRUE); + HideWindow (wrapperWindow); + } + ShowWindow (wrapperWindow); } @@ -223,7 +233,7 @@ public: { if (isShowing()) createWindow(); - else + else if (! keepPluginWindowWhenHidden) deleteWindow(); setEmbeddedWindowToOurSize(); @@ -243,12 +253,15 @@ public: void timerCallback() { - setOurSizeToEmbeddedViewSize(); + if (isShowing()) + { + setOurSizeToEmbeddedViewSize(); - // To avoid strange overpainting problems when the UI is first opened, we'll - // repaint it a few times during the first second that it's on-screen.. - if ((Time::getCurrentTime() - creationTime).inMilliseconds() < 1000) - recursiveHIViewRepaint (HIViewGetRoot (wrapperWindow)); + // To avoid strange overpainting problems when the UI is first opened, we'll + // repaint it a few times during the first second that it's on-screen.. + if ((Time::getCurrentTime() - creationTime).inMilliseconds() < 1000) + recursiveHIViewRepaint (HIViewGetRoot (wrapperWindow)); + } } OSStatus carbonEventHandler (EventHandlerCallRef /*nextHandlerRef*/, EventRef event) @@ -269,7 +282,9 @@ public: SetEventParameter (event, kEventParamClickActivation, typeClickActivationResult, sizeof (ClickActivationResult), &howToHandleClick); - HIViewSetNeedsDisplay (embeddedView, true); + if (embeddedView != 0) + HIViewSetNeedsDisplay (embeddedView, true); + return noErr; } } @@ -282,6 +297,8 @@ public: return ((CarbonViewWrapperComponent*) userData)->carbonEventHandler (nextHandlerRef, event); } + bool keepPluginWindowWhenHidden; + protected: WindowRef wrapperWindow; NSWindow* carbonWindow; diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm index 693696907..e35b64924 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp new file mode 100644 index 000000000..84f4a8cca --- /dev/null +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp @@ -0,0 +1,207 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ + +namespace MouseCursorHelpers +{ + extern NSImage* createNSImage (const Image&); +} + +class SystemTrayIconComponent::Pimpl +{ +public: + Pimpl (SystemTrayIconComponent& iconComp, const Image& im) + : owner (iconComp), statusItem (nil), + statusIcon (MouseCursorHelpers::createNSImage (im)), + isHighlighted (false) + { + static SystemTrayViewClass cls; + view = [cls.createInstance() init]; + SystemTrayViewClass::setOwner (view, this); + SystemTrayViewClass::setImage (view, statusIcon); + + setIconSize(); + + statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength: NSSquareStatusItemLength] retain]; + [statusItem setView: view]; + } + + ~Pimpl() + { + [[NSStatusBar systemStatusBar] removeStatusItem: statusItem]; + [statusItem release]; + [view release]; + [statusIcon release]; + } + + void updateIcon (const Image& newImage) + { + [statusIcon release]; + statusIcon = MouseCursorHelpers::createNSImage (newImage); + setIconSize(); + SystemTrayViewClass::setImage (view, statusIcon); + } + + void setHighlighted (bool shouldHighlight) + { + isHighlighted = shouldHighlight; + [view setNeedsDisplay: true]; + } + + void handleStatusItemAction (NSEvent* e) + { + NSEventType type = [e type]; + + const bool isLeft = (type == NSLeftMouseDown || type == NSLeftMouseUp); + const bool isRight = (type == NSRightMouseDown || type == NSRightMouseUp); + + if (owner.isCurrentlyBlockedByAnotherModalComponent()) + { + if (isLeft || isRight) + if (Component* const current = Component::getCurrentlyModalComponent()) + current->inputAttemptWhenModal(); + } + else + { + ModifierKeys eventMods (ModifierKeys::getCurrentModifiersRealtime()); + + if (([e modifierFlags] & NSCommandKeyMask) != 0) + eventMods = eventMods.withFlags (ModifierKeys::commandModifier); + + NSRect r = [[e window] frame]; + r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.origin.y - r.size.height; + owner.setBounds (convertToRectInt (r)); + + const Time now (Time::getCurrentTime()); + + if (isLeft || isRight) // Only mouse up is sent by the OS, so simulate a down/up + { + owner.mouseDown (MouseEvent (Desktop::getInstance().getMainMouseSource(), + Point<int>(), + eventMods.withFlags (isLeft ? ModifierKeys::leftButtonModifier + : ModifierKeys::rightButtonModifier), + &owner, &owner, now, + Point<int>(), now, 1, false)); + + owner.mouseUp (MouseEvent (Desktop::getInstance().getMainMouseSource(), + Point<int>(), eventMods.withoutMouseButtons(), + &owner, &owner, now, + Point<int>(), now, 1, false)); + } + else if (type == NSMouseMoved) + { + owner.mouseMove (MouseEvent (Desktop::getInstance().getMainMouseSource(), + Point<int>(), eventMods, + &owner, &owner, now, + Point<int>(), now, 1, false)); + } + } + } + +private: + SystemTrayIconComponent& owner; + NSStatusItem* statusItem; + NSImage* statusIcon; + NSControl* view; + bool isHighlighted; + + void setIconSize() + { + [statusIcon setSize: NSMakeSize (20.0f, 20.0f)]; + } + + struct SystemTrayViewClass : public ObjCClass <NSControl> + { + SystemTrayViewClass() : ObjCClass <NSControl> ("JUCESystemTrayView_") + { + addIvar<Pimpl*> ("owner"); + addIvar<NSImage*> ("image"); + + addMethod (@selector (mouseDown:), handleEventDown, "v@:@"); + addMethod (@selector (rightMouseDown:), handleEventDown, "v@:@"); + addMethod (@selector (drawRect:), drawRect, "v@:@"); + + registerClass(); + } + + static Pimpl* getOwner (id self) { return getIvar<Pimpl*> (self, "owner"); } + static NSImage* getImage (id self) { return getIvar<NSImage*> (self, "image"); } + static void setOwner (id self, Pimpl* owner) { object_setInstanceVariable (self, "owner", owner); } + static void setImage (id self, NSImage* image) { object_setInstanceVariable (self, "image", image); } + + private: + static void handleEventDown (id self, SEL, NSEvent* e) + { + if (Pimpl* const owner = getOwner (self)) + { + owner->setHighlighted (! owner->isHighlighted); + owner->handleStatusItemAction (e); + } + } + + static void drawRect (id self, SEL, NSRect) + { + NSRect bounds = [self bounds]; + + if (Pimpl* const owner = getOwner (self)) + [owner->statusItem drawStatusBarBackgroundInRect: bounds + withHighlight: owner->isHighlighted]; + + if (NSImage* const im = getImage (self)) + { + NSSize imageSize = [im size]; + + [im drawInRect: NSMakeRect (bounds.origin.x + ((bounds.size.width - imageSize.width) / 2.0f), + bounds.origin.y + ((bounds.size.height - imageSize.height) / 2.0f), + imageSize.width, imageSize.height) + fromRect: NSZeroRect + operation: NSCompositeSourceOver + fraction: 1.0f]; + } + } + }; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl) +}; + + +//============================================================================== +void SystemTrayIconComponent::setIconImage (const Image& newImage) +{ + if (newImage.isValid()) + { + if (pimpl == nullptr) + pimpl = new Pimpl (*this, newImage); + else + pimpl->updateIcon (newImage); + } + else + { + pimpl = nullptr; + } +} + +void SystemTrayIconComponent::setIconTooltip (const String&) +{ + // xxx not yet implemented! +} diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm index 2f22ba738..c59476538 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index cbc0253cf..2a3f6bf36 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp b/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp index 206fa6cda..2e6a6d512 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -55,10 +54,9 @@ public: // In order to receive the "TaskbarCreated" message, we need to request that it's not filtered out. // (Need to load dynamically, as ChangeWindowMessageFilter is only available in Vista and later) typedef BOOL (WINAPI* ChangeWindowMessageFilterType) (UINT, DWORD); - ChangeWindowMessageFilterType changeWindowMessageFilter - = (ChangeWindowMessageFilterType) getUser32Function ("ChangeWindowMessageFilter"); - if (changeWindowMessageFilter != nullptr) + if (ChangeWindowMessageFilterType changeWindowMessageFilter + = (ChangeWindowMessageFilterType) getUser32Function ("ChangeWindowMessageFilter")) changeWindowMessageFilter (taskbarCreatedMessage, 1 /* MSGFLT_ADD */); } @@ -96,9 +94,7 @@ public: if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN || lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) { - Component* const current = Component::getCurrentlyModalComponent(); - - if (current != nullptr) + if (Component* const current = Component::getCurrentlyModalComponent()) current->inputAttemptWhenModal(); } } @@ -113,9 +109,11 @@ public: else if (lParam == WM_LBUTTONUP || lParam == WM_RBUTTONUP) eventMods = eventMods.withoutMouseButtons(); + const Time eventTime (getMouseEventTime()); + const MouseEvent e (Desktop::getInstance().getMainMouseSource(), - Point<int>(), eventMods, &owner, &owner, Time (getMouseEventTime()), - Point<int>(), Time (getMouseEventTime()), 1, false); + Point<int>(), eventMods, &owner, &owner, eventTime, + Point<int>(), eventTime, 1, false); if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN) { @@ -141,17 +139,9 @@ public: static Pimpl* getPimpl (HWND hwnd) { if (JuceWindowIdentifier::isJUCEWindow (hwnd)) - { - ComponentPeer* peer = (ComponentPeer*) GetWindowLongPtr (hwnd, 8); - - if (peer != nullptr) - { - SystemTrayIconComponent* const iconComp = dynamic_cast<SystemTrayIconComponent*> (&(peer->getComponent())); - - if (iconComp != nullptr) + if (ComponentPeer* peer = (ComponentPeer*) GetWindowLongPtr (hwnd, 8)) + if (SystemTrayIconComponent* const iconComp = dynamic_cast<SystemTrayIconComponent*> (&(peer->getComponent()))) return iconComp->pimpl; - } - } return nullptr; } diff --git a/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp b/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp index 68e728500..66971664b 100644 --- a/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp @@ -1,29 +1,27 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ -//============================================================================== class WebBrowserComponent::Pimpl : public ActiveXControlComponent { public: @@ -48,12 +46,10 @@ public: createControl (&CLSID_WebBrowser); browser = (IWebBrowser2*) queryInterface (&IID_IWebBrowser2); - IConnectionPointContainer* connectionPointContainer = (IConnectionPointContainer*) queryInterface (&IID_IConnectionPointContainer); - - if (connectionPointContainer != nullptr) + if (IConnectionPointContainer* connectionPointContainer + = (IConnectionPointContainer*) queryInterface (&IID_IConnectionPointContainer)) { - connectionPointContainer->FindConnectionPoint (DIID_DWebBrowserEvents2, - &connectionPoint); + connectionPointContainer->FindConnectionPoint (DIID_DWebBrowserEvents2, &connectionPoint); if (connectionPoint != nullptr) { @@ -89,9 +85,9 @@ public: if (postData != nullptr && postData->getSize() > 0) { - LPSAFEARRAY sa = SafeArrayCreateVector (VT_UI1, 0, (ULONG) postData->getSize()); + sa = SafeArrayCreateVector (VT_UI1, 0, (ULONG) postData->getSize()); - if (sa != 0) + if (sa != nullptr) { void* data = nullptr; SafeArrayAccessData (sa, &data); @@ -113,10 +109,9 @@ public: } browser->Navigate ((BSTR) (const OLECHAR*) url.toWideCharPointer(), - &flags, &frame, - &postDataVar, &headersVar); + &flags, &frame, &postDataVar, &headersVar); - if (sa != 0) + if (sa != nullptr) SafeArrayDestroy (sa); VariantClear (&flags); diff --git a/JuceLibraryCode/modules/juce_opengl/juce_module_info b/JuceLibraryCode/modules/juce_opengl/juce_module_info index a54f0f4c2..d5e1ad08a 100644 --- a/JuceLibraryCode/modules/juce_opengl/juce_module_info +++ b/JuceLibraryCode/modules/juce_opengl/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_opengl", "name": "JUCE OpenGL classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for rendering OpenGL in a JUCE window.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", @@ -18,5 +18,6 @@ "OSXFrameworks": "OpenGL", "iOSFrameworks": "OpenGLES", - "LinuxLibs": "GL" + "LinuxLibs": "GL", + "mingwLibs": "opengl32" } diff --git a/JuceLibraryCode/modules/juce_opengl/juce_opengl.cpp b/JuceLibraryCode/modules/juce_opengl/juce_opengl.cpp index b32bd1805..5e8042006 100644 --- a/JuceLibraryCode/modules/juce_opengl/juce_opengl.cpp +++ b/JuceLibraryCode/modules/juce_opengl/juce_opengl.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/juce_opengl.h b/JuceLibraryCode/modules/juce_opengl/juce_opengl.h index 897444d70..c32598254 100644 --- a/JuceLibraryCode/modules/juce_opengl/juce_opengl.h +++ b/JuceLibraryCode/modules/juce_opengl/juce_opengl.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/juce_opengl.mm b/JuceLibraryCode/modules/juce_opengl/juce_opengl.mm index 536a9903f..6db235d87 100644 --- a/JuceLibraryCode/modules/juce_opengl/juce_opengl.mm +++ b/JuceLibraryCode/modules/juce_opengl/juce_opengl.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/native/juce_MissingGLDefinitions.h b/JuceLibraryCode/modules/juce_opengl/native/juce_MissingGLDefinitions.h index 4978aeec5..90a03b11f 100644 --- a/JuceLibraryCode/modules/juce_opengl/native/juce_MissingGLDefinitions.h +++ b/JuceLibraryCode/modules/juce_opengl/native/juce_MissingGLDefinitions.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -138,7 +137,8 @@ namespace GL_ARRAY_BUFFER = 0x8892, GL_ELEMENT_ARRAY_BUFFER = 0x8893, GL_STATIC_DRAW = 0x88E4, - GL_DYNAMIC_DRAW = 0x88E8 + GL_DYNAMIC_DRAW = 0x88E8, + GL_STREAM_DRAW = 0x88E0 }; typedef char GLchar; diff --git a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGLExtensions.h b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGLExtensions.h index bd762a5da..e0cec4af9 100644 --- a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGLExtensions.h +++ b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGLExtensions.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_android.h b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_android.h index 4032265c6..84c414f7a 100644 --- a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_android.h +++ b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_android.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -63,7 +62,7 @@ public: glView.clear(); } - void initialiseOnRenderThread() {} + void initialiseOnRenderThread (OpenGLContext&) {} void shutdownOnRenderThread() {} bool makeActive() const noexcept { return isInsideGLCallback; } diff --git a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_ios.h b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_ios.h index 4b0bb4e2c..a72b91cab 100644 --- a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_ios.h +++ b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_ios.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -52,38 +51,40 @@ public: swapFrames (0), useDepthBuffer (pixelFormat.depthBufferBits > 0) { JUCE_AUTORELEASEPOOL - ComponentPeer* const peer = component.getPeer(); - jassert (peer != nullptr); + { + ComponentPeer* const peer = component.getPeer(); + jassert (peer != nullptr); - const Rectangle<int> bounds (peer->getComponent().getLocalArea (&component, component.getLocalBounds())); - lastWidth = bounds.getWidth(); - lastHeight = bounds.getHeight(); + const Rectangle<int> bounds (peer->getComponent().getLocalArea (&component, component.getLocalBounds())); + lastWidth = bounds.getWidth(); + lastHeight = bounds.getHeight(); - view = [[JuceGLView alloc] initWithFrame: convertToCGRect (bounds)]; - view.opaque = YES; - view.hidden = NO; - view.backgroundColor = [UIColor blackColor]; - view.userInteractionEnabled = NO; + view = [[JuceGLView alloc] initWithFrame: convertToCGRect (bounds)]; + view.opaque = YES; + view.hidden = NO; + view.backgroundColor = [UIColor blackColor]; + view.userInteractionEnabled = NO; - glLayer = (CAEAGLLayer*) [view layer]; - glLayer.contentsScale = Desktop::getInstance().getDisplays().getMainDisplay().scale; + glLayer = (CAEAGLLayer*) [view layer]; + glLayer.contentsScale = Desktop::getInstance().getDisplays().getMainDisplay().scale; - [((UIView*) peer->getNativeHandle()) addSubview: view]; + [((UIView*) peer->getNativeHandle()) addSubview: view]; - context = [EAGLContext alloc]; + context = [EAGLContext alloc]; - const NSUInteger type = kEAGLRenderingAPIOpenGLES2; + const NSUInteger type = kEAGLRenderingAPIOpenGLES2; - if (contextToShareWith != nullptr) - [context initWithAPI: type sharegroup: [(EAGLContext*) contextToShareWith sharegroup]]; - else - [context initWithAPI: type]; + if (contextToShareWith != nullptr) + [context initWithAPI: type sharegroup: [(EAGLContext*) contextToShareWith sharegroup]]; + else + [context initWithAPI: type]; - // I'd prefer to put this stuff in the initialiseOnRenderThread() call, but doing - // so causes myserious timing-related failures. - [EAGLContext setCurrentContext: context]; - createGLBuffers(); - deactivateCurrentContext(); + // I'd prefer to put this stuff in the initialiseOnRenderThread() call, but doing + // so causes myserious timing-related failures. + [EAGLContext setCurrentContext: context]; + createGLBuffers(); + deactivateCurrentContext(); + } } ~NativeContext() @@ -95,7 +96,7 @@ public: [view release]; } - void initialiseOnRenderThread() {} + void initialiseOnRenderThread (OpenGLContext&) {} void shutdownOnRenderThread() { diff --git a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_linux.h b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_linux.h index f55853025..f45bbd766 100644 --- a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_linux.h +++ b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_linux.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -103,11 +102,11 @@ public: XFree (bestVisual); } - void initialiseOnRenderThread() + void initialiseOnRenderThread (OpenGLContext& context) { ScopedXLock xlock; renderContext = glXCreateContext (display, bestVisual, (GLXContext) contextToShareWith, GL_TRUE); - makeActive(); + context.makeActive(); } void shutdownOnRenderThread() diff --git a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_osx.h b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_osx.h index cc8d0c087..7838ff502 100644 --- a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_osx.h +++ b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_osx.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -81,7 +80,7 @@ public: renderContext = nil; } - void initialiseOnRenderThread() {} + void initialiseOnRenderThread (OpenGLContext&) {} void shutdownOnRenderThread() { deactivateCurrentContext(); } bool createdOk() const noexcept { return getRawContext() != nullptr; } diff --git a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_win32.h b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_win32.h index 2d2369083..346601d70 100644 --- a/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_win32.h +++ b/JuceLibraryCode/modules/juce_opengl/native/juce_OpenGL_win32.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -81,7 +80,7 @@ public: releaseDC(); } - void initialiseOnRenderThread() {} + void initialiseOnRenderThread (OpenGLContext&) {} void shutdownOnRenderThread() { deactivateCurrentContext(); } static void deactivateCurrentContext() { wglMakeCurrent (0, 0); } diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_Draggable3DOrientation.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_Draggable3DOrientation.h index da74e0591..d3c6872f9 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_Draggable3DOrientation.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_Draggable3DOrientation.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -116,7 +115,7 @@ private: QuaternionType quaternion; Point<float> lastMouse; - Point<float> mousePosToProportion (const Point<float>& mousePos) const noexcept + Point<float> mousePosToProportion (const Point<float> mousePos) const noexcept { const int scale = (jmin (area.getWidth(), area.getHeight()) / 2); @@ -128,7 +127,7 @@ private: (area.getCentreY() - mousePos.y) / scale); } - VectorType projectOnSphere (const Point<float>& pos) const noexcept + VectorType projectOnSphere (const Point<float> pos) const noexcept { const GLfloat radiusSquared = radius * radius; const GLfloat xySquared = pos.x * pos.x + pos.y * pos.y; diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_Matrix3D.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_Matrix3D.h index e473f62bb..8c86c16c4 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_Matrix3D.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_Matrix3D.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index e9e5092b9..a045752dd 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -303,10 +302,6 @@ public: initialiseOnThread(); - #if JUCE_USE_OPENGL_SHADERS && ! JUCE_OPENGL_ES - shadersAvailable = OpenGLShaderProgram::getLanguageVersion() > 0; - #endif - hasInitialised = true; while (! threadShouldExit()) @@ -320,16 +315,23 @@ public: void initialiseOnThread() { - jassert (associatedObjectNames.size() == 0); - jassert (! cachedImageFrameBuffer.isValid()); + // On android, this can get called twice, so drop any previous state.. + associatedObjectNames.clear(); + associatedObjects.clear(); + cachedImageFrameBuffer.release(); context.makeActive(); - nativeContext->initialiseOnRenderThread(); + nativeContext->initialiseOnRenderThread (context); + glViewport (0, 0, component.getWidth(), component.getHeight()); context.extensions.initialise(); nativeContext->setSwapInterval (1); + #if JUCE_USE_OPENGL_SHADERS && ! JUCE_OPENGL_ES + shadersAvailable = OpenGLShaderProgram::getLanguageVersion() > 0; + #endif + if (context.renderer != nullptr) context.renderer->newOpenGLContextCreated(); } @@ -470,7 +472,18 @@ private: static bool canBeAttached (const Component& comp) noexcept { - return comp.getWidth() > 0 && comp.getHeight() > 0 && comp.isShowing(); + return comp.getWidth() > 0 && comp.getHeight() > 0 && isShowingOrMinimised (comp); + } + + static bool isShowingOrMinimised (const Component& c) + { + if (! c.isVisible()) + return false; + + if (Component* p = c.getParentComponent()) + return isShowingOrMinimised (*p); + + return c.getPeer() != nullptr; } static bool isAttached (const Component& comp) noexcept diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLContext.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLContext.h index 5d5dee9e9..8bf45bcc8 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLContext.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLContext.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index 9b60f72ed..1c09df59e 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -293,7 +292,7 @@ void OpenGLFrameBuffer::releaseAsRenderingTarget() pimpl->context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, 0); } -void OpenGLFrameBuffer::clear (const Colour& colour) +void OpenGLFrameBuffer::clear (Colour colour) { if (makeCurrentRenderingTarget()) { @@ -367,7 +366,7 @@ void OpenGLFrameBuffer::draw2D (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, - const Colour& colour) const + Colour colour) const { if (pimpl != nullptr) { @@ -381,7 +380,7 @@ void OpenGLFrameBuffer::draw3D (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, - const Colour& colour) const + Colour colour) const { if (pimpl != nullptr) { diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h index 958f9f659..699b60f6e 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -102,7 +101,7 @@ public: static GLuint getCurrentFrameBufferTarget(); /** Clears the framebuffer with the specified colour. */ - void clear (const Colour& colour); + void clear (Colour colour); /** Selects the framebuffer as the current target, and clears it to transparent. */ void makeCurrentAndClear(); @@ -113,14 +112,14 @@ public: float x2, float y2, float x3, float y3, float x4, float y4, - const Colour& colour) const; + Colour colour) const; /** Draws this framebuffer onto the current context, with the specified corner positions. */ void draw3D (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, - const Colour& colour) const; + Colour colour) const; /** Draws the framebuffer at a given position. */ void drawAt (float x1, float y1) const; diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index a95d02514..eb641389a 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -32,7 +31,7 @@ struct Target : context (c), frameBufferID (frameBufferID_), bounds (width, height) {} - Target (OpenGLContext& c, OpenGLFrameBuffer& fb, const Point<int>& origin) noexcept + Target (OpenGLContext& c, OpenGLFrameBuffer& fb, Point<int> origin) noexcept : context (c), frameBufferID (fb.getFrameBufferID()), bounds (origin.x, origin.y, fb.getWidth(), fb.getHeight()) { @@ -72,8 +71,8 @@ struct Target class PositionedTexture { public: - PositionedTexture (OpenGLTexture& texture, const EdgeTable& et, const Rectangle<int>& clip_) - : clip (clip_.getIntersection (et.getMaximumBounds())) + PositionedTexture (OpenGLTexture& texture, const EdgeTable& et, const Rectangle<int>& clipRegion) + : clip (clipRegion.getIntersection (et.getMaximumBounds())) { if (clip.contains (et.getMaximumBounds())) { @@ -87,8 +86,8 @@ public: } } - PositionedTexture (GLuint textureID_, const Rectangle<int> area_, const Rectangle<int> clip_) noexcept - : textureID (textureID_), area (area_), clip (clip_) + PositionedTexture (GLuint texture, const Rectangle<int> r, const Rectangle<int> clipRegion) noexcept + : textureID (texture), area (r), clip (clipRegion) {} GLuint textureID; @@ -298,7 +297,7 @@ public: matrix (program, "matrix") {} - void setMatrix (const Point<float>& p1, const Point<float>& p2, const Point<float>& p3) + void setMatrix (const Point<float> p1, const Point<float> p2, const Point<float> p3) { const AffineTransform t (AffineTransform::fromTargetPoints (p1.x, p1.y, 0.0f, 0.0f, p2.x, p2.y, 1.0f, 0.0f, @@ -665,8 +664,8 @@ struct StateHelpers template <class QuadQueueType> struct EdgeTableRenderer { - EdgeTableRenderer (QuadQueueType& quadQueue_, const PixelARGB& colour_) noexcept - : quadQueue (quadQueue_), colour (colour_) + EdgeTableRenderer (QuadQueueType& q, const PixelARGB c) noexcept + : quadQueue (q), colour (c) {} void setEdgeTableYPos (const int y) noexcept @@ -709,8 +708,8 @@ struct StateHelpers template <class QuadQueueType> struct FloatRectangleRenderer { - FloatRectangleRenderer (QuadQueueType& quadQueue_, const PixelARGB& colour_) noexcept - : quadQueue (quadQueue_), colour (colour_) + FloatRectangleRenderer (QuadQueueType& q, const PixelARGB c) noexcept + : quadQueue (q), colour (c) {} void operator() (const int x, const int y, const int w, const int h, const int alpha) noexcept @@ -922,6 +921,8 @@ struct StateHelpers ~ShaderQuadQueue() noexcept { static_jassert (sizeof (VertexInfo) == 8); + context.extensions.glBindBuffer (GL_ARRAY_BUFFER, 0); + context.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); context.extensions.glDeleteBuffers (2, buffers); } @@ -937,13 +938,14 @@ struct StateHelpers } context.extensions.glGenBuffers (2, buffers); - context.extensions.glBindBuffer (GL_ARRAY_BUFFER, buffers[0]); - context.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, buffers[1]); + context.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, buffers[0]); context.extensions.glBufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indexData), indexData, GL_STATIC_DRAW); + context.extensions.glBindBuffer (GL_ARRAY_BUFFER, buffers[1]); + context.extensions.glBufferData (GL_ARRAY_BUFFER, sizeof (vertexData), vertexData, GL_STREAM_DRAW); JUCE_CHECK_OPENGL_ERROR } - void add (const int x, const int y, const int w, const int h, const PixelARGB& colour) noexcept + void add (const int x, const int y, const int w, const int h, const PixelARGB colour) noexcept { jassert (w > 0 && h > 0); @@ -965,24 +967,24 @@ struct StateHelpers draw(); } - void add (const Rectangle<int>& r, const PixelARGB& colour) noexcept + void add (const Rectangle<int>& r, const PixelARGB colour) noexcept { add (r.getX(), r.getY(), r.getWidth(), r.getHeight(), colour); } - void add (const Rectangle<float>& r, const PixelARGB& colour) noexcept + void add (const Rectangle<float>& r, const PixelARGB colour) noexcept { FloatRectangleRenderer<ShaderQuadQueue> frr (*this, colour); RenderingHelpers::FloatRectangleRasterisingInfo (r).iterate (frr); } - void add (const RectangleList& list, const PixelARGB& colour) noexcept + void add (const RectangleList& list, const PixelARGB colour) noexcept { for (const Rectangle<int>* i = list.begin(), * const e = list.end(); i != e; ++i) add (*i, colour); } - void add (const RectangleList& list, const Rectangle<int>& clip, const PixelARGB& colour) noexcept + void add (const RectangleList& list, const Rectangle<int>& clip, const PixelARGB colour) noexcept { for (const Rectangle<int>* i = list.begin(), * const e = list.end(); i != e; ++i) { @@ -993,7 +995,7 @@ struct StateHelpers } } - void add (const EdgeTable& et, const PixelARGB& colour) + void add (const EdgeTable& et, const PixelARGB colour) { EdgeTableRenderer<ShaderQuadQueue> etr (*this, colour); et.iterate (etr); @@ -1012,10 +1014,10 @@ struct StateHelpers GLuint colour; }; - #if ! (JUCE_MAC || JUCE_ANDROID || JUCE_IOS) - enum { numQuads = 64 }; // (had problems with my drivers segfaulting when these buffers are any larger) + #if JUCE_MAC || JUCE_ANDROID || JUCE_IOS + enum { numQuads = 256 }; #else - enum { numQuads = 8192 }; + enum { numQuads = 64 }; // (had problems with my drivers segfaulting when these buffers are any larger) #endif GLuint buffers[2]; @@ -1026,7 +1028,9 @@ struct StateHelpers void draw() noexcept { - context.extensions.glBufferData (GL_ARRAY_BUFFER, numVertices * sizeof (VertexInfo), vertexData, GL_DYNAMIC_DRAW); + context.extensions.glBufferSubData (GL_ARRAY_BUFFER, 0, numVertices * sizeof (VertexInfo), vertexData); + // NB: If you get a random crash in here and are running in a Parallels VM, it seems to be a bug in + // their driver.. Can't find a workaround unfortunately. glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, 0); JUCE_CHECK_OPENGL_ERROR numVertices = 0; @@ -1039,8 +1043,7 @@ struct StateHelpers struct CurrentShader { CurrentShader (OpenGLContext& c) noexcept - : context (c), - activeShader (nullptr) + : context (c), activeShader (nullptr) { const char programValueID[] = "GraphicsContextPrograms"; programs = static_cast <ShaderPrograms*> (context.getAssociatedObject (programValueID)); @@ -1104,11 +1107,11 @@ struct StateHelpers class GLState { public: - GLState (const Target& target_) noexcept - : target (target_), - activeTextures (target_.context), - currentShader (target_.context), - shaderQuadQueue (target_.context), + GLState (const Target& t) noexcept + : target (t), + activeTextures (t.context), + currentShader (t.context), + shaderQuadQueue (t.context), previousFrameBufferTarget (OpenGLFrameBuffer::getCurrentFrameBufferTarget()) { // This object can only be created and used when the current thread has an active OpenGL context. @@ -1118,21 +1121,6 @@ public: target.makeActive(); blendMode.resync(); JUCE_CHECK_OPENGL_ERROR - - #ifdef GL_COLOR_ARRAY - glDisableClientState (GL_COLOR_ARRAY); - glDisableClientState (GL_NORMAL_ARRAY); - glDisableClientState (GL_VERTEX_ARRAY); - glDisableClientState (GL_INDEX_ARRAY); - - for (int i = 3; --i >= 0;) - { - activeTextures.setActiveTexture (i); - glDisableClientState (GL_TEXTURE_COORD_ARRAY); - } - #endif - - JUCE_CHECK_OPENGL_ERROR activeTextures.clear(); shaderQuadQueue.initialise(); JUCE_CHECK_OPENGL_ERROR @@ -1142,13 +1130,6 @@ public: { flush(); target.context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, previousFrameBufferTarget); - - #if defined (GL_INDEX_ARRAY) - glDisableClientState (GL_INDEX_ARRAY); - #endif - - target.context.extensions.glBindBuffer (GL_ARRAY_BUFFER, 0); - target.context.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); } void flush() @@ -1282,13 +1263,13 @@ public: { setShader (programs->imageMasked); imageParams = &programs->imageMasked.imageParams; - maskParams = &programs->imageMasked.maskParams; + maskParams = &programs->imageMasked.maskParams; } else { setShader (programs->tiledImageMasked); imageParams = &programs->tiledImageMasked.imageParams; - maskParams = &programs->tiledImageMasked.maskParams; + maskParams = &programs->tiledImageMasked.maskParams; } } else diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h index cf5362841..a13cd62cf 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp index f6b1e706e..f24f432f5 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -64,7 +63,7 @@ bool OpenGLHelpers::isExtensionSupported (const char* const extensionName) return false; } -void OpenGLHelpers::clear (const Colour& colour) +void OpenGLHelpers::clear (Colour colour) { glClearColor (colour.getFloatRed(), colour.getFloatGreen(), colour.getFloatBlue(), colour.getFloatAlpha()); @@ -73,7 +72,7 @@ void OpenGLHelpers::clear (const Colour& colour) } #if JUCE_USE_OPENGL_FIXED_FUNCTION -void OpenGLHelpers::setColour (const Colour& colour) +void OpenGLHelpers::setColour (Colour colour) { glColor4f (colour.getFloatRed(), colour.getFloatGreen(), colour.getFloatBlue(), colour.getFloatAlpha()); @@ -143,7 +142,7 @@ void OpenGLHelpers::drawQuad2D (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, - const Colour& colour) + Colour colour) { const GLfloat vertices[] = { x1, y1, x2, y2, x4, y4, x3, y3 }; const GLfloat textureCoords[] = { 0, 0, 1.0f, 0, 0, 1.0f, 1.0f, 1.0f }; @@ -166,7 +165,7 @@ void OpenGLHelpers::drawQuad3D (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, - const Colour& colour) + Colour colour) { const GLfloat vertices[] = { x1, y1, z1, x2, y2, z2, x4, y4, z4, x3, y3, z3 }; const GLfloat textureCoords[] = { 0, 0, 1.0f, 0, 0, 1.0f, 1.0f, 1.0f }; @@ -233,7 +232,7 @@ void OpenGLHelpers::fillRectWithTexture (const Rectangle<int>& rect, GLuint text drawTextureQuad (textureID, rect); } -void OpenGLHelpers::fillRectWithColour (const Rectangle<int>& rect, const Colour& colour) +void OpenGLHelpers::fillRectWithColour (const Rectangle<int>& rect, Colour colour) { glEnableClientState (GL_VERTEX_ARRAY); glDisableClientState (GL_TEXTURE_COORD_ARRAY); diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLHelpers.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLHelpers.h index 1605c5703..29a80ff38 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLHelpers.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLHelpers.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -44,7 +43,7 @@ public: static bool isContextActive(); /** Clears the current context using the given colour. */ - static void clear (const Colour& colour); + static void clear (Colour colour); static void enableScissorTest (const Rectangle<int>& clip); @@ -56,7 +55,7 @@ public: #if JUCE_USE_OPENGL_FIXED_FUNCTION /** Sets the current colour using a JUCE colour. */ - static void setColour (const Colour& colour); + static void setColour (Colour colour); /** Gives the current context an orthoganal rendering mode for 2D drawing into the given size. */ static void prepareFor2D (int width, int height); @@ -76,14 +75,14 @@ public: float x2, float y2, float x3, float y3, float x4, float y4, - const Colour& colour); + Colour colour); /** Draws a 3D quad with the specified corner points. */ static void drawQuad3D (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, - const Colour& colour); + Colour colour); static void drawTriangleStrip (const GLfloat* const vertices, const GLfloat* const textureCoords, const int numVertices) noexcept; static void drawTriangleStrip (const GLfloat* const vertices, const GLfloat* const textureCoords, @@ -95,7 +94,7 @@ public: /** Fills a rectangle with the specified colour. */ static void fillRectWithColour (const Rectangle<int>& rect, - const Colour& colour); + Colour colour); static void fillRect (const Rectangle<int>& rect); #endif diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLImage.cpp b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLImage.cpp index e9339ec8b..b2940a0f4 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLImage.cpp +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLImage.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -156,7 +155,9 @@ private: { DataReleaser* r = new DataReleaser (frameBuffer, x, y, bitmapData.width, bitmapData.height); bitmapData.dataReleaser = r; - bitmapData.data = (uint8*) (r->data + (x + y * bitmapData.width)); + + bitmapData.data = (uint8*) r->data.getData(); + bitmapData.lineStride = (bitmapData.width * bitmapData.pixelStride + 3) & ~3; ReaderType::read (frameBuffer, bitmapData, x, y); } diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLImage.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLImage.h index 10bbb49b9..5c998ee17 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLImage.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLImage.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp index 400fd79f7..b7aa03236 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h index cf17864c7..2af6bb68e 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLRenderer.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLRenderer.h index e6772ad04..1c740b3e8 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLRenderer.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLRenderer.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp index bfda40747..ffd4de10b 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h index 920974e8f..a20627c9b 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp index 9cca33a05..49fb95d0d 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -174,7 +173,7 @@ void OpenGLTexture::draw2D (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, - const Colour& colour) const + Colour colour) const { bind(); OpenGLHelpers::drawQuad2D (x1, y1, x2, y2, x3, y3, x4, y4, colour); @@ -185,7 +184,7 @@ void OpenGLTexture::draw3D (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, - const Colour& colour) const + Colour colour) const { bind(); OpenGLHelpers::drawQuad3D (x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, colour); diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLTexture.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLTexture.h index bd59cccc7..c59c66a55 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLTexture.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_OpenGLTexture.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -84,14 +83,14 @@ public: float x2, float y2, float x3, float y3, float x4, float y4, - const Colour& colour) const; + Colour colour) const; /** Draws this texture into the current context, with the specified corner positions. */ void draw3D (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, - const Colour& colour) const; + Colour colour) const; #endif /** Returns the GL texture ID number. */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_Quaternion.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_Quaternion.h index 691241381..9780c1753 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_Quaternion.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_Quaternion.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_opengl/opengl/juce_Vector3D.h b/JuceLibraryCode/modules/juce_opengl/opengl/juce_Vector3D.h index bb67056a7..0404f8ed9 100644 --- a/JuceLibraryCode/modules/juce_opengl/opengl/juce_Vector3D.h +++ b/JuceLibraryCode/modules/juce_opengl/opengl/juce_Vector3D.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/capture/juce_CameraDevice.h b/JuceLibraryCode/modules/juce_video/capture/juce_CameraDevice.h index ddb0b7eb8..886487c65 100644 --- a/JuceLibraryCode/modules/juce_video/capture/juce_CameraDevice.h +++ b/JuceLibraryCode/modules/juce_video/capture/juce_CameraDevice.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/juce_module_info b/JuceLibraryCode/modules/juce_video/juce_module_info index e4b10f23e..93810e904 100644 --- a/JuceLibraryCode/modules/juce_video/juce_module_info +++ b/JuceLibraryCode/modules/juce_video/juce_module_info @@ -1,7 +1,7 @@ { "id": "juce_video", "name": "JUCE video playback and capture classes", - "version": "2.0.38", + "version": "2.1.1", "description": "Classes for playing video and capturing camera input.", "website": "http://www.juce.com/juce", "license": "GPL/Commercial", diff --git a/JuceLibraryCode/modules/juce_video/juce_video.cpp b/JuceLibraryCode/modules/juce_video/juce_video.cpp index 6c7c8139c..423706b7d 100644 --- a/JuceLibraryCode/modules/juce_video/juce_video.cpp +++ b/JuceLibraryCode/modules/juce_video/juce_video.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/juce_video.h b/JuceLibraryCode/modules/juce_video/juce_video.h index e6c7e5dce..e457dd846 100644 --- a/JuceLibraryCode/modules/juce_video/juce_video.h +++ b/JuceLibraryCode/modules/juce_video/juce_video.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/juce_video.mm b/JuceLibraryCode/modules/juce_video/juce_video.mm index 47d01fc52..b0cad20ab 100644 --- a/JuceLibraryCode/modules/juce_video/juce_video.mm +++ b/JuceLibraryCode/modules/juce_video/juce_video.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/native/juce_android_CameraDevice.cpp b/JuceLibraryCode/modules/juce_video/native/juce_android_CameraDevice.cpp index f115405b5..66276cdff 100644 --- a/JuceLibraryCode/modules/juce_video/native/juce_android_CameraDevice.cpp +++ b/JuceLibraryCode/modules/juce_video/native/juce_android_CameraDevice.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/native/juce_mac_CameraDevice.mm b/JuceLibraryCode/modules/juce_video/native/juce_mac_CameraDevice.mm index 3c225a4d5..7c4a345d9 100644 --- a/JuceLibraryCode/modules/juce_video/native/juce_mac_CameraDevice.mm +++ b/JuceLibraryCode/modules/juce_video/native/juce_mac_CameraDevice.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -44,44 +43,45 @@ public: averageTimeOffset (0) { JUCE_AUTORELEASEPOOL + { + session = [[QTCaptureSession alloc] init]; - session = [[QTCaptureSession alloc] init]; - - NSArray* devs = [QTCaptureDevice inputDevicesWithMediaType: QTMediaTypeVideo]; - device = (QTCaptureDevice*) [devs objectAtIndex: index]; - - static DelegateClass cls; - callbackDelegate = [cls.createInstance() init]; - DelegateClass::setOwner (callbackDelegate, this); + NSArray* devs = [QTCaptureDevice inputDevicesWithMediaType: QTMediaTypeVideo]; + device = (QTCaptureDevice*) [devs objectAtIndex: index]; - NSError* err = nil; - [device retain]; - [device open: &err]; + static DelegateClass cls; + callbackDelegate = [cls.createInstance() init]; + DelegateClass::setOwner (callbackDelegate, this); - if (err == nil) - { - input = [[QTCaptureDeviceInput alloc] initWithDevice: device]; - audioInput = [[QTCaptureDeviceInput alloc] initWithDevice: device]; - - [session addInput: input error: &err]; + NSError* err = nil; + [device retain]; + [device open: &err]; if (err == nil) { - resetFile(); + input = [[QTCaptureDeviceInput alloc] initWithDevice: device]; + audioInput = [[QTCaptureDeviceInput alloc] initWithDevice: device]; - imageOutput = [[QTCaptureDecompressedVideoOutput alloc] init]; - [imageOutput setDelegate: callbackDelegate]; + [session addInput: input error: &err]; if (err == nil) { - [session startRunning]; - return; + resetFile(); + + imageOutput = [[QTCaptureDecompressedVideoOutput alloc] init]; + [imageOutput setDelegate: callbackDelegate]; + + if (err == nil) + { + [session startRunning]; + return; + } } } - } - openingError = nsStringToJuce ([err description]); - DBG (openingError); + openingError = nsStringToJuce ([err description]); + DBG (openingError); + } } ~QTCameraDeviceInternal() @@ -237,10 +237,11 @@ private: if (internal->listeners.size() > 0) { JUCE_AUTORELEASEPOOL - - internal->callListeners ([CIImage imageWithCVImageBuffer: videoFrame], - CVPixelBufferGetWidth (videoFrame), - CVPixelBufferGetHeight (videoFrame)); + { + internal->callListeners ([CIImage imageWithCVImageBuffer: videoFrame], + CVPixelBufferGetWidth (videoFrame), + CVPixelBufferGetHeight (videoFrame)); + } } } @@ -258,11 +259,13 @@ public: QTCaptureViewerComp (CameraDevice* const cameraDevice, QTCameraDeviceInternal* const internal) { JUCE_AUTORELEASEPOOL - captureView = [[QTCaptureView alloc] init]; - [captureView setCaptureSession: internal->session]; + { + captureView = [[QTCaptureView alloc] init]; + [captureView setCaptureSession: internal->session]; - setSize (640, 480); // xxx need to somehow get the movie size - how? - setView (captureView); + setSize (640, 480); // xxx need to somehow get the movie size - how? + setView (captureView); + } } ~QTCaptureViewerComp() @@ -373,17 +376,18 @@ void CameraDevice::removeListener (Listener* listenerToRemove) StringArray CameraDevice::getAvailableDevices() { JUCE_AUTORELEASEPOOL + { + StringArray results; + NSArray* devs = [QTCaptureDevice inputDevicesWithMediaType: QTMediaTypeVideo]; - StringArray results; - NSArray* devs = [QTCaptureDevice inputDevicesWithMediaType: QTMediaTypeVideo]; + for (int i = 0; i < (int) [devs count]; ++i) + { + QTCaptureDevice* dev = (QTCaptureDevice*) [devs objectAtIndex: i]; + results.add (nsStringToJuce ([dev localizedDisplayName])); + } - for (int i = 0; i < (int) [devs count]; ++i) - { - QTCaptureDevice* dev = (QTCaptureDevice*) [devs objectAtIndex: i]; - results.add (nsStringToJuce ([dev localizedDisplayName])); + return results; } - - return results; } CameraDevice* CameraDevice::openDevice (int index, diff --git a/JuceLibraryCode/modules/juce_video/native/juce_mac_QuickTimeMovieComponent.mm b/JuceLibraryCode/modules/juce_video/native/juce_mac_QuickTimeMovieComponent.mm index c9966a78d..d2afbdb9a 100644 --- a/JuceLibraryCode/modules/juce_video/native/juce_mac_QuickTimeMovieComponent.mm +++ b/JuceLibraryCode/modules/juce_video/native/juce_mac_QuickTimeMovieComponent.mm @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/native/juce_win32_CameraDevice.cpp b/JuceLibraryCode/modules/juce_video/native/juce_win32_CameraDevice.cpp index 74534b68f..fd95080f3 100644 --- a/JuceLibraryCode/modules/juce_video/native/juce_win32_CameraDevice.cpp +++ b/JuceLibraryCode/modules/juce_video/native/juce_win32_CameraDevice.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/native/juce_win32_DirectShowComponent.cpp b/JuceLibraryCode/modules/juce_video/native/juce_win32_DirectShowComponent.cpp index 70e27769d..93130a6c9 100644 --- a/JuceLibraryCode/modules/juce_video/native/juce_win32_DirectShowComponent.cpp +++ b/JuceLibraryCode/modules/juce_video/native/juce_win32_DirectShowComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ @@ -802,7 +801,7 @@ void DirectShowComponent::paint (Graphics& g) context->handleUpdateNowIfNeeded(); if (ComponentPeer* const peer = getPeer()) - peer->addMaskedRegion (getScreenBounds() - peer->getScreenPosition()); + peer->addMaskedRegion (peer->globalToLocal (getScreenBounds())); } else { diff --git a/JuceLibraryCode/modules/juce_video/native/juce_win32_QuickTimeMovieComponent.cpp b/JuceLibraryCode/modules/juce_video/native/juce_win32_QuickTimeMovieComponent.cpp index 93511f4e6..2b28b0d2f 100644 --- a/JuceLibraryCode/modules/juce_video/native/juce_win32_QuickTimeMovieComponent.cpp +++ b/JuceLibraryCode/modules/juce_video/native/juce_win32_QuickTimeMovieComponent.cpp @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/playback/juce_DirectShowComponent.h b/JuceLibraryCode/modules/juce_video/playback/juce_DirectShowComponent.h index ce16b4552..14677bb4d 100644 --- a/JuceLibraryCode/modules/juce_video/playback/juce_DirectShowComponent.h +++ b/JuceLibraryCode/modules/juce_video/playback/juce_DirectShowComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/JuceLibraryCode/modules/juce_video/playback/juce_QuickTimeMovieComponent.h b/JuceLibraryCode/modules/juce_video/playback/juce_QuickTimeMovieComponent.h index fdd5f6134..7cf67476c 100644 --- a/JuceLibraryCode/modules/juce_video/playback/juce_QuickTimeMovieComponent.h +++ b/JuceLibraryCode/modules/juce_video/playback/juce_QuickTimeMovieComponent.h @@ -1,24 +1,23 @@ /* ============================================================================== - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-11 by Raw Material Software Ltd. + This file is part of the JUCE library. + Copyright (c) 2013 - Raw Material Software Ltd. - ------------------------------------------------------------------------------ + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. + Details of these licenses can be found at: www.gnu.org/licenses JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ------------------------------------------------------------------------------ + ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. + available: visit www.juce.com for more information. ============================================================================== */ diff --git a/Source/Audio/AudioComponent.cpp b/Source/Audio/AudioComponent.cpp index 0fcbfd88b..e2dfac3c1 100644 --- a/Source/Audio/AudioComponent.cpp +++ b/Source/Audio/AudioComponent.cpp @@ -156,6 +156,8 @@ void AudioComponent::beginCallbacks() { restartDevice(); + + const MessageManagerLock mmLock; // add a lock to prevent crashes std::cout << std::endl << "Adding audio callback." << std::endl; deviceManager.addAudioCallback(graphPlayer); diff --git a/Source/Processors/Editors/SpikeDisplayEditor.cpp b/Source/Processors/Editors/SpikeDisplayEditor.cpp index 0f9fc3db2..33399f9b9 100755 --- a/Source/Processors/Editors/SpikeDisplayEditor.cpp +++ b/Source/Processors/Editors/SpikeDisplayEditor.cpp @@ -182,6 +182,24 @@ Visualizer* SpikeDisplayEditor::createNewCanvas() } +void SpikeDisplayEditor::startRecording() +{ + + SpikeDisplayCanvas* sdc = (SpikeDisplayCanvas*) canvas.get(); + + sdc->startRecording(); + +} + +void SpikeDisplayEditor::stopRecording() +{ + + SpikeDisplayCanvas* sdc = (SpikeDisplayCanvas*) canvas.get(); + + sdc->stopRecording(); + +} + // void SpikeDisplayEditor::updateSettings() // { // // called by base class diff --git a/Source/Processors/Editors/SpikeDisplayEditor.h b/Source/Processors/Editors/SpikeDisplayEditor.h index 9a9a5e76b..0294c6dc6 100755 --- a/Source/Processors/Editors/SpikeDisplayEditor.h +++ b/Source/Processors/Editors/SpikeDisplayEditor.h @@ -52,6 +52,9 @@ public: ~SpikeDisplayEditor(); void buttonCallback(Button* button); + + void startRecording(); + void stopRecording(); // void updateSettings(); // void updateVisualizer(); diff --git a/Source/Processors/GenericProcessor.h b/Source/Processors/GenericProcessor.h index 2179dc26a..70c488d17 100755 --- a/Source/Processors/GenericProcessor.h +++ b/Source/Processors/GenericProcessor.h @@ -390,6 +390,12 @@ public: { return true; } + + /** Called whenever recording has started. */ + virtual void startRecording() { } + + /** Called whenever recording has stopped. */ + virtual void stopRecording() { } /** Informs a processor's editor that data acquisition is about to begin. */ virtual void enableEditor(); diff --git a/Source/Processors/ProcessorGraph.cpp b/Source/Processors/ProcessorGraph.cpp index 1af9de78f..e083058c8 100644 --- a/Source/Processors/ProcessorGraph.cpp +++ b/Source/Processors/ProcessorGraph.cpp @@ -703,6 +703,38 @@ bool ProcessorGraph::disableProcessors() return true; } +void ProcessorGraph::setRecordState(bool isRecording) +{ + + // const MessageManagerLock mmLock; // lock the message manager to prevent rendering crashes + + // inform other processors that recording will begin + +// for (int i = 0; i < getNumNodes(); i++) +// { +// Node* node = getNode(i); +// if (node->nodeId != OUTPUT_NODE_ID) +// { +// GenericProcessor* p = (GenericProcessor*) node->getProcessor(); +// +// if (isRecording) +// p->startRecording(); +// else +// p->stopRecording(); +// +// } +// } +// +// // actually start recording +// if (isRecording) +// { +// getRecordNode()->setParameter(1,10.0f); +// } else { +// getRecordNode()->setParameter(0,10.0f); +// } + +} + AudioNode* ProcessorGraph::getAudioNode() { diff --git a/Source/Processors/ProcessorGraph.h b/Source/Processors/ProcessorGraph.h index 44775bf8f..c660b75a2 100755 --- a/Source/Processors/ProcessorGraph.h +++ b/Source/Processors/ProcessorGraph.h @@ -80,6 +80,8 @@ public: void restoreParameters(); void updatePointers(); + + void setRecordState(bool); private: diff --git a/Source/Processors/RecordNode.cpp b/Source/Processors/RecordNode.cpp index 447d78054..fa8d11baf 100755 --- a/Source/Processors/RecordNode.cpp +++ b/Source/Processors/RecordNode.cpp @@ -397,6 +397,8 @@ void RecordNode::openFile(Channel* ch) FILE* chFile; bool fileExists = f.exists(); + + diskWriteLock.enter(); chFile = fopen(ch->filename.toUTF8(), "ab"); @@ -418,7 +420,7 @@ void RecordNode::openFile(Channel* ch) std::cout << "File already exists, just opening." << std::endl; } - + diskWriteLock.exit(); //To avoid a race condition resulting on data written before the header, //do not assign the channel pointer until the header has been written @@ -429,9 +431,14 @@ void RecordNode::openFile(Channel* ch) void RecordNode::closeFile(Channel* ch) { + + diskWriteLock.enter(); + std::cout << "CLOSING FILE: " << ch->filename << std::endl; if (ch->file != NULL) fclose(ch->file); + + diskWriteLock.exit(); } String RecordNode::generateHeader(Channel* ch) @@ -564,6 +571,7 @@ void RecordNode::writeContinuousBuffer(float* data, int nSamples, int channel) writeTimestampAndSampleCount(channelPointers[channel]->file); } + diskWriteLock.enter(); // FIXME: ensure fwrite returns equal "count"; otherwise, // there was an error. fwrite(continuousDataIntegerBuffer, // ptr @@ -571,6 +579,8 @@ void RecordNode::writeContinuousBuffer(float* data, int nSamples, int channel) nSamples, // count channelPointers[channel]->file); // ptr to FILE object + diskWriteLock.exit(); + if (sampleCount + nSamples == BLOCK_LENGTH) { writeRecordMarker(channelPointers[channel]->file); @@ -581,6 +591,8 @@ void RecordNode::writeContinuousBuffer(float* data, int nSamples, int channel) void RecordNode::writeTimestampAndSampleCount(FILE* file) { + diskWriteLock.enter(); + int16 samps = BLOCK_LENGTH; fwrite(×tamp, // ptr @@ -593,17 +605,20 @@ void RecordNode::writeTimestampAndSampleCount(FILE* file) 1, // count file); // ptr to FILE object + diskWriteLock.exit(); } void RecordNode::writeRecordMarker(FILE* file) { // write a 10-byte marker indicating the end of a record + diskWriteLock.enter(); fwrite(recordMarker, // ptr 1, // size of each element 10, // count file); // ptr to FILE object + diskWriteLock.exit(); } void RecordNode::writeEventBuffer(MidiMessage& event, int samplePosition) //, int node, int channel) @@ -616,6 +631,7 @@ void RecordNode::writeEventBuffer(MidiMessage& event, int samplePosition) //, in uint64 eventTimestamp = timestamp + samplePos; + diskWriteLock.enter(); // write timestamp (for buffer only, not the actual event timestamp!!!!!) fwrite(&eventTimestamp, // ptr 8, // size of each element @@ -629,6 +645,7 @@ void RecordNode::writeEventBuffer(MidiMessage& event, int samplePosition) //, in // write 1st four bytes of event (type, nodeId, eventId, eventChannel) fwrite(dataptr, 1, 4, eventChannel->file); + diskWriteLock.exit(); } diff --git a/Source/Processors/RecordNode.h b/Source/Processors/RecordNode.h index 7e3efe36b..eeafef90f 100755 --- a/Source/Processors/RecordNode.h +++ b/Source/Processors/RecordNode.h @@ -114,6 +114,8 @@ public: /** Generate a Matlab-compatible datestring */ String generateDateString(); + + CriticalSection* getLock() {return &diskWriteLock;} private: @@ -199,6 +201,8 @@ private: /** Used to indicate the end of each record */ char* recordMarker; + + CriticalSection diskWriteLock; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RecordNode); diff --git a/Source/Processors/SpikeDisplayNode.cpp b/Source/Processors/SpikeDisplayNode.cpp index ce983edeb..9fa35f4c9 100755 --- a/Source/Processors/SpikeDisplayNode.cpp +++ b/Source/Processors/SpikeDisplayNode.cpp @@ -139,6 +139,19 @@ int SpikeDisplayNode::getNumElectrodes() } +void SpikeDisplayNode::startRecording() +{ + SpikeDisplayEditor* editor = (SpikeDisplayEditor*) getEditor(); + editor->startRecording(); + +} + +void SpikeDisplayNode::stopRecording() +{ + SpikeDisplayEditor* editor = (SpikeDisplayEditor*) getEditor(); + editor->stopRecording(); +} + void SpikeDisplayNode::setParameter(int param, float val) { @@ -161,6 +174,8 @@ void SpikeDisplayNode::handleEvent(int eventType, MidiMessage& event, int sample if (eventType == SPIKE) { + const MessageManagerLock mmLock; // get the lock to prevent the midi buffer from being read + eventBuffer->addEvent(event, 0); } diff --git a/Source/Processors/SpikeDisplayNode.h b/Source/Processors/SpikeDisplayNode.h index 9de5055d3..5ffe9d1cc 100755 --- a/Source/Processors/SpikeDisplayNode.h +++ b/Source/Processors/SpikeDisplayNode.h @@ -65,6 +65,9 @@ public: bool enable(); bool disable(); + + void startRecording(); + void stopRecording(); MidiBuffer* getSpikeBufferAddress() { diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp index b34633311..025b9dad1 100755 --- a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp +++ b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp @@ -119,6 +119,16 @@ void SpikeDisplayCanvas::refresh() repaint(); } +void SpikeDisplayCanvas::startRecording() +{ + spikeDisplay->startRecording(); +} + +void SpikeDisplayCanvas::stopRecording() +{ + spikeDisplay->startRecording(); +} + RecordNode* SpikeDisplayCanvas::getRecordNode() { return processor->getProcessorGraph()->getRecordNode(); @@ -127,6 +137,8 @@ RecordNode* SpikeDisplayCanvas::getRecordNode() void SpikeDisplayCanvas::processSpikeEvents() { + const MessageManagerLock mmLock; // get the lock to prevent the midi buffer from being updated + if (spikeBuffer->getNumEvents() > 0) { @@ -215,6 +227,34 @@ void SpikeDisplay::clear() } +void SpikeDisplay::startRecording() +{ + + // const MessageManagerLock mmLock; + + if (spikePlots.size() > 0) + { + for (int i = 0; i < spikePlots.size(); i++) + { + spikePlots[i]->startRecording(); + } + } +} + +void SpikeDisplay::stopRecording() +{ + + // const MessageManagerLock mmLock; + + if (spikePlots.size() > 0) + { + for (int i = 0; i < spikePlots.size(); i++) + { + spikePlots[i]->stopRecording(); + } + } +} + void SpikeDisplay::removePlots() { spikePlots.clear(); @@ -362,6 +402,7 @@ SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p, String name_) { recordNode = sdc->getRecordNode(); + diskWriteLock = sdc->getRecordNode()->getLock(); font = Font("Default", 15, Font::plain); @@ -428,6 +469,8 @@ SpikePlot::~SpikePlot() void SpikePlot::paint(Graphics& g) { + + //const MessageManagerLock mmLock; g.setColour(Colours::white); g.drawRect(0,0,getWidth(),getHeight()); @@ -435,7 +478,7 @@ void SpikePlot::paint(Graphics& g) g.setFont(font); g.drawText(name,10,0,200,20,Justification::left,false); - + } void SpikePlot::processSpikeObject(const SpikeObject& s) @@ -459,45 +502,32 @@ void SpikePlot::processSpikeObject(const SpikeObject& s) pAxes[i]->updateSpikeData(s); } - - // then record it! - if (recordNode->isRecording) - { - if (!isRecording) - { - // open file - openFile(); - - isRecording = true; - //std::cout << "Start recording spikes." << std::endl; - - } - - if (aboveThreshold) + if (aboveThreshold && isRecording) { // write spike to disk - writeSpike(s); + // writeSpike(s); } - } - else - { - - if (isRecording) - { - // close file - closeFile(); +} - isRecording = false; - //std::cout << "Stop recording spikes." << std::endl; - } - } +void SpikePlot::startRecording() +{ + //openFile(); + isRecording = true; + +} +void SpikePlot::stopRecording() +{ + // closeFile(); + isRecording = false; } void SpikePlot::openFile() { - dataDirectory = recordNode->getDataDirectory(); + //const MessageManagerLock mmLock; + + dataDirectory = File("/Users/Josh/Programming/open-ephys/GUI/Builds/MacOSX/build/Debug");//recordNode->getDataDirectory(); filename = dataDirectory.getFullPathName(); filename += File::separator; @@ -508,6 +538,9 @@ void SpikePlot::openFile() File fileToUse = File(filename); + diskWriteLock->enter(); + //const MessageManagerLock mmLock; + if (!fileToUse.exists()) { // open it and write header @@ -524,6 +557,8 @@ void SpikePlot::openFile() // append it file = fopen(filename.toUTF8(), "ab"); } + + diskWriteLock->exit(); } @@ -532,11 +567,17 @@ void SpikePlot::closeFile() { std::cout << "CLOSING FILE: " << filename << std::endl; + + // const MessageManagerLock mmLock; + diskWriteLock->enter(); + if (file != NULL) { fclose(file); } + + diskWriteLock->exit(); } @@ -560,8 +601,15 @@ void SpikePlot::writeSpike(const SpikeObject& s) // 2*n*m bytes for 16-bit samples // 2*n bytes for 16-bit gains // 2*n bytes for 16-bit thresholds + + // const MessageManagerLock mmLock; + + diskWriteLock->enter(); fwrite(spikeBuffer, 1, totalBytes, file); + + + diskWriteLock->exit(); } diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.h b/Source/Processors/Visualization/SpikeDisplayCanvas.h index ba91a18ef..915499b6f 100755 --- a/Source/Processors/Visualization/SpikeDisplayCanvas.h +++ b/Source/Processors/Visualization/SpikeDisplayCanvas.h @@ -95,6 +95,9 @@ public: bool keyPressed(const KeyPress& key); void buttonClicked(Button* button); + + void startRecording(); + void stopRecording(); RecordNode* getRecordNode(); SpikeDisplayNode* processor; @@ -139,6 +142,9 @@ public: { return totalHeight; } + + void startRecording(); + void stopRecording(); private: @@ -200,11 +206,14 @@ public: void buttonClicked(Button* button); + void startRecording(); + void stopRecording(); + + private: bool isRecording; - int plotType; int nWaveAx; int nProjAx; @@ -237,6 +246,8 @@ private: String filename; File dataDirectory; uint8_t* spikeBuffer; + + CriticalSection* diskWriteLock; }; diff --git a/Source/UI/ControlPanel.cpp b/Source/UI/ControlPanel.cpp index 65ffb46aa..4c0d88b5a 100755 --- a/Source/UI/ControlPanel.cpp +++ b/Source/UI/ControlPanel.cpp @@ -564,6 +564,9 @@ void ControlPanel::labelTextChanged(Label* label) void ControlPanel::buttonClicked(Button* button) { + + //const MessageManagerLock mmLock; + if (button == recordButton) { std::cout << "Record button pressed." << std::endl; @@ -571,14 +574,14 @@ void ControlPanel::buttonClicked(Button* button) { playButton->setToggleState(true,false); - //graph->getRecordNode()->setParameter(1,10.0f); masterClock->startRecording(); // turn on recording } else { - graph->getRecordNode()->setParameter(0,10.0f); // turn off recording + graph->setRecordState(false); // turn off recording in processor graph + //graph->getRecordNode()->setParameter(0,10.0f); // turn off recording masterClock->stopRecording(); newDirectoryButton->setEnabledState(true); } @@ -600,7 +603,7 @@ void ControlPanel::buttonClicked(Button* button) } else if (button == newDirectoryButton && newDirectoryButton->getEnabledState()) { - getProcessorGraph()->getRecordNode()->newDirectoryNeeded = true; + graph->getRecordNode()->newDirectoryNeeded = true; newDirectoryButton->setEnabledState(false); masterClock->resetRecordTime(); return; @@ -616,7 +619,10 @@ void ControlPanel::buttonClicked(Button* button) if (graph->enableProcessors()) { if (recordButton->getToggleState()) - graph->getRecordNode()->setParameter(1,10.0f); + graph->setRecordState(true); + + + //graph->getRecordNode()->setParameter(1,10.0f); stopTimer(); startTimer(250); // refresh every 250 ms @@ -629,7 +635,9 @@ void ControlPanel::buttonClicked(Button* button) { if (recordButton->getToggleState()) - graph->getRecordNode()->setParameter(1,10.0f); + { + graph->setRecordState(true); //getRecordNode()->setParameter(1,10.0f); + } } -- GitLab