RESOLVED FIXED Bug 202177
[FTW] Correct compositing, shadow, and radial gradient implementations
https://bugs.webkit.org/show_bug.cgi?id=202177
Summary [FTW] Correct compositing, shadow, and radial gradient implementations
Brent Fulgham
Reported 2019-09-24 15:53:01 PDT
This patch corrects a number of errors in the implementations of basic Canvas drawing routines.
Attachments
Patch (18.69 KB, patch)
2019-09-24 16:19 PDT, Brent Fulgham
no flags
Patch (31.74 KB, patch)
2019-09-26 16:25 PDT, Brent Fulgham
no flags
Patch (43.63 KB, patch)
2019-09-28 23:15 PDT, Brent Fulgham
no flags
Patch (43.60 KB, patch)
2019-09-28 23:26 PDT, Brent Fulgham
Hironori.Fujii: review+
Brent Fulgham
Comment 1 2019-09-24 16:19:44 PDT
Brent Fulgham
Comment 2 2019-09-24 16:59:55 PDT
Prior to this change: 629 / 775 Pass With this change: 665 / 775 Pass
Brent Fulgham
Comment 3 2019-09-26 16:25:44 PDT
Fujii Hironori
Comment 4 2019-09-26 20:08:25 PDT
Comment on attachment 379693 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=379693&action=review > Source/WebCore/platform/graphics/win/Direct2DOperations.cpp:41 > +#include "FloatSize.h" You don't need to include FloatSize.h because FloatRect.h includes it indirectly. > Source/WebCore/platform/graphics/win/Direct2DUtilities.cpp:97 > + constexpr double dpiBase = 96.0; 96.0 → 96 https://webkit.org/code-style-guidelines/#float-suffixes > Source/WebCore/platform/graphics/win/PathDirect2D.cpp:346 > FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const How will you implement Path::strokeBoundingRect which is taking StrokeStyleApplier as the argument? > Source/WebCore/platform/graphics/win/PlatformContextDirect2D.cpp:57 > + RELEASE_ASSERT(SUCCEEDED(hr)); Let's use COMPtr method. m_deviceContext.query(m_renderTarget.get()); RELEASE_ASSERT(!!m_deviceContext); > Source/WebCore/platform/graphics/win/PlatformContextDirect2D.cpp:385 > + compositeIfNeeded(); You don't need to call compositeIfNeeded here because endDraw is called above.
Fujii Hironori
Comment 5 2019-09-26 20:11:03 PDT
Comment on attachment 379693 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=379693&action=review > Source/WebCore/platform/graphics/win/Direct2DOperations.cpp:-237 > - platformContext.setCompositeMode(targetCompositeMode); Remove PlatformContextDirect2D::setBlendMode and PlatformContextDirect2D::setCompositeMode which are unused anymore.
Fujii Hironori
Comment 6 2019-09-26 20:31:22 PDT
Comment on attachment 379693 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=379693&action=review > Source/WebCore/platform/graphics/win/Direct2DOperations.h:136 > +void drawWithoutShadow(PlatformContextDirect2D&, const FloatRect& ignored, const WTF::Function<void(ID2D1RenderTarget*)>& drawCommands); I think boundingRect should be removed from drawWithoutShadow's argument. There are a lot of code looks like the following: > if (shadowState.isVisible()) > drawWithShadow(platformContext, rect, shadowState, drawFunction); > else > drawWithoutShadow(platformContext, rect, drawFunction); This condition should be moved into drawWithShadow.
Brent Fulgham
Comment 7 2019-09-27 14:18:48 PDT
Comment on attachment 379693 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=379693&action=review >> Source/WebCore/platform/graphics/win/Direct2DOperations.cpp:41 >> +#include "FloatSize.h" > > You don't need to include FloatSize.h because FloatRect.h includes it indirectly. Fixed. >> Source/WebCore/platform/graphics/win/Direct2DOperations.cpp:-237 >> - platformContext.setCompositeMode(targetCompositeMode); > > Remove PlatformContextDirect2D::setBlendMode and PlatformContextDirect2D::setCompositeMode which are unused anymore. Done. >> Source/WebCore/platform/graphics/win/Direct2DUtilities.cpp:97 >> + constexpr double dpiBase = 96.0; > > 96.0 → 96 > https://webkit.org/code-style-guidelines/#float-suffixes Will do! >> Source/WebCore/platform/graphics/win/PathDirect2D.cpp:346 >> FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const > > How will you implement Path::strokeBoundingRect which is taking StrokeStyleApplier as the argument? Oh gosh -- I didn't even look at this one. Can I do that as a separate patch? >> Source/WebCore/platform/graphics/win/PlatformContextDirect2D.cpp:57 >> + RELEASE_ASSERT(SUCCEEDED(hr)); > > Let's use COMPtr method. > > m_deviceContext.query(m_renderTarget.get()); > RELEASE_ASSERT(!!m_deviceContext); Oh! That's much better. I'll do so here and the 'setRenderTarget' method, too. >> Source/WebCore/platform/graphics/win/PlatformContextDirect2D.cpp:385 >> + compositeIfNeeded(); > > You don't need to call compositeIfNeeded here because endDraw is called above. Good point!
Brent Fulgham
Comment 8 2019-09-27 14:22:07 PDT
(In reply to Fujii Hironori from comment #6) > Comment on attachment 379693 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=379693&action=review > > > Source/WebCore/platform/graphics/win/Direct2DOperations.h:136 > > +void drawWithoutShadow(PlatformContextDirect2D&, const FloatRect& ignored, const WTF::Function<void(ID2D1RenderTarget*)>& drawCommands); > > I think boundingRect should be removed from drawWithoutShadow's argument. Okay. > There are a lot of code looks like the following: > > > if (shadowState.isVisible()) > > drawWithShadow(platformContext, rect, shadowState, drawFunction); > > else > > drawWithoutShadow(platformContext, rect, drawFunction); > > This condition should be moved into drawWithShadow. Sounds good.
Fujii Hironori
Comment 9 2019-09-27 17:43:41 PDT
Comment on attachment 379693 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=379693&action=review >>> Source/WebCore/platform/graphics/win/PathDirect2D.cpp:346 >>> FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const >> >> How will you implement Path::strokeBoundingRect which is taking StrokeStyleApplier as the argument? > > Oh gosh -- I didn't even look at this one. Can I do that as a separate patch? Yup.
Brent Fulgham
Comment 10 2019-09-28 23:15:00 PDT
Brent Fulgham
Comment 11 2019-09-28 23:26:29 PDT
Brent Fulgham
Comment 12 2019-09-28 23:33:23 PDT
With this change: 681 / 775 Pass
Fujii Hironori
Comment 13 2019-09-29 01:10:44 PDT
Comment on attachment 379805 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=379805&action=review > Source/WebCore/platform/graphics/win/Direct2DOperations.cpp:562 > + auto rect = path.fastBoundingRectForStroke(platformContext); This rect is a unused variable. > Source/WebCore/platform/graphics/win/Direct2DUtilities.cpp:494 > + Direct2D::writeDiagnosticPNGToPath(bitmapTarget, currentCanvas.get(), L"C:/Projects/WebKit/data/currentCanvas.png"); I think this debugging code should be removed.
Fujii Hironori
Comment 14 2019-09-29 01:13:53 PDT
Comment on attachment 379805 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=379805&action=review > Source/WebCore/platform/graphics/win/PlatformContextDirect2D.cpp:349 > + Direct2D::writeDiagnosticPNGToPath(bitmapTarget.get(), bitmap.get(), L"C:/Projects/WebKit/data/after.png"); Ditto.
Fujii Hironori
Comment 15 2019-09-29 01:26:34 PDT
Comment on attachment 379805 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=379805&action=review > Source/WebCore/platform/graphics/win/PathDirect2D.cpp:335 > + float tolerance = 10.0; https://webkit.org/code-style-guidelines/#float-suffixes
Brent Fulgham
Comment 16 2019-09-29 12:07:43 PDT
Comment on attachment 379805 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=379805&action=review Thank you for reviewing -- these reviews have been very helpful to me. >> Source/WebCore/platform/graphics/win/Direct2DOperations.cpp:562 >> + auto rect = path.fastBoundingRectForStroke(platformContext); > > This rect is a unused variable. Great catch! That's a potentially expensive operation, so good to avoid if possible. >> Source/WebCore/platform/graphics/win/Direct2DUtilities.cpp:494 >> + Direct2D::writeDiagnosticPNGToPath(bitmapTarget, currentCanvas.get(), L"C:/Projects/WebKit/data/currentCanvas.png"); > > I think this debugging code should be removed. Oh no! How stupid of me. I made this same mistake in several places. I forgot to search and remove before uploading the patch. :-( >> Source/WebCore/platform/graphics/win/PathDirect2D.cpp:335 >> + float tolerance = 10.0; > > https://webkit.org/code-style-guidelines/#float-suffixes Fixed! >> Source/WebCore/platform/graphics/win/PlatformContextDirect2D.cpp:349 >> + Direct2D::writeDiagnosticPNGToPath(bitmapTarget.get(), bitmap.get(), L"C:/Projects/WebKit/data/after.png"); > > Ditto. :-(
Brent Fulgham
Comment 17 2019-09-29 12:33:39 PDT
Radar WebKit Bug Importer
Comment 18 2019-09-29 12:34:20 PDT
Note You need to log in before you can comment on or make changes to this bug.