Title: [147110] trunk/Source/WebCore
Revision
147110
Author
commit-qu...@webkit.org
Date
2013-03-28 07:04:13 -0700 (Thu, 28 Mar 2013)

Log Message

[BlackBerry] Handle EXIF orientation for ImageDocuments
https://bugs.webkit.org/show_bug.cgi?id=113423

Internal Bug: PR 293648
Informally Reviewed by Jeff Rogers
Patch by Chris Hutten-Czapski <chut...@blackberry.com> on 2013-03-28
Reviewed by Rob Buis.

Support image orientation in our image draw calls, and advertise
the capability to the calling code. This allows us to respect EXIF
orientation data.

* platform/graphics/BitmapImage.h:
* platform/graphics/blackberry/ImageBlackBerry.cpp:
(WebCore::BitmapImage::draw):
(WebCore):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::shouldRespectImageOrientation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147109 => 147110)


--- trunk/Source/WebCore/ChangeLog	2013-03-28 13:46:13 UTC (rev 147109)
+++ trunk/Source/WebCore/ChangeLog	2013-03-28 14:04:13 UTC (rev 147110)
@@ -1,3 +1,23 @@
+2013-03-28  Chris Hutten-Czapski  <chut...@blackberry.com>
+
+        [BlackBerry] Handle EXIF orientation for ImageDocuments
+        https://bugs.webkit.org/show_bug.cgi?id=113423
+
+        Internal Bug: PR 293648
+        Informally Reviewed by Jeff Rogers
+        Reviewed by Rob Buis.
+
+        Support image orientation in our image draw calls, and advertise
+        the capability to the calling code. This allows us to respect EXIF
+        orientation data.
+
+        * platform/graphics/BitmapImage.h:
+        * platform/graphics/blackberry/ImageBlackBerry.cpp:
+        (WebCore::BitmapImage::draw):
+        (WebCore):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::shouldRespectImageOrientation):
+
 2013-03-28  Andrey Kosyakov  <ca...@chromium.org>
 
         Web Inspector: name timeline overview controls consistently

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (147109 => 147110)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.h	2013-03-28 13:46:13 UTC (rev 147109)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h	2013-03-28 14:04:13 UTC (rev 147110)
@@ -208,7 +208,7 @@
     virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator);
 #endif
     virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
-#if USE(CG) || PLATFORM(CHROMIUM) || USE(CAIRO)
+#if USE(CG) || PLATFORM(CHROMIUM) || USE(CAIRO) || PLATFORM(BLACKBERRY)
     virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode, RespectImageOrientationEnum) OVERRIDE;
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp (147109 => 147110)


--- trunk/Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp	2013-03-28 13:46:13 UTC (rev 147109)
+++ trunk/Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp	2013-03-28 14:04:13 UTC (rev 147110)
@@ -121,6 +121,11 @@
 
 void BitmapImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
 {
+    draw(context, dstRect, srcRect, styleColorSpace, op, DoNotRespectImageOrientation);
+}
+
+void BitmapImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation)
+{
     startAnimation();
 
     NativeImagePtr image = nativeImageForCurrentFrame();
@@ -137,6 +142,27 @@
     normSrcRect = adjustSourceRectForDownSampling(normSrcRect, image->size());
 #endif
 
+    // use similar orientation code as ImageSkia
+    ImageOrientation orientation = DefaultImageOrientation;
+    if (shouldRespectImageOrientation == RespectImageOrientation)
+        orientation = frameOrientationAtIndex(m_currentFrame);
+
+    GraphicsContextStateSaver saveContext(*context, false);
+    if (orientation != DefaultImageOrientation) {
+        saveContext.save();
+
+        // ImageOrientation expects the origin to be at (0, 0)
+        context->translate(normDstRect.x(), normDstRect.y());
+        normDstRect.setLocation(FloatPoint());
+
+        context->concatCTM(orientation.transformFromDefault(normDstRect.size()));
+        if (orientation.usesWidthAsHeight()) {
+            // The destination rect will have its width and height already reversed for the orientation of
+            // the image, as it was needed for page layout, so we need to reverse it back here.
+            normDstRect = FloatRect(normDstRect.x(), normDstRect.y(), normDstRect.height(), normDstRect.width());
+        }
+    }
+
     CompositeOperator oldOperator = context->compositeOperation();
     context->setCompositeOperation(op);
     context->platformContext()->addImage(normDstRect, normSrcRect, image);

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (147109 => 147110)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2013-03-28 13:46:13 UTC (rev 147109)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2013-03-28 14:04:13 UTC (rev 147110)
@@ -2289,7 +2289,7 @@
     // Respect the image's orientation if it's being used as a full-page image or it's
     // an <img> and the setting to respect it everywhere is set.
     return
-#if USE(CG) || PLATFORM(CHROMIUM) || USE(CAIRO)
+#if USE(CG) || PLATFORM(CHROMIUM) || USE(CAIRO) || PLATFORM(BLACKBERRY)
         // This can only be enabled for ports which honor the orientation flag in their drawing code.
         document()->isImageDocument() ||
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to