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