WK2 AVKit fullscreen doesn't display video.
[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     encoder << m_videoLayerIDsPendingFullscreen;
418 }
419
420 bool RemoteLayerTreeTransaction::decode(IPC::ArgumentDecoder& decoder, RemoteLayerTreeTransaction& result)
421 {
422     if (!decoder.decode(result.m_rootLayerID))
423         return false;
424     if (!result.m_rootLayerID)
425         return false;
426
427     if (!decoder.decode(result.m_createdLayers))
428         return false;
429
430     int numChangedLayerProperties;
431     if (!decoder.decode(numChangedLayerProperties))
432         return false;
433
434     for (int i = 0; i < numChangedLayerProperties; ++i) {
435         GraphicsLayer::PlatformLayerID layerID;
436         if (!decoder.decode(layerID))
437             return false;
438
439         std::unique_ptr<LayerProperties> layerProperties = std::make_unique<LayerProperties>();
440         if (!decoder.decode(*layerProperties))
441             return false;
442
443         result.changedLayers().set(layerID, std::move(layerProperties));
444     }
445
446     if (!decoder.decode(result.m_destroyedLayerIDs))
447         return false;
448
449     for (auto layerID : result.m_destroyedLayerIDs) {
450         if (!layerID)
451             return false;
452     }
453
454     if (!decoder.decode(result.m_contentsSize))
455         return false;
456
457     if (!decoder.decode(result.m_pageScaleFactor))
458         return false;
459
460     if (!decoder.decode(result.m_minimumScaleFactor))
461         return false;
462
463     if (!decoder.decode(result.m_maximumScaleFactor))
464         return false;
465
466     if (!decoder.decode(result.m_allowsUserScaling))
467         return false;
468     
469     if (!decoder.decode(result.m_renderTreeSize))
470         return false;
471     
472     if (!decoder.decode(result.m_videoLayerIDsPendingFullscreen))
473         return false;
474
475     return true;
476 }
477
478 void RemoteLayerTreeTransaction::setRootLayerID(GraphicsLayer::PlatformLayerID rootLayerID)
479 {
480     ASSERT_ARG(rootLayerID, rootLayerID);
481
482     m_rootLayerID = rootLayerID;
483 }
484
485 void RemoteLayerTreeTransaction::layerPropertiesChanged(PlatformCALayerRemote* remoteLayer, RemoteLayerTreeTransaction::LayerProperties& properties)
486 {
487     m_changedLayerProperties.set(remoteLayer->layerID(), std::make_unique<RemoteLayerTreeTransaction::LayerProperties>(properties));
488 }
489
490 void RemoteLayerTreeTransaction::setCreatedLayers(Vector<LayerCreationProperties> createdLayers)
491 {
492     m_createdLayers = std::move(createdLayers);
493 }
494
495 void RemoteLayerTreeTransaction::setDestroyedLayerIDs(Vector<GraphicsLayer::PlatformLayerID> destroyedLayerIDs)
496 {
497     m_destroyedLayerIDs = std::move(destroyedLayerIDs);
498 }
499
500 #if !defined(NDEBUG) || !LOG_DISABLED
501
502 class RemoteLayerTreeTextStream : public TextStream
503 {
504 public:
505     using TextStream::operator<<;
506
507     RemoteLayerTreeTextStream()
508         : m_indent(0)
509     {
510     }
511
512     RemoteLayerTreeTextStream& operator<<(const TransformationMatrix&);
513     RemoteLayerTreeTextStream& operator<<(PlatformCALayer::FilterType);
514     RemoteLayerTreeTextStream& operator<<(FloatPoint3D);
515     RemoteLayerTreeTextStream& operator<<(Color);
516     RemoteLayerTreeTextStream& operator<<(FloatRect);
517     RemoteLayerTreeTextStream& operator<<(const Vector<WebCore::GraphicsLayer::PlatformLayerID>& layers);
518     RemoteLayerTreeTextStream& operator<<(const FilterOperations&);
519
520     void increaseIndent() { ++m_indent; }
521     void decreaseIndent() { --m_indent; ASSERT(m_indent >= 0); }
522
523     void writeIndent();
524
525 private:
526     int m_indent;
527 };
528
529 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const TransformationMatrix& transform)
530 {
531     RemoteLayerTreeTextStream& ts = *this;
532     ts << "\n";
533     ts.increaseIndent();
534     ts.writeIndent();
535     ts << "[" << transform.m11() << " " << transform.m12() << " " << transform.m13() << " " << transform.m14() << "]\n";
536     ts.writeIndent();
537     ts << "[" << transform.m21() << " " << transform.m22() << " " << transform.m23() << " " << transform.m24() << "]\n";
538     ts.writeIndent();
539     ts << "[" << transform.m31() << " " << transform.m32() << " " << transform.m33() << " " << transform.m34() << "]\n";
540     ts.writeIndent();
541     ts << "[" << transform.m41() << " " << transform.m42() << " " << transform.m43() << " " << transform.m44() << "]";
542     ts.decreaseIndent();
543     return ts;
544 }
545
546 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCALayer::FilterType filterType)
547 {
548     RemoteLayerTreeTextStream& ts = *this;
549     switch (filterType) {
550     case PlatformCALayer::Linear:
551         ts << "linear";
552         break;
553     case PlatformCALayer::Nearest:
554         ts << "nearest";
555         break;
556     case PlatformCALayer::Trilinear:
557         ts << "trilinear";
558         break;
559     default:
560         ASSERT_NOT_REACHED();
561         break;
562     }
563     return ts;
564 }
565
566 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const FilterOperations& filters)
567 {
568     RemoteLayerTreeTextStream& ts = *this;
569     for (size_t i = 0; i < filters.size(); ++i) {
570         const auto filter = filters.at(i);
571         switch (filter->type()) {
572         case FilterOperation::REFERENCE:
573             ts << "reference";
574             break;
575         case FilterOperation::GRAYSCALE:
576             ts << "grayscale";
577             break;
578         case FilterOperation::SEPIA:
579             ts << "sepia";
580             break;
581         case FilterOperation::SATURATE:
582             ts << "saturate";
583             break;
584         case FilterOperation::HUE_ROTATE:
585             ts << "hue rotate";
586             break;
587         case FilterOperation::INVERT:
588             ts << "invert";
589             break;
590         case FilterOperation::OPACITY:
591             ts << "opacity";
592             break;
593         case FilterOperation::BRIGHTNESS:
594             ts << "brightness";
595             break;
596         case FilterOperation::CONTRAST:
597             ts << "contrast";
598             break;
599         case FilterOperation::BLUR:
600             ts << "blur";
601             break;
602         case FilterOperation::DROP_SHADOW:
603             ts << "drop shadow";
604             break;
605         case FilterOperation::PASSTHROUGH:
606             ts << "passthrough";
607             break;
608         case FilterOperation::NONE:
609             ts << "none";
610             break;
611         }
612
613         if (i < filters.size() - 1)
614             ts << " ";
615     }
616     return ts;
617 }
618
619 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatPoint3D point)
620 {
621     RemoteLayerTreeTextStream& ts = *this;
622     ts << point.x() << " " << point.y() << " " << point.z();
623     return ts;
624 }
625
626 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(Color color)
627 {
628     RemoteLayerTreeTextStream& ts = *this;
629     ts << color.serialized();
630     return ts;
631 }
632
633 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatRect rect)
634 {
635     RemoteLayerTreeTextStream& ts = *this;
636     ts << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height();
637     return ts;
638 }
639
640 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const Vector<GraphicsLayer::PlatformLayerID>& layers)
641 {
642     RemoteLayerTreeTextStream& ts = *this;
643
644     for (size_t i = 0; i < layers.size(); ++i) {
645         if (i)
646             ts << " ";
647         ts << layers[i];
648     }
649
650     return ts;
651 }
652
653 void RemoteLayerTreeTextStream::writeIndent()
654 {
655     for (int i = 0; i < m_indent; ++i)
656         *this << "  ";
657 }
658
659 template <class T>
660 static void dumpProperty(RemoteLayerTreeTextStream& ts, String name, T value)
661 {
662     ts << "\n";
663     ts.increaseIndent();
664     ts.writeIndent();
665     ts << "(" << name << " ";
666     ts << value << ")";
667     ts.decreaseIndent();
668 }
669
670 static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const RemoteLayerTreeTransaction::LayerPropertiesMap& changedLayerProperties)
671 {
672     if (changedLayerProperties.isEmpty())
673         return;
674
675     ts << "\n";
676     ts.writeIndent();
677     ts << "(changed-layers";
678
679     // Dump the layer properties sorted by layer ID.
680     Vector<GraphicsLayer::PlatformLayerID> layerIDs;
681     copyKeysToVector(changedLayerProperties, layerIDs);
682     std::sort(layerIDs.begin(), layerIDs.end());
683
684     for (auto layerID : layerIDs) {
685         const RemoteLayerTreeTransaction::LayerProperties& layerProperties = *changedLayerProperties.get(layerID);
686
687         ts << "\n";
688         ts.increaseIndent();
689         ts.writeIndent();
690         ts << "(layer " << layerID;
691
692         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
693             dumpProperty<String>(ts, "name", layerProperties.name);
694
695         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged)
696             dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "children", layerProperties.children);
697
698         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::PositionChanged)
699             dumpProperty<FloatPoint3D>(ts, "position", layerProperties.position);
700
701         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SizeChanged)
702             dumpProperty<FloatSize>(ts, "size", layerProperties.size);
703
704         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::AnchorPointChanged)
705             dumpProperty<FloatPoint3D>(ts, "anchorPoint", layerProperties.anchorPoint);
706
707         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackgroundColorChanged)
708             dumpProperty<Color>(ts, "backgroundColor", layerProperties.backgroundColor);
709
710         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderColorChanged)
711             dumpProperty<Color>(ts, "borderColor", layerProperties.borderColor);
712
713         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderWidthChanged)
714             dumpProperty<float>(ts, "borderWidth", layerProperties.borderWidth);
715
716         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpacityChanged)
717             dumpProperty<float>(ts, "opacity", layerProperties.opacity);
718
719         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TransformChanged)
720             dumpProperty<TransformationMatrix>(ts, "transform", layerProperties.transform ? *layerProperties.transform : TransformationMatrix());
721
722         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SublayerTransformChanged)
723             dumpProperty<TransformationMatrix>(ts, "sublayerTransform", layerProperties.sublayerTransform ? *layerProperties.sublayerTransform : TransformationMatrix());
724
725         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::HiddenChanged)
726             dumpProperty<bool>(ts, "hidden", layerProperties.hidden);
727
728         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::GeometryFlippedChanged)
729             dumpProperty<bool>(ts, "geometryFlipped", layerProperties.geometryFlipped);
730
731         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::DoubleSidedChanged)
732             dumpProperty<bool>(ts, "doubleSided", layerProperties.doubleSided);
733
734         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MasksToBoundsChanged)
735             dumpProperty<bool>(ts, "masksToBounds", layerProperties.masksToBounds);
736
737         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpaqueChanged)
738             dumpProperty<bool>(ts, "opaque", layerProperties.opaque);
739
740         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged)
741             dumpProperty<GraphicsLayer::PlatformLayerID>(ts, "maskLayer", layerProperties.maskLayerID);
742
743         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsRectChanged)
744             dumpProperty<FloatRect>(ts, "contentsRect", layerProperties.contentsRect);
745
746         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsScaleChanged)
747             dumpProperty<float>(ts, "contentsScale", layerProperties.contentsScale);
748
749         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
750             dumpProperty<PlatformCALayer::FilterType>(ts, "minificationFilter", layerProperties.minificationFilter);
751
752         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MagnificationFilterChanged)
753             dumpProperty<PlatformCALayer::FilterType>(ts, "magnificationFilter", layerProperties.magnificationFilter);
754
755         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SpeedChanged)
756             dumpProperty<float>(ts, "speed", layerProperties.speed);
757
758         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TimeOffsetChanged)
759             dumpProperty<double>(ts, "timeOffset", layerProperties.timeOffset);
760
761         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged)
762             dumpProperty<IntSize>(ts, "backingStore", layerProperties.backingStore ? layerProperties.backingStore->size() : IntSize());
763
764         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
765             dumpProperty<FilterOperations>(ts, "filters", layerProperties.filters ? *layerProperties.filters : FilterOperations());
766
767         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
768             dumpProperty<unsigned>(ts, "edgeAntialiasingMask", layerProperties.edgeAntialiasingMask);
769
770         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomAppearanceChanged)
771             dumpProperty<GraphicsLayer::CustomAppearance>(ts, "customAppearance", layerProperties.customAppearance);
772
773         ts << ")";
774
775         ts.decreaseIndent();
776     }
777
778     ts.decreaseIndent();
779 }
780
781 void RemoteLayerTreeTransaction::dump() const
782 {
783     fprintf(stderr, "%s", description().data());
784 }
785
786 CString RemoteLayerTreeTransaction::description() const
787 {
788     RemoteLayerTreeTextStream ts;
789
790     ts << "(\n";
791     ts.increaseIndent();
792     ts.writeIndent();
793     ts << "(root-layer " << m_rootLayerID << ")";
794
795     if (!m_createdLayers.isEmpty()) {
796         ts << "\n";
797         ts.writeIndent();
798         ts << "(created-layers";
799         ts.increaseIndent();
800         for (const auto& createdLayer : m_createdLayers) {
801             ts << "\n";
802             ts.writeIndent();
803             ts << "(";
804             switch (createdLayer.type) {
805             case PlatformCALayer::LayerTypeLayer:
806             case PlatformCALayer::LayerTypeWebLayer:
807             case PlatformCALayer::LayerTypeSimpleLayer:
808                 ts << "layer";
809                 break;
810             case PlatformCALayer::LayerTypeTransformLayer:
811                 ts << "transform-layer";
812                 break;
813             case PlatformCALayer::LayerTypeWebTiledLayer:
814                 ts << "tiled-layer";
815                 break;
816             case PlatformCALayer::LayerTypeTiledBackingLayer:
817                 ts << "tiled-backing-layer";
818                 break;
819             case PlatformCALayer::LayerTypePageTiledBackingLayer:
820                 ts << "page-tiled-backing-layer";
821                 break;
822             case PlatformCALayer::LayerTypeTiledBackingTileLayer:
823                 ts << "tiled-backing-tile";
824                 break;
825             case PlatformCALayer::LayerTypeRootLayer:
826                 ts << "root-layer";
827                 break;
828             case PlatformCALayer::LayerTypeAVPlayerLayer:
829                 ts << "av-player-layer";
830                 break;
831             case PlatformCALayer::LayerTypeCustom:
832                 ts << "custom-layer (context-id " << createdLayer.hostingContextID << ")";
833                 break;
834             }
835             ts << " " << createdLayer.layerID << ")";
836         }
837         ts << ")";
838         ts.decreaseIndent();
839     }
840
841     dumpChangedLayers(ts, m_changedLayerProperties);
842
843     if (!m_destroyedLayerIDs.isEmpty())
844         dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "destroyed-layers", m_destroyedLayerIDs);
845
846     ts << ")\n";
847
848     return ts.release().utf8();
849 }
850
851 #endif // !defined(NDEBUG) || !LOG_DISABLED
852
853 } // namespace WebKit