- Revision
- 132525
- Author
- [email protected]
- Date
- 2012-10-25 13:32:20 -0700 (Thu, 25 Oct 2012)
Log Message
Source/WebCore: Move ImageOrientation transform back in CG space (lower-left origin), adapt the skia code to work with that, turn on feature for chromium
https://bugs.webkit.org/show_bug.cgi?id=100401
Reviewed by Eric Seidel.
This is an alternative fix for the regression caused by r132384 / bug
100179. The bug exists because different pieces of code didn't agree
which space the transformation returned by ImageOrientation was in.
r132384 moved it from CG coordinates to skia coordinates, but didn't
do it completetely. This CL reverts this part of r132384 so that the
transformation is in CG coordinates again, and adapts the skia code to
work in that space.
Alternatively, https://bugs.webkit.org/show_bug.cgi?id=100319 woudl
make the cg code work with the transform in skia coordinates.
Covered by fast/images/exif-orientation.html
* platform/chromium/DragImageChromiumSkia.cpp:
(WebCore::createDragImageFromImage):
* platform/graphics/ImageOrientation.cpp:
(WebCore::ImageOrientation::transformFromDefault):
* platform/graphics/ImageOrientation.h:
(WebCore):
(WebCore::ImageOrientation::usesWidthAsHeight):
(WebCore::ImageOrientation::fromEXIFValue):
(ImageOrientation):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::drawNativeImage):
* platform/graphics/skia/ImageSkia.cpp:
(WebCore::BitmapImage::draw):
* platform/mac/DragImageMac.mm:
(WebCore::createDragImageFromImage):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::shouldRespectImageOrientation):
LayoutTests: Move ImageOrientation transform back in CG space (lower-left origin), adapt the skia code to work with that, turn on feature for chromium
https://bugs.webkit.org/show_bug.cgi?id=100319
Reviewed by Eric Seidel.
* platform/chromium/TestExpectations:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (132524 => 132525)
--- trunk/LayoutTests/ChangeLog 2012-10-25 20:16:07 UTC (rev 132524)
+++ trunk/LayoutTests/ChangeLog 2012-10-25 20:32:20 UTC (rev 132525)
@@ -1,3 +1,12 @@
+2012-10-25 Nico Weber <[email protected]>
+
+ Move ImageOrientation transform back in CG space (lower-left origin), adapt the skia code to work with that, turn on feature for chromium
+ https://bugs.webkit.org/show_bug.cgi?id=100319
+
+ Reviewed by Eric Seidel.
+
+ * platform/chromium/TestExpectations:
+
2012-10-25 Simon Fraser <[email protected]>
Log the tile cache tile size in test output
Modified: trunk/LayoutTests/platform/chromium/TestExpectations (132524 => 132525)
--- trunk/LayoutTests/platform/chromium/TestExpectations 2012-10-25 20:16:07 UTC (rev 132524)
+++ trunk/LayoutTests/platform/chromium/TestExpectations 2012-10-25 20:32:20 UTC (rev 132525)
@@ -3314,7 +3314,6 @@
webkit.org/b/83324 [ Win Debug ] fast/js/cross-global-object-inline-global-var.html [ Failure Pass ]
# EXIF orientation support has not yet been implemented for this platform
-webkit.org/b/19688 fast/images/exif-orientation.html
webkit.org/b/19688 fast/images/exif-orientation-css.html
crbug.com/122462 [ Linux Win ] http/tests/inspector/inspect-element.html [ Failure Slow ]
@@ -3985,6 +3984,9 @@
webkit.org/b/98275 media/event-queue-crash.html [ Skip ]
+# BUGTHAKIS: Requires baselines
+webkit.org/b/19688 fast/images/exif-orientation.html [ ImageOnlyFailure ]
+
# These are real failues due to 95121.
# This is spilling caused by LANCZOS3 scaling algorithm that samples outside the source rect.
webkit.org/b/95121 fast/images/pixel-crack-image-background-webkit-transform-scale.html [ ImageOnlyFailure ]
Modified: trunk/Source/WebCore/ChangeLog (132524 => 132525)
--- trunk/Source/WebCore/ChangeLog 2012-10-25 20:16:07 UTC (rev 132524)
+++ trunk/Source/WebCore/ChangeLog 2012-10-25 20:32:20 UTC (rev 132525)
@@ -1,3 +1,42 @@
+2012-10-25 Nico Weber <[email protected]>
+
+ Move ImageOrientation transform back in CG space (lower-left origin), adapt the skia code to work with that, turn on feature for chromium
+ https://bugs.webkit.org/show_bug.cgi?id=100401
+
+ Reviewed by Eric Seidel.
+
+ This is an alternative fix for the regression caused by r132384 / bug
+ 100179. The bug exists because different pieces of code didn't agree
+ which space the transformation returned by ImageOrientation was in.
+
+ r132384 moved it from CG coordinates to skia coordinates, but didn't
+ do it completetely. This CL reverts this part of r132384 so that the
+ transformation is in CG coordinates again, and adapts the skia code to
+ work in that space.
+
+ Alternatively, https://bugs.webkit.org/show_bug.cgi?id=100319 woudl
+ make the cg code work with the transform in skia coordinates.
+
+ Covered by fast/images/exif-orientation.html
+
+ * platform/chromium/DragImageChromiumSkia.cpp:
+ (WebCore::createDragImageFromImage):
+ * platform/graphics/ImageOrientation.cpp:
+ (WebCore::ImageOrientation::transformFromDefault):
+ * platform/graphics/ImageOrientation.h:
+ (WebCore):
+ (WebCore::ImageOrientation::usesWidthAsHeight):
+ (WebCore::ImageOrientation::fromEXIFValue):
+ (ImageOrientation):
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::drawNativeImage):
+ * platform/graphics/skia/ImageSkia.cpp:
+ (WebCore::BitmapImage::draw):
+ * platform/mac/DragImageMac.mm:
+ (WebCore::createDragImageFromImage):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::shouldRespectImageOrientation):
+
2012-10-25 Simon Fraser <[email protected]>
Log the tile cache tile size in test output
Modified: trunk/Source/WebCore/platform/chromium/DragImageChromiumSkia.cpp (132524 => 132525)
--- trunk/Source/WebCore/platform/chromium/DragImageChromiumSkia.cpp 2012-10-25 20:16:07 UTC (rev 132524)
+++ trunk/Source/WebCore/platform/chromium/DragImageChromiumSkia.cpp 2012-10-25 20:32:20 UTC (rev 132525)
@@ -127,14 +127,21 @@
SkBitmap::kARGB_8888_Config, sizeRespectingOrientation.width(), sizeRespectingOrientation.height());
dragImageChromium->bitmap->allocPixels();
+ FloatRect destRect(FloatPoint(), sizeRespectingOrientation);
SkCanvas canvas(*dragImageChromium->bitmap);
- SkMatrix transform = orientation.transformFromDefault(sizeRespectingOrientation);
- canvas.concat(transform);
- FloatRect destRect(FloatPoint(), sizeRespectingOrientation);
+ // ImageOrientation expects the origin in the lower left corner, so flip, transform, and then...
+ canvas.translate(0, destRect.height());
+ canvas.scale(1, -1);
+ canvas.concat(orientation.transformFromDefault(sizeRespectingOrientation));
+
if (orientation.usesWidthAsHeight())
destRect = FloatRect(destRect.x(), destRect.y(), destRect.height(), destRect.width());
+ // ...flip back.
+ canvas.translate(0, destRect.height());
+ canvas.scale(1, -1);
+
canvas.drawBitmapRect(bitmap->bitmap(), 0, destRect);
return dragImageChromium;
}
Modified: trunk/Source/WebCore/platform/graphics/ImageOrientation.h (132524 => 132525)
--- trunk/Source/WebCore/platform/graphics/ImageOrientation.h 2012-10-25 20:16:07 UTC (rev 132524)
+++ trunk/Source/WebCore/platform/graphics/ImageOrientation.h 2012-10-25 20:32:20 UTC (rev 132525)
@@ -39,10 +39,10 @@
OriginTopRight = 2, // mirror along y-axis
OriginBottomRight = 3, // 180 degree rotation
OriginBottomLeft = 4, // mirror along the x-axis
- OriginRightBottom = 5, // mirror along x-axis + 270 degree CW rotation
- OriginLeftBottom = 6, // 90 degree CW rotation
- OriginLeftTop = 7, // mirror along x-axis + 90 degree CW rotation
- OriginRightTop = 8, // 270 degree CW rotation
+ OriginLeftTop = 5, // mirror along x-axis + 270 degree CW rotation
+ OriginRightTop = 6, // 90 degree CW rotation
+ OriginRightBottom = 7, // mirror along x-axis + 90 degree CW rotation
+ OriginLeftBottom = 8, // 270 degree CW rotation
// All other values are "reserved" as of EXIF 2.2
DefaultImageOrientation = OriginTopLeft,
};
@@ -62,7 +62,7 @@
bool usesWidthAsHeight() const
{
// Values 5 through 8 all flip the width/height.
- return m_orientation >= OriginRightBottom;
+ return m_orientation >= OriginLeftTop;
}
// ImageOrientationEnum currently matches EXIF values, however code outside
@@ -70,12 +70,13 @@
static ImageOrientation fromEXIFValue(int exifValue)
{
// Values direct from images may be invalid, in which case we use the default.
- if (exifValue < OriginTopLeft || exifValue > OriginRightTop)
+ if (exifValue < OriginTopLeft || exifValue > OriginLeftBottom)
return DefaultImageOrientation;
return static_cast<ImageOrientationEnum>(exifValue);
}
// This transform can be used for drawing an image according to the orientation.
+ // It should be used in a left-handed coordinate system.
AffineTransform transformFromDefault(const FloatSize& drawnSize) const;
inline bool operator==(const ImageOrientation& other) const { return other.m_orientation == m_orientation; }
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (132524 => 132525)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2012-10-25 20:16:07 UTC (rev 132524)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2012-10-25 20:32:20 UTC (rev 132525)
@@ -326,6 +326,11 @@
setPlatformCompositeOperation(op);
+ // Flip the coords.
+ CGContextTranslateCTM(context, adjustedDestRect.x(), adjustedDestRect.maxY());
+ CGContextScaleCTM(context, 1, -1);
+ adjustedDestRect.setLocation(FloatPoint());
+
if (orientation != DefaultImageOrientation) {
CGContextConcatCTM(context, orientation.transformFromDefault(adjustedDestRect.size()));
if (orientation.usesWidthAsHeight()) {
@@ -335,11 +340,6 @@
}
}
- // Flip the coords.
- CGContextTranslateCTM(context, adjustedDestRect.x(), adjustedDestRect.maxY());
- CGContextScaleCTM(context, 1, -1);
- adjustedDestRect.setLocation(FloatPoint());
-
// Adjust the color space.
image = Image::imageWithColorSpace(image.get(), styleColorSpace);
Modified: trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp (132524 => 132525)
--- trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp 2012-10-25 20:16:07 UTC (rev 132524)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp 2012-10-25 20:32:20 UTC (rev 132525)
@@ -614,12 +614,25 @@
GraphicsContextStateSaver saveContext(*ctxt, false);
if (orientation != DefaultImageOrientation) {
saveContext.save();
+
+ // ImageOrientation expects the origin to be at (0, 0)
+ ctxt->translate(normDstRect.x(), normDstRect.y());
+ normDstRect.setLocation(FloatPoint());
+
+ // ImageOrientation also expects the origin in the lower left corner, so flip, transform, and then...
+ ctxt->translate(0, normDstRect.height());
+ ctxt->scale(FloatSize(1, -1));
ctxt->concatCTM(orientation.transformFromDefault(normDstRect.size()));
+
if (orientation.usesWidthAsHeight()) {
// The destination rect will have it's 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());
}
+
+ // ...flip back.
+ ctxt->translate(0, normDstRect.height());
+ ctxt->scale(FloatSize(1, -1));
}
paintSkBitmap(ctxt->platformContext(),
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (132524 => 132525)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2012-10-25 20:16:07 UTC (rev 132524)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2012-10-25 20:32:20 UTC (rev 132525)
@@ -2227,7 +2227,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)
+#if USE(CG) || PLATFORM(CHROMIUM)
// This can only be enabled for ports which honor the orientation flag in their drawing code.
document()->isImageDocument() ||
#endif