Revision: 21619 http://sourceforge.net/p/bibdesk/svn/21619 Author: hofman Date: 2017-11-20 16:43:15 +0000 (Mon, 20 Nov 2017) Log Message: ----------- Revert an earlier change to FileView code, this lads to a crasher
Modified Paths: -------------- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageDescription.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.h trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.mm Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageDescription.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageDescription.m 2017-11-05 15:55:28 UTC (rev 21618) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageDescription.m 2017-11-20 16:43:15 UTC (rev 21619) @@ -73,7 +73,7 @@ _colorSpaceDescription = [[FVCGColorSpaceDescription allocWithZone:[self zone]] initWithColorSpace:CGImageGetColorSpace(_image)]; size_t bitmapPtrSize; - const uint8_t *bitmapPtr = __FVCGImageRetainBytePtr(_image, &bitmapPtrSize); + const uint8_t *bitmapPtr = __FVCGImageGetBytePtr(_image, &bitmapPtrSize); if (NULL == bitmapPtr) { _bitmapData = CGDataProviderCopyData(CGImageGetDataProvider(_image)); } @@ -90,7 +90,6 @@ - (void)dealloc { [_colorSpaceDescription release]; - __FVCGImageReleaseBytePtr(_image); if (_bitmapData) CFRelease(_bitmapData); NSZoneFree([self zone], _decode); CGImageRelease(_image); Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.h =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.h 2017-11-05 15:55:28 UTC (rev 21618) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.h 2017-11-20 16:43:15 UTC (rev 21619) @@ -70,18 +70,12 @@ @todo What length is returned for float32 or uint16_t images? - @warning This uses CoreGraphics SPI, and may return NULL at any time; use CGDataProviderCopyData as a fallback, or don't use it at all unless you absolutely need the memory performance. This should always be paired with __FVCGImageReleaseBytePtr. + @warning This uses CoreGraphics SPI, and may return NULL at any time; use CGDataProviderCopyData as a fallback, or don't use it at all unless you absolutely need the memory performance. @param image The image whose bitmap data you want to access. @param len Returns the length of the bitmap pointer by reference. @return A pointer to the data, or NULL on failure. */ -FV_PRIVATE_EXTERN const uint8_t * __FVCGImageRetainBytePtr(CGImageRef image, size_t *len); +FV_PRIVATE_EXTERN const uint8_t * __FVCGImageGetBytePtr(CGImageRef image, size_t *len); -/** @internal @brief Releases bitmap storage. - - @warning This uses CoreGraphics SPI. - @param image The image whose bitmap data you want to release. */ -FV_PRIVATE_EXTERN const void __FVCGImageReleaseBytePtr(CGImageRef image); - /** @internal @brief Get the CGColorSpaceModel of a color space. @warning This is a hack on 10.4 and earlier. Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.mm =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.mm 2017-11-05 15:55:28 UTC (rev 21618) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageUtilities.mm 2017-11-20 16:43:15 UTC (rev 21619) @@ -158,22 +158,15 @@ return toReturn; } -// private on newer versions of OS X -FV_EXTERN void * CGDataProviderRetainBytePtr(CGDataProviderRef provider) WEAK_IMPORT_ATTRIBUTE; -FV_EXTERN void CGDataProviderReleaseBytePtr(CGDataProviderRef provider) WEAK_IMPORT_ATTRIBUTE; // private on all versions of OS X FV_EXTERN void * CGDataProviderGetBytePtr(CGDataProviderRef provider) WEAK_IMPORT_ATTRIBUTE; FV_EXTERN size_t CGDataProviderGetSize(CGDataProviderRef provider) WEAK_IMPORT_ATTRIBUTE; -const uint8_t * __FVCGImageRetainBytePtr(CGImageRef image, size_t *len) +const uint8_t * __FVCGImageGetBytePtr(CGImageRef image, size_t *len) { CGDataProviderRef provider = CGImageGetDataProvider(image); uint8_t *bytePtr = NULL; - if (NULL != CGDataProviderRetainBytePtr && NULL != CGDataProviderGetSize) { - bytePtr = (uint8_t *)CGDataProviderRetainBytePtr(provider); - if (len) *len = CGDataProviderGetSize(provider); - } - else if (NULL != CGDataProviderGetBytePtr && NULL != CGDataProviderGetSize) { + if (NULL != CGDataProviderGetBytePtr && NULL != CGDataProviderGetSize) { bytePtr = (uint8_t *)CGDataProviderGetBytePtr(provider); if (len) *len = CGDataProviderGetSize(provider); } @@ -180,14 +173,6 @@ return bytePtr; } -const void __FVCGImageReleaseBytePtr(CGImageRef image) -{ - CGDataProviderRef provider = CGImageGetDataProvider(image); - if (NULL != CGDataProviderReleaseBytePtr && NULL != CGDataProviderRetainBytePtr && NULL != CGDataProviderGetSize) { - CGDataProviderReleaseBytePtr(provider); - } -} - static inline bool __FVBitmapInfoIsIncompatible(CGImageRef image) { CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(image); @@ -775,15 +760,9 @@ // make this call early to increase the allocation size record if needed CFDataRef originalImageData = NULL; - const uint8_t *srcBytes = __FVCGImageRetainBytePtr(image, NULL); + const uint8_t *srcBytes = __FVCGImageGetBytePtr(image, NULL); if (NULL == srcBytes) { -#if FV_LIMIT_TILEMEMORY_USAGE - const size_t allocSize = __FVCGImageGetDataSize(image); - // increase before calling rest of __FVTileAndScale_8888_or_888_Image; will be decreased after releasing copied data - __FVCGImageRequestAllocationSize(allocSize); -#endif - originalImageData = CGDataProviderCopyData(CGImageGetDataProvider(image)); // !!! early return @@ -1001,9 +980,6 @@ vImageDestroyResamplingFilter(filter); - // paired with __FVCGImageRetainBytePtr, this does nothing when not needed - __FVCGImageReleaseBytePtr(image); - if (originalImageData) { CFRelease(originalImageData); #if FV_LIMIT_TILEMEMORY_USAGE @@ -1146,5 +1122,10 @@ return __FVCopyImageUsingCacheColorspace(image, desiredSize); } +#if FV_LIMIT_TILEMEMORY_USAGE + const size_t allocSize = __FVCGImageGetBytePtr(image, NULL) == NULL ? __FVCGImageGetDataSize(image) : 0; + // increase before calling __FVTileAndScale_8888_or_888_Image; will be decreased after releasing copied data + __FVCGImageRequestAllocationSize(allocSize); +#endif return __FVTileAndScale_8888_or_888_Image(image, desiredSize); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit