Support "plus-lighter" in mix-blend mode
[WebKit-https.git] / Source / WebKit2 / Shared / mac / RemoteLayerTreeTransaction.mm
index 7a7130b..1b73aae 100644 (file)
@@ -86,16 +86,17 @@ RemoteLayerTreeTransaction::LayerProperties::LayerProperties()
     , timeOffset(0)
     , speed(1)
     , contentsScale(1)
+    , cornerRadius(0)
     , borderWidth(0)
     , opacity(1)
     , backgroundColor(Color::transparent)
     , borderColor(Color::black)
     , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
     , customAppearance(GraphicsLayer::NoCustomAppearance)
-    , customBehavior(GraphicsLayer::NoCustomBehavior)
     , minificationFilter(PlatformCALayer::FilterType::Linear)
     , magnificationFilter(PlatformCALayer::FilterType::Linear)
     , blendMode(BlendModeNormal)
+    , windRule(RULE_NONZERO)
     , hidden(false)
     , geometryFlipped(false)
     , doubleSided(true)
@@ -115,21 +116,23 @@ RemoteLayerTreeTransaction::LayerProperties::LayerProperties(const LayerProperti
     , anchorPoint(other.anchorPoint)
     , bounds(other.bounds)
     , contentsRect(other.contentsRect)
+    , shapePath(other.shapePath)
     , maskLayerID(other.maskLayerID)
     , clonedLayerID(other.clonedLayerID)
     , timeOffset(other.timeOffset)
     , speed(other.speed)
     , contentsScale(other.contentsScale)
+    , cornerRadius(other.cornerRadius)
     , borderWidth(other.borderWidth)
     , opacity(other.opacity)
     , backgroundColor(other.backgroundColor)
     , borderColor(other.borderColor)
     , edgeAntialiasingMask(other.edgeAntialiasingMask)
     , customAppearance(other.customAppearance)
-    , customBehavior(other.customBehavior)
     , minificationFilter(other.minificationFilter)
     , magnificationFilter(other.magnificationFilter)
     , blendMode(other.blendMode)
+    , windRule(other.windRule)
     , hidden(other.hidden)
     , geometryFlipped(other.geometryFlipped)
     , doubleSided(other.doubleSided)
@@ -218,6 +221,15 @@ void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::ArgumentEncoder& e
     if (changedProperties & ContentsScaleChanged)
         encoder << contentsScale;
 
+    if (changedProperties & CornerRadiusChanged)
+        encoder << cornerRadius;
+
+    if (changedProperties & ShapeRoundedRectChanged)
+        encoder << *shapeRoundedRect;
+
+    if (changedProperties & ShapePathChanged)
+        encoder << shapePath;
+
     if (changedProperties & MinificationFilterChanged)
         encoder.encodeEnum(minificationFilter);
 
@@ -227,6 +239,9 @@ void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::ArgumentEncoder& e
     if (changedProperties & BlendModeChanged)
         encoder.encodeEnum(blendMode);
 
+    if (changedProperties & WindRuleChanged)
+        encoder.encodeEnum(windRule);
+
     if (changedProperties & SpeedChanged)
         encoder << speed;
 
@@ -248,9 +263,6 @@ void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::ArgumentEncoder& e
 
     if (changedProperties & CustomAppearanceChanged)
         encoder.encodeEnum(customAppearance);
-
-    if (changedProperties & CustomBehaviorChanged)
-        encoder.encodeEnum(customBehavior);
 }
 
 bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& decoder, LayerProperties& result)
@@ -377,6 +389,27 @@ bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& d
             return false;
     }
 
+    if (result.changedProperties & CornerRadiusChanged) {
+        if (!decoder.decode(result.cornerRadius))
+            return false;
+    }
+
+    if (result.changedProperties & ShapeRoundedRectChanged) {
+        FloatRoundedRect roundedRect;
+        if (!decoder.decode(roundedRect))
+            return false;
+        
+        result.shapeRoundedRect = std::make_unique<FloatRoundedRect>(roundedRect);
+    }
+
+    if (result.changedProperties & ShapePathChanged) {
+        Path path;
+        if (!decoder.decode(path))
+            return false;
+        
+        result.shapePath = WTF::move(path);
+    }
+
     if (result.changedProperties & MinificationFilterChanged) {
         if (!decoder.decodeEnum(result.minificationFilter))
             return false;
@@ -392,6 +425,11 @@ bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& d
             return false;
     }
 
+    if (result.changedProperties & WindRuleChanged) {
+        if (!decoder.decodeEnum(result.windRule))
+            return false;
+    }
+
     if (result.changedProperties & SpeedChanged) {
         if (!decoder.decode(result.speed))
             return false;
@@ -433,15 +471,17 @@ bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& d
             return false;
     }
 
-    if (result.changedProperties & CustomBehaviorChanged) {
-        if (!decoder.decodeEnum(result.customBehavior))
-            return false;
-    }
-
     return true;
 }
 
 RemoteLayerTreeTransaction::RemoteLayerTreeTransaction()
+    : m_pageScaleFactor(1)
+    , m_minimumScaleFactor(1)
+    , m_maximumScaleFactor(1)
+    , m_renderTreeSize(0)
+    , m_transactionID(0)
+    , m_scaleWasSetByUIProcess(false)
+    , m_allowsUserScaling(false)
 {
 }
 
