Controls panel should have system blurry background
[WebKit-https.git] / Source / WebKit2 / Shared / mac / RemoteLayerTreeTransaction.mm
1 /*
2  * Copyright (C) 2012 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #import "config.h"
27 #import "RemoteLayerTreeTransaction.h"
28
29 #import "ArgumentCoders.h"
30 #import "MessageDecoder.h"
31 #import "MessageEncoder.h"
32 #import "PlatformCAAnimationRemote.h"
33 #import "PlatformCALayerRemote.h"
34 #import "WebCoreArgumentCoders.h"
35 #import <QuartzCore/QuartzCore.h>
36 #import <WebCore/LengthFunctions.h>
37 #import <WebCore/TextStream.h>
38 #import <WebCore/TimingFunction.h>
39 #import <wtf/text/CString.h>
40 #import <wtf/text/StringBuilder.h>
41
42 using namespace WebCore;
43
44 namespace WebKit {
45
46 RemoteLayerTreeTransaction::LayerCreationProperties::LayerCreationProperties()
47     : layerID(0)
48     , type(PlatformCALayer::LayerTypeLayer)
49     , hostingContextID(0)
50     , hostingDeviceScaleFactor(1)
51 {
52 }
53
54 void RemoteLayerTreeTransaction::LayerCreationProperties::encode(IPC::ArgumentEncoder& encoder) const
55 {
56     encoder << layerID;
57     encoder.encodeEnum(type);
58     encoder << hostingContextID;
59     encoder << hostingDeviceScaleFactor;
60 }
61
62 bool RemoteLayerTreeTransaction::LayerCreationProperties::decode(IPC::ArgumentDecoder& decoder, LayerCreationProperties& result)
63 {
64     if (!decoder.decode(result.layerID))
65         return false;
66
67     if (!decoder.decodeEnum(result.type))
68         return false;
69
70     if (!decoder.decode(result.hostingContextID))
71         return false;
72
73     if (!decoder.decode(result.hostingDeviceScaleFactor))
74         return false;
75
76     return true;
77 }
78
79 RemoteLayerTreeTransaction::LayerProperties::LayerProperties()
80     : changedProperties(NoChange)
81     , everChangedProperties(NoChange)
82     , anchorPoint(0.5, 0.5, 0)
83     , contentsRect(FloatPoint(), FloatSize(1, 1))
84     , maskLayerID(0)
85     , clonedLayerID(0)
86     , timeOffset(0)
87     , speed(1)
88     , contentsScale(1)
89     , cornerRadius(0)
90     , borderWidth(0)
91     , opacity(1)
92     , backgroundColor(Color::transparent)
93     , borderColor(Color::black)
94     , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
95     , customAppearance(GraphicsLayer::NoCustomAppearance)
96     , minificationFilter(PlatformCALayer::FilterType::Linear)
97     , magnificationFilter(PlatformCALayer::FilterType::Linear)
98     , blendMode(BlendModeNormal)
99     , windRule(RULE_NONZERO)
100     , hidden(false)
101     , geometryFlipped(false)
102     , doubleSided(true)
103     , masksToBounds(false)
104     , opaque(false)
105 {
106 }
107
108 RemoteLayerTreeTransaction::LayerProperties::LayerProperties(const LayerProperties& other)
109     : changedProperties(other.changedProperties)
110     , everChangedProperties(other.everChangedProperties)
111     , name(other.name)
112     , children(other.children)
113     , addedAnimations(other.addedAnimations)
114     , keyPathsOfAnimationsToRemove(other.keyPathsOfAnimationsToRemove)
115     , position(other.position)
116     , anchorPoint(other.anchorPoint)
117     , bounds(other.bounds)
118     , contentsRect(other.contentsRect)
119     , shapePath(other.shapePath)
120     , maskLayerID(other.maskLayerID)
121     , clonedLayerID(other.clonedLayerID)
122     , timeOffset(other.timeOffset)
123     , speed(other.speed)
124     , contentsScale(other.contentsScale)
125     , cornerRadius(other.cornerRadius)
126     , borderWidth(other.borderWidth)
127     , opacity(other.opacity)
128     , backgroundColor(other.backgroundColor)
129     , borderColor(other.borderColor)
130     , edgeAntialiasingMask(other.edgeAntialiasingMask)
131     , customAppearance(other.customAppearance)
132     , minificationFilter(other.minificationFilter)
133     , magnificationFilter(other.magnificationFilter)
134     , blendMode(other.blendMode)
135     , windRule(other.windRule)
136     , hidden(other.hidden)
137     , geometryFlipped(other.geometryFlipped)
138     , doubleSided(other.doubleSided)
139     , masksToBounds(other.masksToBounds)
140     , opaque(other.opaque)
141 {
142     // FIXME: LayerProperties should reference backing store by ID, so that two layers can have the same backing store (for clones).
143     // FIXME: LayerProperties shouldn't be copyable; PlatformCALayerRemote::clone should copy the relevant properties.
144
145     if (other.transform)
146         transform = std::make_unique<TransformationMatrix>(*other.transform);
147
148     if (other.sublayerTransform)
149         sublayerTransform = std::make_unique<TransformationMatrix>(*other.sublayerTransform);
150
151     if (other.filters)
152         filters = std::make_unique<FilterOperations>(*other.filters);
153 }
154
155 void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::ArgumentEncoder& encoder) const
156 {
157     encoder.encodeEnum(changedProperties);
158
159     if (changedProperties & NameChanged)
160         encoder << name;
161
162     if (changedProperties & ChildrenChanged)
163         encoder << children;
164
165     if (changedProperties & AnimationsChanged) {
166         encoder << addedAnimations;
167         encoder << keyPathsOfAnimationsToRemove;
168     }
169
170     if (changedProperties & PositionChanged)
171         encoder << position;
172
173     if (changedProperties & BoundsChanged)
174         encoder << bounds;
175
176     if (changedProperties & BackgroundColorChanged)
177         encoder << backgroundColor;
178
179     if (changedProperties & AnchorPointChanged)
180         encoder << anchorPoint;
181
182     if (changedProperties & BorderWidthChanged)
183         encoder << borderWidth;
184
185     if (changedProperties & BorderColorChanged)
186         encoder << borderColor;
187
188     if (changedProperties & OpacityChanged)
189         encoder << opacity;
190
191     if (changedProperties & TransformChanged)
192         encoder << *transform;
193
194     if (changedProperties & SublayerTransformChanged)
195         encoder << *sublayerTransform;
196
197     if (changedProperties & HiddenChanged)
198         encoder << hidden;
199
200     if (changedProperties & GeometryFlippedChanged)
201         encoder << geometryFlipped;
202
203     if (changedProperties & DoubleSidedChanged)
204         encoder << doubleSided;
205
206     if (changedProperties & MasksToBoundsChanged)
207         encoder << masksToBounds;
208
209     if (changedProperties & OpaqueChanged)
210         encoder << opaque;
211
212     if (changedProperties & MaskLayerChanged)
213         encoder << maskLayerID;
214
215     if (changedProperties & ClonedContentsChanged)
216         encoder << clonedLayerID;
217
218     if (changedProperties & ContentsRectChanged)
219         encoder << contentsRect;
220
221     if (changedProperties & ContentsScaleChanged)
222         encoder << contentsScale;
223
224     if (changedProperties & CornerRadiusChanged)
225         encoder << cornerRadius;
226
227     if (changedProperties & ShapeRoundedRectChanged)
228         encoder << *shapeRoundedRect;
229
230     if (changedProperties & ShapePathChanged)
231         encoder << shapePath;
232
233     if (changedProperties & MinificationFilterChanged)
234         encoder.encodeEnum(minificationFilter);
235
236     if (changedProperties & MagnificationFilterChanged)
237         encoder.encodeEnum(magnificationFilter);
238
239     if (changedProperties & BlendModeChanged)
240         encoder.encodeEnum(blendMode);
241
242     if (changedProperties & WindRuleChanged)
243         encoder.encodeEnum(windRule);
244
245     if (changedProperties & SpeedChanged)
246         encoder << speed;
247
248     if (changedProperties & TimeOffsetChanged)
249         encoder << timeOffset;
250
251     if (changedProperties & BackingStoreChanged) {
252         bool hasFrontBuffer = backingStore && backingStore->hasFrontBuffer();
253         encoder << hasFrontBuffer;
254         if (hasFrontBuffer)
255             encoder << *backingStore;
256     }
257
258     if (changedProperties & FiltersChanged)
259         encoder << *filters;
260
261     if (changedProperties & EdgeAntialiasingMaskChanged)
262         encoder << edgeAntialiasingMask;
263
264     if (changedProperties & CustomAppearanceChanged)
265         encoder.encodeEnum(customAppearance);
266 }
267
268 bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& decoder, LayerProperties& result)
269 {
270     if (!decoder.decodeEnum(result.changedProperties))
271         return false;
272
273     if (result.changedProperties & NameChanged) {
274         if (!decoder.decode(result.name))
275             return false;
276     }
277
278     if (result.changedProperties & ChildrenChanged) {
279         if (!decoder.decode(result.children))
280             return false;
281
282         for (auto& layerID : result.children) {
283             if (!layerID)
284                 return false;
285         }
286     }
287
288     if (result.changedProperties & AnimationsChanged) {
289         if (!decoder.decode(result.addedAnimations))
290             return false;
291
292         if (!decoder.decode(result.keyPathsOfAnimationsToRemove))
293             return false;
294     }
295
296     if (result.changedProperties & PositionChanged) {
297         if (!decoder.decode(result.position))
298             return false;
299     }
300
301     if (result.changedProperties & BoundsChanged) {
302         if (!decoder.decode(result.bounds))
303             return false;
304     }
305
306     if (result.changedProperties & BackgroundColorChanged) {
307         if (!decoder.decode(result.backgroundColor))
308             return false;
309     }
310
311     if (result.changedProperties & AnchorPointChanged) {
312         if (!decoder.decode(result.anchorPoint))
313             return false;
314     }
315
316     if (result.changedProperties & BorderWidthChanged) {
317         if (!decoder.decode(result.borderWidth))
318             return false;
319     }
320
321     if (result.changedProperties & BorderColorChanged) {
322         if (!decoder.decode(result.borderColor))
323             return false;
324     }
325
326     if (result.changedProperties & OpacityChanged) {
327         if (!decoder.decode(result.opacity))
328             return false;
329     }
330
331     if (result.changedProperties & TransformChanged) {
332         TransformationMatrix transform;
333         if (!decoder.decode(transform))
334             return false;
335         
336         result.transform = std::make_unique<TransformationMatrix>(transform);
337     }
338
339     if (result.changedProperties & SublayerTransformChanged) {
340         TransformationMatrix transform;
341         if (!decoder.decode(transform))
342             return false;
343
344         result.sublayerTransform = std::make_unique<TransformationMatrix>(transform);
345     }
346
347     if (result.changedProperties & HiddenChanged) {
348         if (!decoder.decode(result.hidden))
349             return false;
350     }
351
352     if (result.changedProperties & GeometryFlippedChanged) {
353         if (!decoder.decode(result.geometryFlipped))
354             return false;
355     }
356
357     if (result.changedProperties & DoubleSidedChanged) {
358         if (!decoder.decode(result.doubleSided))
359             return false;
360     }
361
362     if (result.changedProperties & MasksToBoundsChanged) {
363         if (!decoder.decode(result.masksToBounds))
364             return false;
365     }
366
367     if (result.changedProperties & OpaqueChanged) {
368         if (!decoder.decode(result.opaque))
369             return false;
370     }
371
372     if (result.changedProperties & MaskLayerChanged) {
373         if (!decoder.decode(result.maskLayerID))
374             return false;
375     }
376
377     if (result.changedProperties & ClonedContentsChanged) {
378         if (!decoder.decode(result.clonedLayerID))
379             return false;
380     }
381
382     if (result.changedProperties & ContentsRectChanged) {
383         if (!decoder.decode(result.contentsRect))
384             return false;
385     }
386
387     if (result.changedProperties & ContentsScaleChanged) {
388         if (!decoder.decode(result.contentsScale))
389             return false;
390     }
391
392     if (result.changedProperties & CornerRadiusChanged) {
393         if (!decoder.decode(result.cornerRadius))
394             return false;
395     }
396
397     if (result.changedProperties & ShapeRoundedRectChanged) {
398         FloatRoundedRect roundedRect;
399         if (!decoder.decode(roundedRect))
400             return false;
401         
402         result.shapeRoundedRect = std::make_unique<FloatRoundedRect>(roundedRect);
403     }
404
405     if (result.changedProperties & ShapePathChanged) {
406         Path path;
407         if (!decoder.decode(path))
408             return false;
409         
410         result.shapePath = WTF::move(path);
411     }
412
413     if (result.changedProperties & MinificationFilterChanged) {
414         if (!decoder.decodeEnum(result.minificationFilter))
415             return false;
416     }
417
418     if (result.changedProperties & MagnificationFilterChanged) {
419         if (!decoder.decodeEnum(result.magnificationFilter))
420             return false;
421     }
422
423     if (result.changedProperties & BlendModeChanged) {
424         if (!decoder.decodeEnum(result.blendMode))
425             return false;
426     }
427
428     if (result.changedProperties & WindRuleChanged) {
429         if (!decoder.decodeEnum(result.windRule))
430             return false;
431     }
432
433     if (result.changedProperties & SpeedChanged) {
434         if (!decoder.decode(result.speed))
435             return false;
436     }
437
438     if (result.changedProperties & TimeOffsetChanged) {
439         if (!decoder.decode(result.timeOffset))
440             return false;
441     }
442
443     if (result.changedProperties & BackingStoreChanged) {
444         bool hasFrontBuffer = false;
445         if (!decoder.decode(hasFrontBuffer))
446             return false;
447         if (hasFrontBuffer) {
448             std::unique_ptr<RemoteLayerBackingStore> backingStore = std::make_unique<RemoteLayerBackingStore>(nullptr);
449             if (!decoder.decode(*backingStore))
450                 return false;
451             
452             result.backingStore = WTF::move(backingStore);
453         } else
454             result.backingStore = nullptr;
455     }
456
457     if (result.changedProperties & FiltersChanged) {
458         std::unique_ptr<FilterOperations> filters = std::make_unique<FilterOperations>();
459         if (!decoder.decode(*filters))
460             return false;
461         result.filters = WTF::move(filters);
462     }
463
464     if (result.changedProperties & EdgeAntialiasingMaskChanged) {
465         if (!decoder.decode(result.edgeAntialiasingMask))
466             return false;
467     }
468
469     if (result.changedProperties & CustomAppearanceChanged) {
470         if (!decoder.decodeEnum(result.customAppearance))
471             return false;
472     }
473
474     return true;
475 }
476
477 RemoteLayerTreeTransaction::RemoteLayerTreeTransaction()
478     : m_pageScaleFactor(1)
479     , m_minimumScaleFactor(1)
480     , m_maximumScaleFactor(1)
481     , m_renderTreeSize(0)
482     , m_transactionID(0)
483     , m_scaleWasSetByUIProcess(false)
484     , m_allowsUserScaling(false)
485 {
486 }
487
488 RemoteLayerTreeTransaction::~RemoteLayerTreeTransaction()
489 {
490 }
491
492 void RemoteLayerTreeTransaction::encode(IPC::ArgumentEncoder& encoder) const
493 {
494     encoder << m_rootLayerID;
495     encoder << m_createdLayers;
496
497     encoder << static_cast<uint64_t>(m_changedLayers.size());
498
499     for (RefPtr<PlatformCALayerRemote> layer : m_changedLayers) {
500         encoder << layer->layerID();
501         encoder << layer->properties();
502     }
503     
504     encoder << m_destroyedLayerIDs;
505     encoder << m_videoLayerIDsPendingFullscreen;
506     encoder << m_layerIDsWithNewlyUnreachableBackingStore;
507
508     encoder << m_contentsSize;
509 #if PLATFORM(MAC)
510     encoder << m_scrollPosition;
511 #endif
512     encoder << m_pageExtendedBackgroundColor;
513     encoder << m_pageScaleFactor;
514     encoder << m_minimumScaleFactor;
515     encoder << m_maximumScaleFactor;
516
517     encoder << m_renderTreeSize;
518     encoder << m_transactionID;
519
520     encoder << m_scaleWasSetByUIProcess;
521     encoder << m_allowsUserScaling;
522
523     encoder << m_callbackIDs;
524 }
525
526 bool RemoteLayerTreeTransaction::decode(IPC::ArgumentDecoder& decoder, RemoteLayerTreeTransaction& result)
527 {
528     if (!decoder.decode(result.m_rootLayerID))
529         return false;
530     if (!result.m_rootLayerID)
531         return false;
532
533     if (!decoder.decode(result.m_createdLayers))
534         return false;
535
536     uint64_t numChangedLayerProperties;
537     if (!decoder.decode(numChangedLayerProperties))
538         return false;
539
540     for (uint64_t i = 0; i < numChangedLayerProperties; ++i) {
541         GraphicsLayer::PlatformLayerID layerID;
542         if (!decoder.decode(layerID))
543             return false;
544
545         std::unique_ptr<LayerProperties> layerProperties = std::make_unique<LayerProperties>();
546         if (!decoder.decode(*layerProperties))
547             return false;
548
549         result.changedLayerProperties().set(layerID, WTF::move(layerProperties));
550     }
551
552     if (!decoder.decode(result.m_destroyedLayerIDs))
553         return false;
554
555     for (auto& layerID : result.m_destroyedLayerIDs) {
556         if (!layerID)
557             return false;
558     }
559
560     if (!decoder.decode(result.m_videoLayerIDsPendingFullscreen))
561         return false;
562
563     if (!decoder.decode(result.m_layerIDsWithNewlyUnreachableBackingStore))
564         return false;
565
566     for (auto& layerID : result.m_layerIDsWithNewlyUnreachableBackingStore) {
567         if (!layerID)
568             return false;
569     }
570
571     if (!decoder.decode(result.m_contentsSize))
572         return false;
573
574 #if PLATFORM(MAC)
575     if (!decoder.decode(result.m_scrollPosition))
576         return false;
577 #endif
578     
579     if (!decoder.decode(result.m_pageExtendedBackgroundColor))
580         return false;
581
582     if (!decoder.decode(result.m_pageScaleFactor))
583         return false;
584
585     if (!decoder.decode(result.m_minimumScaleFactor))
586         return false;
587
588     if (!decoder.decode(result.m_maximumScaleFactor))
589         return false;
590
591     if (!decoder.decode(result.m_renderTreeSize))
592         return false;
593
594     if (!decoder.decode(result.m_transactionID))
595         return false;
596
597     if (!decoder.decode(result.m_scaleWasSetByUIProcess))
598         return false;
599
600     if (!decoder.decode(result.m_allowsUserScaling))
601         return false;
602
603     if (!decoder.decode(result.m_callbackIDs))
604         return false;
605
606     return true;
607 }
608
609 void RemoteLayerTreeTransaction::setRootLayerID(GraphicsLayer::PlatformLayerID rootLayerID)
610 {
611     ASSERT_ARG(rootLayerID, rootLayerID);
612
613     m_rootLayerID = rootLayerID;
614 }
615
616 void RemoteLayerTreeTransaction::layerPropertiesChanged(PlatformCALayerRemote& remoteLayer)
617 {
618     m_changedLayers.append(&remoteLayer);
619 }
620
621 void RemoteLayerTreeTransaction::setCreatedLayers(Vector<LayerCreationProperties> createdLayers)
622 {
623     m_createdLayers = WTF::move(createdLayers);
624 }
625
626 void RemoteLayerTreeTransaction::setDestroyedLayerIDs(Vector<GraphicsLayer::PlatformLayerID> destroyedLayerIDs)
627 {
628     m_destroyedLayerIDs = WTF::move(destroyedLayerIDs);
629 }
630
631 void RemoteLayerTreeTransaction::setLayerIDsWithNewlyUnreachableBackingStore(Vector<GraphicsLayer::PlatformLayerID> layerIDsWithNewlyUnreachableBackingStore)
632 {
633     m_layerIDsWithNewlyUnreachableBackingStore = WTF::move(layerIDsWithNewlyUnreachableBackingStore);
634 }
635
636 #if !defined(NDEBUG) || !LOG_DISABLED
637
638 class RemoteLayerTreeTextStream : public TextStream
639 {
640 public:
641     using TextStream::operator<<;
642
643     RemoteLayerTreeTextStream()
644         : m_indent(0)
645     {
646     }
647
648     RemoteLayerTreeTextStream& operator<<(const TransformationMatrix&);
649     RemoteLayerTreeTextStream& operator<<(PlatformCALayer::FilterType);
650     RemoteLayerTreeTextStream& operator<<(const FloatRoundedRect&);
651     RemoteLayerTreeTextStream& operator<<(FloatPoint3D);
652     RemoteLayerTreeTextStream& operator<<(Color);
653     RemoteLayerTreeTextStream& operator<<(FloatRect);
654     RemoteLayerTreeTextStream& operator<<(const Vector<WebCore::GraphicsLayer::PlatformLayerID>&);
655     RemoteLayerTreeTextStream& operator<<(const FilterOperation&);
656     RemoteLayerTreeTextStream& operator<<(const FilterOperations&);
657     RemoteLayerTreeTextStream& operator<<(const PlatformCAAnimationRemote::Properties&);
658     RemoteLayerTreeTextStream& operator<<(const RemoteLayerBackingStore&);
659     RemoteLayerTreeTextStream& operator<<(BlendMode);
660     RemoteLayerTreeTextStream& operator<<(PlatformCAAnimation::AnimationType);
661     RemoteLayerTreeTextStream& operator<<(PlatformCAAnimation::FillModeType);
662     RemoteLayerTreeTextStream& operator<<(PlatformCAAnimation::ValueFunctionType);
663     RemoteLayerTreeTextStream& operator<<(const TimingFunction&);
664     RemoteLayerTreeTextStream& operator<<(const PlatformCAAnimationRemote::KeyframeValue&);
665
666     void increaseIndent() { ++m_indent; }
667     void decreaseIndent() { --m_indent; ASSERT(m_indent >= 0); }
668
669     void writeIndent();
670
671 private:
672     int m_indent;
673 };
674
675 template <class T>
676 static void dumpProperty(RemoteLayerTreeTextStream& ts, String name, T value)
677 {
678     ts << "\n";
679     ts.increaseIndent();
680     ts.writeIndent();
681     ts << "(" << name << " ";
682     ts << value << ")";
683     ts.decreaseIndent();
684 }
685
686 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const TransformationMatrix& transform)
687 {
688     RemoteLayerTreeTextStream& ts = *this;
689     ts << "\n";
690     ts.increaseIndent();
691     ts.writeIndent();
692     ts << "[" << transform.m11() << " " << transform.m12() << " " << transform.m13() << " " << transform.m14() << "]\n";
693     ts.writeIndent();
694     ts << "[" << transform.m21() << " " << transform.m22() << " " << transform.m23() << " " << transform.m24() << "]\n";
695     ts.writeIndent();
696     ts << "[" << transform.m31() << " " << transform.m32() << " " << transform.m33() << " " << transform.m34() << "]\n";
697     ts.writeIndent();
698     ts << "[" << transform.m41() << " " << transform.m42() << " " << transform.m43() << " " << transform.m44() << "]";
699     ts.decreaseIndent();
700     return ts;
701 }
702
703 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const FloatRoundedRect& roundedRect)
704 {
705     RemoteLayerTreeTextStream& ts = *this;
706     ts << roundedRect.rect().x() << " " << roundedRect.rect().y() << " " << roundedRect.rect().width() << " " << roundedRect.rect().height() << "\n";
707
708     ts.increaseIndent();
709     ts.writeIndent();
710     ts << "topLeft=" << roundedRect.topLeftCorner().width() << " " << roundedRect.topLeftCorner().height() << "\n";
711     ts.writeIndent();
712     ts << "topRight=" << roundedRect.topRightCorner().width() << " " << roundedRect.topRightCorner().height() << "\n";
713     ts.writeIndent();
714     ts << "bottomLeft=" << roundedRect.bottomLeftCorner().width() << " " << roundedRect.bottomLeftCorner().height() << "\n";
715     ts.writeIndent();
716     ts << "bottomRight=" << roundedRect.bottomRightCorner().width() << " " << roundedRect.bottomRightCorner().height();
717     ts.decreaseIndent();
718
719     return ts;
720 }
721
722 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCALayer::FilterType filterType)
723 {
724     RemoteLayerTreeTextStream& ts = *this;
725     switch (filterType) {
726     case PlatformCALayer::Linear:
727         ts << "linear";
728         break;
729     case PlatformCALayer::Nearest:
730         ts << "nearest";
731         break;
732     case PlatformCALayer::Trilinear:
733         ts << "trilinear";
734         break;
735     default:
736         ASSERT_NOT_REACHED();
737         break;
738     }
739     return ts;
740 }
741
742 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const FilterOperations& filters)
743 {
744     RemoteLayerTreeTextStream& ts = *this;
745     for (size_t i = 0; i < filters.size(); ++i) {
746         const auto filter = filters.at(i);
747         if (filter)
748             ts << *filter;
749         else
750             ts << "(null)";
751         if (i < filters.size() - 1)
752             ts << " ";
753     }
754     return ts;
755 }
756     
757 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const FilterOperation& filter)
758 {
759     RemoteLayerTreeTextStream& ts = *this;
760     switch (filter.type()) {
761     case FilterOperation::REFERENCE:
762         ts << "reference";
763         break;
764     case FilterOperation::GRAYSCALE: {
765         const auto& colorMatrixFilter = downcast<BasicColorMatrixFilterOperation>(filter);
766         ts << "grayscale(" << colorMatrixFilter.amount() << ")";
767         break;
768     }
769     case FilterOperation::SEPIA: {
770         const auto& colorMatrixFilter = downcast<BasicColorMatrixFilterOperation>(filter);
771         ts << "sepia(" << colorMatrixFilter.amount() << ")";
772         break;
773     }
774     case FilterOperation::SATURATE: {
775         const auto& colorMatrixFilter = downcast<BasicColorMatrixFilterOperation>(filter);
776         ts << "saturate(" << colorMatrixFilter.amount() << ")";
777         break;
778     }
779     case FilterOperation::HUE_ROTATE: {
780         const auto& colorMatrixFilter = downcast<BasicColorMatrixFilterOperation>(filter);
781         ts << "hue-rotate(" << colorMatrixFilter.amount() << ")";
782         break;
783     }
784     case FilterOperation::INVERT: {
785         const auto& componentTransferFilter = downcast<BasicComponentTransferFilterOperation>(filter);
786         ts << "invert(" << componentTransferFilter.amount() << ")";
787         break;
788     }
789     case FilterOperation::OPACITY: {
790         const auto& componentTransferFilter = downcast<BasicComponentTransferFilterOperation>(filter);
791         ts << "opacity(" << componentTransferFilter.amount() << ")";
792         break;
793     }
794     case FilterOperation::BRIGHTNESS: {
795         const auto& componentTransferFilter = downcast<BasicComponentTransferFilterOperation>(filter);
796         ts << "brightness(" << componentTransferFilter.amount() << ")";
797         break;
798     }
799     case FilterOperation::CONTRAST: {
800         const auto& componentTransferFilter = downcast<BasicComponentTransferFilterOperation>(filter);
801         ts << "contrast(" << componentTransferFilter.amount() << ")";
802         break;
803     }
804     case FilterOperation::BLUR: {
805         const auto& blurFilter = downcast<BlurFilterOperation>(filter);
806         ts << "blur(" << floatValueForLength(blurFilter.stdDeviation(), 0) << ")";
807         break;
808     }
809     case FilterOperation::DROP_SHADOW: {
810         const auto& dropShadowFilter = downcast<DropShadowFilterOperation>(filter);
811         ts << "drop-shadow(" << dropShadowFilter.x() << " " << dropShadowFilter.y() << " " << dropShadowFilter.location() << " ";
812         ts << dropShadowFilter.color() << ")";
813         break;
814     }
815     case FilterOperation::PASSTHROUGH:
816         ts << "passthrough";
817         break;
818     case FilterOperation::DEFAULT: {
819         const auto& defaultFilter = downcast<DefaultFilterOperation>(filter);
820         ts << "default type=" << (int)defaultFilter.representedType();
821         break;
822     }
823     case FilterOperation::NONE:
824         ts << "none";
825         break;
826     }
827     return ts;
828 }
829
830 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(BlendMode blendMode)
831 {
832     RemoteLayerTreeTextStream& ts = *this;
833     switch (blendMode) {
834     case BlendModeNormal: ts << "normal"; break;
835     case BlendModeMultiply: ts << "multiply"; break;
836     case BlendModeScreen: ts << "screen"; break;
837     case BlendModeOverlay: ts << "overlay"; break;
838     case BlendModeDarken: ts << "darken"; break;
839     case BlendModeLighten: ts << "lighten"; break;
840     case BlendModeColorDodge: ts << "color-dodge"; break;
841     case BlendModeColorBurn: ts << "color-burn"; break;
842     case BlendModeHardLight: ts << "hard-light"; break;
843     case BlendModeSoftLight: ts << "soft-light"; break;
844     case BlendModeDifference: ts << "difference"; break;
845     case BlendModeExclusion: ts << "exclusion"; break;
846     case BlendModeHue: ts << "hue"; break;
847     case BlendModeSaturation: ts << "saturation"; break;
848     case BlendModeColor: ts << "color"; break;
849     case BlendModeLuminosity: ts << "luminosity"; break;
850     case BlendModePlusDarker: ts << "plus-darker"; break;
851     }
852     return ts;
853 }
854
855 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCAAnimation::AnimationType type)
856 {
857     RemoteLayerTreeTextStream& ts = *this;
858     switch (type) {
859     case PlatformCAAnimation::Basic: ts << "basic"; break;
860     case PlatformCAAnimation::Keyframe: ts << "keyframe"; break;
861     }
862     return ts;
863 }
864
865 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCAAnimation::FillModeType type)
866 {
867     RemoteLayerTreeTextStream& ts = *this;
868     switch (type) {
869     case PlatformCAAnimation::NoFillMode: ts << "none"; break;
870     case PlatformCAAnimation::Forwards: ts << "forwards"; break;
871     case PlatformCAAnimation::Backwards: ts << "backwards"; break;
872     case PlatformCAAnimation::Both: ts << "both"; break;
873     }
874     return ts;
875 }
876
877 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCAAnimation::ValueFunctionType type)
878 {
879     RemoteLayerTreeTextStream& ts = *this;
880     switch (type) {
881     case PlatformCAAnimation::NoValueFunction: ts << "none"; break;
882     case PlatformCAAnimation::RotateX: ts << "rotateX"; break;
883     case PlatformCAAnimation::RotateY: ts << "rotateY"; break;
884     case PlatformCAAnimation::RotateZ: ts << "rotateX"; break;
885     case PlatformCAAnimation::ScaleX: ts << "scaleX"; break;
886     case PlatformCAAnimation::ScaleY: ts << "scaleY"; break;
887     case PlatformCAAnimation::ScaleZ: ts << "scaleX"; break;
888     case PlatformCAAnimation::Scale: ts << "scale"; break;
889     case PlatformCAAnimation::TranslateX: ts << "translateX"; break;
890     case PlatformCAAnimation::TranslateY: ts << "translateY"; break;
891     case PlatformCAAnimation::TranslateZ: ts << "translateZ"; break;
892     case PlatformCAAnimation::Translate: ts << "translate"; break;
893     }
894     return ts;
895 }
896
897 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const PlatformCAAnimationRemote::KeyframeValue& value)
898 {
899     RemoteLayerTreeTextStream& ts = *this;
900
901     switch (value.keyframeType()) {
902     case PlatformCAAnimationRemote::KeyframeValue::NumberKeyType:
903         ts << "number=" << value.numberValue();
904         break;
905     case PlatformCAAnimationRemote::KeyframeValue::ColorKeyType:
906         ts << "color=";
907         ts << value.colorValue();
908         break;
909     case PlatformCAAnimationRemote::KeyframeValue::PointKeyType:
910         ts << "point=";
911         ts << value.pointValue();
912         break;
913     case PlatformCAAnimationRemote::KeyframeValue::TransformKeyType:
914         ts << "transform=";
915         ts << value.transformValue();
916         break;
917     case PlatformCAAnimationRemote::KeyframeValue::FilterKeyType:
918         ts << "filter=";
919         if (value.filterValue())
920             ts << *value.filterValue();
921         else
922             ts << "null";
923         break;
924     }
925     return ts;
926 }
927
928 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const TimingFunction& timingFunction)
929 {
930     RemoteLayerTreeTextStream& ts = *this;
931     switch (timingFunction.type()) {
932     case TimingFunction::LinearFunction:
933         ts << "linear";
934         break;
935     case TimingFunction::CubicBezierFunction: {
936         const CubicBezierTimingFunction& cubicBezierFunction = static_cast<const CubicBezierTimingFunction&>(timingFunction);
937         ts << "cubic-bezier(" << cubicBezierFunction.x1() << ", " << cubicBezierFunction.y1() << ", " <<  cubicBezierFunction.x2() << ", " << cubicBezierFunction.y2() << ")";
938         break;
939     }
940     case TimingFunction::StepsFunction: {
941         const StepsTimingFunction& stepsFunction = static_cast<const StepsTimingFunction&>(timingFunction);
942         ts << "steps(" << stepsFunction.numberOfSteps() << ", " << (stepsFunction.stepAtStart() ? "start" : "end") << ")";
943         break;
944     }
945     }
946     return ts;
947 }
948
949 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const PlatformCAAnimationRemote::Properties& animation)
950 {
951     RemoteLayerTreeTextStream& ts = *this;
952
953     ts << "type=";
954     ts << animation.animationType;
955     ts << " keyPath=";
956     ts << animation.keyPath;
957
958     if (animation.beginTime)
959         dumpProperty(ts, "beginTime", animation.beginTime);
960
961     if (animation.duration)
962         dumpProperty(ts, "duration", animation.duration);
963
964     if (animation.timeOffset)
965         dumpProperty(ts, "timeOffset", animation.timeOffset);
966
967     dumpProperty(ts, "repeatCount", animation.repeatCount);
968
969     if (animation.speed != 1)
970         dumpProperty(ts, "speed", animation.speed);
971
972     dumpProperty(ts, "fillMode", animation.fillMode);
973     dumpProperty(ts, "valueFunction", animation.valueFunction);
974
975     if (animation.autoReverses)
976         dumpProperty(ts, "autoReverses", animation.autoReverses);
977
978     if (!animation.removedOnCompletion)
979         dumpProperty(ts, "removedOnCompletion", animation.removedOnCompletion);
980
981     if (animation.additive)
982         dumpProperty(ts, "additive", animation.additive);
983
984     if (animation.reverseTimingFunctions)
985         dumpProperty(ts, "reverseTimingFunctions", animation.reverseTimingFunctions);
986
987     if (animation.hasExplicitBeginTime)
988         dumpProperty(ts, "hasExplicitBeginTime", animation.hasExplicitBeginTime);
989
990     ts << "\n";
991     ts.increaseIndent();
992     ts.writeIndent();
993     ts << "(" << "keyframes";
994     ts.increaseIndent();
995
996     size_t maxFrames = std::max(animation.keyValues.size(), animation.keyTimes.size());
997     maxFrames = std::max(maxFrames, animation.timingFunctions.size());
998
999     for (size_t i = 0; i < maxFrames; ++i) {
1000         ts << "\n";
1001         ts.writeIndent();
1002         ts << "(keyframe " << unsigned(i);
1003         if (i < animation.keyTimes.size())
1004             dumpProperty(ts, "time", animation.keyTimes[i]);
1005
1006         if (i < animation.timingFunctions.size() && animation.timingFunctions[i])
1007             dumpProperty<const TimingFunction&>(ts, "timing function", *animation.timingFunctions[i]);
1008
1009         if (i < animation.keyValues.size())
1010             dumpProperty(ts, "value", animation.keyValues[i]);
1011
1012         ts << ")";
1013     }
1014
1015     ts.decreaseIndent();
1016     ts.decreaseIndent();
1017
1018     return ts;
1019 }
1020
1021 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatPoint3D point)
1022 {
1023     RemoteLayerTreeTextStream& ts = *this;
1024     ts << point.x() << " " << point.y() << " " << point.z();
1025     return ts;
1026 }
1027
1028 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(Color color)
1029 {
1030     RemoteLayerTreeTextStream& ts = *this;
1031     ts << color.serialized();
1032     return ts;
1033 }
1034
1035 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatRect rect)
1036 {
1037     RemoteLayerTreeTextStream& ts = *this;
1038     ts << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height();
1039     return ts;
1040 }
1041
1042 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const Vector<GraphicsLayer::PlatformLayerID>& layers)
1043 {
1044     RemoteLayerTreeTextStream& ts = *this;
1045
1046     for (size_t i = 0; i < layers.size(); ++i) {
1047         if (i)
1048             ts << " ";
1049         ts << layers[i];
1050     }
1051
1052     return ts;
1053 }
1054
1055 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const RemoteLayerBackingStore& backingStore)
1056 {
1057     RemoteLayerTreeTextStream& ts = *this;
1058     ts << backingStore.size();
1059     ts << " scale=" << backingStore.scale();
1060     if (backingStore.isOpaque())
1061         ts << " opaque";
1062     if (backingStore.acceleratesDrawing())
1063         ts << " accelerated";
1064     return ts;
1065 }
1066
1067 void RemoteLayerTreeTextStream::writeIndent()
1068 {
1069     for (int i = 0; i < m_indent; ++i)
1070         *this << "  ";
1071 }
1072
1073 static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const RemoteLayerTreeTransaction::LayerPropertiesMap& changedLayerProperties)
1074 {
1075     if (changedLayerProperties.isEmpty())
1076         return;
1077
1078     ts << "\n";
1079     ts.writeIndent();
1080     ts << "(changed-layers";
1081
1082     // Dump the layer properties sorted by layer ID.
1083     Vector<GraphicsLayer::PlatformLayerID> layerIDs;
1084     copyKeysToVector(changedLayerProperties, layerIDs);
1085     std::sort(layerIDs.begin(), layerIDs.end());
1086
1087     for (auto& layerID : layerIDs) {
1088         const RemoteLayerTreeTransaction::LayerProperties& layerProperties = *changedLayerProperties.get(layerID);
1089
1090         ts << "\n";
1091         ts.increaseIndent();
1092         ts.writeIndent();
1093         ts << "(layer " << layerID;
1094
1095         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
1096             dumpProperty(ts, "name", layerProperties.name);
1097
1098         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged)
1099             dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "children", layerProperties.children);
1100
1101         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::PositionChanged)
1102             dumpProperty(ts, "position", layerProperties.position);
1103
1104         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BoundsChanged)
1105             dumpProperty(ts, "bounds", layerProperties.bounds);
1106
1107         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::AnchorPointChanged)
1108             dumpProperty(ts, "anchorPoint", layerProperties.anchorPoint);
1109
1110         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackgroundColorChanged)
1111             dumpProperty(ts, "backgroundColor", layerProperties.backgroundColor);
1112
1113         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderColorChanged)
1114             dumpProperty(ts, "borderColor", layerProperties.borderColor);
1115
1116         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderWidthChanged)
1117             dumpProperty(ts, "borderWidth", layerProperties.borderWidth);
1118
1119         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpacityChanged)
1120             dumpProperty(ts, "opacity", layerProperties.opacity);
1121
1122         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TransformChanged)
1123             dumpProperty(ts, "transform", layerProperties.transform ? *layerProperties.transform : TransformationMatrix());
1124
1125         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SublayerTransformChanged)
1126             dumpProperty(ts, "sublayerTransform", layerProperties.sublayerTransform ? *layerProperties.sublayerTransform : TransformationMatrix());
1127
1128         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::HiddenChanged)
1129             dumpProperty(ts, "hidden", layerProperties.hidden);
1130
1131         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::GeometryFlippedChanged)
1132             dumpProperty(ts, "geometryFlipped", layerProperties.geometryFlipped);
1133
1134         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::DoubleSidedChanged)
1135             dumpProperty(ts, "doubleSided", layerProperties.doubleSided);
1136
1137         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MasksToBoundsChanged)
1138             dumpProperty(ts, "masksToBounds", layerProperties.masksToBounds);
1139
1140         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpaqueChanged)
1141             dumpProperty(ts, "opaque", layerProperties.opaque);
1142
1143         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged)
1144             dumpProperty(ts, "maskLayer", layerProperties.maskLayerID);
1145
1146         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ClonedContentsChanged)
1147             dumpProperty(ts, "clonedLayer", layerProperties.clonedLayerID);
1148
1149         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsRectChanged)
1150             dumpProperty(ts, "contentsRect", layerProperties.contentsRect);
1151
1152         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsScaleChanged)
1153             dumpProperty(ts, "contentsScale", layerProperties.contentsScale);
1154
1155         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CornerRadiusChanged)
1156             dumpProperty(ts, "cornerRadius", layerProperties.cornerRadius);
1157
1158         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ShapeRoundedRectChanged)
1159             dumpProperty(ts, "shapeRect", layerProperties.shapeRoundedRect ? *layerProperties.shapeRoundedRect : FloatRoundedRect());
1160
1161         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
1162             dumpProperty(ts, "minificationFilter", layerProperties.minificationFilter);
1163
1164         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MagnificationFilterChanged)
1165             dumpProperty(ts, "magnificationFilter", layerProperties.magnificationFilter);
1166
1167         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BlendModeChanged)
1168             dumpProperty(ts, "blendMode", layerProperties.blendMode);
1169
1170         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SpeedChanged)
1171             dumpProperty(ts, "speed", layerProperties.speed);
1172
1173         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TimeOffsetChanged)
1174             dumpProperty(ts, "timeOffset", layerProperties.timeOffset);
1175
1176         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged) {
1177             if (const RemoteLayerBackingStore* backingStore = layerProperties.backingStore.get())
1178                 dumpProperty<const RemoteLayerBackingStore&>(ts, "backingStore", *backingStore);
1179             else
1180                 dumpProperty(ts, "backingStore", "removed");
1181         }
1182
1183         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
1184             dumpProperty(ts, "filters", layerProperties.filters ? *layerProperties.filters : FilterOperations());
1185
1186         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::AnimationsChanged) {
1187             for (const auto& keyAnimationPair : layerProperties.addedAnimations)
1188                 dumpProperty(ts, "animation " +  keyAnimationPair.first, keyAnimationPair.second);
1189
1190             for (const auto& name : layerProperties.keyPathsOfAnimationsToRemove)
1191                 dumpProperty(ts, "removed animation", name);
1192         }
1193
1194         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
1195             dumpProperty(ts, "edgeAntialiasingMask", layerProperties.edgeAntialiasingMask);
1196
1197         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomAppearanceChanged)
1198             dumpProperty(ts, "customAppearance", layerProperties.customAppearance);
1199
1200         ts << ")";
1201
1202         ts.decreaseIndent();
1203     }
1204
1205     ts.decreaseIndent();
1206 }
1207
1208 void RemoteLayerTreeTransaction::dump() const
1209 {
1210     fprintf(stderr, "%s", description().data());
1211 }
1212
1213 CString RemoteLayerTreeTransaction::description() const
1214 {
1215     RemoteLayerTreeTextStream ts;
1216
1217     ts << "(\n";
1218     ts.increaseIndent();
1219     ts.writeIndent();
1220     ts << "(root-layer " << m_rootLayerID << ")";
1221
1222     if (!m_createdLayers.isEmpty()) {
1223         ts << "\n";
1224         ts.writeIndent();
1225         ts << "(created-layers";
1226         ts.increaseIndent();
1227         for (const auto& createdLayer : m_createdLayers) {
1228             ts << "\n";
1229             ts.writeIndent();
1230             ts << "(";
1231             switch (createdLayer.type) {
1232             case PlatformCALayer::LayerTypeLayer:
1233             case PlatformCALayer::LayerTypeWebLayer:
1234             case PlatformCALayer::LayerTypeSimpleLayer:
1235                 ts << "layer";
1236                 break;
1237             case PlatformCALayer::LayerTypeTransformLayer:
1238                 ts << "transform-layer";
1239                 break;
1240             case PlatformCALayer::LayerTypeWebTiledLayer:
1241                 ts << "tiled-layer";
1242                 break;
1243             case PlatformCALayer::LayerTypeTiledBackingLayer:
1244                 ts << "tiled-backing-layer";
1245                 break;
1246             case PlatformCALayer::LayerTypePageTiledBackingLayer:
1247                 ts << "page-tiled-backing-layer";
1248                 break;
1249             case PlatformCALayer::LayerTypeTiledBackingTileLayer:
1250                 ts << "tiled-backing-tile";
1251                 break;
1252             case PlatformCALayer::LayerTypeRootLayer:
1253                 ts << "root-layer";
1254                 break;
1255             case PlatformCALayer::LayerTypeBackdropLayer:
1256                 ts << "backdrop-layer";
1257                 break;
1258             case PlatformCALayer::LayerTypeAVPlayerLayer:
1259                 ts << "av-player-layer (context-id " << createdLayer.hostingContextID << ")";
1260                 break;
1261             case PlatformCALayer::LayerTypeWebGLLayer:
1262                 ts << "web-gl-layer (context-id " << createdLayer.hostingContextID << ")";
1263                 break;
1264             case PlatformCALayer::LayerTypeShapeLayer:
1265                 ts << "shape-layer";
1266                 break;
1267             case PlatformCALayer::LayerTypeScrollingLayer:
1268                 ts << "scrolling-layer";
1269                 break;
1270             case PlatformCALayer::LayerTypeCustom:
1271                 ts << "custom-layer (context-id " << createdLayer.hostingContextID << ")";
1272                 break;
1273             case PlatformCALayer::LayerTypeLightSystemBackdropLayer:
1274                 ts << "light-system-backdrop-layer";
1275                 break;
1276             case PlatformCALayer::LayerTypeDarkSystemBackdropLayer:
1277                 ts << "dark-system-backdrop-layer";
1278                 break;
1279             }
1280             ts << " " << createdLayer.layerID << ")";
1281         }
1282         ts << ")";
1283         ts.decreaseIndent();
1284     }
1285
1286     dumpChangedLayers(ts, m_changedLayerProperties);
1287
1288     if (!m_destroyedLayerIDs.isEmpty())
1289         dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "destroyed-layers", m_destroyedLayerIDs);
1290
1291     ts << ")\n";
1292
1293     return ts.release().utf8();
1294 }
1295
1296 #endif // !defined(NDEBUG) || !LOG_DISABLED
1297
1298 } // namespace WebKit