Commit 175321de authored by psolanki@apple.com's avatar psolanki@apple.com

Reduce calls to CGImageSourceCopyPropertiesAtIndex from frameSizeAtIndex

https://bugs.webkit.org/show_bug.cgi?id=98607

Reviewed by Dan Bernstein.

Refactor code so that we avoid a second call to CGImageSourceCopyPropertiesAtIndex under
ImageSource::frameSizeAtIndex().

No new tests because no functional change.

* platform/graphics/cg/ImageSourceCG.cpp:
(WebCore::orientationFromProperties):
(WebCore):
(WebCore::ImageSource::frameSizeAtIndex):
(WebCore::ImageSource::orientationAtIndex):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130591 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c93969b0
2012-10-06 Pratik Solanki <psolanki@apple.com>
Reduce calls to CGImageSourceCopyPropertiesAtIndex from frameSizeAtIndex
https://bugs.webkit.org/show_bug.cgi?id=98607
Reviewed by Dan Bernstein.
Refactor code so that we avoid a second call to CGImageSourceCopyPropertiesAtIndex under
ImageSource::frameSizeAtIndex().
No new tests because no functional change.
* platform/graphics/cg/ImageSourceCG.cpp:
(WebCore::orientationFromProperties):
(WebCore):
(WebCore::ImageSource::frameSizeAtIndex):
(WebCore::ImageSource::orientationAtIndex):
2012-10-06 Mark Rowe <mrowe@apple.com>
Build fix.
......
......@@ -194,6 +194,18 @@ bool ImageSource::isSizeAvailable()
return result;
}
static ImageOrientation orientationFromProperties(CFDictionaryRef imageProperties)
{
ASSERT(imageProperties);
CFNumberRef orientationProperty = (CFNumberRef)CFDictionaryGetValue(imageProperties, kCGImagePropertyOrientation);
if (!orientationProperty)
return DefaultImageOrientation;
int exifValue;
CFNumberGetValue(orientationProperty, kCFNumberIntType, &exifValue);
return ImageOrientation::fromEXIFValue(exifValue);
}
IntSize ImageSource::frameSizeAtIndex(size_t index, RespectImageOrientationEnum shouldRespectOrientation) const
{
RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions(SkipMetadata)));
......@@ -209,7 +221,7 @@ IntSize ImageSource::frameSizeAtIndex(size_t index, RespectImageOrientationEnum
if (num)
CFNumberGetValue(num, kCFNumberIntType, &h);
if ((shouldRespectOrientation == RespectImageOrientation) && orientationAtIndex(index).usesWidthAsHeight())
if ((shouldRespectOrientation == RespectImageOrientation) && orientationFromProperties(properties.get()).usesWidthAsHeight())
return IntSize(h, w);
return IntSize(w, h);
......@@ -221,13 +233,7 @@ ImageOrientation ImageSource::orientationAtIndex(size_t index) const
if (!properties)
return DefaultImageOrientation;
CFNumberRef orientationProperty = (CFNumberRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyOrientation);
if (!orientationProperty)
return DefaultImageOrientation;
int exifValue;
CFNumberGetValue(orientationProperty, kCFNumberIntType, &exifValue);
return ImageOrientation::fromEXIFValue(exifValue);
return orientationFromProperties(properties.get());
}
IntSize ImageSource::size(RespectImageOrientationEnum shouldRespectOrientation) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment