Only include "deep color" in layer tree dumps if a tests requests it
https://bugs.webkit.org/show_bug.cgi?id=203125

Reviewed by Tim Horton.
Source/WebCore:

Layer tree dumping tests can fail when run on different devices because the "deep color"
property on layers is device-dependent. Stop dumping this by default, and have one test
that sets the bit. iphone-7 is the only device we test that has deep color support.

Tests: compositing/contents-format/deep-color-backing-store.html
       compositing/contents-format/ipad/deep-color-backing-store.html
       compositing/contents-format/iphone-7/deep-color-backing-store.html

* page/Frame.h:
* platform/graphics/GraphicsLayerClient.h:
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::layerTreeAsText):
* testing/Internals.cpp:
(WebCore::toLayerTreeFlags):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* TestExpectations:
* compositing/contents-format/deep-color-backing-store-expected.txt: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt.
* compositing/contents-format/deep-color-backing-store.html: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html.
* compositing/contents-format/ipad/deep-color-backing-store-expected.txt: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt.
* compositing/contents-format/ipad/deep-color-backing-store.html: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html.
* compositing/contents-format/iphone-7/deep-color-backing-store-expected.txt: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt.
* compositing/contents-format/iphone-7/deep-color-backing-store.html: Renamed from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html.
* platform/ipad/TestExpectations:
* platform/iphone-7/TestExpectations: Added.
* platform/mac-wk1/compositing/contents-format/deep-color-backing-store-expected.txt: Renamed from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251273 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e691220..626e03a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,23 @@
 2019-10-17  Simon Fraser  <simon.fraser@apple.com>
 
+        Only include "deep color" in layer tree dumps if a tests requests it
+        https://bugs.webkit.org/show_bug.cgi?id=203125
+
+        Reviewed by Tim Horton.
+
+        * TestExpectations:
+        * compositing/contents-format/deep-color-backing-store-expected.txt: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt.
+        * compositing/contents-format/deep-color-backing-store.html: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html.
+        * compositing/contents-format/ipad/deep-color-backing-store-expected.txt: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt.
+        * compositing/contents-format/ipad/deep-color-backing-store.html: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html.
+        * compositing/contents-format/iphone-7/deep-color-backing-store-expected.txt: Copied from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt.
+        * compositing/contents-format/iphone-7/deep-color-backing-store.html: Renamed from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html.
+        * platform/ipad/TestExpectations:
+        * platform/iphone-7/TestExpectations: Added.
+        * platform/mac-wk1/compositing/contents-format/deep-color-backing-store-expected.txt: Renamed from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt.
+
+2019-10-17  Simon Fraser  <simon.fraser@apple.com>
+
         REGRESSION (r243347) Layout tests fast/events/touch/ios/drag-block-without-overflow-scroll-and-passive-observer-on* are flakey
         https://bugs.webkit.org/show_bug.cgi?id=203122
         rdar://problem/50058173
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index cc2bbb2..d453a9a 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -7,6 +7,8 @@
 #//////////////////////////////////////////////////////////////////////////////////////////
 
 compositing/ios [ Skip ]
+compositing/contents-format/ipad [ Skip ]
+compositing/contents-format/iphone-7 [ Skip ]
 css3/touch-action [ Skip ]
 accessibility/ios-simulator [ Skip ]
 accessibility/gtk [ Skip ]
