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