Title: [157623] trunk/Source/WebKit2
Revision
157623
Author
[email protected]
Date
2013-10-17 22:23:38 -0700 (Thu, 17 Oct 2013)

Log Message

Remote Layer Tree: Proxy layer contents to the UI process
http://bugs.webkit.org/show_bug.cgi?id=123003

Reviewed by Anders Carlsson.

Proxy layer contents to the UI process. Contents are painted into ShareableBitmaps
for now, and are fully repainted on any invalidation. Also, contents do not respect
any kind of scale or use of contentsRect/etc.

* Shared/mac/RemoteLayerTreeTransaction.h:
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
(WebKit::dumpChangedLayers):
Store/encode/decode/dump the new RemoteLayerBackingStore.

* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::commit):
Fix a mistake where contentsRect was getting reset when contentsScale changed.
Set the layer contents when the backing store changes.

* WebKit2.xcodeproj/project.pbxproj:
Add RemoteLayerBackingStore.

* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(PlatformCALayerRemote::recursiveBuildTransaction):
Paint while building our transaction, and mark the backing store as changed
if we did any painting.

(PlatformCALayerRemote::ensureBackingStore):
Keep the backing store's properties up-to-date with our layer.

(PlatformCALayerRemote::setNeedsDisplay):
Inform the backing store that it needs to paint.

* WebProcess/WebPage/mac/PlatformCALayerRemote.h:

* WebProcess/WebPage/mac/RemoteLayerBackingStore.h: Added.
* WebProcess/WebPage/mac/RemoteLayerBackingStore.mm: Added.
(RemoteLayerBackingStore::RemoteLayerBackingStore):
(RemoteLayerBackingStore::encode):
(RemoteLayerBackingStore::decode):
Encode/decode our ShareableBitmap (via its handle) and size.

(RemoteLayerBackingStore::setNeedsDisplay):
For now, repaint the world.

(RemoteLayerBackingStore::display):
Create a new bitmap if needed, and paint into it.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (157622 => 157623)


--- trunk/Source/WebKit2/ChangeLog	2013-10-18 04:41:49 UTC (rev 157622)
+++ trunk/Source/WebKit2/ChangeLog	2013-10-18 05:23:38 UTC (rev 157623)
@@ -1,3 +1,55 @@
+2013-10-17  Tim Horton  <[email protected]>
+
+        Remote Layer Tree: Proxy layer contents to the UI process
+        http://bugs.webkit.org/show_bug.cgi?id=123003
+
+        Reviewed by Anders Carlsson.
+
+        Proxy layer contents to the UI process. Contents are painted into ShareableBitmaps
+        for now, and are fully repainted on any invalidation. Also, contents do not respect
+        any kind of scale or use of contentsRect/etc.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
+        (WebKit::dumpChangedLayers):
+        Store/encode/decode/dump the new RemoteLayerBackingStore.
+
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::commit):
+        Fix a mistake where contentsRect was getting reset when contentsScale changed.
+        Set the layer contents when the backing store changes.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add RemoteLayerBackingStore.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (PlatformCALayerRemote::recursiveBuildTransaction):
+        Paint while building our transaction, and mark the backing store as changed
+        if we did any painting.
+
+        (PlatformCALayerRemote::ensureBackingStore):
+        Keep the backing store's properties up-to-date with our layer.
+
+        (PlatformCALayerRemote::setNeedsDisplay):
+        Inform the backing store that it needs to paint.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+
+        * WebProcess/WebPage/mac/RemoteLayerBackingStore.h: Added.
+        * WebProcess/WebPage/mac/RemoteLayerBackingStore.mm: Added.
+        (RemoteLayerBackingStore::RemoteLayerBackingStore):
+        (RemoteLayerBackingStore::encode):
+        (RemoteLayerBackingStore::decode):
+        Encode/decode our ShareableBitmap (via its handle) and size.
+
+        (RemoteLayerBackingStore::setNeedsDisplay):
+        For now, repaint the world.
+
+        (RemoteLayerBackingStore::display):
+        Create a new bitmap if needed, and paint into it.
+
 2013-10-17  Dan Bernstein  <[email protected]>
 
         Fixed a typo in the definition of WK_API_ENABLED.

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h (157622 => 157623)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h	2013-10-18 04:41:49 UTC (rev 157622)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h	2013-10-18 05:23:38 UTC (rev 157623)
@@ -26,6 +26,7 @@
 #ifndef RemoteLayerTreeTransaction_h
 #define RemoteLayerTreeTransaction_h
 
+#include "RemoteLayerBackingStore.h"
 #include <WebCore/Color.h>
 #include <WebCore/FloatPoint3D.h>
 #include <WebCore/FloatSize.h>
@@ -71,7 +72,8 @@
         MinificationFilterChanged = 1 << 20,
         MagnificationFilterChanged = 1 << 21,
         SpeedChanged = 1 << 22,
