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