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