-        TimeOffsetChanged = 1 << 23
+        TimeOffsetChanged = 1 << 23,
+        BackingStoreChanged = 1 << 24
     };
 
     struct LayerCreationProperties {
@@ -117,6 +119,7 @@
         WebCore::PlatformCALayer::FilterType magnificationFilter;
         float speed;
         double timeOffset;
+        RemoteLayerBackingStore backingStore;
     };
 
     explicit RemoteLayerTreeTransaction();

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (157622 => 157623)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm	2013-10-18 04:41:49 UTC (rev 157622)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm	2013-10-18 05:23:38 UTC (rev 157623)
@@ -137,6 +137,9 @@
 
     if (changedProperties & TimeOffsetChanged)
         encoder << timeOffset;
+
+    if (changedProperties & BackingStoreChanged)
+        encoder << backingStore;
 }
 
 bool RemoteLayerTreeTransaction::LayerProperties::decode(CoreIPC::ArgumentDecoder& decoder, LayerProperties& result)
@@ -264,6 +267,11 @@
             return false;
     }
 
+    if (result.changedProperties & BackingStoreChanged) {
+        if (!decoder.decode(result.backingStore))
+            return false;
+    }
+
     return true;
 }
 
@@ -587,6 +595,16 @@
             builder.append(')');
         }
 
+        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged) {
+            builder.append('\n');
+            writeIndent(builder, 3);
+            builder.append("(backingStore ");
+            builder.appendNumber(layerProperties.backingStore.bitmap()->size().width());
+            builder.append(" ");
+            builder.appendNumber(layerProperties.backingStore.bitmap()->size().height());
+            builder.append(')');
+        }
+
         builder.append(")\n");
     }
 }

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm (157622 => 157623)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm	2013-10-18 04:41:49 UTC (rev 157622)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm	2013-10-18 05:23:38 UTC (rev 157623)
@@ -28,6 +28,7 @@
 
 #import "RemoteLayerTreeHostMessages.h"
 #import "RemoteLayerTreeTransaction.h"
+#import "ShareableBitmap.h"
 #import "WebPageProxy.h"
 #import "WebProcessProxy.h"
 #import <WebCore/PlatformLayer.h>
@@ -183,7 +184,7 @@
             layer.contentsRect = properties.contentsRect;
 
         if (properties.changedProperties & RemoteLayerTreeTransaction::ContentsScaleChanged)
-            layer.contentsRect = properties.contentsRect;
+            layer.contentsScale = properties.contentsScale;
 
         if (properties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
             layer.minificationFilter = toCAFilterType(properties.minificationFilter);
@@ -196,6 +197,12 @@
 
         if (properties.changedProperties & RemoteLayerTreeTransaction::TimeOffsetChanged)
             layer.timeOffset = properties.timeOffset;
+
+        if (properties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged) {
+            // FIXME: Do we need Copy?
+            RetainPtr<CGImageRef> image = properties.backingStore.bitmap()->makeCGImageCopy();
+            layer.contents = (id)image.get();
+        }
     }
 
     for (auto destroyedLayer : transaction.destroyedLayers())

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (157622 => 157623)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2013-10-18 04:41:49 UTC (rev 157622)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2013-10-18 05:23:38 UTC (rev 157623)
@@ -312,6 +312,8 @@
 		2D2ADF0B16362DDB00197E47 /* PDFPluginAnnotation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2ADF031636243500197E47 /* PDFPluginAnnotation.mm */; };
 		2D2ADF1016364D8200197E47 /* PDFPluginChoiceAnnotation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2ADF0E16364D8200197E47 /* PDFPluginChoiceAnnotation.mm */; };
 		2D429BFD1721E2C700EC681F /* PDFPluginPasswordField.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D429BFB1721E2BA00EC681F /* PDFPluginPasswordField.mm */; };
+		2D47B56C1810714E003A3AEE /* RemoteLayerBackingStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D47B56A1810714E003A3AEE /* RemoteLayerBackingStore.mm */; };
+		2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */; };
 		2D870D1016234FFE000A3F20 /* PDFPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D870D0E1622B7F9000A3F20 /* PDFPlugin.mm */; };
 		2DA049B3180CCCD300AAFA9E /* PlatformCALayerRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */; };
 		2DA049B4180CCCD300AAFA9E /* PlatformCALayerRemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */; };