diff --git a/LayoutTests/compositing/contents-format/deep-color-backing-store-expected.txt b/LayoutTests/compositing/contents-format/deep-color-backing-store-expected.txt
new file mode 100644
index 0000000..85e222b
--- /dev/null
+++ b/LayoutTests/compositing/contents-format/deep-color-backing-store-expected.txt
@@ -0,0 +1,36 @@
+Box
+Box
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 5018.00 2018.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 5018.00 2018.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+      (children 2
+        (GraphicsLayer
+          (position 18.00 10.00)
+          (bounds 100.00 100.00)
+          (contentsOpaque 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 18.00 120.00)
+          (bounds 5000.00 100.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (tile cache coverage 0, 0 1024 x 100)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 2 x 1)
+          (in window 1)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html b/LayoutTests/compositing/contents-format/deep-color-backing-store.html
similarity index 93%
rename from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html
rename to LayoutTests/compositing/contents-format/deep-color-backing-store.html
index 9c8c310..28a3d57 100644
--- a/LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html
+++ b/LayoutTests/compositing/contents-format/deep-color-backing-store.html
@@ -29,7 +29,7 @@
         function doTest()
         {
             if (window.internals)
-                document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES | internals.LAYER_TREE_INCLUDES_DEEP_COLOR);
         }
         window.addEventListener('load', doTest, false);
     </script>
diff --git a/LayoutTests/compositing/contents-format/ipad/deep-color-backing-store-expected.txt b/LayoutTests/compositing/contents-format/ipad/deep-color-backing-store-expected.txt
new file mode 100644
index 0000000..85e222b
--- /dev/null
+++ b/LayoutTests/compositing/contents-format/ipad/deep-color-backing-store-expected.txt
@@ -0,0 +1,36 @@
+Box
+Box
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 5018.00 2018.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 5018.00 2018.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+      (children 2
+        (GraphicsLayer
+          (position 18.00 10.00)
+          (bounds 100.00 100.00)
+          (contentsOpaque 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 18.00 120.00)
+          (bounds 5000.00 100.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (tile cache coverage 0, 0 1024 x 100)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 2 x 1)
+          (in window 1)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html b/LayoutTests/compositing/contents-format/ipad/deep-color-backing-store.html
similarity index 93%
copy from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html
copy to LayoutTests/compositing/contents-format/ipad/deep-color-backing-store.html
index 9c8c310..28a3d57 100644
--- a/LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html
+++ b/LayoutTests/compositing/contents-format/ipad/deep-color-backing-store.html
@@ -29,7 +29,7 @@
         function doTest()
         {
             if (window.internals)
-                document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES | internals.LAYER_TREE_INCLUDES_DEEP_COLOR);
         }
         window.addEventListener('load', doTest, false);
     </script>
diff --git a/LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt b/LayoutTests/compositing/contents-format/iphone-7/deep-color-backing-store-expected.txt
similarity index 100%
rename from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color-expected.txt
rename to LayoutTests/compositing/contents-format/iphone-7/deep-color-backing-store-expected.txt
diff --git a/LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html b/LayoutTests/compositing/contents-format/iphone-7/deep-color-backing-store.html
similarity index 93%
copy from LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html
copy to LayoutTests/compositing/contents-format/iphone-7/deep-color-backing-store.html
index 9c8c310..28a3d57 100644
--- a/LayoutTests/platform/iphone-7/tiled-drawing/compositing-layers-deep-color.html
+++ b/LayoutTests/compositing/contents-format/iphone-7/deep-color-backing-store.html
@@ -29,7 +29,7 @@
         function doTest()
         {
             if (window.internals)
-                document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES | internals.LAYER_TREE_INCLUDES_DEEP_COLOR);
         }
         window.addEventListener('load', doTest, false);
     </script>
diff --git a/LayoutTests/platform/ipad/TestExpectations b/LayoutTests/platform/ipad/TestExpectations
index 4042ef7..bf9f96b 100644
--- a/LayoutTests/platform/ipad/TestExpectations
+++ b/LayoutTests/platform/ipad/TestExpectations
@@ -2,6 +2,8 @@
 css-dark-mode [ Pass ]
 css-dark-mode/older-systems [ Skip ]
 
+compositing/contents-format/ipad [ Pass ]
+
 # iPads don't zoom when form elements are focused
 fast/visual-viewport/ios/caret-after-focus-in-fixed.html [ Skip ]
 
diff --git a/LayoutTests/platform/iphone-7/TestExpectations b/LayoutTests/platform/iphone-7/TestExpectations
new file mode 100644
index 0000000..deb5c41
--- /dev/null
+++ b/LayoutTests/platform/iphone-7/TestExpectations
@@ -0,0 +1 @@
+compositing/contents-format/iphone-7 [ Pass ]
diff --git a/LayoutTests/platform/mac-wk1/compositing/contents-format/deep-color-backing-store-expected.txt b/LayoutTests/platform/mac-wk1/compositing/contents-format/deep-color-backing-store-expected.txt
new file mode 100644
index 0000000..5b6a6d5
--- /dev/null
+++ b/LayoutTests/platform/mac-wk1/compositing/contents-format/deep-color-backing-store-expected.txt
@@ -0,0 +1,32 @@
+Box
+Box
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 5018.00 2018.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 5018.00 2018.00)
+      (contentsOpaque 1)
+      (children 2
+        (GraphicsLayer
+          (position 18.00 10.00)
+          (bounds 100.00 100.00)
+          (contentsOpaque 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 18.00 120.00)
+          (bounds 5000.00 100.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (tile cache coverage 0, 0 1024 x 100)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 2 x 1)
+          (in window 1)
+        )
+      )
+    )
+  )
+)
+
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 7d56871..2db0719 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2019-10-17  Simon Fraser  <simon.fraser@apple.com>
+
+        Only include "deep color" in layer tree dumps if a tests requests it
+        https://bugs.webkit.org/show_bug.cgi?id=203125
+
+        Reviewed by Tim Horton.
+        
+        Layer tree dumping tests can fail when run on different devices because the "deep color"
+        property on layers is device-dependent. Stop dumping this by default, and have one test
+        that sets the bit. iphone-7 is the only device we test that has deep color support.
+
+        Tests: compositing/contents-format/deep-color-backing-store.html
+               compositing/contents-format/ipad/deep-color-backing-store.html
+               compositing/contents-format/iphone-7/deep-color-backing-store.html
+
+        * page/Frame.h:
+        * platform/graphics/GraphicsLayerClient.h:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::layerTreeAsText):
+        * testing/Internals.cpp:
+        (WebCore::toLayerTreeFlags):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2019-10-17  Dean Jackson  <dino@apple.com>
 
         ctx.font = "" asserts in CSS parser
