Diff
Modified: trunk/Source/WebCore/ChangeLog (248906 => 248907)
--- trunk/Source/WebCore/ChangeLog 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebCore/ChangeLog 2019-08-20 17:50:09 UTC (rev 248907)
@@ -1,3 +1,31 @@
+2019-08-20 Brent Fulgham <bfulg...@apple.com>
+
+ [FTW] Fix scrolling in modern WebKit views
+ https://bugs.webkit.org/show_bug.cgi?id=200923
+
+ Reviewed by Don Olmstead.
+
+ The initial implementation of scrolling in Direct2D had errors that
+ caused hilarious rendering glitches. This patch corrects the logic
+ so that page scroll is correct.
+
+ * platform/graphics/win/BackingStoreBackendDirect2D.h:
+ * platform/graphics/win/BackingStoreBackendDirect2DImpl.cpp:
+ (WebCore::BackingStoreBackendDirect2DImpl::scroll):
+ (WebCore::BackingStoreBackendDirect2DImpl::bitmapBrush):
+ * platform/graphics/win/BackingStoreBackendDirect2DImpl.h:
+ * platform/graphics/win/Direct2DOperations.cpp:
+ (WebCore::Direct2D::drawNativeImage):
+ * platform/graphics/win/Direct2DUtilities.cpp:
+ (WebCore::Direct2D::copyRectFromOneSurfaceToAnother):
+ (WebCore::Direct2D::writeImageToDiskAsPNG): Added diagnostic utility to
+ dump textures to disk for review.
+ * platform/graphics/win/Direct2DUtilities.h:
+ * platform/graphics/win/ImageDecoderDirect2D.cpp:
+ (WebCore::ImageDecoderDirect2D::systemImagingFactory): Switch to more
+ recent factory with additional features.
+ * platform/graphics/win/ImageDecoderDirect2D.h:
+
2019-08-20 Saam Barati <sbar...@apple.com>
[WHLSL] Only take the pointer of a variable or global variable reference if it is used
Modified: trunk/Source/WebCore/platform/graphics/win/BackingStoreBackendDirect2D.h (248906 => 248907)
--- trunk/Source/WebCore/platform/graphics/win/BackingStoreBackendDirect2D.h 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebCore/platform/graphics/win/BackingStoreBackendDirect2D.h 2019-08-20 17:50:09 UTC (rev 248907)
@@ -33,6 +33,7 @@
#include <wtf/Noncopyable.h>
interface ID2D1Bitmap;
+interface ID2D1BitmapBrush;
interface ID2D1DCRenderTarget;
namespace WebCore {
@@ -48,6 +49,7 @@
const IntSize& size() const { return m_size; }
virtual void scroll(const IntRect& scrollRect, const IntSize& scrollOffset) = 0;
+ virtual ID2D1BitmapBrush* bitmapBrush() = 0;
protected:
BackingStoreBackendDirect2D(const IntSize& size)
Modified: trunk/Source/WebCore/platform/graphics/win/BackingStoreBackendDirect2DImpl.cpp (248906 => 248907)
--- trunk/Source/WebCore/platform/graphics/win/BackingStoreBackendDirect2DImpl.cpp 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebCore/platform/graphics/win/BackingStoreBackendDirect2DImpl.cpp 2019-08-20 17:50:09 UTC (rev 248907)
@@ -60,27 +60,55 @@
void BackingStoreBackendDirect2DImpl::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
{
- IntRect targetRect = scrollRect;
- targetRect.move(scrollOffset);
- targetRect.shiftMaxXEdgeTo(targetRect.maxX() - scrollOffset.width());
- targetRect.shiftMaxYEdgeTo(targetRect.maxY() - scrollOffset.height());
- if (targetRect.isEmpty())
- return;
+ IntRect sourceRect = scrollRect;
+ sourceRect.move(-scrollOffset);
+ sourceRect.intersect(scrollRect);
- if (!m_scrollSurface) {
- auto floatSize = Direct2D::bitmapSize(m_surface.get());
- IntSize size(floatSize.width(), floatSize.height());
- auto scale = Direct2D::bitmapResolution(m_surface.get());
- ASSERT(scale.x() == scale.y());
- m_scrollSurface = Direct2D::createBitmap(m_renderTarget.get(), size);
+ if (!m_scrollSurface || scrollRect.size() != m_scrollSurfaceSize) {
+#ifndef _NDEBUG
+ ASSERT(m_size.width() >= scrollRect.size().width());
+ ASSERT(m_size.height() >= scrollRect.size().height());
+#endif
+ m_scrollSurfaceSize = sourceRect.size();
+ m_scrollSurface = Direct2D::createBitmap(m_renderTarget.get(), m_scrollSurfaceSize);
}
- Direct2D::copyRectFromOneSurfaceToAnother(m_surface.get(), m_scrollSurface.get(), scrollOffset, targetRect);
- Direct2D::copyRectFromOneSurfaceToAnother(m_scrollSurface.get(), m_surface.get(), IntSize(), targetRect);
+ auto sourceRectLocation = IntSize(sourceRect.x(), sourceRect.y());
+ auto destRectLocation = IntSize(); // Top left corner of scroll surface
+ Direct2D::copyRectFromOneSurfaceToAnother(m_surface.get(), m_scrollSurface.get(), sourceRectLocation, sourceRect, destRectLocation);
+ IntRect destRect = scrollRect;
+ destRect.setHeight(sourceRect.height());
+ destRect.setWidth(sourceRect.width());
+
+ IntSize destPosition;
+ if (scrollOffset.width() > 0 || scrollOffset.height() > 0) {
+ destPosition.setWidth(std::min(scrollRect.width(), scrollOffset.width()));
+ destPosition.setHeight(std::min(scrollRect.height(), scrollOffset.height()));
+ }
+
+ auto sourceScrollSurfaceLocation = IntSize(); // Top left corner of scroll surface
+ Direct2D::copyRectFromOneSurfaceToAnother(m_scrollSurface.get(), m_surface.get(), sourceScrollSurfaceLocation, destRect, destPosition);
+
m_scrolledHysteresis.impulse();
}
+ID2D1BitmapBrush* BackingStoreBackendDirect2DImpl::bitmapBrush()
+{
+ if (!m_renderTarget || !m_surface)
+ return nullptr;
+
+ if (!m_bitmapBrush) {
+ auto bitmapBrushProperties = D2D1::BitmapBrushProperties();
+ auto brushProperties = D2D1::BrushProperties();
+
+ HRESULT hr = m_renderTarget->CreateBitmapBrush(m_surface.get(), &bitmapBrushProperties, &brushProperties, &m_bitmapBrush);
+ ASSERT(SUCCEEDED(hr));
+ }
+
+ return m_bitmapBrush.get();
+}
+
} // namespace WebCore
#endif // USE(DIRECT2D)
Modified: trunk/Source/WebCore/platform/graphics/win/BackingStoreBackendDirect2DImpl.h (248906 => 248907)
--- trunk/Source/WebCore/platform/graphics/win/BackingStoreBackendDirect2DImpl.h 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebCore/platform/graphics/win/BackingStoreBackendDirect2DImpl.h 2019-08-20 17:50:09 UTC (rev 248907)
@@ -30,6 +30,7 @@
#include "BackingStoreBackendDirect2D.h"
#include <pal/HysteresisActivity.h>
+interface ID2D1BitmapBrush;
interface IWICBitmap;
namespace WebCore {
@@ -43,8 +44,11 @@
private:
void scroll(const IntRect&, const IntSize&) override;
+ ID2D1BitmapBrush* bitmapBrush() override;
+ IntSize m_scrollSurfaceSize;
COMPtr<ID2D1Bitmap> m_scrollSurface;
+ COMPtr<ID2D1BitmapBrush> m_bitmapBrush;
PAL::HysteresisActivity m_scrolledHysteresis;
};
Modified: trunk/Source/WebCore/platform/graphics/win/Direct2DOperations.cpp (248906 => 248907)
--- trunk/Source/WebCore/platform/graphics/win/Direct2DOperations.cpp 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebCore/platform/graphics/win/Direct2DOperations.cpp 2019-08-20 17:50:09 UTC (rev 248907)
@@ -42,6 +42,7 @@
#include "GraphicsContextPlatformPrivateDirect2D.h"
#include "Image.h"
#include "ImageBuffer.h"
+#include "ImageDecoderDirect2D.h"
#include "NotImplemented.h"
#include "Path.h"
#include "PlatformContextDirect2D.h"
@@ -764,13 +765,15 @@
}
-void drawNativeImage(PlatformContextDirect2D& platformContext, IWICBitmap* image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator compositeOperator, BlendMode blendMode, ImageOrientation orientation, InterpolationQuality imageInterpolationQuality, float globalAlpha, const ShadowState& shadowState)
+void drawNativeImage(PlatformContextDirect2D& platformContext, IWICBitmap* image, const FloatSize& originalImageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator compositeOperator, BlendMode blendMode, ImageOrientation orientation, InterpolationQuality imageInterpolationQuality, float globalAlpha, const ShadowState& shadowState)
{
+ auto nativeImageSize = bitmapSize(image);
COMPtr<ID2D1Bitmap> deviceBitmap;
HRESULT hr = platformContext.renderTarget()->CreateBitmapFromWicBitmap(image, &deviceBitmap);
if (!SUCCEEDED(hr))
return;
+ auto imageSize = bitmapSize(deviceBitmap.get());
drawNativeImage(platformContext, deviceBitmap.get(), imageSize, destRect, srcRect, compositeOperator, blendMode, orientation, imageInterpolationQuality, globalAlpha, shadowState);
}
@@ -824,8 +827,8 @@
context->SetTags(1, __LINE__);
- Function<void(ID2D1RenderTarget*)> drawFunction = [image, adjustedDestRect, srcRect](ID2D1RenderTarget* renderTarget) {
- renderTarget->DrawBitmap(image, adjustedDestRect, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, static_cast<D2D1_RECT_F>(srcRect));
+ Function<void(ID2D1RenderTarget*)> drawFunction = [image, adjustedDestRect, globalAlpha, srcRect](ID2D1RenderTarget* renderTarget) {
+ renderTarget->DrawBitmap(image, adjustedDestRect, globalAlpha, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, srcRect);
};
if (shadowState.isVisible())
Modified: trunk/Source/WebCore/platform/graphics/win/Direct2DUtilities.cpp (248906 => 248907)
--- trunk/Source/WebCore/platform/graphics/win/Direct2DUtilities.cpp 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebCore/platform/graphics/win/Direct2DUtilities.cpp 2019-08-20 17:50:09 UTC (rev 248907)
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
* Copyright (C) 2010 Igalia S.L.
* Copyright (C) 2011 ProFUSION embedded systems
*
@@ -36,7 +37,8 @@
#include "ImageDecoderDirect2D.h"
#include "IntRect.h"
#include "IntSize.h"
-#include <d2d1.h>
+#include <d2d1_1.h>
+#include <shlwapi.h>
#include <wincodec.h>
@@ -173,12 +175,75 @@
void copyRectFromOneSurfaceToAnother(ID2D1Bitmap* from, ID2D1Bitmap* to, const IntSize& sourceOffset, const IntRect& rect, const IntSize& destOffset)
{
- auto offset = D2D1::Point2U();
- auto sourceRect = D2D1::RectU(sourceOffset.width(), -sourceOffset.height(), rect.width(), rect.height());
- HRESULT hr = to->CopyFromBitmap(&offset, from, &sourceRect);
+ IntSize sourceBitmapSize = from->GetPixelSize();
+ if (sourceBitmapSize.isZero())
+ return;
+
+ IntSize targetBitmapSize = to->GetPixelSize();
+ if (targetBitmapSize.isZero())
+ return;
+
+ IntRect sourceRect(sourceOffset.width(), sourceOffset.height(), rect.width(), rect.height());
+ IntRect targetRect(destOffset.width(), destOffset.height(), rect.width(), rect.height());
+
+ IntRect sourceBitmapRect(IntPoint(), sourceBitmapSize);
+ IntRect targetBitmapRect(IntPoint(), targetBitmapSize);
+
+ sourceRect.intersect(sourceBitmapRect);
+ targetRect.intersect(targetBitmapRect);
+
+ D2D1_RECT_U d2dSourceRect = D2D1::RectU(sourceRect.x(), sourceRect.y(), sourceRect.x() + targetRect.width(), sourceRect.y() + targetRect.height());
+ auto offset = D2D1::Point2U(destOffset.width(), destOffset.height());
+
+ HRESULT hr = to->CopyFromBitmap(&offset, from, &d2dSourceRect);
ASSERT(SUCCEEDED(hr));
}
+void writeImageToDiskAsPNG(ID2D1RenderTarget* renderTarget, ID2D1Bitmap* bitmap, LPCWSTR fileName)
+{
+ COMPtr<IWICBitmapEncoder> wicBitmapEncoder;
+ HRESULT hr = ImageDecoderDirect2D::systemImagingFactory()->CreateEncoder(GUID_ContainerFormatPng, nullptr, &wicBitmapEncoder);
+ ASSERT(SUCCEEDED(hr));
+
+ DWORD mode = STGM_CREATE | STGM_READWRITE | STGM_SHARE_DENY_WRITE;
+ COMPtr<IStream> stream;
+ hr = ::SHCreateStreamOnFileEx(fileName, mode, FILE_ATTRIBUTE_NORMAL, TRUE, nullptr, &stream);
+ ASSERT(SUCCEEDED(hr));
+
+ hr = wicBitmapEncoder->Initialize(stream.get(), WICBitmapEncoderNoCache);
+ ASSERT(SUCCEEDED(hr));
+
+ COMPtr<IWICBitmapFrameEncode> wicFrameEncode;
+ hr = wicBitmapEncoder->CreateNewFrame(&wicFrameEncode, nullptr);
+ ASSERT(SUCCEEDED(hr));
+
+ hr = wicFrameEncode->Initialize(nullptr);
+ ASSERT(SUCCEEDED(hr));
+
+ COMPtr<ID2D1DeviceContext> d2dDeviceContext;
+ hr = renderTarget->QueryInterface(__uuidof(ID2D1DeviceContext), reinterpret_cast<void**>(&d2dDeviceContext));
+ ASSERT(SUCCEEDED(hr));
+
+ COMPtr<ID2D1Device> d2dDevice;
+ d2dDeviceContext->GetDevice(&d2dDevice);
+
+ COMPtr<IWICImageEncoder> imageEncoder;
+ hr = ImageDecoderDirect2D::systemImagingFactory()->CreateImageEncoder(d2dDevice.get(), &imageEncoder);
+ ASSERT(SUCCEEDED(hr));
+
+ hr = imageEncoder->WriteFrame(bitmap, wicFrameEncode.get(), nullptr);
+ ASSERT(SUCCEEDED(hr));
+
+ hr = wicFrameEncode->Commit();
+ ASSERT(SUCCEEDED(hr));
+
+ hr = wicBitmapEncoder->Commit();
+ ASSERT(SUCCEEDED(hr));
+
+ hr = stream->Commit(STGC_DEFAULT);
+ ASSERT(SUCCEEDED(hr));
+}
+
} // namespace Direct2D
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/win/Direct2DUtilities.h (248906 => 248907)
--- trunk/Source/WebCore/platform/graphics/win/Direct2DUtilities.h 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebCore/platform/graphics/win/Direct2DUtilities.h 2019-08-20 17:50:09 UTC (rev 248907)
@@ -61,6 +61,8 @@
void copyRectFromOneSurfaceToAnother(ID2D1Bitmap* from, ID2D1Bitmap* to, const IntSize& sourceOffset, const IntRect&, const IntSize& destOffset = IntSize());
+void writeImageToDiskAsPNG(ID2D1RenderTarget*, ID2D1Bitmap*, LPCWSTR fileName);
+
} // namespace Direct2D
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp (248906 => 248907)
--- trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp 2019-08-20 17:50:09 UTC (rev 248907)
@@ -46,11 +46,11 @@
{
}
-IWICImagingFactory* ImageDecoderDirect2D::systemImagingFactory()
+IWICImagingFactory2* ImageDecoderDirect2D::systemImagingFactory()
{
- static IWICImagingFactory* wicImagingFactory = nullptr;
+ static IWICImagingFactory2* wicImagingFactory = nullptr;
if (!wicImagingFactory) {
- HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*)&wicImagingFactory);
+ HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory2, (LPVOID*)&wicImagingFactory);
RELEASE_ASSERT(SUCCEEDED(hr));
}
Modified: trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h (248906 => 248907)
--- trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h 2019-08-20 17:50:09 UTC (rev 248907)
@@ -32,7 +32,7 @@
interface ID2D1RenderTarget;
interface IWICBitmapDecoder;
-interface IWICImagingFactory;
+interface IWICImagingFactory2;
namespace WebCore {
@@ -78,7 +78,7 @@
void setTargetContext(ID2D1RenderTarget*);
- static IWICImagingFactory* systemImagingFactory();
+ static IWICImagingFactory2* systemImagingFactory();
protected:
bool m_isAllDataReceived { false };
Modified: trunk/Source/WebKit/ChangeLog (248906 => 248907)
--- trunk/Source/WebKit/ChangeLog 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebKit/ChangeLog 2019-08-20 17:50:09 UTC (rev 248907)
@@ -1,3 +1,32 @@
+2019-08-20 Brent Fulgham <bfulg...@apple.com>
+
+ [FTW] Fix scrolling in modern WebKit views
+ https://bugs.webkit.org/show_bug.cgi?id=200923
+
+ Reviewed by Don Olmstead.
+
+ The initial implementation of scrolling in Direct2D had errors that
+ caused hilarious rendering glitches. This patch corrects the logic
+ so that page scroll is correct.
+
+ This patch also fixes a bug that would trigger when resizing windows.
+
+ * Shared/win/ShareableBitmapDirect2D.cpp:
+ (WebKit::ShareableBitmap::paint):
+ * UIProcess/BackingStore.h:
+ (WebKit::BackingStore::renderTarget): Deleted.
+ * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:
+ (WebKit::DrawingAreaProxyCoordinatedGraphics::sizeDidChange):
+ (WebKit::DrawingAreaProxyCoordinatedGraphics::deviceScaleFactorDidChange):
+ * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h:
+ * UIProcess/win/BackingStoreDirect2D.cpp:
+ (WebKit::BackingStore::paint):
+ (WebKit::BackingStore::incorporateUpdate):
+ (WebKit::BackingStore::scroll):
+ * UIProcess/win/WebView.cpp:
+ (WebKit::WebView::paint):
+ (WebKit::WebView::onSizeEvent):
+
2019-08-20 Chris Dumez <cdu...@apple.com>
Unsafe usage of CookieStorageObserver from a background thread
Modified: trunk/Source/WebKit/Shared/win/ShareableBitmapDirect2D.cpp (248906 => 248907)
--- trunk/Source/WebKit/Shared/win/ShareableBitmapDirect2D.cpp 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebKit/Shared/win/ShareableBitmapDirect2D.cpp 2019-08-20 17:50:09 UTC (rev 248907)
@@ -82,6 +82,13 @@
{
auto surface = createDirect2DSurface();
+#ifndef _NDEBUG
+ unsigned width, height;
+ HRESULT hr = surface->GetSize(&width, &height);
+ ASSERT(width == m_size.width());
+ ASSERT(height == m_size.height());
+#endif
+
FloatRect destRect(dstPoint, srcRect.size());
FloatRect srcRectScaled(srcRect);
srcRectScaled.scale(scaleFactor);
Modified: trunk/Source/WebKit/UIProcess/BackingStore.h (248906 => 248907)
--- trunk/Source/WebKit/UIProcess/BackingStore.h 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebKit/UIProcess/BackingStore.h 2019-08-20 17:50:09 UTC (rev 248907)
@@ -58,16 +58,16 @@
#if USE(CAIRO)
typedef cairo_t* PlatformGraphicsContext;
#elif USE(DIRECT2D)
- typedef ID2D1RenderTarget* PlatformGraphicsContext;
+ struct GdiConnections {
+ HWND hwnd;
+ HDC hdc;
+ };
+ typedef GdiConnections PlatformGraphicsContext;
#endif
void paint(PlatformGraphicsContext, const WebCore::IntRect&);
void incorporateUpdate(const UpdateInfo&);
-#if USE(DIRECT2D)
- ID2D1DCRenderTarget* renderTarget() { return m_backend->renderTarget(); }
-#endif
-
private:
void incorporateUpdate(ShareableBitmap*, const UpdateInfo&);
void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
Modified: trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp (248906 => 248907)
--- trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp 2019-08-20 17:50:09 UTC (rev 248907)
@@ -118,11 +118,17 @@
void DrawingAreaProxyCoordinatedGraphics::sizeDidChange()
{
+#if USE(DIRECT2D)
+ m_backingStore = nullptr;
+#endif
backingStoreStateDidChange(RespondImmediately);
}
void DrawingAreaProxyCoordinatedGraphics::deviceScaleFactorDidChange()
{
+#if USE(DIRECT2D)
+ m_backingStore = nullptr;
+#endif
backingStoreStateDidChange(RespondImmediately);
}
Modified: trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h (248906 => 248907)
--- trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h 2019-08-20 17:50:09 UTC (rev 248907)
@@ -47,10 +47,6 @@
void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, WebCore::Region& unpaintedRegion);
#endif
-#if USE(DIRECT2D)
- ID2D1DCRenderTarget* renderTarget() { return m_backingStore ? m_backingStore->renderTarget() : nullptr; }
-#endif
-
bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
const LayerTreeContext& layerTreeContext() const { return m_layerTreeContext; }
Modified: trunk/Source/WebKit/UIProcess/win/BackingStoreDirect2D.cpp (248906 => 248907)
--- trunk/Source/WebKit/UIProcess/win/BackingStoreDirect2D.cpp 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebKit/UIProcess/win/BackingStoreDirect2D.cpp 2019-08-20 17:50:09 UTC (rev 248907)
@@ -44,57 +44,61 @@
return makeUnique<BackingStoreBackendDirect2DImpl>(m_size, m_deviceScaleFactor);
}
-void BackingStore::paint(ID2D1RenderTarget* renderTarget, const IntRect& rect)
+void BackingStore::paint(GdiConnections gdiConnections, const IntRect& rect)
{
- renderTarget->BeginDraw();
-
ASSERT(m_backend);
+ ASSERT(m_backend->size() == m_size);
- auto bitmapBrushProperties = D2D1::BitmapBrushProperties();
- auto brushProperties = D2D1::BrushProperties();
+ auto* renderTarget = m_backend->renderTarget();
- COMPtr<ID2D1BitmapBrush> patternBrush;
- HRESULT hr = renderTarget->CreateBitmapBrush(m_backend->surface(), &bitmapBrushProperties, &brushProperties, &patternBrush);
- ASSERT(SUCCEEDED(hr));
- if (!SUCCEEDED(hr))
- return;
+ RECT viewRect;
+ ::GetClientRect(gdiConnections.hwnd, &viewRect);
+ renderTarget->BindDC(gdiConnections.hdc, &viewRect);
- D2D1_RECT_F destRect(rect);
- renderTarget->FillRectangle(&destRect, patternBrush.get());
- renderTarget->EndDraw();
+ D2D1_RECT_F destRect = rect;
+
+ if (auto* patternBrush = m_backend->bitmapBrush()) {
+ renderTarget->BeginDraw();
+ renderTarget->FillRectangle(&destRect, patternBrush);
+ renderTarget->EndDraw();
+ }
}
void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo)
{
- WTFLogAlways("BackingStore::incorporateUpdate");
if (!m_backend)
m_backend = createBackend();
scroll(updateInfo.scrollRect, updateInfo.scrollOffset);
- // Paint all update rects.
- IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
+ IntPoint updateRectBoundsLocation = updateInfo.updateRectBounds.location();
- COMPtr<ID2D1BitmapRenderTarget> bitmapRenderTarget;
- HRESULT hr = m_backend->renderTarget()->CreateCompatibleRenderTarget(&bitmapRenderTarget);
- GraphicsContext graphicsContext(GraphicsContextImplDirect2D::createFactory(bitmapRenderTarget.get()));
+ auto updateWICBitmap = bitmap->createDirect2DSurface();
- // When m_webPageProxy.drawsBackground() is false, bitmap contains transparent parts as a background of the webpage.
- // For such case, bitmap must be drawn using CompositeCopy to overwrite the existing surface.
- graphicsContext.setCompositeOperation(WebCore::CompositeCopy);
+ HRESULT hr = S_OK;
+#ifndef _NDEBUG
+ unsigned width, height;
+ hr = updateWICBitmap->GetSize(&width, &height);
+ ASSERT(width == updateInfo.updateRectBounds.width());
+ ASSERT(height == updateInfo.updateRectBounds.height());
+#endif
+ COMPtr<ID2D1Bitmap> deviceUpdateBitmap;
+ hr = m_backend->renderTarget()->CreateBitmapFromWicBitmap(updateWICBitmap.get(), &deviceUpdateBitmap);
+ if (!SUCCEEDED(hr))
+ return;
+
+#ifndef _NDEBUG
+ auto deviceBitmapSize = deviceUpdateBitmap->GetPixelSize();
+ ASSERT(deviceBitmapSize.width == updateInfo.updateRectBounds.width());
+ ASSERT(deviceBitmapSize.height == updateInfo.updateRectBounds.height());
+#endif
+
for (const auto& updateRect : updateInfo.updateRects) {
- IntRect srcRect = updateRect;
- srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
- bitmap->paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect);
+ auto currentRectLocation = IntSize(updateRect.x() - updateRectBoundsLocation.x(), updateRect.y() - updateRectBoundsLocation.y());
+ auto destRectLocation = IntSize(updateRect.x(), updateRect.y());
+ Direct2D::copyRectFromOneSurfaceToAnother(deviceUpdateBitmap.get(), m_backend->surface(), currentRectLocation, updateRect, destRectLocation);
}
-
- COMPtr<ID2D1Bitmap> output;
- hr = bitmapRenderTarget->GetBitmap(&output);
- D2D1_POINT_2U destPoint = D2D1::Point2U();
- auto size = Direct2D::bitmapSize(output.get());
- D2D1_RECT_U destRect = D2D1::RectU(0, 0, size.width(), size.height());
- hr = m_backend->surface()->CopyFromBitmap(&destPoint, output.get(), &destRect);
}
void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
@@ -102,8 +106,6 @@
if (scrollOffset.isZero())
return;
- WTFLogAlways("BackingStore::scroll");
-
ASSERT(m_backend);
m_backend->scroll(scrollRect, scrollOffset);
}
Modified: trunk/Source/WebKit/UIProcess/win/WebView.cpp (248906 => 248907)
--- trunk/Source/WebKit/UIProcess/win/WebView.cpp 2019-08-20 17:37:07 UTC (rev 248906)
+++ trunk/Source/WebKit/UIProcess/win/WebView.cpp 2019-08-20 17:50:09 UTC (rev 248907)
@@ -491,11 +491,8 @@
cairo_destroy(context);
cairo_surface_destroy(surface);
#else
- RECT d2DirtyRect = dirtyRect;
- if (COMPtr<ID2D1DCRenderTarget> renderTarget = drawingArea->renderTarget()) {
- renderTarget->BindDC(hdc, &d2DirtyRect);
- drawingArea->paint(renderTarget.get(), dirtyRect, unpaintedRegion);
- }
+ BackingStore::GdiConnections context { ::WindowFromDC(hdc), hdc };
+ drawingArea->paint(context, dirtyRect, unpaintedRegion);
#endif
auto unpaintedRects = unpaintedRegion.rects();
@@ -532,7 +529,7 @@
return 0;
}
-LRESULT WebView::onSizeEvent(HWND, UINT, WPARAM, LPARAM lParam, bool& handled)
+LRESULT WebView::onSizeEvent(HWND hwnd, UINT, WPARAM, LPARAM lParam, bool& handled)
{
int width = LOWORD(lParam);
int height = HIWORD(lParam);