- Revision
- 250581
- Author
- bfulg...@apple.com
- Date
- 2019-10-01 14:26:06 -0700 (Tue, 01 Oct 2019)
Log Message
[FTW] Correct additional canvas test failures
https://bugs.webkit.org/show_bug.cgi?id=202388
Reviewed by Fujii Hironori.
This patch corrects a handful of errors in Direct2D's drawing code.
* platform/graphics/win/Direct2DOperations.cpp:
(WebCore::Direct2D::clearRect): Use the transformed dimensions of
rects to determine whether they intersect with the render target.
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::copyRectFromData const):
(WebCore::ImageBufferData::loadDataToBitmapIfNeeded): It is not
necessary (or correct) to 'endDraw' when loading image data to the
Bitmap target.
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::strokeBoundingRect const): Provide an implementation.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (250580 => 250581)
--- trunk/Source/WebCore/ChangeLog 2019-10-01 20:41:32 UTC (rev 250580)
+++ trunk/Source/WebCore/ChangeLog 2019-10-01 21:26:06 UTC (rev 250581)
@@ -1,3 +1,23 @@
+2019-10-01 Brent Fulgham <bfulg...@apple.com>
+
+ [FTW] Correct additional canvas test failures
+ https://bugs.webkit.org/show_bug.cgi?id=202388
+
+ Reviewed by Fujii Hironori.
+
+ This patch corrects a handful of errors in Direct2D's drawing code.
+
+ * platform/graphics/win/Direct2DOperations.cpp:
+ (WebCore::Direct2D::clearRect): Use the transformed dimensions of
+ rects to determine whether they intersect with the render target.
+ * platform/graphics/win/ImageBufferDataDirect2D.cpp:
+ (WebCore::ImageBufferData::copyRectFromData const):
+ (WebCore::ImageBufferData::loadDataToBitmapIfNeeded): It is not
+ necessary (or correct) to 'endDraw' when loading image data to the
+ Bitmap target.
+ * platform/graphics/win/PathDirect2D.cpp:
+ (WebCore::Path::strokeBoundingRect const): Provide an implementation.
+
2019-10-01 Alex Christensen <achristen...@webkit.org>
Progress towards successful CMake build on Mac
Modified: trunk/Source/WebCore/platform/graphics/win/Direct2DOperations.cpp (250580 => 250581)
--- trunk/Source/WebCore/platform/graphics/win/Direct2DOperations.cpp 2019-10-01 20:41:32 UTC (rev 250580)
+++ trunk/Source/WebCore/platform/graphics/win/Direct2DOperations.cpp 2019-10-01 21:26:06 UTC (rev 250581)
@@ -705,8 +705,23 @@
{
drawWithoutShadow(platformContext, [&platformContext, rect](ID2D1RenderTarget* renderTarget) {
FloatRect renderTargetRect(FloatPoint(), renderTarget->GetSize());
+
+ D2D1::Matrix3x2F matrix;
+ renderTarget->GetTransform(&matrix);
+
+ AffineTransform transform(matrix);
+
FloatRect rectToClear(rect);
+ if (!transform.preservesAxisAlignment()) {
+ COMPtr<ID2D1RectangleGeometry> rectangle;
+ HRESULT hr = GraphicsContext::systemFactory()->CreateRectangleGeometry(rectToClear, &rectangle);
+ RELEASE_ASSERT(SUCCEEDED(hr));
+ renderTarget->FillGeometry(rectangle.get(), platformContext.brushWithColor(D2D1::ColorF(0, 0, 0, 0)).get());
+ return;
+ }
+ rectToClear = transform.mapRect(rectToClear);
+
if (rectToClear.contains(renderTargetRect)) {
platformContext.setTags(1, __LINE__);
renderTarget->Clear(D2D1::ColorF(0, 0, 0, 0));
@@ -713,11 +728,6 @@
return;
}
- if (!rectToClear.intersects(renderTargetRect))
- return;
-
- rectToClear.intersect(renderTargetRect);
-
platformContext.setTags(1, __LINE__);
renderTarget->PushAxisAlignedClip(rectToClear, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
renderTarget->Clear(D2D1::ColorF(0, 0, 0, 0));
Modified: trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp (250580 => 250581)
--- trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp 2019-10-01 20:41:32 UTC (rev 250580)
+++ trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp 2019-10-01 21:26:06 UTC (rev 250581)
@@ -169,8 +169,11 @@
IntRect scaledRect = rect;
scaledRect.scale(scaleFactor);
- if (!IntRect(IntPoint(), backingStoreSize).contains(scaledRect))
- return false;
+ if (!IntRect(IntPoint(), backingStoreSize).contains(scaledRect)) {
+ // Requested rect is outside the buffer. Return zero-filled buffer.
+ result->zeroFill();
+ return true;
+ }
return copyRectFromSourceToDest(scaledRect, backingStoreSize, data.data(), rect.size(), result->data(), IntPoint());
}
@@ -453,21 +456,11 @@
else
inPlaceSwizzle<AlphaPremultiplication::Premultiplied>(data.data(), data.size()); // PRGBA -> PBGRA
- // Copy the bits from current renderTarget to the output target.
- // We cannot access the data backing an IWICBitmap or ID2D1Bitmap while an active draw session is open.
- context->endDraw();
-
- COMPtr<ID2D1BitmapRenderTarget> bitmapRenderTarget;
- HRESULT hr = platformContext->renderTarget()->QueryInterface(&bitmapRenderTarget);
- ASSERT(SUCCEEDED(hr));
-
auto bytesPerRowInData = backingStoreSize.width() * 4;
- hr = bitmap->CopyFromMemory(nullptr, data.data(), bytesPerRowInData);
+ HRESULT hr = bitmap->CopyFromMemory(nullptr, data.data(), bytesPerRowInData);
ASSERT(SUCCEEDED(hr));
- context->beginDraw();
-
bitmapBufferSync = BitmapBufferSync::InSync;
}
Modified: trunk/Source/WebCore/platform/graphics/win/PathDirect2D.cpp (250580 => 250581)
--- trunk/Source/WebCore/platform/graphics/win/PathDirect2D.cpp 2019-10-01 20:41:32 UTC (rev 250580)
+++ trunk/Source/WebCore/platform/graphics/win/PathDirect2D.cpp 2019-10-01 21:26:06 UTC (rev 250581)
@@ -348,14 +348,13 @@
if (isNull())
return FloatRect();
- if (!applier)
- return boundingRect();
+ PlatformContextDirect2D scratchContextD2D(scratchRenderTarget());
+ GraphicsContext scratchContext(&scratchContextD2D, GraphicsContext::BitmapRenderingContextType::GPUMemory);
- UNUSED_PARAM(applier);
- notImplemented();
+ if (applier)
+ applier->strokeStyle(&scratchContext);
- // Just return regular bounding rect for now.
- return boundingRect();
+ return fastBoundingRectForStroke(scratchContextD2D);
}
void Path::openFigureAtCurrentPointIfNecessary()