WebGL doesn't update with remotely hosted layers
https://bugs.webkit.org/show_bug.cgi?id=128390

Reviewed by Simon Fraser.

PlatformCALayerRemote was intercepting the setNeedsDisplay calls to
WebGL layers, and thus causing them to not draw. Fix this by adding an
override in PlatformCALayerRemoteCustom to check if it is a WebGLLayer
and call setNeedsDisplay directly.

* WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h:
* WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
(PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
(PlatformCALayerRemoteCustom::setNeedsDisplay):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@163646 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 73791a0..11021a6 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,20 @@
+2014-02-07  Dean Jackson  <dino@apple.com>
+
+        WebGL doesn't update with remotely hosted layers
+        https://bugs.webkit.org/show_bug.cgi?id=128390
+
+        Reviewed by Simon Fraser.
+
+        PlatformCALayerRemote was intercepting the setNeedsDisplay calls to
+        WebGL layers, and thus causing them to not draw. Fix this by adding an
+        override in PlatformCALayerRemoteCustom to check if it is a WebGLLayer
+        and call setNeedsDisplay directly.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h:
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
+        (PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
+        (PlatformCALayerRemoteCustom::setNeedsDisplay):
+
 2014-02-07  Benjamin Poulain  <bpoulain@apple.com>
 
         [WK2] Fitler touch events only based on touch start
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h b/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h
index 332b720..e69b569 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h
+++ b/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.h
@@ -41,11 +41,14 @@
 
     virtual uint32_t hostingContextID() override;
 
+    virtual void setNeedsDisplay(const WebCore::FloatRect* dirtyRect = 0) override;
+
 private:
     PlatformCALayerRemoteCustom(PlatformLayer*, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext*);
 
     std::unique_ptr<LayerHostingContext> m_layerHostingContext;
     RetainPtr<PlatformLayer> m_platformLayer;
+    bool m_providesContents;
 };
 
 } // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm b/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm
index 95a1dda..deec9f4 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm
+++ b/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm
@@ -57,6 +57,8 @@
 
     m_platformLayer = customLayer;
     [customLayer web_disableAllActions];
+
+    m_providesContents = [customLayer isKindOfClass:NSClassFromString(@"WebGLLayer")];
 }
 
 PlatformCALayerRemoteCustom::~PlatformCALayerRemoteCustom()
@@ -67,3 +69,14 @@
 {
     return m_layerHostingContext->contextID();
 }
+
+void PlatformCALayerRemoteCustom::setNeedsDisplay(const FloatRect* rect)
+{
+    if (m_providesContents) {
+        if (rect)
+            [m_platformLayer setNeedsDisplayInRect:*rect];
+        else
+            [m_platformLayer setNeedsDisplay];
+    } else
+        PlatformCALayerRemote::setNeedsDisplay(rect);
+}