diff --git a/Source/WebCore/page/Frame.h b/Source/WebCore/page/Frame.h
index 9aa1c66..dd9802c 100644
--- a/Source/WebCore/page/Frame.h
+++ b/Source/WebCore/page/Frame.h
@@ -117,6 +117,7 @@
     LayerTreeFlagsIncludeBackingStoreAttached   = 1 << 8,
     LayerTreeFlagsIncludeRootLayerProperties    = 1 << 9,
     LayerTreeFlagsIncludeEventRegion            = 1 << 10,
+    LayerTreeFlagsIncludeDeepColor              = 1 << 11,
 };
 typedef unsigned LayerTreeFlags;
 
diff --git a/Source/WebCore/platform/graphics/GraphicsLayerClient.h b/Source/WebCore/platform/graphics/GraphicsLayerClient.h
index 4d535dc..79a3f53 100644
--- a/Source/WebCore/platform/graphics/GraphicsLayerClient.h
+++ b/Source/WebCore/platform/graphics/GraphicsLayerClient.h
@@ -74,6 +74,7 @@
     LayerTreeAsTextIncludeBackingStoreAttached  = 1 << 9,
     LayerTreeAsTextIncludeRootLayerProperties   = 1 << 10,
     LayerTreeAsTextIncludeEventRegion           = 1 << 11,
+    LayerTreeAsTextIncludeDeepColor             = 1 << 12,
     LayerTreeAsTextShowAll                      = 0xFFFF
 };
 typedef unsigned LayerTreeAsTextBehavior;
diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
index 9b9f59c..9a4918c 100644
--- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
+++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
@@ -3753,7 +3753,7 @@
         textStream << indent << "(in window " << tiledBacking()->isInWindow() << ")\n";
     }
 
-    if (m_layer->wantsDeepColorBackingStore())
+    if ((behavior & LayerTreeAsTextIncludeDeepColor) && m_layer->wantsDeepColorBackingStore())
         textStream << indent << "(deep color 1)\n";
 
     if (behavior & LayerTreeAsTextIncludeContentLayers) {
diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp
index ff9febf..f235ce1 100644
--- a/Source/WebCore/rendering/RenderLayerCompositor.cpp
+++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp
@@ -2137,6 +2137,8 @@
         layerTreeBehavior |= LayerTreeAsTextIncludeRootLayerProperties;
     if (flags & LayerTreeFlagsIncludeEventRegion)
         layerTreeBehavior |= LayerTreeAsTextIncludeEventRegion;
+    if (flags & LayerTreeFlagsIncludeDeepColor)
+        layerTreeBehavior |= LayerTreeAsTextIncludeDeepColor;
 
     // We skip dumping the scroll and clip layers to keep layerTreeAsText output
     // similar between platforms.
diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp
index 97389d3..82ea00d 100644
--- a/Source/WebCore/testing/Internals.cpp
+++ b/Source/WebCore/testing/Internals.cpp
@@ -2626,6 +2626,8 @@
         layerTreeFlags |= LayerTreeFlagsIncludeRootLayerProperties;
     if (flags & Internals::LAYER_TREE_INCLUDES_EVENT_REGION)
         layerTreeFlags |= LayerTreeFlagsIncludeEventRegion;
+    if (flags & Internals::LAYER_TREE_INCLUDES_DEEP_COLOR)
+        layerTreeFlags |= LayerTreeFlagsIncludeDeepColor;
 
     return layerTreeFlags;
 }
diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h
index 19f789f..f9b33a25 100644
--- a/Source/WebCore/testing/Internals.h
+++ b/Source/WebCore/testing/Internals.h
@@ -371,6 +371,7 @@
         LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 128,
         LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES = 256,
         LAYER_TREE_INCLUDES_EVENT_REGION = 512,
+        LAYER_TREE_INCLUDES_DEEP_COLOR = 1024,
     };
     ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
     ExceptionOr<uint64_t> layerIDForElement(Element&);
diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl
index 01db242..5ff471a 100644
--- a/Source/WebCore/testing/Internals.idl
+++ b/Source/WebCore/testing/Internals.idl
@@ -398,6 +398,7 @@
     const unsigned short LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 128;
     const unsigned short LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES = 256;
     const unsigned short LAYER_TREE_INCLUDES_EVENT_REGION = 512;
+    const unsigned short LAYER_TREE_INCLUDES_DEEP_COLOR = 1024;
     [MayThrowException] DOMString layerTreeAsText(Document document, optional unsigned short flags = 0);
 
     [MayThrowException] unsigned long long layerIDForElement(Element element);