Title: [190235] trunk/Source
Revision
190235
Author
[email protected]
Date
2015-09-24 20:41:35 -0700 (Thu, 24 Sep 2015)

Log Message

[Win] Support composited content in WebView render-to-context methods
https://bugs.webkit.org/show_bug.cgi?id=149516
<rdar://problem/22635080>

Reviewed by Simon Fraser.

Source/WebCore:

Extend the CACFLayerTreeHost implementation to render into a passed
device context when requested. When no context is provided (the default
case) paint as normal.

Will be tested by existing compositing tests in a future bug. DumpRenderTree
has to be extended to do this painting properly.

* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::paint): Accept an optional HDC argument, and
pass it to the render method.
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp: Add missing SOFT_LINK
command for the WKCACFViewDrawIntoDC.
(WebCore::WKCACFViewLayerTreeHost::paint): Accept optional HDC argument and
pass it to the parent class.
(WebCore::WKCACFViewLayerTreeHost::render): Accept new optional HDC argument.
If provided, call WKCACFViewDrawIntoDC. Otherwise, call WKCACFVIewDraw.
(WebCore::WKCACFViewLayerTreeHost::setShouldInvertColors):
* platform/graphics/ca/win/WKCACFViewLayerTreeHost.h:

Source/WebKit/win:

* WebView.cpp:
(WebView::paint): Call the new 'paintCompositedContentToHDC' method. If
it handles the pain, return.
(WebView::paintCompositedContentToHDC): New method to share code with other
paint methods.
(WebView::paintDocumentRectToContext): Call new 'paintCompositedContentToHDC'
to handle any composited layers. Otherwise, use slow drawing path.
(WebView::paintScrollViewRectToContextAtPoint): Ditto.
* WebView.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (190234 => 190235)


--- trunk/Source/WebCore/ChangeLog	2015-09-25 02:56:47 UTC (rev 190234)
+++ trunk/Source/WebCore/ChangeLog	2015-09-25 03:41:35 UTC (rev 190235)
@@ -1,3 +1,31 @@
+2015-09-24  Brent Fulgham  <[email protected]>
+
+        [Win] Support composited content in WebView render-to-context methods
+        https://bugs.webkit.org/show_bug.cgi?id=149516
+        <rdar://problem/22635080>
+
+        Reviewed by Simon Fraser.
+
+        Extend the CACFLayerTreeHost implementation to render into a passed
+        device context when requested. When no context is provided (the default
+        case) paint as normal.
+
+        Will be tested by existing compositing tests in a future bug. DumpRenderTree
+        has to be extended to do this painting properly.
+
+        * platform/graphics/ca/win/CACFLayerTreeHost.cpp:
+        (WebCore::CACFLayerTreeHost::paint): Accept an optional HDC argument, and
+        pass it to the render method.
+        * platform/graphics/ca/win/CACFLayerTreeHost.h:
+        * platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp: Add missing SOFT_LINK
+        command for the WKCACFViewDrawIntoDC.
+        (WebCore::WKCACFViewLayerTreeHost::paint): Accept optional HDC argument and
+        pass it to the parent class.
+        (WebCore::WKCACFViewLayerTreeHost::render): Accept new optional HDC argument.
+        If provided, call WKCACFViewDrawIntoDC. Otherwise, call WKCACFVIewDraw.
+        (WebCore::WKCACFViewLayerTreeHost::setShouldInvertColors):
+        * platform/graphics/ca/win/WKCACFViewLayerTreeHost.h:
+
 2015-09-24  Chris Dumez  <[email protected]>
 
         Drop [NotDeletable] from QuickTimePluginReplacement.postEvent()

Modified: trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp (190234 => 190235)


--- trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp	2015-09-25 02:56:47 UTC (rev 190234)
+++ trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp	2015-09-25 03:41:35 UTC (rev 190235)
@@ -261,11 +261,11 @@
         outRects[i] = winRectToCGRect(*rect, clientRect);
 }
 
-void CACFLayerTreeHost::paint()
+void CACFLayerTreeHost::paint(HDC dc)
 {
     Vector<CGRect> dirtyRects;
     getDirtyRects(m_window, dirtyRects);
-    render(dirtyRects);
+    render(dirtyRects, dc);
 }
 
 void CACFLayerTreeHost::flushPendingGraphicsLayerChangesSoon()

