2769ab8f3aa0046cf1d9db4f47d75fd81c6ec932
[WebKit-https.git] / Source / WebKit2 / Shared / mac / RemoteLayerTreeTransaction.mm
1 /*
2  * Copyright (C) 2012 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #import "config.h"
27 #import "RemoteLayerTreeTransaction.h"
28
29 #import "ArgumentCoders.h"
30 #import "MessageDecoder.h"
31 #import "MessageEncoder.h"
32 #import "PlatformCALayerRemote.h"
33 #import "WebCoreArgumentCoders.h"
34 #import <QuartzCore/QuartzCore.h>
35 #import <WebCore/TextStream.h>
36 #import <wtf/text/CString.h>
37 #import <wtf/text/StringBuilder.h>
38
39 using namespace WebCore;
40
41 namespace WebKit {
42
43 RemoteLayerTreeTransaction::LayerCreationProperties::LayerCreationProperties()
44 {
45 }
46
47 void RemoteLayerTreeTransaction::LayerCreationProperties::encode(IPC::ArgumentEncoder& encoder) const
48 {
49     encoder << layerID;
50     encoder.encodeEnum(type);
51
52     if (type == PlatformCALayer::LayerTypeCustom)
53         encoder << hostingContextID;
54 }
55
56 bool RemoteLayerTreeTransaction::LayerCreationProperties::decode(IPC::ArgumentDecoder& decoder, LayerCreationProperties& result)
57 {
58     if (!decoder.decode(result.layerID))
59         return false;
60
61     if (!decoder.decodeEnum(result.type))
62         return false;
63
64     if (result.type == PlatformCALayer::LayerTypeCustom) {
65         if (!decoder.decode(result.hostingContextID))
66             return false;
67     }
68
69     return true;
70 }
71
72 RemoteLayerTreeTransaction::LayerProperties::LayerProperties()
73     : changedProperties(NoChange)
74     , everChangedProperties(NoChange)
75     , backgroundColor(Color::transparent)
76     , anchorPoint(0.5, 0.5, 0)
77     , borderWidth(0)
78     , borderColor(Color::black)
79     , opacity(1)
80     , hidden(false)
81     , geometryFlipped(false)
82     , doubleSided(true)
83     , masksToBounds(false)
84     , opaque(false)
85     , maskLayerID(0)
86     , contentsRect(FloatPoint(), FloatSize(1, 1))
87     , contentsScale(1)
88     , minificationFilter(PlatformCALayer::FilterType::Linear)
89     , magnificationFilter(PlatformCALayer::FilterType::Linear)
90     , speed(1)
91     , timeOffset(0)
92     , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
93     , customAppearance(GraphicsLayer::NoCustomAppearance)
94 {
95 }
96
97 void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::ArgumentEncoder& encoder) const
98 {
99     encoder.encodeEnum(changedProperties);
100
101     if (changedProperties & NameChanged)
102         encoder << name;
103
104     if (changedProperties & ChildrenChanged)
105         encoder << children;
106
107     if (changedProperties & PositionChanged)
108         encoder << position;
109
110     if (changedProperties & SizeChanged)
111         encoder << size;
112
113     if (changedProperties & BackgroundColorChanged)
114         encoder << backgroundColor;
115
116     if (changedProperties & AnchorPointChanged)
117         encoder << anchorPoint;
118
119     if (changedProperties & BorderWidthChanged)
120         encoder << borderWidth;
121
122     if (changedProperties & BorderColorChanged)
123         encoder << borderColor;
124
125     if (changedProperties & OpacityChanged)
126         encoder << opacity;
127
128     if (changedProperties & TransformChanged)
129         encoder << transform;
130
131     if (changedProperties & SublayerTransformChanged)
132         encoder << sublayerTransform;
133
134     if (changedProperties & HiddenChanged)
135         encoder << hidden;
136
137     if (changedProperties & GeometryFlippedChanged)
138         encoder << geometryFlipped;
139
140     if (changedProperties & DoubleSidedChanged)
141         encoder << doubleSided;
142
143     if (changedProperties & MasksToBoundsChanged)
144         encoder << masksToBounds;
145
146     if (changedProperties & OpaqueChanged)
147         encoder << opaque;
148
149     if (changedProperties & MaskLayerChanged)
150         encoder << maskLayerID;
151
152     if (changedProperties & ContentsRectChanged)
153         encoder << contentsRect;
154
155     if (changedProperties & ContentsScaleChanged)
156         encoder << contentsScale;
157
158     if (changedProperties & MinificationFilterChanged)
159         encoder.encodeEnum(minificationFilter);
160
161     if (changedProperties & MagnificationFilterChanged)
162         encoder.encodeEnum(magnificationFilter);
163
164     if (changedProperties & SpeedChanged)
165         encoder << speed;
166
167     if (changedProperties & TimeOffsetChanged)
168         encoder << timeOffset;
169
170     if (changedProperties & BackingStoreChanged) {
171         encoder << backingStore.hasFrontBuffer();
172         if (backingStore.hasFrontBuffer())
173             encoder << backingStore;
174     }
175
176     if (changedProperties & FiltersChanged)
177         encoder << filters;
178
179     if (changedProperties & EdgeAntialiasingMaskChanged)
180         encoder << edgeAntialiasingMask;
181
182     if (changedProperties & CustomAppearanceChanged)
183         encoder.encodeEnum(customAppearance);
184 }
185
186 bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& decoder, LayerProperties& result)
187 {
188     if (!decoder.decodeEnum(result.changedProperties))
189         return false;
190
191     if (result.changedProperties & NameChanged) {
192         if (!decoder.decode(result.name))
193             return false;
194     }
195
196     if (result.changedProperties & ChildrenChanged) {
197         if (!decoder.decode(result.children))
198             return false;
199
200         for (auto layerID : result.children) {
201             if (!layerID)
202                 return false;
203         }
204     }
205
206     if (result.changedProperties & PositionChanged) {
207         if (!decoder.decode(result.position))
208             return false;
209     }
210
211     if (result.changedProperties & SizeChanged) {
212         if (!decoder.decode(result.size))
213             return false;
214     }
215
216     if (result.changedProperties & BackgroundColorChanged) {
217         if (!decoder.decode(result.backgroundColor))
218             return false;
219     }
220
221     if (result.changedProperties & AnchorPointChanged) {
222         if (!decoder.decode(result.anchorPoint))
223             return false;
224     }
225
226     if (result.changedProperties & BorderWidthChanged) {
227         if (!decoder.decode(result.borderWidth))
228             return false;
229     }
230
231     if (result.changedProperties & BorderColorChanged) {
232         if (!decoder.decode(result.borderColor))
233             return false;
234     }
235
236     if (result.changedProperties & OpacityChanged) {
237         if (!decoder.decode(result.opacity))
238             return false;
239     }
240
241     if (result.changedProperties & TransformChanged) {
242         if (!decoder.decode(result.transform))
243             return false;
244     }
245
246     if (result.changedProperties & SublayerTransformChanged) {
247         if (!decoder.decode(result.sublayerTransform))
248             return false;
249     }
250
251     if (result.changedProperties & HiddenChanged) {
252         if (!decoder.decode(result.hidden))
253             return false;
254     }
255
256     if (result.changedProperties & GeometryFlippedChanged) {
257         if (!decoder.decode(result.geometryFlipped))
258             return false;
259     }
260
261     if (result.changedProperties & DoubleSidedChanged) {
262         if (!decoder.decode(result.doubleSided))
263             return false;
264     }
265
266     if (result.changedProperties & MasksToBoundsChanged) {
267         if (!decoder.decode(result.masksToBounds))
268             return false;
269     }
270
271     if (result.changedProperties & OpaqueChanged) {
272         if (!decoder.decode(result.opaque))
273             return false;
274     }
275
276     if (result.changedProperties & MaskLayerChanged) {
277         if (!decoder.decode(result.maskLayerID))
278             return false;
279     }
280
281     if (result.changedProperties & ContentsRectChanged) {
282         if (!decoder.decode(result.contentsRect))
283             return false;
284     }
285
286     if (result.changedProperties & ContentsScaleChanged) {
287         if (!decoder.decode(result.contentsScale))
288             return false;
289     }
290
291     if (result.changedProperties & MinificationFilterChanged) {
292         if (!decoder.decodeEnum(result.minificationFilter))
293             return false;
294     }
295
296     if (result.changedProperties & MagnificationFilterChanged) {
297         if (!decoder.decodeEnum(result.magnificationFilter))
298             return false;
299     }
300
301     if (result.changedProperties & SpeedChanged) {
302         if (!decoder.decode(result.speed))
303             return false;
304     }
305
306     if (result.changedProperties & TimeOffsetChanged) {
307         if (!decoder.decode(result.timeOffset))
308             return false;
309     }
310
311     if (result.changedProperties & BackingStoreChanged) {
312         bool hasFrontBuffer = false;
313         if (!decoder.decode(hasFrontBuffer))
314             return false;
315         if (hasFrontBuffer && !decoder.decode(result.backingStore))
316             return false;
317     }
318
319     if (result.changedProperties & FiltersChanged) {
320         if (!decoder.decode(result.filters))
321             return false;
322     }
323
324     if (result.changedProperties & EdgeAntialiasingMaskChanged) {
325         if (!decoder.decode(result.edgeAntialiasingMask))
326             return false;
327     }
328
329     if (result.changedProperties & CustomAppearanceChanged) {
330         if (!decoder.decodeEnum(result.customAppearance))
331             return false;
332     }
333
334     return true;
335 }
336
337 RemoteLayerTreeTransaction::RemoteLayerTreeTransaction()
338 {
339 }
340
341 RemoteLayerTreeTransaction::~RemoteLayerTreeTransaction()
342 {
343 }
344
345 void RemoteLayerTreeTransaction::encode(IPC::ArgumentEncoder& encoder) const
346 {
347     encoder << m_rootLayerID;
348     encoder << m_createdLayers;
349     encoder << m_changedLayerProperties;
350     encoder << m_destroyedLayerIDs;
351 }
352
353 bool RemoteLayerTreeTransaction::decode(IPC::ArgumentDecoder& decoder, RemoteLayerTreeTransaction& result)
354 {
355     if (!decoder.decode(result.m_rootLayerID))
356         return false;
357     if (!result.m_rootLayerID)
358         return false;
359
360     if (!decoder.decode(result.m_createdLayers))
361         return false;
362
363     if (!decoder.decode(result.m_changedLayerProperties))
364         return false;
365
366     if (!decoder.decode(result.m_destroyedLayerIDs))
367         return false;
368
369     for (auto layerID : result.m_destroyedLayerIDs) {
370         if (!layerID)
371             return false;
372     }
373
374     return true;
375 }
376
377 void RemoteLayerTreeTransaction::setRootLayerID(GraphicsLayer::PlatformLayerID rootLayerID)
378 {
379     ASSERT_ARG(rootLayerID, rootLayerID);
380
381     m_rootLayerID = rootLayerID;
382 }
383
384 void RemoteLayerTreeTransaction::layerPropertiesChanged(PlatformCALayerRemote* remoteLayer, RemoteLayerTreeTransaction::LayerProperties& properties)
385 {
386     m_changedLayerProperties.set(remoteLayer->layerID(), properties);
387 }
388
389 void RemoteLayerTreeTransaction::setCreatedLayers(Vector<LayerCreationProperties> createdLayers)
390 {
391     m_createdLayers = std::move(createdLayers);
392 }
393
394 void RemoteLayerTreeTransaction::setDestroyedLayerIDs(Vector<GraphicsLayer::PlatformLayerID> destroyedLayerIDs)
395 {
396     m_destroyedLayerIDs = std::move(destroyedLayerIDs);
397 }
398
399 #if !defined(NDEBUG) || !LOG_DISABLED
400
401 class RemoteLayerTreeTextStream : public TextStream
402 {
403 public:
404     using TextStream::operator<<;
405
406     RemoteLayerTreeTextStream()
407         : m_indent(0)
408     {
409     }
410
411     RemoteLayerTreeTextStream& operator<<(const TransformationMatrix&);
412     RemoteLayerTreeTextStream& operator<<(PlatformCALayer::FilterType);
413     RemoteLayerTreeTextStream& operator<<(FloatPoint3D);
414     RemoteLayerTreeTextStream& operator<<(Color);
415     RemoteLayerTreeTextStream& operator<<(FloatRect);
416     RemoteLayerTreeTextStream& operator<<(const Vector<WebCore::GraphicsLayer::PlatformLayerID>& layers);
417     RemoteLayerTreeTextStream& operator<<(const FilterOperations&);
418
419     void increaseIndent() { ++m_indent; }
420     void decreaseIndent() { --m_indent; ASSERT(m_indent >= 0); }
421
422     void writeIndent();
423
424 private:
425     int m_indent;
426 };
427
428 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const TransformationMatrix& transform)
429 {
430     RemoteLayerTreeTextStream& ts = *this;
431     ts << "\n";
432     ts.increaseIndent();
433     ts.writeIndent();
434     ts << "[" << transform.m11() << " " << transform.m12() << " " << transform.m13() << " " << transform.m14() << "]\n";
435     ts.writeIndent();
436     ts << "[" << transform.m21() << " " << transform.m22() << " " << transform.m23() << " " << transform.m24() << "]\n";
437     ts.writeIndent();
438     ts << "[" << transform.m31() << " " << transform.m32() << " " << transform.m33() << " " << transform.m34() << "]\n";
439     ts.writeIndent();
440     ts << "[" << transform.m41() << " " << transform.m42() << " " << transform.m43() << " " << transform.m44() << "]";
441     ts.decreaseIndent();
442     return ts;
443 }
444
445 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCALayer::FilterType filterType)
446 {
447     RemoteLayerTreeTextStream& ts = *this;
448     switch (filterType) {
449     case PlatformCALayer::Linear:
450         ts << "linear";
451         break;
452     case PlatformCALayer::Nearest:
453         ts << "nearest";
454         break;
455     case PlatformCALayer::Trilinear:
456         ts << "trilinear";
457         break;
458     default:
459         ASSERT_NOT_REACHED();
460         break;
461     }
462     return ts;
463 }
464
465 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const FilterOperations& filters)
466 {
467     RemoteLayerTreeTextStream& ts = *this;
468     for (size_t i = 0; i < filters.size(); ++i) {
469         const auto filter = filters.at(i);
470         switch (filter->type()) {
471         case FilterOperation::REFERENCE:
472             ts << "reference";
473             break;
474         case FilterOperation::GRAYSCALE:
475             ts << "grayscale";
476             break;
477         case FilterOperation::SEPIA:
478             ts << "sepia";
479             break;
480         case FilterOperation::SATURATE:
481             ts << "saturate";
482             break;
483         case FilterOperation::HUE_ROTATE:
484             ts << "hue rotate";
485             break;
486         case FilterOperation::INVERT:
487             ts << "invert";
488             break;
489         case FilterOperation::OPACITY:
490             ts << "opacity";
491             break;
492         case FilterOperation::BRIGHTNESS:
493             ts << "brightness";
494             break;
495         case FilterOperation::CONTRAST:
496             ts << "contrast";
497             break;
498         case FilterOperation::BLUR:
499             ts << "blur";
500             break;
501         case FilterOperation::DROP_SHADOW:
502             ts << "drop shadow";
503             break;
504         case FilterOperation::PASSTHROUGH:
505             ts << "passthrough";
506             break;
507         case FilterOperation::NONE:
508             ts << "none";
509             break;
510         }
511
512         if (i < filters.size() - 1)
513             ts << " ";
514     }
515     return ts;
516 }
517
518 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatPoint3D point)
519 {
520     RemoteLayerTreeTextStream& ts = *this;
521     ts << point.x() << " " << point.y() << " " << point.z();
522     return ts;
523 }
524
525 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(Color color)
526 {
527     RemoteLayerTreeTextStream& ts = *this;
528     ts << color.serialized();
529     return ts;
530 }
531
532 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(FloatRect rect)
533 {
534     RemoteLayerTreeTextStream& ts = *this;
535     ts << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height();
536     return ts;
537 }
538
539 RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const Vector<GraphicsLayer::PlatformLayerID>& layers)
540 {
541     RemoteLayerTreeTextStream& ts = *this;
542
543     for (size_t i = 0; i < layers.size(); ++i) {
544         if (i)
545             ts << " ";
546         ts << layers[i];
547     }
548
549     return ts;
550 }
551
552 void RemoteLayerTreeTextStream::writeIndent()
553 {
554     for (int i = 0; i < m_indent; ++i)
555         *this << "  ";
556 }
557
558 template <class T>
559 static void dumpProperty(RemoteLayerTreeTextStream& ts, String name, T value)
560 {
561     ts << "\n";
562     ts.increaseIndent();
563     ts.writeIndent();
564     ts << "(" << name << " ";
565     ts << value << ")";
566     ts.decreaseIndent();
567 }
568
569 static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const HashMap<GraphicsLayer::PlatformLayerID, RemoteLayerTreeTransaction::LayerProperties>& changedLayerProperties)
570 {
571     if (changedLayerProperties.isEmpty())
572         return;
573
574     ts << "\n";
575     ts.writeIndent();
576     ts << "(changed-layers";
577
578     // Dump the layer properties sorted by layer ID.
579     Vector<GraphicsLayer::PlatformLayerID> layerIDs;
580     copyKeysToVector(changedLayerProperties, layerIDs);
581     std::sort(layerIDs.begin(), layerIDs.end());
582
583     for (auto layerID : layerIDs) {
584         const RemoteLayerTreeTransaction::LayerProperties& layerProperties = changedLayerProperties.get(layerID);
585
586         ts << "\n";
587         ts.increaseIndent();
588         ts.writeIndent();
589         ts << "(layer " << layerID;
590
591         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
592             dumpProperty<String>(ts, "name", layerProperties.name);
593
594         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged)
595             dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "children", layerProperties.children);
596
597         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::PositionChanged)
598             dumpProperty<FloatPoint3D>(ts, "position", layerProperties.position);
599
600         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SizeChanged)
601             dumpProperty<FloatSize>(ts, "size", layerProperties.size);
602
603         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::AnchorPointChanged)
604             dumpProperty<FloatPoint3D>(ts, "anchorPoint", layerProperties.anchorPoint);
605
606         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackgroundColorChanged)
607             dumpProperty<Color>(ts, "backgroundColor", layerProperties.backgroundColor);
608
609         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderColorChanged)
610             dumpProperty<Color>(ts, "borderColor", layerProperties.borderColor);
611
612         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BorderWidthChanged)
613             dumpProperty<float>(ts, "borderWidth", layerProperties.borderWidth);
614
615         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpacityChanged)
616             dumpProperty<float>(ts, "opacity", layerProperties.opacity);
617
618         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TransformChanged)
619             dumpProperty<TransformationMatrix>(ts, "transform", layerProperties.transform);
620
621         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SublayerTransformChanged)
622             dumpProperty<TransformationMatrix>(ts, "sublayerTransform", layerProperties.sublayerTransform);
623
624         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::HiddenChanged)
625             dumpProperty<bool>(ts, "hidden", layerProperties.hidden);
626
627         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::GeometryFlippedChanged)
628             dumpProperty<bool>(ts, "geometryFlipped", layerProperties.geometryFlipped);
629
630         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::DoubleSidedChanged)
631             dumpProperty<bool>(ts, "doubleSided", layerProperties.doubleSided);
632
633         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MasksToBoundsChanged)
634             dumpProperty<bool>(ts, "masksToBounds", layerProperties.masksToBounds);
635
636         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::OpaqueChanged)
637             dumpProperty<bool>(ts, "opaque", layerProperties.opaque);
638
639         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged)
640             dumpProperty<GraphicsLayer::PlatformLayerID>(ts, "maskLayer", layerProperties.maskLayerID);
641
642         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsRectChanged)
643             dumpProperty<FloatRect>(ts, "contentsRect", layerProperties.contentsRect);
644
645         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsScaleChanged)
646             dumpProperty<float>(ts, "contentsScale", layerProperties.contentsScale);
647
648         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
649             dumpProperty<PlatformCALayer::FilterType>(ts, "minificationFilter", layerProperties.minificationFilter);
650
651         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MagnificationFilterChanged)
652             dumpProperty<PlatformCALayer::FilterType>(ts, "magnificationFilter", layerProperties.magnificationFilter);
653
654         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SpeedChanged)
655             dumpProperty<float>(ts, "speed", layerProperties.speed);
656
657         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TimeOffsetChanged)
658             dumpProperty<double>(ts, "timeOffset", layerProperties.timeOffset);
659
660         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged)
661             dumpProperty<IntSize>(ts, "backingStore", layerProperties.backingStore.size());
662
663         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
664             dumpProperty<FilterOperations>(ts, "filters", layerProperties.filters);
665
666         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
667             dumpProperty<unsigned>(ts, "edgeAntialiasingMask", layerProperties.edgeAntialiasingMask);
668
669         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomAppearanceChanged)
670             dumpProperty<GraphicsLayer::CustomAppearance>(ts, "customAppearance", layerProperties.customAppearance);
671
672         ts << ")";
673
674         ts.decreaseIndent();
675     }
676
677     ts.decreaseIndent();
678 }
679
680 void RemoteLayerTreeTransaction::dump() const
681 {
682     fprintf(stderr, "%s", description().data());
683 }
684
685 CString RemoteLayerTreeTransaction::description() const
686 {
687     RemoteLayerTreeTextStream ts;
688
689     ts << "(\n";
690     ts.increaseIndent();
691     ts.writeIndent();
692     ts << "(root-layer " << m_rootLayerID << ")";
693
694     if (!m_createdLayers.isEmpty()) {
695         ts << "\n";
696         ts.writeIndent();
697         ts << "(created-layers";
698         ts.increaseIndent();
699         for (const auto& createdLayer : m_createdLayers) {
700             ts << "\n";
701             ts.writeIndent();
702             ts << "(";
703             switch (createdLayer.type) {
704             case PlatformCALayer::LayerTypeLayer:
705             case PlatformCALayer::LayerTypeWebLayer:
706             case PlatformCALayer::LayerTypeSimpleLayer:
707                 ts << "layer";
708                 break;
709             case PlatformCALayer::LayerTypeTransformLayer:
710                 ts << "transform-layer";
711                 break;
712             case PlatformCALayer::LayerTypeWebTiledLayer:
713                 ts << "tiled-layer";
714                 break;
715             case PlatformCALayer::LayerTypeTiledBackingLayer:
716                 ts << "tiled-backing-layer";
717                 break;
718             case PlatformCALayer::LayerTypePageTiledBackingLayer:
719                 ts << "page-tiled-backing-layer";
720                 break;
721             case PlatformCALayer::LayerTypeTiledBackingTileLayer:
722                 ts << "tiled-backing-tile";
723                 break;
724             case PlatformCALayer::LayerTypeRootLayer:
725                 ts << "root-layer";
726                 break;
727             case PlatformCALayer::LayerTypeAVPlayerLayer:
728                 ts << "av-player-layer";
729                 break;
730             case PlatformCALayer::LayerTypeCustom:
731                 ts << "custom-layer (context-id " << createdLayer.hostingContextID << ")";
732                 break;
733             }
734             ts << " " << createdLayer.layerID << ")";
735         }
736         ts << ")";
737         ts.decreaseIndent();
738     }
739
740     dumpChangedLayers(ts, m_changedLayerProperties);
741
742     if (!m_destroyedLayerIDs.isEmpty())
743         dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>(ts, "destroyed-layers", m_destroyedLayerIDs);
744
745     ts << ")\n";
746
747     return ts.release().utf8();
748 }
749
750 #endif // !defined(NDEBUG) || !LOG_DISABLED
751
752 } // namespace WebKit