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