Diff
Modified: trunk/LayoutTests/ChangeLog (260015 => 260016)
--- trunk/LayoutTests/ChangeLog 2020-04-13 16:43:05 UTC (rev 260015)
+++ trunk/LayoutTests/ChangeLog 2020-04-13 16:43:21 UTC (rev 260016)
@@ -1,3 +1,16 @@
+2020-04-13 Said Abou-Hallawa <[email protected]>
+
+ When drawing an image srcRect and imageRect have to be in the orientation of destRect
+ https://bugs.webkit.org/show_bug.cgi?id=210364
+
+ Reviewed by Darin Adler.
+
+ * fast/images/image-orientation-none-canvas.html:
+ Make this test for images with "visibility: hidden;" only. This guarantees
+ the images have renderers. Images with "display: none;" will be covered
+ in another patch because the width and height is currently incorrect if
+ "image-orientation: none;".
+
2020-04-13 Youenn Fablet <[email protected]>
Fix mute/unmute of CoreAudioCapture sources after revision 257914
Modified: trunk/LayoutTests/fast/images/image-orientation-none-canvas.html (260015 => 260016)
--- trunk/LayoutTests/fast/images/image-orientation-none-canvas.html 2020-04-13 16:43:05 UTC (rev 260015)
+++ trunk/LayoutTests/fast/images/image-orientation-none-canvas.html 2020-04-13 16:43:21 UTC (rev 260016)
@@ -11,7 +11,13 @@
width: 102px;
height: 52px;
}
+ img {
+ position: fixed;
+ image-orientation: none;
+ visibility: hidden;
+ }
canvas {
+ position: fixed;
border: 1px solid black;
width: 100px;
height: 50px;
@@ -23,25 +29,29 @@
<br>
<div class ="container">
<div class ="box">
- <canvas id="canvas1"></canvas>
+ <img src=""
+ <canvas></canvas>
</div>
<br>Normal
</div>
<div class ="container">
<div class ="box">
- <canvas id="canvas2"></canvas>
+ <img src=""
+ <canvas></canvas>
</div>
<br>Flipped horizontally
</div>
<div class ="container">
<div class ="box">
- <canvas id="canvas3"></canvas>
+ <img src=""
+ <canvas></canvas>
</div>
<br>Rotated 180°
</div>
<div class ="container">
<div class ="box">
- <canvas id="canvas4"></canvas>
+ <img src=""
+ <canvas></canvas>
</div>
<br>Flipped vertically
</div>
@@ -48,25 +58,29 @@
<br>
<div class ="container">
<div class ="box">
- <canvas id="canvas5"></canvas>
+ <img src=""
+ <canvas></canvas>
</div>
<br>Rotated 90° CCW and flipped vertically
</div>
<div class ="container">
<div class ="box">
- <canvas id="canvas6"></canvas>
+ <img src=""
+ <canvas></canvas>
</div>
<br>Rotated 90° CCW
</div>
<div class ="container">
<div class ="box">
- <canvas id="canvas7"></canvas>
+ <img src=""
+ <canvas></canvas>
</div>
<br>Rotated 90° CW and flipped vertically
</div>
<div class ="container">
<div class ="box">
- <canvas id="canvas8"></canvas>
+ <img src=""
+ <canvas></canvas>
</div>
<br>Rotated 90° CW
</div>
@@ -73,7 +87,8 @@
<br>
<div class ="container">
<div class ="box">
- <canvas id="canvas9"></canvas>
+ <img src=""
+ <canvas></canvas>
</div>
<br>Undefined (invalid value)
</div>
@@ -82,38 +97,18 @@
window.testRunner.waitUntilDone();
window._onload_ = function() {
- var names = [
- { resource: "resources/exif-orientation-1-ul.jpg", id : "canvas1" },
- { resource: "resources/exif-orientation-2-ur.jpg", id : "canvas2" },
- { resource: "resources/exif-orientation-3-lr.jpg", id : "canvas3" },
- { resource: "resources/exif-orientation-4-lol.jpg", id : "canvas4" },
- { resource: "resources/exif-orientation-5-lu.jpg", id : "canvas5" },
- { resource: "resources/exif-orientation-6-ru.jpg", id : "canvas6" },
- { resource: "resources/exif-orientation-7-rl.jpg", id : "canvas7" },
- { resource: "resources/exif-orientation-8-llo.jpg", id : "canvas8" },
- { resource: "resources/exif-orientation-9-u.jpg", id : "canvas9" }
- ];
+ var boxes = document.querySelectorAll(".box");
- var drawCount = 0;
+ boxes.forEach(function(box) {
+ let image = box.querySelector("img");
+ let canvas = box.querySelector("canvas");
+ canvas.width = canvas.clientWidth;
+ canvas.height = canvas.clientHeight;
+ let context = canvas.getContext("2d");
+ context.drawImage(image, 0, 0, canvas.width, canvas.height);
+ });
- names.forEach(function(name) {
- var image = new Image;
- image.style.imageOrientation = "none";
- image.style.display = "none";
- image.src = ""
- document.body.appendChild(image);
- image.decode().then(() => {
- let canvas = document.getElementById(name.id);
- canvas.width = canvas.offsetWidth - 2;
- canvas.height = canvas.offsetHeight - 2;
- let context = canvas.getContext("2d");
- context.drawImage(image, 0, 0, canvas.width, canvas.height);
- if (++drawCount == names.length) {
- if (window.testRunner)
- window.testRunner.notifyDone();
- }
- });
- });
+ window.testRunner.notifyDone();
}
</script>
</body>
Modified: trunk/Source/WebCore/ChangeLog (260015 => 260016)
--- trunk/Source/WebCore/ChangeLog 2020-04-13 16:43:05 UTC (rev 260015)
+++ trunk/Source/WebCore/ChangeLog 2020-04-13 16:43:21 UTC (rev 260016)
@@ -1,3 +1,24 @@
+2020-04-13 Said Abou-Hallawa <[email protected]>
+
+ When drawing an image srcRect and imageRect have to be in the orientation of destRect
+ https://bugs.webkit.org/show_bug.cgi?id=210364
+
+ Reviewed by Darin Adler.
+
+ * html/canvas/CanvasRenderingContext2DBase.cpp:
+ (WebCore::CanvasRenderingContext2DBase::drawImage):
+ Use the renderer to get the orientation of the image if it is available.
+ Otherwise fall back to computedStyle().
+
+ * platform/graphics/BitmapImage.cpp:
+ (WebCore::BitmapImage::draw):
+ For async image decoding, we will use the none oriented size as the
+ sizeForDrawing. imageRect must be in the same orientation as destRect.
+
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::drawImage):
+ srcRect must be in the same orientation as destRect.
+
2020-04-13 Joonghun Park <[email protected]>
Unreviewed. Remove redundant move in return statement.
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (260015 => 260016)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp 2020-04-13 16:43:05 UTC (rev 260015)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp 2020-04-13 16:43:21 UTC (rev 260016)
@@ -1465,7 +1465,9 @@
FloatRect imageRect = FloatRect(FloatPoint(), size(imageElement, ImageSizeType::BeforeDevicePixelRatio));
auto orientation = ImageOrientation::FromImage;
- if (auto* computedStyle = imageElement.computedStyle())
+ if (auto* renderer = imageElement.renderer())
+ orientation = renderer->style().imageOrientation();
+ else if (auto* computedStyle = imageElement.computedStyle())
orientation = computedStyle->imageOrientation();
auto result = drawImage(imageElement.document(), imageElement.cachedImage(), imageElement.renderer(), imageRect, srcRect, dstRect, op, blendMode, orientation);
Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (260015 => 260016)
--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp 2020-04-13 16:43:05 UTC (rev 260015)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp 2020-04-13 16:43:21 UTC (rev 260016)
@@ -210,7 +210,7 @@
return ImageDrawResult::DidNothing;
FloatSize scaleFactorForDrawing = context.scaleFactorForDrawing(destRect, srcRect);
- IntSize sizeForDrawing = expandedIntSize(size() * scaleFactorForDrawing);
+ IntSize sizeForDrawing = expandedIntSize(size(ImageOrientation::None) * scaleFactorForDrawing);
ImageDrawResult result = ImageDrawResult::DidDraw;
m_currentSubsamplingLevel = m_allowSubsampling ? subsamplingLevelForScaleFactor(context, scaleFactorForDrawing) : SubsamplingLevel::Default;
@@ -289,10 +289,12 @@
return result;
}
- if (options.orientation() == ImageOrientation::FromImage)
- drawNativeImage(image, context, destRect, srcRect, IntSize(size()), { options, frameOrientationAtIndex(m_currentFrame) });
- else
- drawNativeImage(image, context, destRect, srcRect, IntSize(size()), options);
+ auto orientation = options.orientation();
+ if (orientation == ImageOrientation::FromImage) {
+ orientation = frameOrientationAtIndex(m_currentFrame);
+ drawNativeImage(image, context, destRect, srcRect, IntSize(size(orientation)), { options, orientation });
+ } else
+ drawNativeImage(image, context, destRect, srcRect, IntSize(size(orientation)), options);
m_currentFrameDecodingStatus = frameDecodingStatusAtIndex(m_currentFrame);
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (260015 => 260016)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2020-04-13 16:43:05 UTC (rev 260015)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2020-04-13 16:43:21 UTC (rev 260016)
@@ -711,7 +711,7 @@
ImageDrawResult GraphicsContext::drawImage(Image& image, const FloatRect& destination, const ImagePaintingOptions& imagePaintingOptions)
{
- FloatRect srcRect(FloatPoint(), image.size());
+ FloatRect srcRect(FloatPoint(), image.size(imagePaintingOptions.orientation()));
return drawImage(image, destination, srcRect, imagePaintingOptions);
}