Modified: trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h (190234 => 190235)


--- trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h	2015-09-25 02:56:47 UTC (rev 190234)
+++ trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h	2015-09-25 03:41:35 UTC (rev 190235)
@@ -67,7 +67,7 @@
     void setRootChildLayer(PlatformCALayer*);
     void setWindow(HWND);
     void setPage(Page*);
-    virtual void paint();
+    virtual void paint(HDC = nullptr);
     virtual void resize() = 0;
     void flushPendingGraphicsLayerChangesSoon();
     virtual void setShouldInvertColors(bool);
@@ -108,7 +108,7 @@
 
     virtual void flushContext() = 0;
     virtual CFTimeInterval lastCommitTime() const = 0;
-    virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>()) = 0;
+    virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>(), HDC dc = nullptr) = 0;
     virtual void initializeContext(void* userData, PlatformCALayer*) = 0;
 
     CACFLayerTreeHostClient* m_client { nullptr };

Modified: trunk/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp (190234 => 190235)


--- trunk/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp	2015-09-25 02:56:47 UTC (rev 190234)
+++ trunk/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp	2015-09-25 03:41:35 UTC (rev 190235)
@@ -52,6 +52,7 @@
 SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewUpdate, void, __cdecl, (WKCACFViewRef view, HWND window, const CGRect* bounds), (view, window, bounds))
 SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewCanDraw, bool, __cdecl, (WKCACFViewRef view), (view))
 SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewDraw, void, __cdecl, (WKCACFViewRef view), (view))
+SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewDrawIntoDC, void, __cdecl, (WKCACFViewRef view, HDC dc), (view, dc))
 SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewFlushContext, void, __cdecl, (WKCACFViewRef view), (view))
 SOFT_LINK(WebKitQuartzCoreAdditions, WKCACFViewInvalidateRects, void, __cdecl, (WKCACFViewRef view, const CGRect rects[], size_t count), (view, rects, count))
 typedef void (*WKCACFViewContextDidChangeCallback)(WKCACFViewRef view, void* info);
@@ -156,16 +157,19 @@
     WKCACFViewFlushContext(m_view.get());
 }
 
-void WKCACFViewLayerTreeHost::paint()
+void WKCACFViewLayerTreeHost::paint(HDC dc)
 {
     updateViewIfNeeded();
-    CACFLayerTreeHost::paint();
+    CACFLayerTreeHost::paint(dc);
 }
 
-void WKCACFViewLayerTreeHost::render(const Vector<CGRect>& dirtyRects)
+void WKCACFViewLayerTreeHost::render(const Vector<CGRect>& dirtyRects, HDC dc)
 {
     WKCACFViewInvalidateRects(m_view.get(), dirtyRects.data(), dirtyRects.size());
-    WKCACFViewDraw(m_view.get());
+    if (dc)
+        WKCACFViewDrawIntoDC(m_view.get(), dc);
+    else
+        WKCACFViewDraw(m_view.get());
 }
 
 void WKCACFViewLayerTreeHost::setShouldInvertColors(bool shouldInvertColors)

Modified: trunk/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h (190234 => 190235)


--- trunk/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h	2015-09-25 02:56:47 UTC (rev 190234)
+++ trunk/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h	2015-09-25 03:41:35 UTC (rev 190235)
@@ -49,8 +49,8 @@
     virtual void destroyRenderer();
     virtual void flushContext();
     virtual void contextDidChange();
-    virtual void paint();
-    virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>());
+    void paint(HDC = nullptr) override;
+    void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>(), HDC dc = nullptr) override;
     virtual CFTimeInterval lastCommitTime() const;
     virtual void setShouldInvertColors(bool);
 #if USE(AVFOUNDATION)

Modified: trunk/Source/WebKit/win/ChangeLog (190234 => 190235)


