Title: [190259] branches/safari-601-branch/Source
Revision
190259
Author
[email protected]
Date
2015-09-25 17:13:00 -0700 (Fri, 25 Sep 2015)

Log Message

Merge r190235. rdar://problem/22852382

    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.

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/LegacyCACFLayerTreeHost.cpp: Add missing SOFT_LINK
    command for the WKCACFViewDrawIntoDC.
    (WebCore::LegacyCACFLayerTreeHost::paint): Accept optional HDC argument and
    pass it to the parent class.
    (WebCore::LegacyCACFLayerTreeHost::render): Accept new optional HDC argument.
    If provided, call WKCACFViewDrawIntoDC. Otherwise, call WKCACFVIewDraw.
    * platform/graphics/ca/win/LegacyCACFLayerTreeHost.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.
    * 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::unused5): Work around a linker issue that may appear when building
    test infrastructure on this branch.
    * WebView.h:

Modified Paths

Property Changed

Diff

Property changes: branches/safari-601-branch/Source/WebCore


Modified: svn:mergeinfo

/trunk/Source/WebCore:186677,186980 /trunk/WebCore:53455 + /branches/ftlopt/Source/WebCore:170680 /trunk/Source/WebCore:186677,186980,190235 /trunk/WebCore:53455

Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (190258 => 190259)


--- branches/safari-601-branch/Source/WebCore/ChangeLog	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog	2015-09-26 00:13:00 UTC (rev 190259)
@@ -1,3 +1,41 @@
+2015-09-25  Brent Fulgham  <[email protected]>
+
+        Merge r190235. rdar://problem/22852382
+
+    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/LegacyCACFLayerTreeHost.cpp: Add missing SOFT_LINK
+            command for the WKCACFViewDrawIntoDC.
+            (WebCore::LegacyCACFLayerTreeHost::paint): Accept optional HDC argument and
+            pass it to the parent class.
+            (WebCore::LegacyCACFLayerTreeHost::render): Accept new optional HDC argument.
+            If provided, call WKCACFViewDrawIntoDC. Otherwise, call WKCACFVIewDraw.
+            * platform/graphics/ca/win/LegacyCACFLayerTreeHost.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.
+            * platform/graphics/ca/win/WKCACFViewLayerTreeHost.h:
+
 2015-09-22  Matthew Hanson  <[email protected]>
 
         Merge r189200. rdar://problem/22803080

Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp (190258 => 190259)


--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp	2015-09-26 00:13:00 UTC (rev 190259)
@@ -260,11 +260,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: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h (190258 => 190259)


--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h	2015-09-26 00:13:00 UTC (rev 190259)
@@ -64,7 +64,7 @@
 
     void setRootChildLayer(PlatformCALayer*);
     void setWindow(HWND);
-    virtual void paint();
+    virtual void paint(HDC = nullptr);
     virtual void resize() = 0;
     void flushPendingGraphicsLayerChangesSoon();
     virtual void setShouldInvertColors(bool);
@@ -100,7 +100,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;

Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.cpp (190258 => 190259)


--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.cpp	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.cpp	2015-09-26 00:13:00 UTC (rev 190259)
@@ -229,7 +229,7 @@
     paint();
 }
 
-void LegacyCACFLayerTreeHost::paint()
+void LegacyCACFLayerTreeHost::paint(HDC hdc)
 {
     createRenderer();
     if (!m_d3dDevice) {
@@ -238,10 +238,10 @@
         return;
     }
 
-    CACFLayerTreeHost::paint();
+    CACFLayerTreeHost::paint(hdc);
 }
 
