Title: [130591] trunk/Source/WebCore
Revision
130591
Author
[email protected]
Date
2012-10-06 17:02:44 -0700 (Sat, 06 Oct 2012)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (130590 => 130591)


--- trunk/Source/WebCore/ChangeLog	2012-10-06 21:51:48 UTC (rev 130590)
+++ trunk/Source/WebCore/ChangeLog	2012-10-07 00:02:44 UTC (rev 130591)
@@ -1,3 +1,21 @@
+2012-10-06  Pratik Solanki  <[email protected]>
+
+        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  <[email protected]>
 
         Build fix.

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp (130590 => 130591)


--- trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp	2012-10-06 21:51:48 UTC (rev 130590)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp	2012-10-07 00:02:44 UTC (rev 130591)
@@ -194,6 +194,18 @@
     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 @@
     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 @@
     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
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to