--- trunk/Source/WebKit/win/ChangeLog	2015-09-25 02:56:47 UTC (rev 190234)
+++ trunk/Source/WebKit/win/ChangeLog	2015-09-25 03:41:35 UTC (rev 190235)
@@ -1,3 +1,21 @@
+2015-09-24  Brent Fulgham  <[email protected]>
+
+        [Win] Support composited content in WebView render-to-context methods
+        https://bugs.webkit.org/show_bug.cgi?id=149516
+        <rdar://problem/22635080>
+
+        Reviewed by Simon Fraser.
+
+        * WebView.cpp:
+        (WebView::paint): Call the new 'paintCompositedContentToHDC' method. If
+        it handles the pain, return.
+        (WebView::paintCompositedContentToHDC): New method to share code with other
+        paint methods.
+        (WebView::paintDocumentRectToContext): Call new 'paintCompositedContentToHDC'
+        to handle any composited layers. Otherwise, use slow drawing path.
+        (WebView::paintScrollViewRectToContextAtPoint): Ditto.
+        * WebView.h:
+
 2015-09-24  Per Arne Vollan  <[email protected]>
 
         [WinCairo] NULL pointer crash when trying to use tiled backing for frame view.

Modified: trunk/Source/WebKit/win/WebView.cpp (190234 => 190235)


--- trunk/Source/WebKit/win/WebView.cpp	2015-09-25 02:56:47 UTC (rev 190234)
+++ trunk/Source/WebKit/win/WebView.cpp	2015-09-25 03:41:35 UTC (rev 190235)
@@ -1119,21 +1119,9 @@
 {
     LOCAL_GDI_COUNTER(0, __FUNCTION__);
 
-    if (isAcceleratedCompositing() && !usesLayeredWindow()) {
-#if USE(CA)
-        m_layerTreeHost->flushPendingLayerChangesNow();
-#elif USE(TEXTURE_MAPPER_GL)
-        m_acceleratedCompositingContext->flushAndRenderLayers();
-#endif
-        // Flushing might have taken us out of compositing mode.
-        if (isAcceleratedCompositing()) {
-#if USE(CA)
-            // FIXME: We need to paint into dc (if provided). <http://webkit.org/b/52578>
-            m_layerTreeHost->paint();
-#endif
-            ::ValidateRect(m_viewWindow, 0);
-            return;
-        }
+    if (paintCompositedContentToHDC(dc)) {
+        ::ValidateRect(m_viewWindow, nullptr);
+        return;
     }
 
     Frame* coreFrame = core(m_mainFrame);
@@ -6143,6 +6131,28 @@
     return S_OK;
 }
 
+bool WebView::paintCompositedContentToHDC(HDC deviceContext)
+{
+    if (!isAcceleratedCompositing() || usesLayeredWindow())
+        return false;
+
+#if USE(CA)
+    m_layerTreeHost->flushPendingLayerChangesNow();
+#elif USE(TEXTURE_MAPPER_GL)
+    m_acceleratedCompositingContext->flushAndRenderLayers();
+#endif
+
+    // Flushing might have taken us out of compositing mode.
+    if (!isAcceleratedCompositing())
+        return false;
+
+#if USE(CA)
+    m_layerTreeHost->paint(deviceContext);
+#endif
+
+    return true;
+}
+
 HRESULT WebView::paintDocumentRectToContext(RECT rect, _In_ HDC deviceContext)
 {
     if (!deviceContext)
@@ -6151,6 +6161,9 @@
     if (!m_mainFrame)
         return E_UNEXPECTED;
 
+    if (paintCompositedContentToHDC(deviceContext))
+        return S_OK;
+
     return m_mainFrame->paintDocumentRectToContext(rect, deviceContext);
 }
 
@@ -6162,6 +6175,9 @@
     if (!m_mainFrame)
         return E_UNEXPECTED;
 
+    if (paintCompositedContentToHDC(deviceContext))
+        return S_OK;
+
     return m_mainFrame->paintScrollViewRectToContextAtPoint(rect, pt, deviceContext);
 }
 

Modified: trunk/Source/WebKit/win/WebView.h (190234 => 190235)


--- trunk/Source/WebKit/win/WebView.h	2015-09-25 02:56:47 UTC (rev 190234)
+++ trunk/Source/WebKit/win/WebView.h	2015-09-25 03:41:35 UTC (rev 190235)
@@ -569,6 +569,7 @@
     static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
 
     void updateWindowIfNeeded(HWND hWnd, UINT message);
+    bool paintCompositedContentToHDC(HDC);
 
     HIMC getIMMContext();
     void releaseIMMContext(HIMC);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to