@@ -1762,6 +1764,8 @@
 		2D2ADF0E16364D8200197E47 /* PDFPluginChoiceAnnotation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPluginChoiceAnnotation.mm; path = PDF/PDFPluginChoiceAnnotation.mm; sourceTree = "<group>"; };
 		2D429BFA1721E2BA00EC681F /* PDFPluginPasswordField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPluginPasswordField.h; path = PDF/PDFPluginPasswordField.h; sourceTree = "<group>"; };
 		2D429BFB1721E2BA00EC681F /* PDFPluginPasswordField.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPluginPasswordField.mm; path = PDF/PDFPluginPasswordField.mm; sourceTree = "<group>"; };
+		2D47B56A1810714E003A3AEE /* RemoteLayerBackingStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerBackingStore.mm; sourceTree = "<group>"; };
+		2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerBackingStore.h; sourceTree = "<group>"; };
 		2D870D0D1622B7F9000A3F20 /* PDFPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPlugin.h; path = PDF/PDFPlugin.h; sourceTree = "<group>"; };
 		2D870D0E1622B7F9000A3F20 /* PDFPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPlugin.mm; path = PDF/PDFPlugin.mm; sourceTree = "<group>"; };
 		2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCALayerRemote.cpp; sourceTree = "<group>"; };
@@ -4823,6 +4827,8 @@
 				2DA049B6180CCD0A00AAFA9E /* GraphicsLayerCARemote.h */,
 				2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */,
 				2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */,
+				2D47B56A1810714E003A3AEE /* RemoteLayerBackingStore.mm */,
+				2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */,
 				1AB16AE8164B3A8800290D62 /* RemoteLayerTreeContext.h */,
 				1AB16AE7164B3A8800290D62 /* RemoteLayerTreeContext.mm */,
 				1AB16ADC1648598400290D62 /* RemoteLayerTreeDrawingArea.h */,
@@ -5711,6 +5717,7 @@
 				BCBAAC74144E61A50053F82F /* WKBrowsingContextControllerInternal.h in Headers */,
 				3788A05C14743C90006319E5 /* WKBrowsingContextControllerPrivate.h in Headers */,
 				BCBAACF41452324F0053F82F /* WKBrowsingContextGroup.h in Headers */,
+				2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */,
 				BCBAACF61452324F0053F82F /* WKBrowsingContextGroupPrivate.h in Headers */,
 				BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */,
 				BC204EEF11C83EC8008F3375 /* WKBundle.h in Headers */,
@@ -6617,6 +6624,7 @@
 				BCE81D98131AE02100241910 /* DictionaryPopupInfo.cpp in Sources */,
 				5167EEA1170377BF007681CA /* DiskCacheMonitor.mm in Sources */,
 				518E8F0716B2093700E91429 /* Download.cpp in Sources */,
+				2D47B56C1810714E003A3AEE /* RemoteLayerBackingStore.mm in Sources */,
 				518E8F0916B2093700E91429 /* DownloadAuthenticationClient.cpp in Sources */,
 				518E8F0D16B2093700E91429 /* DownloadMac.mm in Sources */,
 				518E8F0B16B2093700E91429 /* DownloadManager.cpp in Sources */,

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp (157622 => 157623)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp	2013-10-18 04:41:49 UTC (rev 157622)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp	2013-10-18 05:23:38 UTC (rev 157623)
@@ -29,6 +29,7 @@
 
 #import "PlatformCALayerRemote.h"
 
+#import "RemoteLayerBackingStore.h"
 #import "RemoteLayerTreeContext.h"
 #import <WebCore/AnimationUtilities.h>
 #import <WebCore/GraphicsContext.h>
