Add a typedef for PlatformLayerID on GraphicsLayer, and migrate RemoteLayerTreeTransa...
[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 "PlatformCALayerRemote.h"
33 #import "WebCoreArgumentCoders.h"
34 #import <QuartzCore/QuartzCore.h>
35 #import <WebCore/TextStream.h>
36 #import <wtf/text/CString.h>
37 #import <wtf/text/StringBuilder.h>
38
39 using namespace WebCore;
40
41 namespace WebKit {
42
43 RemoteLayerTreeTransaction::LayerCreationProperties::LayerCreationProperties()
44 {
45 }
46
47 void RemoteLayerTreeTransaction::LayerCreationProperties::encode(IPC::ArgumentEncoder& encoder) const
48 {
49     encoder << layerID;
50     encoder.encodeEnum(type);
51
52     if (type == PlatformCALayer::LayerTypeCustom)
53         encoder << hostingContextID;
54 }
55
56 bool RemoteLayerTreeTransaction::LayerCreationProperties::decode(IPC::ArgumentDecoder& decoder, LayerCreationProperties& result)
57 {
58     if (!decoder.decode(result.layerID))
59         return false;
60
61     if (!decoder.decodeEnum(result.type))
62         return false;
63
64     if (result.type == PlatformCALayer::LayerTypeCustom) {
65         if (!decoder.decode(result.hostingContextID))
66             return false;
67     }
68
69     return true;
70 }
71
72 RemoteLayerTreeTransaction::LayerProperties::LayerProperties()
73     : changedProperties(NoChange)
74     , everChangedProperties(NoChange)
75     , backgroundColor(Color::transparent)
76     , anchorPoint(0.5, 0.5, 0)
77     , borderWidth(0)
78     , borderColor(Color::black)
79     , opacity(1)
80     , hidden(false)
81     , geometryFlipped(false)
82     , doubleSided(true)
83     , masksToBounds(false)
84     , opaque(false)
85     , maskLayerID(0)
86     , contentsRect(FloatPoint(), FloatSize(1, 1))
87     , contentsScale(1)
88     , minificationFilter(PlatformCALayer::FilterType::Linear)
89     , magnificationFilter(PlatformCALayer::FilterType::Linear)
90     , speed(1)
91     , timeOffset(0)
92     , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
93     , customAppearance(GraphicsLayer::NoCustomAppearance)
94 {
95 }
96
97 void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::ArgumentEncoder& encoder) const
98 {
99     encoder.encodeEnum(changedProperties);
100
101     if (changedProperties & NameChanged)
102         encoder << name;
103
104     if (changedProperties & ChildrenChanged)
105         encoder << children;
106
107     if (changedProperties & PositionChanged)
108         encoder << position;
109
110     if (changedProperties & SizeChanged)
111         encoder << size;
112
113     if (changedProperties & BackgroundColorChanged)
114         encoder << backgroundColor;
115
116     if (changedProperties & AnchorPointChanged)
117         encoder << anchorPoint;
118
119     if (changedProperties & BorderWidthChanged)
120         encoder << borderWidth;
121
122     if (changedProperties & BorderColorChanged)
123         encoder << borderColor;
124
125     if (changedProperties & OpacityChanged)
126         encoder << opacity;
127
128     if (changedProperties & TransformChanged)
129         encoder << transform;
130
131     if (changedProperties & SublayerTransformChanged)
132         encoder << sublayerTransform;
133
134     if (changedProperties & HiddenChanged)
135         encoder << hidden;
136
137     if (changedProperties & GeometryFlippedChanged)
138         encoder << geometryFlipped;
139
140     if (changedProperties & DoubleSidedChanged)
141         encoder << doubleSided;
142
143     if (changedProperties & MasksToBoundsChanged)
144         encoder << masksToBounds;
145
146     if (changedProperties & OpaqueChanged)
147         encoder << opaque;
148
149     if (changedProperties & MaskLayerChanged)
150         encoder << maskLayerID;
151
152     if (changedProperties & ContentsRectChanged)
153         encoder << contentsRect;
154
155     if (changedProperties & ContentsScaleChanged)
156         encoder << contentsScale;
157
158     if (changedProperties & MinificationFilterChanged)
159         encoder.encodeEnum(minificationFilter);
160
161     if (changedProperties & MagnificationFilterChanged)
162         encoder.encodeEnum(magnificationFilter);
163
164     if (changedProperties & SpeedChanged)
165         encoder << speed;
166
167     if (changedProperties & TimeOffsetChanged)
168         encoder << timeOffset;
169
170     if (changedProperties & BackingStoreChanged)
171         encoder << backingStore;
172
173     if (changedProperties & FiltersChanged)
174         encoder << filters;
175
176     if (changedProperties & EdgeAntialiasingMaskChanged)
177         encoder << edgeAntialiasingMask;
178
179     if (changedProperties & CustomAppearanceChanged)
180         encoder.encodeEnum(customAppearance);
181 }
182
183 bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& decoder, LayerProperties& result)
184 {
185     if (!decoder.decodeEnum(result.changedProperties))
186         return false;
187
188     if (result.changedProperties & NameChanged) {
189         if (!decoder.decode(result.name))
190             return false;
191     }
192
193     if (result.changedProperties & ChildrenChanged) {
194         if (!decoder.decode(result.children))
195             return false;
196
197         for (auto layerID : result.children) {
198             if (!layerID)
199                 return false;
200         }
201     }
202
203     if (result.changedProperties & PositionChanged) {
204         if (!decoder.decode(result.position))
205             return false;
206     }
207
208     if (result.changedProperties & SizeChanged) {
209         if (!decoder.decode(result.size))
210             return false;
211     }
212
213     if (result.changedProperties & BackgroundColorChanged) {
214         if (!decoder.decode(result.backgroundColor))
215             return false;
216     }
217
218     if (result.changedProperties & AnchorPointChanged) {
219         if (!decoder.decode(result.anchorPoint))
220             return false;
221     }
222
223     if (result.changedProperties & BorderWidthChanged) {
224         if (!decoder.decode(result.borderWidth))
225             return false;
226     }
227
228     if (result.changedProperties & BorderColorChanged) {
229         if (!decoder.decode(result.borderColor))
230             return false;
231     }
232
233     if (result.changedProperties & OpacityChanged) {
234         if (!decoder.decode(result.opacity))
235             return false;
236     }
237
238     if (result.changedProperties & TransformChanged) {
239         if (!decoder.decode(result.transform))
240             return false;
241     }
242
243     if (result.changedProperties & SublayerTransformChanged) {
244         if (!decoder.decode(result.sublayerTransform))
245             return false;
246     }
247
248     if (result.changedProperties & HiddenChanged) {
249         if (!decoder.decode(result.hidden))
250             return false;
251     }
252
253     if (result.changedProperties & GeometryFlippedChanged) {
254         if (!decoder.decode(result.geometryFlipped))
255             return false;
256     }
257
258     if (result.changedProperties & DoubleSidedChanged) {
259         if (!decoder.decode(result.doubleSided))
260             return false;
261     }
262
263     if (result.changedProperties & MasksToBoundsChanged) {
264         if (!decoder.decode(result.masksToBounds))
265             return false;
266     }
267
268     if (result.changedProperties & OpaqueChanged) {
269         if (!decoder.decode(result.opaque))
270             return false;
271     }
272
273     if (result.changedProperties & MaskLayerChanged) {
274         if (!decoder.decode(result.maskLayerID))
275             return false;
276     }
277
278     if (result.changedProperties & ContentsRectChanged) {
279         if (!decoder.decode(result.contentsRect))
280             return false;
281     }
282
283     if (result.changedProperties & ContentsScaleChanged) {
284         if (!decoder.decode(result.contentsScale))
285             return false;
286     }
287
288     if (result.changedProperties & MinificationFilterChanged) {
289         if (!decoder.decodeEnum(result.minificationFilter))
290             return false;
291     }
292
293     if (result.changedProperties & MagnificationFilterChanged) {
294         if (!decoder.decodeEnum(result.magnificationFilter))
295             return false;
296     }
297
298     if (result.changedProperties & SpeedChanged) {
299         if (!decoder.decode(result.speed))
300             return false;
301     }
302
303     if (result.changedProperties & TimeOffsetChanged) {
304         if (!decoder.decode(result.timeOffset))
305             return false;
306     }
307
308     if (result.changedProperties & BackingStoreChanged) {
309         if (!decoder.decode(result.backingStore))
310             return false;
311     }
312
313     if (result.changedProperties & FiltersChanged) {
314         if (!decoder.decode(result.filters))
315             return false;
316     }
317
318     if (result.changedProperties & EdgeAntialiasingMaskChanged) {
319         if (!decoder.decode(result.edgeAntialiasingMask))
320             return false;
321     }
322
323     if (result.changedProperties & CustomAppearanceChanged) {
324         if (!decoder.decodeEnum(result.customAppearance))
325             return false;
326     }
327
328     return true;
329 }
330
331 RemoteLayerTreeTransaction::RemoteLayerTreeTransaction()
332 {
333 }
334
335 RemoteLayerTreeTransaction::~RemoteLayerTreeTransaction()
336 {
337 }
338
339 void RemoteLayerTreeTransaction::encode(IPC::ArgumentEncoder& encoder) const
340 {
341     encoder << m_rootLayerID;
342     encoder << m_createdLayers;
343     encoder << m_changedLayerProperties;
344     encoder << m_destroyedLayerIDs;
345 }
346
347 bool RemoteLayerTreeTransaction::decode(IPC::ArgumentDecoder& decoder, RemoteLayerTreeTransaction& result)
348 {
349     if (!decoder.decode(result.m_rootLayerID))
350         return false;
351     if (!result.m_rootLayerID)
352         return false;
353
354     if (!decoder.decode(result.m_createdLayers))
355         return false;
356
357     if (!decoder.decode(result.m_changedLayerProperties))
358         return false;
359
360     if (!decoder.decode(result.m_destroyedLayerIDs))
361         return false;
362
363     for (auto layerID : result.m_destroyedLayerIDs) {
364         if (!layerID)
365             return false;
366     }
367
368     return true;
369 }
370
371 void RemoteLayerTreeTransaction::setRootLayerID(GraphicsLayer::PlatformLayerID rootLayerID)
372 {
373     ASSERT_ARG(rootLayerID, rootLayerID);
374
375     m_rootLayerID = rootLayerID;
376 }
377
378 void RemoteLayerTreeTransaction::layerPropertiesChanged(PlatformCALayerRemote* remoteLayer, RemoteLayerTreeTransaction::LayerProperties& properties)
379 {
380     m_changedLayerProperties.set(remoteLayer->layerID(), properties);
381 }
382
383 void RemoteLayerTreeTransaction::setCreatedLayers(Vector<LayerCreationProperties> createdLayers)
384 {
385     m_createdLayers = std::move(createdLayers);
386 }
387
388 void RemoteLayerTreeTransaction::setDestroyedLayerIDs(Vector<GraphicsLayer::PlatformLayerID> destroyedLayerIDs)
389 {
390     m_destroyedLayerIDs = std::move(destroyedLayerIDs);
391 }
392
393 #if !defined(NDEBUG) || !LOG_DISABLED
394
395 class RemoteLayerTreeTextStream : public TextStream
396 {
397 public:
398     using TextStream::operator<<;
399
400     RemoteLayerTreeTextStream()
401         : m_indent(0)
402     {
403     }
404
405     RemoteLayerTreeTextStream& operator<<(const TransformationMatrix&);
406     RemoteLayerTreeTextStream& operator<<(PlatformCALayer::FilterType);
407     RemoteLayerTreeTextStream& operator<<(FloatPoint3D);
408     RemoteLayerTreeTextStream& operator<<(Color);
409     RemoteLayerTreeTextStream& operator<<(FloatRect);
410     RemoteLayerTreeTextStream& operator<<(const Vector<WebCore::GraphicsLayer::PlatformLayerID>& layers);
411     RemoteLayerTreeTextStream& operator<<(const FilterOperations&);
412
413     void increaseIndent() { ++m_indent; }
414     void decreaseIndent() { --m_indent; ASSERT(m_indent >= 0); }
415
416     void writeIndent();
417
418 private:
419     int m_indent;
420 };
421
422 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const TransformationMatrix& transform)
423 {
424     RemoteLayerTreeTextStream& ts = *this;
425     ts << "\n";
426     ts.increaseIndent();
427     ts.writeIndent();
428     ts << "[" << transform.m11() << " " << transform.m12() << " " << transform.m13() << " " << transform.m14() << "]\n";
429     ts.writeIndent();
430     ts << "[" << transform.m21() << " " << transform.m22() << " " << transform.m23() << " " << transform.m24() << "]\n";
431     ts.writeIndent();
432     ts << "[" << transform.m31() << " " << transform.m32() << " " << transform.m33() << " " << transform.m34() << "]\n";
433     ts.writeIndent();
434     ts << "[" << transform.m41() << " " << transform.m42() << " " << transform.m43() << " " << transform.m44() << "]";
435     ts.decreaseIndent();
436     return ts;
437 }
438
439 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCALayer::FilterType filterType)
440 {
441     RemoteLayerTreeTextStream& ts = *this;
442     switch (filterType) {
443     case PlatformCALayer::Linear:
444         ts << "linear";
445         break;
446     case PlatformCALayer::Nearest:
447         ts << "nearest";
448         break;
449     case PlatformCALayer::Trilinear:
450         ts << "trilinear";
451         break;
452     default:
453         ASSERT_NOT_REACHED();
454         break;
455     }
456     return ts;
457 }
458
459 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const FilterOperations& filters)
460 {
461     RemoteLayerTreeTextStream& ts = *this;
462     for (size_t i = 0; i < filters.size(); ++i) {
463         const auto filter = filters.at(i);
464         switch (filter->type()) {
465         case FilterOperation::REFERENCE:
466             ts << "reference";
467             break;
468         case FilterOperation::GRAYSCALE:
469             ts << "grayscale";
470             break;
471         case FilterOperation::SEPIA:
472             ts << "sepia";
473             break;
474         case FilterOperation::SATURATE:
475             ts << "saturate";
476             break;
477         case FilterOperation::HUE_ROTATE:
478             ts << "hue rotate";
479             break;
480         case FilterOperation::INVERT:
481             ts << "invert";
482             break;
483         case FilterOperation::OPACITY:
484             ts << "opacity";
485             break;
486         case FilterOperation::BRIGHTNESS:
487             ts << "brightness";
488             break;
489         case FilterOperation::CONTRAST:
490             ts << "contrast";
491             break;
492         case FilterOperation::BLUR:
493             ts << "blur";
494             break;
495         case FilterOperation::DROP_SHADOW:
496             ts << "drop shadow";
497             break;
498 #if ENABLE(CSS_SHADERS)
499         case FilterOperation::CUSTOM:
500             ts << "custom";
501             break;
502         case FilterOperation::VALIDATED_CUSTOM:
503             ts << "custom (validated)";
504             break;
505 #endif
506         case FilterOperation::PASSTHROUGH:
507             ts << "passthrough";
508             break;
509         case FilterOperation::NONE:
510             ts << "none";
511             break;
512         }
513
514         if (i < filters.size() - 1)
515             ts << " ";
516     }
517     return ts;
518 }
519
520 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatPoint3D point)
521 {
522     RemoteLayerTreeTextStream& ts = *this;
523     ts << point.x() << " " << point.y() << " " << point.z();
524     return ts;
525 }
526
527 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(Color color)
528 {
529     RemoteLayerTreeTextStream& ts = *this;
530     ts << color.serialized();
531     return ts;
532 }
533
534 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatRect rect)
535 {
536     RemoteLayerTreeTextStream& ts = *this;
537     ts << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height();
538     return ts;
539 }
540
541 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const Vector<GraphicsLayer::PlatformLayerID>& layers)
542 {
543     RemoteLayerTreeTextStream& ts = *this;
544
545     for (size_t i = 0; i < layers.size(); ++i) {
546         if (i)
547             ts << " ";
548         ts << layers[i];
549     }
550
551     return ts;
552 }
553
554 void RemoteLayerTreeTextStream::writeIndent()
555 {
556     for (int i = 0; i < m_indent; ++i)
557         *this << "  ";
558 }
559
560 template <class T>
561 static void dumpProperty(RemoteLayerTreeTextStream& ts, String name, T value)
562 {
563     ts << "\n";
564     ts.increaseIndent();
565     ts.writeIndent();
566     ts << "(" << name << " ";
567     ts << value << ")";
568     ts.decreaseIndent();
569 }
570
571 static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const HashMap<GraphicsLayer::PlatformLayerID, RemoteLayerTreeTransaction::LayerProperties>& changedLayerProperties)
572 {
573     if (changedLayerProperties.isEmpty())
574         return;
575
576     ts << "\n";
577     ts.writeIndent();
578     ts << "(changed-layers";
579
580     // Dump the layer properties sorted by layer ID.
581     Vector<GraphicsLayer::PlatformLayerID> layerIDs;
582     copyKeysToVector(changedLayerProperties, layerIDs);
583     std::sort(layerIDs.begin(), layerIDs.end());
584
585     for (auto layerID : layerIDs) {
586         const RemoteLayerTreeTransaction::LayerProperties& layerProperties = changedLayerProperties.get(layerID);
587
588         ts << "\n";
589         ts.increaseIndent();
590         ts.writeIndent();
591         ts << "(layer " << layerID;
592
593         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
594             dumpProperty<String>(ts, "name", layerProperties.name);
595
596         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged)
597             dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "children", layerProperties.children);
598
599         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::PositionChanged)
600             dumpProperty<FloatPoint3D>(ts, "position", layerProperties.position);
601
602         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SizeChanged)
603             dumpProperty<FloatSize>(ts, "size", layerProperties.size);
604
605         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::AnchorPointChanged)
606             dumpProperty<FloatPoint3D>(ts, "anchorPoint", layerProperties.anchorPoint);
607
608         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackgroundColorChanged)
609             dumpProperty<Color>(ts, "backgroundColor", layerProperties.backgroundColor);
610
611         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderColorChanged)
612             dumpProperty<Color>(ts, "borderColor", layerProperties.borderColor);
613
614         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderWidthChanged)
615             dumpProperty<float>(ts, "borderWidth", layerProperties.borderWidth);
616
617         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpacityChanged)
618             dumpProperty<float>(ts, "opacity", layerProperties.opacity);
619
620         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TransformChanged)
621             dumpProperty<TransformationMatrix>(ts, "transform", layerProperties.transform);
622
623         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SublayerTransformChanged)
624             dumpProperty<TransformationMatrix>(ts, "sublayerTransform", layerProperties.sublayerTransform);
625
626         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::HiddenChanged)
627             dumpProperty<bool>(ts, "hidden", layerProperties.hidden);
628
629         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::GeometryFlippedChanged)
630             dumpProperty<bool>(ts, "geometryFlipped", layerProperties.geometryFlipped);
631
632         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::DoubleSidedChanged)
633             dumpProperty<bool>(ts, "doubleSided", layerProperties.doubleSided);
634
635         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MasksToBoundsChanged)
636             dumpProperty<bool>(ts, "masksToBounds", layerProperties.masksToBounds);
637
638         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpaqueChanged)
639             dumpProperty<bool>(ts, "opaque", layerProperties.opaque);
640
641         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged)
642             dumpProperty<GraphicsLayer::PlatformLayerID>(ts, "maskLayer", layerProperties.maskLayerID);
643
644         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsRectChanged)
645             dumpProperty<FloatRect>(ts, "contentsRect", layerProperties.contentsRect);
646
647         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsScaleChanged)
648             dumpProperty<float>(ts, "contentsScale", layerProperties.contentsScale);
649
650         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
651             dumpProperty<PlatformCALayer::FilterType>(ts, "minificationFilter", layerProperties.minificationFilter);
652
653         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MagnificationFilterChanged)
654             dumpProperty<PlatformCALayer::FilterType>(ts, "magnificationFilter", layerProperties.magnificationFilter);
655
656         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SpeedChanged)
657             dumpProperty<float>(ts, "speed", layerProperties.speed);
658
659         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TimeOffsetChanged)
660             dumpProperty<double>(ts, "timeOffset", layerProperties.timeOffset);
661
662         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged)
663             dumpProperty<IntSize>(ts, "backingStore", layerProperties.backingStore.size());
664
665         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
666             dumpProperty<FilterOperations>(ts, "filters", layerProperties.filters);
667
668         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
669             dumpProperty<unsigned>(ts, "edgeAntialiasingMask", layerProperties.edgeAntialiasingMask);
670
671         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomAppearanceChanged)
672             dumpProperty<GraphicsLayer::CustomAppearance>(ts, "customAppearance", layerProperties.customAppearance);
673
674         ts << ")";
675
676         ts.decreaseIndent();
677     }
678
679     ts.decreaseIndent();
680 }
681
682 void RemoteLayerTreeTransaction::dump() const
683 {
684     fprintf(stderr, "%s", description().data());
685 }
686
687 CString RemoteLayerTreeTransaction::description() const
688 {
689     RemoteLayerTreeTextStream ts;
690
691     ts << "(\n";
692     ts.increaseIndent();
693     ts.writeIndent();
694     ts << "(root-layer " << m_rootLayerID << ")";
695
696     if (!m_createdLayers.isEmpty()) {
697         ts << "\n";
698         ts.writeIndent();
699         ts << "(created-layers";
700         ts.increaseIndent();
701         for (const auto& createdLayer : m_createdLayers) {
702             ts << "\n";
703             ts.writeIndent();
704             ts << "(";
705             switch (createdLayer.type) {
706             case PlatformCALayer::LayerTypeLayer:
707             case PlatformCALayer::LayerTypeWebLayer:
708             case PlatformCALayer::LayerTypeSimpleLayer:
709                 ts << "layer";
710                 break;
711             case PlatformCALayer::LayerTypeTransformLayer:
712                 ts << "transform-layer";
713                 break;
714             case PlatformCALayer::LayerTypeWebTiledLayer:
715                 ts << "tiled-layer";
716                 break;
717             case PlatformCALayer::LayerTypeTiledBackingLayer:
718                 ts << "tiled-backing-layer";
719                 break;
720             case PlatformCALayer::LayerTypePageTiledBackingLayer:
721                 ts << "page-tiled-backing-layer";
722                 break;
723             case PlatformCALayer::LayerTypeTiledBackingTileLayer:
724                 ts << "tiled-backing-tile";
725                 break;
726             case PlatformCALayer::LayerTypeRootLayer:
727                 ts << "root-layer";
728                 break;
729             case PlatformCALayer::LayerTypeAVPlayerLayer:
730                 ts << "av-player-layer";
731                 break;
732             case PlatformCALayer::LayerTypeCustom:
733                 ts << "custom-layer (context-id " << createdLayer.hostingContextID << ")";
734                 break;
735             }
736             ts << " " << createdLayer.layerID << ")";
737         }
738         ts << ")";
739         ts.decreaseIndent();
740     }
741
742     dumpChangedLayers(ts, m_changedLayerProperties);
743
744     if (!m_destroyedLayerIDs.isEmpty())
745         dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "destroyed-layers", m_destroyedLayerIDs);
746
747     ts << ")\n";
748
749     return ts.release().utf8();
750 }
751
752 #endif // !defined(NDEBUG) || !LOG_DISABLED
753
754 } // namespace WebKit