Support "plus-lighter" in mix-blend mode
[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     case BlendModePlusLighter: ts << "plus-lighter"; break;
852     }
853     return ts;
854 }
855
856 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCAAnimation::AnimationType type)
857 {
858     RemoteLayerTreeTextStream& ts = *this;
859     switch (type) {
860     case PlatformCAAnimation::Basic: ts << "basic"; break;
861     case PlatformCAAnimation::Keyframe: ts << "keyframe"; break;
862     }
863     return ts;
864 }
865
866 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCAAnimation::FillModeType type)
867 {
868     RemoteLayerTreeTextStream& ts = *this;
869     switch (type) {
870     case PlatformCAAnimation::NoFillMode: ts << "none"; break;
871     case PlatformCAAnimation::Forwards: ts << "forwards"; break;
872     case PlatformCAAnimation::Backwards: ts << "backwards"; break;
873     case PlatformCAAnimation::Both: ts << "both"; break;
874     }
875     return ts;
876 }
877
878 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCAAnimation::ValueFunctionType type)
879 {
880     RemoteLayerTreeTextStream& ts = *this;
881     switch (type) {
882     case PlatformCAAnimation::NoValueFunction: ts << "none"; break;
883     case PlatformCAAnimation::RotateX: ts << "rotateX"; break;
884     case PlatformCAAnimation::RotateY: ts << "rotateY"; break;
885     case PlatformCAAnimation::RotateZ: ts << "rotateX"; break;
886     case PlatformCAAnimation::ScaleX: ts << "scaleX"; break;
887     case PlatformCAAnimation::ScaleY: ts << "scaleY"; break;
888     case PlatformCAAnimation::ScaleZ: ts << "scaleX"; break;
889     case PlatformCAAnimation::Scale: ts << "scale"; break;
890     case PlatformCAAnimation::TranslateX: ts << "translateX"; break;
891     case PlatformCAAnimation::TranslateY: ts << "translateY"; break;
892     case PlatformCAAnimation::TranslateZ: ts << "translateZ"; break;
893     case PlatformCAAnimation::Translate: ts << "translate"; break;
894     }
895     return ts;
896 }
897
898 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const PlatformCAAnimationRemote::KeyframeValue& value)
899 {
900     RemoteLayerTreeTextStream& ts = *this;
901
902     switch (value.keyframeType()) {
903     case PlatformCAAnimationRemote::KeyframeValue::NumberKeyType:
904         ts << "number=" << value.numberValue();
905         break;
906     case PlatformCAAnimationRemote::KeyframeValue::ColorKeyType:
907         ts << "color=";
908         ts << value.colorValue();
909         break;
910     case PlatformCAAnimationRemote::KeyframeValue::PointKeyType:
911         ts << "point=";
912         ts << value.pointValue();
913         break;
914     case PlatformCAAnimationRemote::KeyframeValue::TransformKeyType:
915         ts << "transform=";
916         ts << value.transformValue();
917         break;
918     case PlatformCAAnimationRemote::KeyframeValue::FilterKeyType:
919         ts << "filter=";
920         if (value.filterValue())
921             ts << *value.filterValue();
922         else
923             ts << "null";
924         break;
925     }
926     return ts;
927 }
928
929 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const TimingFunction& timingFunction)
930 {
931     RemoteLayerTreeTextStream& ts = *this;
932     switch (timingFunction.type()) {
933     case TimingFunction::LinearFunction:
934         ts << "linear";
935         break;
936     case TimingFunction::CubicBezierFunction: {
937         const CubicBezierTimingFunction& cubicBezierFunction = static_cast<const CubicBezierTimingFunction&>(timingFunction);
938         ts << "cubic-bezier(" << cubicBezierFunction.x1() << ", " << cubicBezierFunction.y1() << ", " <<  cubicBezierFunction.x2() << ", " << cubicBezierFunction.y2() << ")";
939         break;
940     }
941     case TimingFunction::StepsFunction: {
942         const StepsTimingFunction& stepsFunction = static_cast<const StepsTimingFunction&>(timingFunction);
943         ts << "steps(" << stepsFunction.numberOfSteps() << ", " << (stepsFunction.stepAtStart() ? "start" : "end") << ")";
944         break;
945     }
946     }
947     return ts;
948 }
949
950 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const PlatformCAAnimationRemote::Properties& animation)
951 {
952     RemoteLayerTreeTextStream& ts = *this;
953
954     ts << "type=";
955     ts << animation.animationType;
956     ts << " keyPath=";
957     ts << animation.keyPath;
958
959     if (animation.beginTime)
960         dumpProperty(ts, "beginTime", animation.beginTime);
961
962     if (animation.duration)
963         dumpProperty(ts, "duration", animation.duration);
964
965     if (animation.timeOffset)
966         dumpProperty(ts, "timeOffset", animation.timeOffset);
967
968     dumpProperty(ts, "repeatCount", animation.repeatCount);
969
970     if (animation.speed != 1)
971         dumpProperty(ts, "speed", animation.speed);
972
973     dumpProperty(ts, "fillMode", animation.fillMode);
974     dumpProperty(ts, "valueFunction", animation.valueFunction);
975
976     if (animation.autoReverses)
977         dumpProperty(ts, "autoReverses", animation.autoReverses);
978
979     if (!animation.removedOnCompletion)
980         dumpProperty(ts, "removedOnCompletion", animation.removedOnCompletion);
981
982     if (animation.additive)
983         dumpProperty(ts, "additive", animation.additive);
984
985     if (animation.reverseTimingFunctions)
986         dumpProperty(ts, "reverseTimingFunctions", animation.reverseTimingFunctions);
987
988     if (animation.hasExplicitBeginTime)
989         dumpProperty(ts, "hasExplicitBeginTime", animation.hasExplicitBeginTime);
990
991     ts << "\n";
992     ts.increaseIndent();
993     ts.writeIndent();
994     ts << "(" << "keyframes";
995     ts.increaseIndent();
996
997     size_t maxFrames = std::max(animation.keyValues.size(), animation.keyTimes.size());
998     maxFrames = std::max(maxFrames, animation.timingFunctions.size());
999
1000     for (size_t i = 0; i < maxFrames; ++i) {
1001         ts << "\n";
1002         ts.writeIndent();
1003         ts << "(keyframe " << unsigned(i);
1004         if (i < animation.keyTimes.size())
1005             dumpProperty(ts, "time", animation.keyTimes[i]);
1006
1007         if (i < animation.timingFunctions.size() && animation.timingFunctions[i])
1008             dumpProperty<const TimingFunction&>(ts, "timing function", *animation.timingFunctions[i]);
1009
1010         if (i < animation.keyValues.size())
1011             dumpProperty(ts, "value", animation.keyValues[i]);
1012
1013         ts << ")";
1014     }
1015
1016     ts.decreaseIndent();
1017     ts.decreaseIndent();
1018
1019     return ts;
1020 }
1021
1022 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatPoint3D point)
1023 {
1024     RemoteLayerTreeTextStream& ts = *this;
1025     ts << point.x() << " " << point.y() << " " << point.z();
1026     return ts;
1027 }
1028
1029 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(Color color)
1030 {
1031     RemoteLayerTreeTextStream& ts = *this;
1032     ts << color.serialized();
1033     return ts;
1034 }
1035
1036 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatRect rect)
1037 {
1038     RemoteLayerTreeTextStream& ts = *this;
1039     ts << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height();
1040     return ts;
1041 }
1042
1043 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const Vector<GraphicsLayer::PlatformLayerID>& layers)
1044 {
1045     RemoteLayerTreeTextStream& ts = *this;
1046
1047     for (size_t i = 0; i < layers.size(); ++i) {
1048         if (i)
1049             ts << " ";
1050         ts << layers[i];
1051     }
1052
1053     return ts;
1054 }
1055
1056 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const RemoteLayerBackingStore& backingStore)
1057 {
1058     RemoteLayerTreeTextStream& ts = *this;
1059     ts << backingStore.size();
1060     ts << " scale=" << backingStore.scale();
1061     if (backingStore.isOpaque())
1062         ts << " opaque";
1063     if (backingStore.acceleratesDrawing())
1064         ts << " accelerated";
1065     return ts;
1066 }
1067
1068 void RemoteLayerTreeTextStream::writeIndent()
1069 {
1070     for (int i = 0; i < m_indent; ++i)
1071         *this << "  ";
1072 }
1073
1074 static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const RemoteLayerTreeTransaction::LayerPropertiesMap& changedLayerProperties)
1075 {
1076     if (changedLayerProperties.isEmpty())
1077         return;
1078
1079     ts << "\n";
1080     ts.writeIndent();
1081     ts << "(changed-layers";
1082
1083     // Dump the layer properties sorted by layer ID.
1084     Vector<GraphicsLayer::PlatformLayerID> layerIDs;
1085     copyKeysToVector(changedLayerProperties, layerIDs);
1086     std::sort(layerIDs.begin(), layerIDs.end());
1087
1088     for (auto& layerID : layerIDs) {
1089         const RemoteLayerTreeTransaction::LayerProperties& layerProperties = *changedLayerProperties.get(layerID);
1090
1091         ts << "\n";
1092         ts.increaseIndent();
1093         ts.writeIndent();
1094         ts << "(layer " << layerID;
1095
1096         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
1097             dumpProperty(ts, "name", layerProperties.name);
1098
1099         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged)
1100             dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "children", layerProperties.children);
1101
1102         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::PositionChanged)
1103             dumpProperty(ts, "position", layerProperties.position);
1104
1105         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BoundsChanged)
1106             dumpProperty(ts, "bounds", layerProperties.bounds);
1107
1108         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::AnchorPointChanged)
1109             dumpProperty(ts, "anchorPoint", layerProperties.anchorPoint);
1110
1111         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackgroundColorChanged)
1112             dumpProperty(ts, "backgroundColor", layerProperties.backgroundColor);
1113
1114         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderColorChanged)
1115             dumpProperty(ts, "borderColor", layerProperties.borderColor);
1116
1117         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderWidthChanged)
1118             dumpProperty(ts, "borderWidth", layerProperties.borderWidth);
1119
1120         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpacityChanged)
1121             dumpProperty(ts, "opacity", layerProperties.opacity);
1122
1123         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TransformChanged)
1124             dumpProperty(ts, "transform", layerProperties.transform ? *layerProperties.transform : TransformationMatrix());
1125
1126         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SublayerTransformChanged)
1127             dumpProperty(ts, "sublayerTransform", layerProperties.sublayerTransform ? *layerProperties.sublayerTransform : TransformationMatrix());
1128
1129         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::HiddenChanged)
1130             dumpProperty(ts, "hidden", layerProperties.hidden);
1131
1132         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::GeometryFlippedChanged)
1133             dumpProperty(ts, "geometryFlipped", layerProperties.geometryFlipped);
1134
1135         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::DoubleSidedChanged)
1136             dumpProperty(ts, "doubleSided", layerProperties.doubleSided);
1137
1138         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MasksToBoundsChanged)
1139             dumpProperty(ts, "masksToBounds", layerProperties.masksToBounds);
1140
1141         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpaqueChanged)
1142             dumpProperty(ts, "opaque", layerProperties.opaque);
1143
1144         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged)
1145             dumpProperty(ts, "maskLayer", layerProperties.maskLayerID);
1146
1147         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ClonedContentsChanged)
1148             dumpProperty(ts, "clonedLayer", layerProperties.clonedLayerID);
1149
1150         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsRectChanged)
1151             dumpProperty(ts, "contentsRect", layerProperties.contentsRect);
1152
1153         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsScaleChanged)
1154             dumpProperty(ts, "contentsScale", layerProperties.contentsScale);
1155
1156         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CornerRadiusChanged)
1157             dumpProperty(ts, "cornerRadius", layerProperties.cornerRadius);
1158
1159         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ShapeRoundedRectChanged)
1160             dumpProperty(ts, "shapeRect", layerProperties.shapeRoundedRect ? *layerProperties.shapeRoundedRect : FloatRoundedRect());
1161
1162         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
1163             dumpProperty(ts, "minificationFilter", layerProperties.minificationFilter);
1164
1165         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MagnificationFilterChanged)
1166             dumpProperty(ts, "magnificationFilter", layerProperties.magnificationFilter);
1167
1168         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BlendModeChanged)
1169             dumpProperty(ts, "blendMode", layerProperties.blendMode);
1170
1171         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SpeedChanged)
1172             dumpProperty(ts, "speed", layerProperties.speed);
1173
1174         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TimeOffsetChanged)
1175             dumpProperty(ts, "timeOffset", layerProperties.timeOffset);
1176
1177         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged) {
1178             if (const RemoteLayerBackingStore* backingStore = layerProperties.backingStore.get())
1179                 dumpProperty<const RemoteLayerBackingStore&>(ts, "backingStore", *backingStore);
1180             else
1181                 dumpProperty(ts, "backingStore", "removed");
1182         }
1183
1184         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
1185             dumpProperty(ts, "filters", layerProperties.filters ? *layerProperties.filters : FilterOperations());
1186
1187         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::AnimationsChanged) {
1188             for (const auto& keyAnimationPair : layerProperties.addedAnimations)
1189                 dumpProperty(ts, "animation " +  keyAnimationPair.first, keyAnimationPair.second);
1190
1191             for (const auto& name : layerProperties.keyPathsOfAnimationsToRemove)
1192                 dumpProperty(ts, "removed animation", name);
1193         }
1194
1195         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
1196             dumpProperty(ts, "edgeAntialiasingMask", layerProperties.edgeAntialiasingMask);
1197
1198         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomAppearanceChanged)
1199             dumpProperty(ts, "customAppearance", layerProperties.customAppearance);
1200
1201         ts << ")";
1202
1203         ts.decreaseIndent();
1204     }
1205
1206     ts.decreaseIndent();
1207 }
1208
1209 void RemoteLayerTreeTransaction::dump() const
1210 {
1211     fprintf(stderr, "%s", description().data());
1212 }
1213
1214 CString RemoteLayerTreeTransaction::description() const
1215 {
1216     RemoteLayerTreeTextStream ts;
1217
1218     ts << "(\n";
1219     ts.increaseIndent();
1220     ts.writeIndent();
1221     ts << "(root-layer " << m_rootLayerID << ")";
1222
1223     if (!m_createdLayers.isEmpty()) {
1224         ts << "\n";
1225         ts.writeIndent();
1226         ts << "(created-layers";
1227         ts.increaseIndent();
1228         for (const auto& createdLayer : m_createdLayers) {
1229             ts << "\n";
1230             ts.writeIndent();
1231             ts << "(";
1232             switch (createdLayer.type) {
1233             case PlatformCALayer::LayerTypeLayer:
1234             case PlatformCALayer::LayerTypeWebLayer:
1235             case PlatformCALayer::LayerTypeSimpleLayer:
1236                 ts << "layer";
1237                 break;
1238             case PlatformCALayer::LayerTypeTransformLayer:
1239                 ts << "transform-layer";
1240                 break;
1241             case PlatformCALayer::LayerTypeWebTiledLayer:
1242                 ts << "tiled-layer";
1243                 break;
1244             case PlatformCALayer::LayerTypeTiledBackingLayer:
1245                 ts << "tiled-backing-layer";
1246                 break;
1247             case PlatformCALayer::LayerTypePageTiledBackingLayer:
1248                 ts << "page-tiled-backing-layer";
1249                 break;
1250             case PlatformCALayer::LayerTypeTiledBackingTileLayer:
1251                 ts << "tiled-backing-tile";
1252                 break;
1253             case PlatformCALayer::LayerTypeRootLayer:
1254                 ts << "root-layer";
1255                 break;
1256             case PlatformCALayer::LayerTypeBackdropLayer:
1257                 ts << "backdrop-layer";
1258                 break;
1259             case PlatformCALayer::LayerTypeAVPlayerLayer:
1260                 ts << "av-player-layer (context-id " << createdLayer.hostingContextID << ")";
1261                 break;
1262             case PlatformCALayer::LayerTypeWebGLLayer:
1263                 ts << "web-gl-layer (context-id " << createdLayer.hostingContextID << ")";
1264                 break;
1265             case PlatformCALayer::LayerTypeShapeLayer:
1266                 ts << "shape-layer";
1267                 break;
1268             case PlatformCALayer::LayerTypeScrollingLayer:
1269                 ts << "scrolling-layer";
1270                 break;
1271             case PlatformCALayer::LayerTypeCustom:
1272                 ts << "custom-layer (context-id " << createdLayer.hostingContextID << ")";
1273                 break;
1274             case PlatformCALayer::LayerTypeLightSystemBackdropLayer:
1275                 ts << "light-system-backdrop-layer";
1276                 break;
1277             case PlatformCALayer::LayerTypeDarkSystemBackdropLayer:
1278                 ts << "dark-system-backdrop-layer";
1279                 break;
1280             }
1281             ts << " " << createdLayer.layerID << ")";
1282         }
1283         ts << ")";
1284         ts.decreaseIndent();
1285     }
1286
1287     dumpChangedLayers(ts, m_changedLayerProperties);
1288
1289     if (!m_destroyedLayerIDs.isEmpty())
1290         dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "destroyed-layers", m_destroyedLayerIDs);
1291
1292     ts << ")\n";
1293
1294     return ts.release().utf8();
1295 }
1296
1297 #endif // !defined(NDEBUG) || !LOG_DISABLED
1298
1299 } // namespace WebKit