Changeset 249364 in webkit
- Timestamp:
- Aug 31, 2019 5:47:39 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 18 added
- 7 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r249363 r249364 1 2019-08-31 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 EXIF orientation should be respected when rendering images 4 https://bugs.webkit.org/show_bug.cgi?id=201123 5 6 Reviewed by Simon Fraser. 7 8 Existing tests are made ref-tests. New tests were added to cover more 9 cases for drawing images. 10 11 * fast/images/exif-orientation-background-expected.html: Added. 12 * fast/images/exif-orientation-background.html: Added. 13 * fast/images/exif-orientation-canvas-expected.html: Added. 14 * fast/images/exif-orientation-canvas.html: Added. 15 * fast/images/exif-orientation-composited-expected.html: Added. 16 * fast/images/exif-orientation-composited-expected.txt: Removed. 17 * fast/images/exif-orientation-composited.html: 18 * fast/images/exif-orientation-content-expected.html: Added. 19 * fast/images/exif-orientation-content.html: Added. 20 * fast/images/exif-orientation-css-expected.txt: Removed. 21 * fast/images/exif-orientation-css.html: Removed. 22 * fast/images/exif-orientation-element-expected.html: Added. 23 * fast/images/exif-orientation-element-object-fit-expected.html: Added. 24 * fast/images/exif-orientation-element-object-fit.html: Added. 25 * fast/images/exif-orientation-element.html: Added. 26 * fast/images/exif-orientation-expected.txt: Removed. 27 * fast/images/exif-orientation-image-document-expected.html: Added. 28 * fast/images/exif-orientation-image-document-expected.txt: Removed. 29 * fast/images/exif-orientation-image-document.html: 30 * fast/images/exif-orientation-image-object-expected.html: Added. 31 * fast/images/exif-orientation-image-object.html: Added. 32 * fast/images/exif-orientation-svg-feimage-expected.html: Added. 33 * fast/images/exif-orientation-svg-feimage.html: Added. 34 * fast/images/exif-orientation-svg-image-expected.html: Added. 35 * fast/images/exif-orientation-svg-image.html: Added. 36 * fast/images/exif-orientation.html: Removed. 37 * platform/gtk/TestExpectations: 38 * platform/mac/fast/images/exif-orientation-composited-expected.png: Removed. 39 * platform/win/TestExpectations: 40 1 41 2019-08-31 Wenson Hsieh <wenson_hsieh@apple.com> 2 42 -
trunk/LayoutTests/fast/images/exif-orientation-composited.html
r218754 r249364 1 <html> 2 <head> 3 <script> 4 if (window.internals) 5 internals.settings.setShouldRespectImageOrientation(true); 6 if (window.testRunner) 7 testRunner.dumpAsText(true); 1 <!DOCTYPE html> 2 <style> 3 div.container { 4 display: inline-block; 5 margin-right: 20px; 6 margin-bottom: 10px; 7 width: 100px; 8 vertical-align: top; 9 } 10 div.horizontal { 11 width: 102; 12 height: 52px; 13 } 14 div.vertical { 15 width: 52px; 16 height: 102px; 17 } 18 img { 19 -webkit-transform: translateZ(0); 20 border: 1px solid black; 21 } 22 </style> 23 <body> 24 <b>The images of the composited <img> elements should be rotated respecting their EXIF orientation.</b> 25 <br> 26 <br> 27 <div class="container"> 28 <div class="horizontal"> 29 <img id="img1" src="resources/exif-orientation-1-ul.jpg"> 30 </div> 31 <br>Normal 32 </div> 33 <div class="container"> 34 <div class="horizontal"> 35 <img id="img2" src="resources/exif-orientation-2-ur.jpg"> 36 </div> 37 <br>Flipped horizontally 38 </div> 39 <div class="container"> 40 <div class="horizontal"> 41 <img id="img3" src="resources/exif-orientation-3-lr.jpg"> 42 </div> 43 <br>Rotated 180° 44 </div> 45 <div class="container"> 46 <div class="horizontal"> 47 <img id="img4" src="resources/exif-orientation-4-lol.jpg"> 48 </div> 49 <br>Flipped vertically 50 </div> 51 <br> 52 <div class="container"> 53 <div class="vertical"> 54 <img id="img5" src="resources/exif-orientation-5-lu.jpg"> 55 </div> 56 <br>Rotated 90° CCW and flipped vertically 57 </div> 58 <div class="container"> 59 <div class="vertical"> 60 <img id="img6" src="resources/exif-orientation-6-ru.jpg"> 61 </div> 62 <br>Rotated 90° CCW 63 </div> 64 <div class="container"> 65 <div class="vertical"> 66 <img id="img7" src="resources/exif-orientation-7-rl.jpg"> 67 </div> 68 <br>Rotated 90° CW and flipped vertically 69 </div> 70 <div class="container"> 71 <div class="vertical"> 72 <img id="img8" src="resources/exif-orientation-8-llo.jpg"> 73 </div> 74 <br>Rotated 90° CW 75 </div> 76 <br> 77 <div class="container"> 78 <div class="horizontal"> 79 <img id="img9" src="resources/exif-orientation-9-u.jpg"> 80 </div> 81 <br>Undefined (invalid value) 82 </div> 83 <br> 84 <ul id="console"></ul> 85 <script> 86 function log(str) { 87 var li = document.createElement("li"); 88 li.appendChild(document.createTextNode(str)); 89 var console = document.getElementById("console"); 90 console.appendChild(li); 91 } 8 92 9 function log(str) { 10 var li = document.createElement("li"); 11 li.appendChild(document.createTextNode(str)); 12 var console = document.getElementById("console"); 13 console.appendChild(li); 14 } 93 function imageSize(el) { 94 var computedStyle = window.getComputedStyle(el); 95 return computedStyle.width + " by " + computedStyle.height; 96 } 15 97 16 function imageSize(el) { 17 var computedStyle = window.getComputedStyle(el); 18 return computedStyle.width + " by " + computedStyle.height; 19 } 20 21 22 function load() { 23 for(var i = 1; i <= 7; i++) 24 log("img" + i + " size = " + imageSize(document.getElementById("img" + i))) 25 } 26 27 </script> 28 <style> 29 img { -webkit-transform: translateZ(0); } 30 div { display: inline-block; margin-right: 20px; margin-bottom: 10px; width: 100px; vertical-align: top; } 31 </style> 32 </head> 33 <body onload="load()"> 34 <b>The images should be rotated respecting their EXIF orientation. This test can only be run with testRunner (or by manually setting WebKitShouldRespectImageOrientation to true).</b><br><br> 35 <div><img id="img1" src="resources/exif-orientation-2-ur.jpg"><br>Flipped horizontally</div> 36 <div><img id="img2" src="resources/exif-orientation-3-lr.jpg"><br>Rotated 180°</div> 37 <div><img id="img3" src="resources/exif-orientation-4-lol.jpg"><br>Flipped vertically</div> 38 <br> 39 <div><img id="img4" src="resources/exif-orientation-5-lu.jpg"><br>Rotated 90° CCW and flipped vertically</div> 40 <div><img id="img5" src="resources/exif-orientation-6-ru.jpg"><br>Rotated 90° CCW</div> 41 <div><img id="img6" src="resources/exif-orientation-7-rl.jpg"><br>Rotated 90° CW and flipped vertically </div> 42 <div><img id="img7" src="resources/exif-orientation-8-llo.jpg"><br>Rotated 90° CW</div> 43 <br> 44 <ul id="console"></ul> 98 window.addEventListener('load', (event) => { 99 for(var i = 1; i <= 9; i++) 100 log("img" + i + " size = " + imageSize(document.getElementById("img" + i))); 101 }); 102 </script> 45 103 </body> 46 </html> -
trunk/LayoutTests/fast/images/exif-orientation-image-document.html
r191652 r249364 1 <html> 2 <head> 3 <script> 4 if (window.testRunner) { 5 // Note that this test only passes in DRT. In browsers, the cross-iframe dom inspection usually causes a security exception. 6 testRunner.dumpAsText(true); 7 } 1 <!DOCTYPE html> 2 <style> 3 div.container { 4 display: inline-block; 5 margin-right: 20px; 6 margin-bottom: 10px; 7 width: 100px; 8 vertical-align: top; 9 } 10 div.horizontal { 11 width: 102; 12 height: 52px; 13 } 14 div.vertical { 15 width: 52px; 16 height: 102px; 17 } 18 iframe { 19 border: 1px solid black; 20 } 21 iframe.horizontal { 22 width: 100px; 23 height: 50px; 24 } 25 iframe.vertical { 26 width: 50px; 27 height: 100px; 28 } 29 </style> 30 <body> 31 <b>The images of the ImageDocuments should be rotated respecting their EXIF orientation.</b> 32 <br> 33 <br> 34 <div class="container"> 35 <div class="horizontal"> 36 <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-1-ul.jpg"></iframe> 37 </div> 38 <br>Normal 39 </div> 40 <div class="container"> 41 <div class="horizontal"> 42 <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-2-ur.jpg"></iframe> 43 </div> 44 <br>Flipped horizontally 45 </div> 46 <div class="container"> 47 <div class="horizontal"> 48 <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-3-lr.jpg"></iframe> 49 </div> 50 <br>Rotated 180° 51 </div> 52 <div class="container"> 53 <div class="horizontal"> 54 <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-4-lol.jpg"></iframe> 55 </div> 56 <br>Flipped vertically 57 </div> 58 <br> 59 <div class="container"> 60 <div class="vertical"> 61 <iframe class="vertical" onload="onFrameLoad(this)" src="resources/exif-orientation-5-lu.jpg"></iframe> 62 </div> 63 <br>Rotated 90° CCW and flipped vertically 64 </div> 65 <div class="container"> 66 <div class="vertical"> 67 <iframe class="vertical" onload="onFrameLoad(this)" src="resources/exif-orientation-6-ru.jpg"></iframe> 68 </div> 69 <br>Rotated 90° CCW 70 </div> 71 <div class="container"> 72 <div class="vertical"> 73 <iframe class="vertical" onload="onFrameLoad(this)" src="resources/exif-orientation-7-rl.jpg"></iframe> 74 </div> 75 <br>Rotated 90° CW and flipped vertically 76 </div> 77 <div class="container"> 78 <div class="vertical"> 79 <iframe class="vertical" onload="onFrameLoad(this)" src="resources/exif-orientation-8-llo.jpg"></iframe> 80 </div> 81 <br>Rotated 90° CW 82 </div> 83 <br> 84 <div class="container"> 85 <div class="horizontal"> 86 <iframe class="horizontal" onload="onFrameLoad(this)" src="resources/exif-orientation-9-u.jpg"></iframe> 87 </div> 88 <br>Undefined (invalid value) 89 </div> 90 <script> 91 if (window.testRunner) 92 window.testRunner.waitUntilDone(); 8 93 9 function log(str) { 10 var li = document.createElement("li"); 11 li.appendChild(document.createTextNode(str)); 12 var console = document.getElementById("console"); 13 console.appendChild(li); 14 } 94 var iFrameLoadedCount = 0; 15 95 16 function imageSize(name) { 17 var img = window.frames[name].document.querySelector('img'); 18 return [img.offsetWidth, img.offsetHeight]; 19 } 20 21 22 function load() { 23 var expected = [ 24 [100, 50], [100, 50], [100, 50], [100, 50], 25 [50, 100], [50, 100], [50, 100], [50, 100], 26 [100, 50], 27 ]; 28 var success = true; 29 for(var i = 1; i <= 9; i++) { 30 var s = imageSize("img" + i); 31 if (s[0] !== expected[i - 1][0] || s[1] !== expected[i - 1][1]) 32 success = false; 33 } 34 log(success ? "PASS" : "FAIL"); 35 } 36 37 </script> 38 <style> 39 iframe { display: inline-block; margin-right: 20px; margin-bottom: 10px; width: 120px; height: 110px; vertical-align: top; border: 1px solid black; } 40 </style> 41 </head> 42 <body onload="load()"> 43 <b>The images should be rotated respecting their EXIF orientation. In image documents, this happens independent of WebKitShouldRespectImageOrientation.</b><br><br> 44 <iframe name="img1" src="resources/exif-orientation-1-ul.jpg" frameborder=0></iframe> 45 <iframe name="img2" src="resources/exif-orientation-2-ur.jpg" frameborder=0></iframe> 46 <iframe name="img3" src="resources/exif-orientation-3-lr.jpg" frameborder=0></iframe> 47 <iframe name="img4" src="resources/exif-orientation-4-lol.jpg" frameborder=0></iframe> 48 <br> 49 <iframe name="img5" src="resources/exif-orientation-5-lu.jpg" frameborder=0></iframe> 50 <iframe name="img6" src="resources/exif-orientation-6-ru.jpg" frameborder=0></iframe> 51 <iframe name="img7" src="resources/exif-orientation-7-rl.jpg" frameborder=0></iframe> 52 <iframe name="img8" src="resources/exif-orientation-8-llo.jpg" frameborder=0></iframe> 53 <br> 54 <iframe name="img9" src="resources/exif-orientation-9-u.jpg" frameborder=0></iframe> 55 <br> 56 <ul id="console"></ul> 96 function onFrameLoad() { 97 if (++iFrameLoadedCount == 9) { 98 if (window.testRunner) 99 window.testRunner.notifyDone(); 100 } 101 } 102 </script> 57 103 </body> 58 </html>59 -
trunk/LayoutTests/platform/gtk/TestExpectations
r249325 r249364 2945 2945 webkit.org/b/120839 legacy-animation-engine/animations/cross-fade-background-image.html [ ImageOnlyFailure ] 2946 2946 2947 webkit.org/b/121905 fast/images/exif-orientation.html [ Failure ]2948 2949 2947 webkit.org/b/180581 css3/shapes/shape-outside/values/shape-margin-001.html [ Failure ] 2950 2948 webkit.org/b/180581 css3/shapes/shape-outside/values/shape-outside-circle-004.html [ Failure ] -
trunk/LayoutTests/platform/win/TestExpectations
r249101 r249364 2812 2812 2813 2813 fast/images/image-controls-basic.html [ Failure ] 2814 fast/images/exif-orientation-composited.html [ Failure ]2815 2814 webkit.org/b/140516 [ Debug ] fast/images/large-size-image-crash.html [ Skip ] # Crashing 2816 2815 fast/images/pdf-as-image-with-annotations.html [ ImageOnlyFailure ] 2817 2816 fast/images/support-broken-image-delegate.html [ Failure ] 2818 fast/images/exif-orientation.html [ Failure ]2819 2817 2820 2818 fast/inline/positionedLifetime.html [ Failure ] -
trunk/Source/WebCore/ChangeLog
r249361 r249364 1 2019-08-31 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 EXIF orientation should be respected when rendering images 4 https://bugs.webkit.org/show_bug.cgi?id=201123 5 6 Reviewed by Simon Fraser. 7 8 -- Image::size() will return the rendered size based on the image 9 orientation. If image orientation is FromImage, ImageSource will query 10 the actual image orientation from the ImageDecoder. The low level APIs 11 might transpose the size just before calling the system API to draw 12 the image. 13 14 -- RenderElement::imageOrientation() will return ImageOrientation::FromImage 15 for all images and for all ports till the CSS image-orientation specs 16 is finalized. 17 18 -- The default of ImagePaintingOptions argument of GraphicsContext::drawImage() 19 will be changed to { ImageOrientation::FromImage }. 20 21 -- Image element: RenderImage::paintIntoRect() will pass imageOrientation() 22 which returns ImageOrientation::FromImage to GraphicsContext::drawImage(). 23 24 -- CSS background image: RenderBoxModelObject::paintFillLayerExtended will 25 pass ImageOrientation::FromImage by default to GraphicsContext::drawTiledImage(). 26 27 -- Images on canvas: CanvasRenderingContext2DBase::drawImage() will pass 28 ImageOrientation::FromImage by default to GraphicsContext::drawImage(). 29 30 -- SVG images: RenderSVGImage::paintForeground() calls GraphicsContext::drawImage() 31 with the default ImagePaintingOptions which is now { ImageOrientation::FromImage }. 32 33 -- SVG feImage filters: FEImage::platformApplySoftware() calls 34 GraphicsContext::drawImage() with the default ImagePaintingOptions 35 which is now { ImageOrientation::FromImage }. 36 37 -- ImageDocument: RenderElement::imageOrientation() returns FromImage 38 always and for all ports. 39 40 Tests: fast/images/exif-orientation-background.html 41 fast/images/exif-orientation-canvas.html 42 fast/images/exif-orientation-content.html 43 fast/images/exif-orientation-element-object-fit.html 44 fast/images/exif-orientation-element.html 45 fast/images/exif-orientation-image-object.html 46 fast/images/exif-orientation-svg-feimage.html 47 fast/images/exif-orientation-svg-image.html 48 49 * html/canvas/CanvasRenderingContext2DBase.cpp: 50 (WebCore::CanvasRenderingContext2DBase::drawImage): 51 * loader/cache/CachedImage.cpp: 52 (WebCore::CachedImage::imageSizeForRenderer const): 53 * platform/graphics/BitmapImage.h: 54 * platform/graphics/CrossfadeGeneratedImage.h: 55 * platform/graphics/GeneratedImage.h: 56 * platform/graphics/GraphicsContext.h: 57 (WebCore::GraphicsContext::drawImage): 58 * platform/graphics/Image.h: 59 * platform/graphics/ImageFrame.h: 60 (WebCore::ImageFrame::sizeRespectingOrientation const): Deleted. 61 * platform/graphics/ImageSource.cpp: 62 (WebCore::ImageSource::ImageSource): 63 (WebCore::ImageSource::orientation): 64 (WebCore::ImageSource::size): 65 (WebCore::ImageSource::sizeRespectingOrientation): Deleted. 66 * platform/graphics/ImageSource.h: 67 * platform/graphics/cg/PDFDocumentImage.cpp: 68 (WebCore::PDFDocumentImage::size const): 69 * platform/graphics/cg/PDFDocumentImage.h: 70 * platform/mac/DragImageMac.mm: 71 (WebCore::createDragImageFromImage): 72 * rendering/RenderBoxModelObject.cpp: 73 (WebCore::RenderBoxModelObject::paintFillLayerExtended): 74 * rendering/RenderElement.cpp: 75 (WebCore::RenderElement::imageOrientation const): 76 * rendering/RenderImage.cpp: 77 (WebCore::RenderImage::paintIntoRect): 78 * svg/graphics/SVGImage.h: 79 * svg/graphics/SVGImageForContainer.cpp: 80 (WebCore::SVGImageForContainer::size const): 81 * svg/graphics/SVGImageForContainer.h: 82 1 83 2019-08-31 Rob Buis <rbuis@igalia.com> 2 84 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
r249217 r249364 1579 1579 } 1580 1580 1581 ImagePaintingOptions options = { op, blendMode, ImageOrientation::FromImage }; 1582 1581 1583 if (rectContainsCanvas(normalizedDstRect)) { 1582 c->drawImage(*image, normalizedDstRect, normalizedSrcRect, { op, blendMode });1584 c->drawImage(*image, normalizedDstRect, normalizedSrcRect, options); 1583 1585 didDrawEntireCanvas(); 1584 1586 } else if (isFullCanvasCompositeMode(op)) { … … 1587 1589 } else if (op == CompositeCopy) { 1588 1590 clearCanvas(); 1589 c->drawImage(*image, normalizedDstRect, normalizedSrcRect, { op, blendMode });1591 c->drawImage(*image, normalizedDstRect, normalizedSrcRect, options); 1590 1592 didDrawEntireCanvas(); 1591 1593 } else { 1592 c->drawImage(*image, normalizedDstRect, normalizedSrcRect, { op, blendMode });1594 c->drawImage(*image, normalizedDstRect, normalizedSrcRect, options); 1593 1595 didDraw(normalizedDstRect); 1594 1596 } -
trunk/Source/WebCore/loader/cache/CachedImage.cpp
r248846 r249364 281 281 return { }; 282 282 283 if (is<BitmapImage>(*m_image) && renderer && renderer->imageOrientation() == ImageOrientation::FromImage)284 return downcast<BitmapImage>(*m_image).sizeRespectingOrientation();285 286 283 if (is<SVGImage>(*m_image) && sizeType == UsedSize) 287 284 return m_svgImageCache->imageSizeForRenderer(renderer); 288 285 289 return m_image->size( );286 return m_image->size(renderer ? renderer->imageOrientation() : ImageOrientation(ImageOrientation::FromImage)); 290 287 } 291 288 -
trunk/Source/WebCore/platform/graphics/BitmapImage.h
r249217 r249364 82 82 83 83 // FloatSize due to override. 84 FloatSize size() const override { return m_source->size(); } 85 IntSize sizeRespectingOrientation() const { return m_source->sizeRespectingOrientation(); } 84 FloatSize size(ImageOrientation orientation = ImageOrientation::FromImage) const override { return m_source->size(orientation); } 86 85 Color singlePixelSolidColor() const override { return m_source->singlePixelSolidColor(); } 87 86 bool frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(size_t index, const DecodingOptions& decodingOptions) const { return m_source->frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(index, decodingOptions); } -
trunk/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h
r249217 r249364 45 45 bool hasRelativeHeight() const override { return false; } 46 46 47 FloatSize size( ) const override { return m_crossfadeSize; }47 FloatSize size(ImageOrientation = ImageOrientation::FromImage) const override { return m_crossfadeSize; } 48 48 49 49 protected: -
trunk/Source/WebCore/platform/graphics/GeneratedImage.h
r249217 r249364 41 41 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override; 42 42 43 FloatSize size( ) const override { return m_size; }43 FloatSize size(ImageOrientation = ImageOrientation::FromImage) const override { return m_size; } 44 44 45 45 // Assume that generated content has no decoded data we need to worry about -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r249217 r249364 360 360 WEBCORE_EXPORT void strokeRect(const FloatRect&, float lineWidth); 361 361 362 WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatPoint& destination, const ImagePaintingOptions& = { });363 WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatRect& destination, const ImagePaintingOptions& = { });364 ImageDrawResult drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { });362 WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatPoint& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage }); 363 WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatRect& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage }); 364 ImageDrawResult drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { ImageOrientation::FromImage }); 365 365 366 366 ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& = { }); -
trunk/Source/WebCore/platform/graphics/Image.h
r249217 r249364 112 112 virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio); 113 113 114 virtual FloatSize size( ) const = 0;114 virtual FloatSize size(ImageOrientation = ImageOrientation::FromImage) const = 0; 115 115 FloatRect rect() const { return FloatRect(FloatPoint(), size()); } 116 116 float width() const { return size().width(); } -
trunk/Source/WebCore/platform/graphics/ImageFrame.h
r248657 r249364 62 62 63 63 IntSize size() const; 64 IntSize sizeRespectingOrientation() const { return !m_orientation.usesWidthAsHeight() ? size() : size().transposedSize(); }65 64 unsigned frameBytes() const { return hasNativeImage() ? (size().area() * sizeof(uint32_t)).unsafeGet() : 0; } 66 65 SubsamplingLevel subsamplingLevel() const { return m_subsamplingLevel; } -
trunk/Source/WebCore/platform/graphics/ImageSource.cpp
r248703 r249364 64 64 m_decodedSize = m_frames[0].frameBytes(); 65 65 66 // The assumption is the memory image will be displayed with the default67 // orientation. So set m_sizeRespectingOrientation to be the same as m_size.68 66 m_size = m_frames[0].size(); 69 m_ sizeRespectingOrientation = m_size;67 m_orientation = ImageOrientation(ImageOrientation::None); 70 68 } 71 69 … … 560 558 } 561 559 562 IntSize ImageSource::size() 563 { 560 ImageOrientation ImageSource::orientation() 561 { 562 return frameMetadataAtIndexCacheIfNeeded<ImageOrientation>(0, (&ImageFrame::orientation), &m_orientation, ImageFrame::Caching::Metadata); 563 } 564 565 IntSize ImageSource::size(ImageOrientation orientation) 566 { 567 IntSize size; 564 568 #if !USE(CG) 565 569 // It's possible that we have decoded the metadata, but not frame contents yet. In that case ImageDecoder claims to 566 570 // have the size available, but the frame cache is empty. Return the decoder size without caching in such case. 567 571 if (m_frames.isEmpty() && isDecoderAvailable()) 568 return m_decoder->size(); 572 size = m_decoder->size(); 573 else 569 574 #endif 570 returnframeMetadataAtIndexCacheIfNeeded<IntSize>(0, (&ImageFrame::size), &m_size, ImageFrame::Caching::Metadata, SubsamplingLevel::Default);571 } 572 573 IntSize ImageSource::sizeRespectingOrientation() 574 { 575 return frameMetadataAtIndexCacheIfNeeded<IntSize>(0, (&ImageFrame::sizeRespectingOrientation), &m_sizeRespectingOrientation, ImageFrame::Caching::Metadata, SubsamplingLevel::Default);575 size = frameMetadataAtIndexCacheIfNeeded<IntSize>(0, (&ImageFrame::size), &m_size, ImageFrame::Caching::Metadata, SubsamplingLevel::Default); 576 577 if (orientation == ImageOrientation::FromImage) 578 orientation = this->orientation(); 579 580 return orientation.usesWidthAsHeight() ? size.transposedSize() : size; 576 581 } 577 582 -
trunk/Source/WebCore/platform/graphics/ImageSource.h
r248703 r249364 94 94 String filenameExtension(); 95 95 Optional<IntPoint> hotSpot(); 96 ImageOrientation orientation(); 96 97 97 98 // Image metadata which is calculated from the first ImageFrame. 98 WEBCORE_EXPORT IntSize size( );99 WEBCORE_EXPORT IntSize size(ImageOrientation = ImageOrientation::FromImage); 99 100 IntSize sizeRespectingOrientation(); 100 101 Color singlePixelSolidColor(); … … 197 198 // Image metadata which is calculated from the first ImageFrame. 198 199 Optional<IntSize> m_size; 199 Optional<I ntSize> m_sizeRespectingOrientation;200 Optional<ImageOrientation> m_orientation; 200 201 Optional<Color> m_singlePixelSolidColor; 201 202 Optional<SubsamplingLevel> m_maximumSubsamplingLevel; -
trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
r249217 r249364 67 67 } 68 68 69 FloatSize PDFDocumentImage::size( ) const69 FloatSize PDFDocumentImage::size(ImageOrientation) const 70 70 { 71 71 FloatSize expandedCropBoxSize = FloatSize(expandedIntSize(m_cropBox.size())); -
trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h
r249217 r249364 77 77 78 78 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override; 79 FloatSize size( ) const override;79 FloatSize size(ImageOrientation = ImageOrientation::FromImage) const override; 80 80 81 81 ImageDrawResult draw(GraphicsContext&, const FloatRect& dstRect, const FloatRect& srcRect, const ImagePaintingOptions& = { }) override; -
trunk/Source/WebCore/platform/mac/DragImageMac.mm
r248697 r249364 95 95 RetainPtr<NSImage> createDragImageFromImage(Image* image, ImageOrientation orientation) 96 96 { 97 FloatSize size = image->size();98 99 97 if (is<BitmapImage>(*image)) { 100 98 BitmapImage& bitmapImage = downcast<BitmapImage>(*image); 101 IntSize sizeRespectingOrientation = bitmapImage.sizeRespectingOrientation();102 99 103 100 if (orientation == ImageOrientation::FromImage) … … 106 103 if (orientation != ImageOrientation::None) { 107 104 // Construct a correctly-rotated copy of the image to use as the drag image. 108 FloatRect destRect(FloatPoint(), sizeRespectingOrientation); 109 110 RetainPtr<NSImage> rotatedDragImage = adoptNS([[NSImage alloc] initWithSize:(NSSize)(sizeRespectingOrientation)]); 105 FloatSize imageSize = image->size(orientation); 106 RetainPtr<NSImage> rotatedDragImage = adoptNS([[NSImage alloc] initWithSize:(NSSize)(imageSize)]); 111 107 [rotatedDragImage lockFocus]; 112 108 113 109 // ImageOrientation uses top-left coordinates, need to flip to bottom-left, apply... 114 CGAffineTransform transform = CGAffineTransformMakeTranslation(0, destRect.height());110 CGAffineTransform transform = CGAffineTransformMakeTranslation(0, imageSize.height()); 115 111 transform = CGAffineTransformScale(transform, 1, -1); 116 transform = CGAffineTransformConcat(orientation.transformFromDefault( sizeRespectingOrientation), transform);112 transform = CGAffineTransformConcat(orientation.transformFromDefault(imageSize), transform); 117 113 118 114 if (orientation.usesWidthAsHeight()) 119 destRect = FloatRect(destRect.x(), destRect.y(), destRect.height(), destRect.width());115 imageSize = imageSize.transposedSize(); 120 116 121 117 // ...and flip back. 122 transform = CGAffineTransformTranslate(transform, 0, destRect.height());118 transform = CGAffineTransformTranslate(transform, 0, imageSize.height()); 123 119 transform = CGAffineTransformScale(transform, 1, -1); 124 120 … … 127 123 [cocoaTransform concat]; 128 124 129 [image->snapshotNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositingOperationSourceOver fraction:1.0]; 125 FloatRect imageRect(FloatPoint(), imageSize); 126 [image->snapshotNSImage() drawInRect:imageRect fromRect:imageRect operation:NSCompositingOperationSourceOver fraction:1.0]; 130 127 131 128 [rotatedDragImage unlockFocus]; … … 135 132 } 136 133 134 FloatSize imageSize = image->size(); 137 135 auto dragImage = image->snapshotNSImage(); 138 [dragImage setSize:(NSSize) size];136 [dragImage setSize:(NSSize)imageSize]; 139 137 return dragImage; 140 138 } -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r249217 r249364 948 948 RefPtr<Image> image; 949 949 if (!geometry.destRect().isEmpty() && (image = bgImage->image(backgroundObject ? backgroundObject : this, geometry.tileSize()))) { 950 auto compositeOp = op == CompositeSourceOver ? bgLayer.composite() : op;951 950 context.setDrawLuminanceMask(bgLayer.maskSourceType() == MaskSourceType::Luminance); 952 951 … … 954 953 downcast<BitmapImage>(*image).updateFromSettings(settings()); 955 954 956 auto interpolation = chooseInterpolationQuality(context, *image, &bgLayer, geometry.tileSize()); 957 auto decodingMode = decodingModeForImageDraw(*image, paintInfo); 958 auto drawResult = context.drawTiledImage(*image, geometry.destRect(), toLayoutPoint(geometry.relativePhase()), geometry.tileSize(), geometry.spaceSize(), { compositeOp, bgLayer.blendMode(), decodingMode, interpolation }); 955 ImagePaintingOptions options = { 956 op == CompositeSourceOver ? bgLayer.composite() : op, 957 bgLayer.blendMode(), 958 decodingModeForImageDraw(*image, paintInfo), 959 ImageOrientation::FromImage, 960 chooseInterpolationQuality(context, *image, &bgLayer, geometry.tileSize()) 961 }; 962 963 auto drawResult = context.drawTiledImage(*image, geometry.destRect(), toLayoutPoint(geometry.relativePhase()), geometry.tileSize(), geometry.spaceSize(), options); 959 964 if (drawResult == ImageDrawResult::DidRequestDecoding) { 960 965 ASSERT(bgImage->isCachedImage()); -
trunk/Source/WebCore/rendering/RenderElement.cpp
r249309 r249364 2054 2054 ImageOrientation RenderElement::imageOrientation() const 2055 2055 { 2056 #if USE(CG) || USE(CAIRO) || USE(DIRECT2D) 2057 // This can only be enabled for ports which honor the orientation flag in their drawing code. 2058 if (document().isImageDocument()) 2059 return ImageOrientation::FromImage; 2060 #endif 2061 // Respect the image's orientation if it's being used as a full-page image or it's 2062 // an <img> and the setting to respect it everywhere is set. 2063 if (settings().shouldRespectImageOrientation() && is<HTMLImageElement>(element())) 2064 return ImageOrientation::FromImage; 2065 return style().imageOrientation(); 2056 return ImageOrientation::FromImage; 2066 2057 } 2067 2058 -
trunk/Source/WebCore/rendering/RenderImage.cpp
r249217 r249364 618 618 619 619 HTMLImageElement* imageElement = is<HTMLImageElement>(element()) ? downcast<HTMLImageElement>(element()) : nullptr; 620 CompositeOperator compositeOperator = imageElement ? imageElement->compositeOperator() : CompositeSourceOver;621 620 622 621 // FIXME: Document when image != img.get(). 623 622 Image* image = imageResource().image().get(); 624 InterpolationQuality interpolation = image ? chooseInterpolationQuality(paintInfo.context(), *image, image, LayoutSize(rect.size())) : InterpolationDefault;625 623 626 624 #if USE(CG) … … 632 630 downcast<BitmapImage>(*image).updateFromSettings(settings()); 633 631 634 auto decodingMode = decodingModeForImageDraw(*image, paintInfo); 635 auto drawResult = paintInfo.context().drawImage(*img, rect, { compositeOperator, BlendMode::Normal, decodingMode, imageOrientation(), interpolation }); 632 ImagePaintingOptions options = { 633 imageElement ? imageElement->compositeOperator() : CompositeSourceOver, 634 decodingModeForImageDraw(*image, paintInfo), 635 imageOrientation(), 636 image ? chooseInterpolationQuality(paintInfo.context(), *image, image, LayoutSize(rect.size())) : InterpolationDefault 637 }; 638 639 auto drawResult = paintInfo.context().drawImage(*img, rect, options); 636 640 if (drawResult == ImageDrawResult::DidRequestDecoding) 637 641 imageResource().cachedImage()->addClientWaitingForAsyncDecoding(*this); -
trunk/Source/WebCore/svg/graphics/SVGImage.h
r249217 r249364 49 49 50 50 bool isSVGImage() const final { return true; } 51 FloatSize size( ) const final { return m_intrinsicSize; }51 FloatSize size(ImageOrientation = ImageOrientation::FromImage) const final { return m_intrinsicSize; } 52 52 53 53 bool hasSingleSecurityOrigin() const final; -
trunk/Source/WebCore/svg/graphics/SVGImageForContainer.cpp
r249217 r249364 28 28 namespace WebCore { 29 29 30 FloatSize SVGImageForContainer::size( ) const30 FloatSize SVGImageForContainer::size(ImageOrientation) const 31 31 { 32 32 FloatSize scaledContainerSize(m_containerSize); -
trunk/Source/WebCore/svg/graphics/SVGImageForContainer.h
r249217 r249364 44 44 bool isSVGImage() const final { return true; } 45 45 46 FloatSize size( ) const final;46 FloatSize size(ImageOrientation = ImageOrientation::FromImage) const final; 47 47 48 48 bool usesContainerSize() const final { return m_image->usesContainerSize(); }
Note: See TracChangeset
for help on using the changeset viewer.