-void LegacyCACFLayerTreeHost::render(const Vector<CGRect>& windowDirtyRects)
+void LegacyCACFLayerTreeHost::render(const Vector<CGRect>& windowDirtyRects, HDC)
 {
     ASSERT(m_d3dDevice);
 

Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h (190258 => 190259)


--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h	2015-09-26 00:13:00 UTC (rev 190259)
@@ -59,8 +59,8 @@
     virtual CFTimeInterval lastCommitTime() const;
     virtual void flushContext();
     virtual void contextDidChange();
-    virtual void paint();
-    virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>());
+    virtual void paint(HDC = nullptr);
+    virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>(), HDC dc = nullptr);
 
 #if USE(AVFOUNDATION)
     virtual GraphicsDeviceAdapter* graphicsDeviceAdapter() const override { return 0; }

Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp (190258 => 190259)


--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp	2015-09-26 00:13:00 UTC (rev 190259)
@@ -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: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h (190258 => 190259)


--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h	2015-09-26 00:13:00 UTC (rev 190259)
@@ -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)

Property changes: branches/safari-601-branch/Source/WebKit


Modified: svn:mergeinfo

+ /trunk/Source/WebKit:190235 /trunk/WebKit:53455

Modified: branches/safari-601-branch/Source/WebKit/win/ChangeLog (190258 => 190259)


--- branches/safari-601-branch/Source/WebKit/win/ChangeLog	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebKit/win/ChangeLog	2015-09-26 00:13:00 UTC (rev 190259)
@@ -1,3 +1,27 @@
+2015-09-25  Brent Fulgham  <[email protected]>
+
+        Merge r190235. rdar://problem/22852382
+
+    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::unused5): Work around a linker issue that may appear when building
+            test infrastructure on this branch.
+            * WebView.h:
+
 2015-08-14  Babak Shafiei  <[email protected]>
 
         Merge r188486.

Modified: branches/safari-601-branch/Source/WebKit/win/WebView.cpp (190258 => 190259)


--- branches/safari-601-branch/Source/WebKit/win/WebView.cpp	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebKit/win/WebView.cpp	2015-09-26 00:13:00 UTC (rev 190259)
@@ -130,6 +130,7 @@
 #include <WebCore/PageCache.h>
 #include <WebCore/PageConfiguration.h>
 #include <WebCore/PageGroup.h>
+#include <WebCore/PathUtilities.h>
 #include <WebCore/PlatformKeyboardEvent.h>
 #include <WebCore/PlatformMouseEvent.h>
 #include <WebCore/PlatformWheelEvent.h>
@@ -1123,21 +1124,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);
@@ -6046,6 +6035,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, HDC deviceContext)
 {
     if (!deviceContext)
@@ -6054,6 +6065,9 @@
     if (!m_mainFrame)
         return E_FAIL;
 
+    if (paintCompositedContentToHDC(deviceContext))
+        return S_OK;
+
     return m_mainFrame->paintDocumentRectToContext(rect, deviceContext);
 }
 
@@ -6065,6 +6079,9 @@
     if (!m_mainFrame)
         return E_FAIL;
 
+    if (paintCompositedContentToHDC(deviceContext))
+        return S_OK;
+
     return m_mainFrame->paintScrollViewRectToContextAtPoint(rect, pt, deviceContext);
 }
 
@@ -6686,6 +6703,11 @@
 HRESULT WebView::unused5()
 {
     ASSERT_NOT_REACHED();
+
+    // The following line works around a linker issue in MSVC. unused5 should never be called,
+    // and this code does nothing more than force the symbol to be included in WebKit dll.
+    (void)WebCore::PathUtilities::pathWithShrinkWrappedRects(Vector<FloatRect>(), 0);
+
     return E_FAIL;
 }
 

Modified: branches/safari-601-branch/Source/WebKit/win/WebView.h (190258 => 190259)


--- branches/safari-601-branch/Source/WebKit/win/WebView.h	2015-09-25 23:52:42 UTC (rev 190258)
+++ branches/safari-601-branch/Source/WebKit/win/WebView.h	2015-09-26 00:13:00 UTC (rev 190259)
@@ -1033,6 +1033,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