Changeset 272549 in webkit
- Timestamp:
- Feb 8, 2021 2:23:12 PM (18 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/blink/svg/canvas/canvas-draw-pattern-size-expected.html (modified) (1 diff)
-
LayoutTests/imported/blink/svg/canvas/canvas-draw-pattern-size.html (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/svg/graphics/SVGImage.cpp (modified) (1 diff)
-
Source/WebCore/svg/graphics/SVGImage.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r272548 r272549 1 2021-02-08 Said Abou-Hallawa <said@apple.com> 2 3 A Pattern with an SVG image is not rendered correctly 4 https://bugs.webkit.org/show_bug.cgi?id=221550 5 6 Reviewed by Simon Fraser. 7 8 * imported/blink/svg/canvas/canvas-draw-pattern-size-expected.html: 9 Change the expected result to not use the pattern in its drawing. 10 11 * imported/blink/svg/canvas/canvas-draw-pattern-size.html: 12 Use a rectangle instead of a circle to avoid differences with the expected 13 result due to the edge smoothing. 14 1 15 2021-02-08 Jonathan Bedard <jbedard@apple.com> 2 16 -
trunk/LayoutTests/imported/blink/svg/canvas/canvas-draw-pattern-size-expected.html
r190629 r272549 2 2 <html> 3 3 <head> 4 <script>5 function runTest() {6 var context = document.getElementsByTagName('canvas')[0].getContext('2d');7 var forceLayout = document.body.offsetWidth;8 9 var domImage = document.getElementsByTagName('img')[0];10 context.drawImage(domImage, 10, 10, 80, 80);11 12 var newImage = new Image();13 newImage.src = domImage.src;14 context.fillStyle = context.createPattern(newImage, 'repeat');15 context.fillRect(10, 10, 180, 80);16 17 domImage.parentNode.removeChild(domImage);18 }19 </script>20 4 </head> 21 <body onload='runTest()'>5 <body> 22 6 Test for crbug.com/227481: This test passes if there is a green rectangle with a two blue circles.<br/> 23 <canvas width="200px" height="100px"></canvas> 24 <img style="width: 50px;" src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><rect width='100' height='100' fill='green' /><circle cx='30' cy='30' r='15' fill='blue'/></svg>" > 7 <img style="width: 200px; height: 100px;" src="data:image/svg+xml, 8 <svg xmlns='http://www.w3.org/2000/svg' width='200' height='100'> 9 <rect x='10' y='10' width='180' height='80' fill='green'/> 10 <rect x='15' y='15' width='30' height='30' fill='blue' /> 11 <rect x='115' y='15' width='30' height='30' fill='blue' /> 12 </svg>" > 13 </body> 25 14 </body> 26 15 </html> -
trunk/LayoutTests/imported/blink/svg/canvas/canvas-draw-pattern-size.html
r190629 r272549 2 2 <html> 3 3 <head> 4 <style> 5 canvas { 6 image-rendering: pixelated; 7 } 8 </style> 4 9 <script> 5 10 function runTest() { … … 22 27 Test for crbug.com/227481: This test passes if there is a green rectangle with a two blue circles.<br/> 23 28 <canvas width="200px" height="100px"></canvas> 24 <img style="width: 30px;" src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><rect width='100' height='100' fill='green' /><circle cx='30' cy='30' r='15' fill='blue'/></svg>" > 29 <img style="width: 30px;" src="data:image/svg+xml, 30 <svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'> 31 <rect width='100' height='100' fill='green'/> 32 <rect x='15' y='15' width='30' height='30' fill='blue'/> 33 </svg>" > 25 34 </body> 26 35 </html> -
trunk/Source/WebCore/ChangeLog
r272547 r272549 1 2021-02-08 Said Abou-Hallawa <said@apple.com> 2 3 A Pattern with an SVG image is not rendered correctly 4 https://bugs.webkit.org/show_bug.cgi?id=221550 5 6 Reviewed by Simon Fraser. 7 8 Implement SVGImage::nativeImage() and nativeImageForCurrentFrame() for 9 all platforms. This will make Pattern::createPlatformPattern() creates 10 CGPatternRef with a valid CGImageRef. 11 12 * svg/graphics/SVGImage.cpp: 13 (WebCore::SVGImage::nativeImageForCurrentFrame): 14 (WebCore::SVGImage::nativeImage): 15 * svg/graphics/SVGImage.h: 16 1 17 2021-02-08 Eric Carlson <eric.carlson@apple.com> 2 18 -
trunk/Source/WebCore/svg/graphics/SVGImage.cpp
r272475 r272549 209 209 } 210 210 211 #if USE(CAIRO) 212 // Passes ownership of the native image to the caller so NativeImage needs 213 // to be a smart pointer type. 214 RefPtr<NativeImage> SVGImage::nativeImageForCurrentFrame(const GraphicsContext*) 211 RefPtr<NativeImage> SVGImage::nativeImageForCurrentFrame(const GraphicsContext* targetContext) 212 { 213 return nativeImage(targetContext); 214 } 215 216 RefPtr<NativeImage> SVGImage::nativeImage(const GraphicsContext*) 215 217 { 216 218 if (!m_page) 217 219 return nullptr; 218 220 219 // Cairo does not use the accelerated drawing flag, so it's OK to make an unconditionally unaccelerated buffer. 220 auto buffer = ImageBuffer::create(size(), RenderingMode::Unaccelerated); 221 if (!buffer) // failed to allocate image 221 auto imageBuffer = ImageBuffer::create(size(), RenderingMode::Unaccelerated); 222 if (!imageBuffer) 222 223 return nullptr; 223 224 224 draw(buffer->context(), rect(), rect()); 225 226 // FIXME: WK(Bug 113657): We should use DontCopyBackingStore here. 227 return buffer->copyImage(CopyBackingStore)->nativeImageForCurrentFrame(); 228 } 229 #endif 230 231 #if USE(DIRECT2D) 232 RefPtr<NativeImage> SVGImage::nativeImage(const GraphicsContext* targetContext) 233 { 234 ASSERT(targetContext); 235 if (!m_page || !targetContext) 236 return nullptr; 237 238 ASSERT(targetContext->hasPlatformContext()); 239 auto* renderTarget = targetContext->platformContext()->renderTarget(); 240 241 IntSize bitmapSize(size().width(), size().height()); 242 auto nativeImageTarget = Direct2D::createBitmapRenderTargetOfSize(bitmapSize, renderTarget, 1.0); 243 if (!nativeImageTarget) 244 return nullptr; 245 246 PlatformContextDirect2D platformContext(nativeImageTarget.get()); 247 GraphicsContext localContext(&platformContext, GraphicsContext::BitmapRenderingContextType::GPUMemory); 248 249 draw(localContext, rect(), rect(), { CompositeOperator::SourceOver, BlendMode::Normal, DecodingMode::Synchronous, ImageOrientation::None }); 250 251 COMPtr<ID2D1Bitmap> nativeImage; 252 HRESULT hr = nativeImageTarget->GetBitmap(&nativeImage); 253 if (!SUCCEEDED(hr)) 254 return nullptr; 255 256 #if ASSERT_ENABLED 257 auto nativeImageSize = nativeImage->GetPixelSize(); 258 ASSERT(nativeImageSize.height = rect().size().height()); 259 ASSERT(nativeImageSize.width = rect().size().width()); 260 #endif 261 262 return nativeImage; 263 } 264 #endif 225 ImageObserver* observer = imageObserver(); 226 227 setImageObserver(nullptr); 228 setContainerSize(size()); 229 230 imageBuffer->context().drawImage(*this, FloatPoint(0, 0)); 231 232 setImageObserver(observer); 233 return ImageBuffer::sinkIntoNativeImage(WTFMove(imageBuffer)); 234 } 265 235 266 236 void SVGImage::drawPatternForContainer(GraphicsContext& context, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL, const FloatRect& srcRect, -
trunk/Source/WebCore/svg/graphics/SVGImage.h
r269614 r272549 63 63 void scheduleStartAnimation(); 64 64 65 #if USE(CAIRO)66 RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final;67 #endif68 #if USE(DIRECT2D)69 RefPtr<NativeImage> nativeImage(const GraphicsContext* = nullptr) final;70 #endif71 72 65 Page* internalPage() { return m_page.get(); } 73 66 … … 94 87 bool currentFrameKnownToBeOpaque() const final { return false; } 95 88 89 RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final; 90 RefPtr<NativeImage> nativeImage(const GraphicsContext* = nullptr) final; 91 96 92 void startAnimationTimerFired(); 97 93
Note: See TracChangeset
for help on using the changeset viewer.