@@ -73,6 +74,9 @@
 
 void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeTransaction& transaction)
 {
+    if (m_properties.backingStore.display())
+        m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreChanged);
+
     if (m_properties.changedProperties != RemoteLayerTreeTransaction::NoChange) {
         if (m_properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
             m_properties.children.clear();
@@ -94,8 +98,25 @@
 {
 }
 
+void PlatformCALayerRemote::ensureBackingStore()
+{
+    if (m_properties.backingStore.layer() == this
+        && m_properties.backingStore.size() == m_properties.size
+        && m_properties.backingStore.isOpaque() == m_properties.opaque)
+        return;
+
+    m_properties.backingStore = RemoteLayerBackingStore(this, expandedIntSize(m_properties.size), m_properties.opaque);
+}
+
 void PlatformCALayerRemote::setNeedsDisplay(const FloatRect* dirtyRect)
 {
+    ensureBackingStore();
+
+    // FIXME: Need to map this through contentsRect/contentsScale/etc.
+    if (dirtyRect)
+        m_properties.backingStore.setNeedsDisplay(enclosingIntRect(*dirtyRect));
+    else
+        m_properties.backingStore.setNeedsDisplay();
 }
 
 void PlatformCALayerRemote::setContentsChanged()

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h (157622 => 157623)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h	2013-10-18 04:41:49 UTC (rev 157622)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h	2013-10-18 05:23:38 UTC (rev 157623)
@@ -29,7 +29,6 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include "RemoteLayerTreeTransaction.h"
-
 #include <WebCore/PlatformCALayer.h>
 #include <WebCore/PlatformLayer.h>
 
@@ -149,6 +148,8 @@
 
     virtual AVPlayerLayer *playerLayer() const OVERRIDE;
 
+    void ensureBackingStore();
+
     RemoteLayerTreeTransaction::LayerID m_layerID;
     RemoteLayerTreeTransaction::LayerProperties m_properties;
     WebCore::PlatformCALayerList m_children;

Added: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.h (0 => 157623)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.h	2013-10-18 05:23:38 UTC (rev 157623)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RemoteLayerBackingStore_h
+#define RemoteLayerBackingStore_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "ShareableBitmap.h"
+#include <WebCore/IntRect.h>
+
+namespace WebKit {
+
+class PlatformCALayerRemote;
+
+class RemoteLayerBackingStore {
+public:
+    RemoteLayerBackingStore();
+    RemoteLayerBackingStore(PlatformCALayerRemote*, WebCore::IntSize, bool isOpaque);
+
+    void setNeedsDisplay(WebCore::IntRect);
+    void setNeedsDisplay();
+
+    bool display();
+
+    ShareableBitmap* bitmap() const { return m_bitmap.get(); }
+    WebCore::IntSize size() const { return m_size; }
+    bool isOpaque() const { return m_isOpaque; }
+
+    PlatformCALayerRemote* layer() const { return m_layer; }
+
+    void encode(CoreIPC::ArgumentEncoder&) const;
+    static bool decode(CoreIPC::ArgumentDecoder&, RemoteLayerBackingStore&);
+
+private:
+    PlatformCALayerRemote* m_layer;
+
+    WebCore::IntSize m_size;
+    bool m_isOpaque;
+
+    bool m_needsFullRepaint;
+
+    RefPtr<ShareableBitmap> m_bitmap;
+};
+
+} // namespace WebKit
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // RemoteLayerBackingStore_h

Added: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.mm (0 => 157623)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.mm	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.mm	2013-10-18 05:23:38 UTC (rev 157623)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "RemoteLayerBackingStore.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#import "PlatformCALayerRemote.h"
+#import "ArgumentCoders.h"
+#import "ShareableBitmap.h"
+#import "WebCoreArgumentCoders.h"
+
+using namespace WebCore;
+using namespace WebKit;
+
+RemoteLayerBackingStore::RemoteLayerBackingStore(PlatformCALayerRemote* layer, IntSize size, bool isOpaque)
+    : m_layer(layer)
+    , m_size(size)
+    , m_isOpaque(isOpaque)
+    , m_needsFullRepaint(true)
+{
+    ASSERT(layer);
+}
+
+RemoteLayerBackingStore::RemoteLayerBackingStore()
+    : m_layer(nullptr)
+{
+}
+
+void RemoteLayerBackingStore::encode(CoreIPC::ArgumentEncoder& encoder) const
+{
+    ShareableBitmap::Handle handle;
+    m_bitmap->createHandle(handle);
+
+    encoder << handle;
+    encoder << m_size;
+}
+
+bool RemoteLayerBackingStore::decode(CoreIPC::ArgumentDecoder& decoder, RemoteLayerBackingStore& result)
+{
+    ShareableBitmap::Handle handle;
+    if (!decoder.decode(handle))
+        return false;
+    result.m_bitmap = ShareableBitmap::create(handle);
+
+    if (!decoder.decode(result.m_size))
+        return false;
+
+    return true;
+}
+
+void RemoteLayerBackingStore::setNeedsDisplay(IntRect rect)
+{
+    // FIXME: Only repaint dirty regions.
+    setNeedsDisplay();
+}
+
+void RemoteLayerBackingStore::setNeedsDisplay()
+{
+    m_needsFullRepaint = true;
+}
+
+bool RemoteLayerBackingStore::display()
+{
+    if (!m_layer)
+        return false;
+
+    if (!m_layer->owner()->platformCALayerDrawsContent()) {
+        // If we previously were drawsContent=YES, and now are not, we need
+        // to note that our backing store has changed (by being cleared).
+        if (m_bitmap) {
+            m_bitmap = nullptr;
+            return true;
+        }
+        return false;
+    }
+
+    if (m_bitmap && !m_needsFullRepaint)
+        return false;
+
+    if (!m_bitmap) {
+        m_bitmap = ShareableBitmap::createShareable(m_size, m_isOpaque ? ShareableBitmap::NoFlags : ShareableBitmap::SupportsAlpha);
+        m_needsFullRepaint = true;
+    }
+
+    std::unique_ptr<GraphicsContext> context = m_bitmap->createGraphicsContext();
+    m_layer->owner()->platformCALayerPaintContents(*context.get(), IntRect(IntPoint(), m_size));
+
+    m_needsFullRepaint = false;
+
+    return true;
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to