@@ -466,6 +506,9 @@ void RemoteLayerTreeTransaction::encode(IPC::ArgumentEncoder& encoder) const
     encoder << m_layerIDsWithNewlyUnreachableBackingStore;
 
     encoder << m_contentsSize;
+#if PLATFORM(MAC)
+    encoder << m_scrollPosition;
+#endif
     encoder << m_pageExtendedBackgroundColor;
     encoder << m_pageScaleFactor;
     encoder << m_minimumScaleFactor;
@@ -527,6 +570,11 @@ bool RemoteLayerTreeTransaction::decode(IPC::ArgumentDecoder& decoder, RemoteLay
 
     if (!decoder.decode(result.m_contentsSize))
         return false;
+
+#if PLATFORM(MAC)
+    if (!decoder.decode(result.m_scrollPosition))
+        return false;
+#endif
     
     if (!decoder.decode(result.m_pageExtendedBackgroundColor))
         return false;
@@ -599,6 +647,7 @@ public:
 
     RemoteLayerTreeTextStream& operator<<(const TransformationMatrix&);
     RemoteLayerTreeTextStream& operator<<(PlatformCALayer::FilterType);
+    RemoteLayerTreeTextStream& operator<<(const FloatRoundedRect&);
     RemoteLayerTreeTextStream& operator<<(FloatPoint3D);
     RemoteLayerTreeTextStream& operator<<(Color);
     RemoteLayerTreeTextStream& operator<<(FloatRect);
@@ -651,6 +700,25 @@ RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const Transform
     return ts;
 }
 
+RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const FloatRoundedRect& roundedRect)
+{
+    RemoteLayerTreeTextStream& ts = *this;
+    ts << roundedRect.rect().x() << " " << roundedRect.rect().y() << " " << roundedRect.rect().width() << " " << roundedRect.rect().height() << "\n";
+
+    ts.increaseIndent();
+    ts.writeIndent();
+    ts << "topLeft=" << roundedRect.topLeftCorner().width() << " " << roundedRect.topLeftCorner().height() << "\n";
+    ts.writeIndent();
+    ts << "topRight=" << roundedRect.topRightCorner().width() << " " << roundedRect.topRightCorner().height() << "\n";
+    ts.writeIndent();
+    ts << "bottomLeft=" << roundedRect.bottomLeftCorner().width() << " " << roundedRect.bottomLeftCorner().height() << "\n";
+    ts.writeIndent();
+    ts << "bottomRight=" << roundedRect.bottomRightCorner().width() << " " << roundedRect.bottomRightCorner().height();
+    ts.decreaseIndent();
+
+    return ts;
+}
+
 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCALayer::FilterType filterType)
 {
     RemoteLayerTreeTextStream& ts = *this;
@@ -779,6 +847,8 @@ RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(BlendMode blend
     case BlendModeSaturation: ts << "saturation"; break;
     case BlendModeColor: ts << "color"; break;
     case BlendModeLuminosity: ts << "luminosity"; break;
+    case BlendModePlusDarker: ts << "plus-darker"; break;
+    case BlendModePlusLighter: ts << "plus-lighter"; break;
     }
     return ts;
 }
@@ -1083,6 +1153,12 @@ static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const RemoteLayerTr
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsScaleChanged)
             dumpProperty(ts, "contentsScale", layerProperties.contentsScale);
 
+        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CornerRadiusChanged)
+            dumpProperty(ts, "cornerRadius", layerProperties.cornerRadius);
+
+        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ShapeRoundedRectChanged)
+            dumpProperty(ts, "shapeRect", layerProperties.shapeRoundedRect ? *layerProperties.shapeRoundedRect : FloatRoundedRect());
+
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
             dumpProperty(ts, "minificationFilter", layerProperties.minificationFilter);
 
@@ -1122,9 +1198,6 @@ static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const RemoteLayerTr
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomAppearanceChanged)
             dumpProperty(ts, "customAppearance", layerProperties.customAppearance);
 
-        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomBehaviorChanged)
-            dumpProperty(ts, "customBehavior", layerProperties.customBehavior);
-
         ts << ")";
 
         ts.decreaseIndent();
@@ -1180,15 +1253,30 @@ CString RemoteLayerTreeTransaction::description() const
             case PlatformCALayer::LayerTypeRootLayer:
                 ts << "root-layer";
                 break;
+            case PlatformCALayer::LayerTypeBackdropLayer:
+                ts << "backdrop-layer";
+                break;
             case PlatformCALayer::LayerTypeAVPlayerLayer:
                 ts << "av-player-layer (context-id " << createdLayer.hostingContextID << ")";
                 break;
             case PlatformCALayer::LayerTypeWebGLLayer:
                 ts << "web-gl-layer (context-id " << createdLayer.hostingContextID << ")";
                 break;
+            case PlatformCALayer::LayerTypeShapeLayer:
+                ts << "shape-layer";
+                break;
+            case PlatformCALayer::LayerTypeScrollingLayer:
+                ts << "scrolling-layer";
+                break;
             case PlatformCALayer::LayerTypeCustom:
                 ts << "custom-layer (context-id " << createdLayer.hostingContextID << ")";
                 break;
+            case PlatformCALayer::LayerTypeLightSystemBackdropLayer:
+                ts << "light-system-backdrop-layer";
+                break;
+            case PlatformCALayer::LayerTypeDarkSystemBackdropLayer:
+                ts << "dark-system-backdrop-layer";
+                break;
             }
             ts << " " << createdLayer.layerID << ")";
         }