Make it possible to detach GraphicsLayerCA backing store
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / mac / PlatformCALayerRemote.cpp
1 /*
2  * Copyright (C) 2013 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. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27 #import "PlatformCALayerRemote.h"
28
29 #import "PlatformCALayerRemoteCustom.h"
30 #import "PlatformCALayerRemoteTiledBacking.h"
31 #import "RemoteLayerBackingStore.h"
32 #import "RemoteLayerTreeContext.h"
33 #import "RemoteLayerTreePropertyApplier.h"
34 #import <WebCore/AnimationUtilities.h>
35 #import <WebCore/GraphicsContext.h>
36 #import <WebCore/GraphicsLayerCA.h>
37 #import <WebCore/LengthFunctions.h>
38 #import <WebCore/PlatformCAFilters.h>
39 #import <WebCore/PlatformCALayerMac.h>
40 #import <WebCore/TiledBacking.h>
41 #import <wtf/CurrentTime.h>
42 #import <wtf/RetainPtr.h>
43
44 using namespace WebCore;
45
46 namespace WebKit {
47
48 PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
49 {
50     RefPtr<PlatformCALayerRemote> layer;
51
52     if (layerType == LayerTypeTiledBackingLayer ||  layerType == LayerTypePageTiledBackingLayer)
53         layer = adoptRef(new PlatformCALayerRemoteTiledBacking(layerType, owner, context));
54     else
55         layer = adoptRef(new PlatformCALayerRemote(layerType, owner, context));
56
57     context.layerWasCreated(*layer, layerType);
58
59     return layer.release();
60 }
61
62 PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(PlatformLayer *platformLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
63 {
64     return PlatformCALayerRemoteCustom::create(platformLayer, owner, context);
65 }
66
67 PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(const PlatformCALayerRemote& other, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
68 {
69     RefPtr<PlatformCALayerRemote> layer = adoptRef(new PlatformCALayerRemote(other, owner, context));
70
71     context.layerWasCreated(*layer, other.layerType());
72
73     return layer.release();
74 }
75
76 PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
77     : PlatformCALayer(layerType, owner)
78     , m_superlayer(nullptr)
79     , m_maskLayer(nullptr)
80     , m_acceleratesDrawing(false)
81     , m_context(&context)
82 {
83     if (owner)
84         m_properties.contentsScale = owner->platformCALayerDeviceScaleFactor();
85 }
86
87 PlatformCALayerRemote::PlatformCALayerRemote(const PlatformCALayerRemote& other, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
88     : PlatformCALayer(other.layerType(), owner)
89     , m_superlayer(nullptr)
90     , m_maskLayer(nullptr)
91     , m_acceleratesDrawing(other.acceleratesDrawing())
92     , m_context(&context)
93 {
94 }
95
96 PassRefPtr<PlatformCALayer> PlatformCALayerRemote::clone(PlatformCALayerClient* owner) const
97 {
98     RefPtr<PlatformCALayerRemote> clone = PlatformCALayerRemote::create(*this, owner, *m_context);
99
100     updateClonedLayerProperties(*clone);
101
102     clone->setClonedLayer(this);
103     return clone.release();
104 }
105
106 PlatformCALayerRemote::~PlatformCALayerRemote()
107 {
108     for (const auto& layer : m_children)
109         downcast<PlatformCALayerRemote>(*layer).m_superlayer = nullptr;
110
111     if (m_context)
112         m_context->layerWillBeDestroyed(*this);
113 }
114
115 void PlatformCALayerRemote::updateClonedLayerProperties(PlatformCALayerRemote& clone, bool copyContents) const
116 {
117     clone.setPosition(position());
118     clone.setBounds(bounds());
119     clone.setAnchorPoint(anchorPoint());
120
121     if (m_properties.transform)
122         clone.setTransform(*m_properties.transform);
123
124     if (m_properties.sublayerTransform)
125         clone.setSublayerTransform(*m_properties.sublayerTransform);
126
127     if (copyContents)
128         clone.setContents(contents());
129
130     clone.setMasksToBounds(masksToBounds());
131     clone.setDoubleSided(isDoubleSided());
132     clone.setOpaque(isOpaque());
133     clone.setBackgroundColor(backgroundColor());
134     clone.setContentsScale(contentsScale());
135     clone.setCornerRadius(cornerRadius());
136
137     if (m_properties.shapeRoundedRect)
138         clone.setShapeRoundedRect(*m_properties.shapeRoundedRect);
139
140     if (m_properties.filters)
141         clone.copyFiltersFrom(*this);
142
143     clone.updateCustomAppearance(customAppearance());
144 }
145
146 void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeContext& context, RemoteLayerTreeTransaction& transaction)
147 {
148     ASSERT(!m_properties.backingStore || owner());
149     ASSERT_WITH_SECURITY_IMPLICATION(&context == m_context);
150     
151     if (m_properties.backingStore && (!owner() || !owner()->platformCALayerDrawsContent())) {
152         m_properties.backingStore = nullptr;
153         m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreChanged);
154     }
155
156     if (m_properties.backingStore && m_properties.backingStoreAttached && m_properties.backingStore->display())
157         m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreChanged);
158
159     if (m_properties.changedProperties != RemoteLayerTreeTransaction::NoChange) {
160         if (m_properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
161             m_properties.children.clear();
162             for (const auto& layer : m_children)
163                 m_properties.children.append(layer->layerID());
164         }
165
166         if (isPlatformCALayerRemoteCustom()) {
167             RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), nullptr, m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap());
168             didCommit();
169             return;
170         }
171
172         transaction.layerPropertiesChanged(*this);
173     }
174
175     for (size_t i = 0; i < m_children.size(); ++i) {
176         PlatformCALayerRemote& child = downcast<PlatformCALayerRemote>(*m_children[i]);
177         ASSERT(child.superlayer() == this);
178         child.recursiveBuildTransaction(context, transaction);
179     }
180
181     if (m_maskLayer)
182         m_maskLayer->recursiveBuildTransaction(context, transaction);
183 }
184
185 void PlatformCALayerRemote::didCommit()
186 {
187     m_properties.addedAnimations.clear();
188     m_properties.keyPathsOfAnimationsToRemove.clear();
189     m_properties.resetChangedProperties();
190 }
191
192 void PlatformCALayerRemote::ensureBackingStore()
193 {
194     ASSERT(owner());
195     
196     if (!m_properties.backingStore)
197         m_properties.backingStore = std::make_unique<RemoteLayerBackingStore>(this);
198
199     updateBackingStore();
200 }
201
202 void PlatformCALayerRemote::updateBackingStore()
203 {
204     if (!m_properties.backingStore)
205         return;
206
207     m_properties.backingStore->ensureBackingStore(m_properties.bounds.size(), m_properties.contentsScale, m_acceleratesDrawing, m_properties.opaque);
208 }
209
210 void PlatformCALayerRemote::setNeedsDisplayInRect(const FloatRect& rect)
211 {
212     ensureBackingStore();
213
214     // FIXME: Need to map this through contentsRect/etc.
215     m_properties.backingStore->setNeedsDisplay(enclosingIntRect(rect));
216 }
217
218 void PlatformCALayerRemote::setNeedsDisplay()
219 {
220     ensureBackingStore();
221
222     m_properties.backingStore->setNeedsDisplay();
223 }
224
225 void PlatformCALayerRemote::copyContentsFromLayer(PlatformCALayer* layer)
226 {
227     ASSERT(m_properties.clonedLayerID == layer->layerID());
228     
229     if (!m_properties.changedProperties)
230         m_context->layerPropertyChangedWhileBuildingTransaction(*this);
231
232     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ClonedContentsChanged);
233 }
234
235 PlatformCALayer* PlatformCALayerRemote::superlayer() const
236 {
237     return m_superlayer;
238 }
239
240 void PlatformCALayerRemote::removeFromSuperlayer()
241 {
242     if (!m_superlayer)
243         return;
244
245     m_superlayer->removeSublayer(this);
246 }
247
248 void PlatformCALayerRemote::removeSublayer(PlatformCALayerRemote* layer)
249 {
250     size_t childIndex = m_children.find(layer);
251     if (childIndex != notFound)
252         m_children.remove(childIndex);
253     layer->m_superlayer = nullptr;
254     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ChildrenChanged);
255 }
256
257 void PlatformCALayerRemote::setSublayers(const PlatformCALayerList& list)
258 {
259     removeAllSublayers();
260     m_children = list;
261
262     for (const auto& layer : list) {
263         layer->removeFromSuperlayer();
264         downcast<PlatformCALayerRemote>(*layer).m_superlayer = this;
265     }
266
267     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ChildrenChanged);
268 }
269
270 void PlatformCALayerRemote::removeAllSublayers()
271 {
272     PlatformCALayerList layersToRemove = m_children;
273     for (const auto& layer : layersToRemove)
274         layer->removeFromSuperlayer();
275     ASSERT(m_children.isEmpty());
276     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ChildrenChanged);
277 }
278
279 void PlatformCALayerRemote::appendSublayer(PlatformCALayer& layer)
280 {
281     Ref<PlatformCALayer> layerProtector(layer);
282
283     layer.removeFromSuperlayer();
284     m_children.append(&layer);
285     downcast<PlatformCALayerRemote>(layer).m_superlayer = this;
286     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ChildrenChanged);
287 }
288
289 void PlatformCALayerRemote::insertSublayer(PlatformCALayer& layer, size_t index)
290 {
291     Ref<PlatformCALayer> layerProtector(layer);
292
293     layer.removeFromSuperlayer();
294     m_children.insert(index, &layer);
295     downcast<PlatformCALayerRemote>(layer).m_superlayer = this;
296     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ChildrenChanged);
297 }
298
299 void PlatformCALayerRemote::replaceSublayer(PlatformCALayer& reference, PlatformCALayer& layer)
300 {
301     ASSERT(reference.superlayer() == this);
302     Ref<PlatformCALayer> layerProtector(layer);
303
304     layer.removeFromSuperlayer();
305     size_t referenceIndex = m_children.find(&reference);
306     if (referenceIndex != notFound) {
307         m_children[referenceIndex]->removeFromSuperlayer();
308         m_children.insert(referenceIndex, &layer);
309         downcast<PlatformCALayerRemote>(layer).m_superlayer = this;
310     }
311
312     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ChildrenChanged);
313 }
314
315 void PlatformCALayerRemote::adoptSublayers(PlatformCALayer& source)
316 {
317     PlatformCALayerList layersToMove = downcast<PlatformCALayerRemote>(source).m_children;
318
319     if (const PlatformCALayerList* customLayers = source.customSublayers()) {
320         for (const auto& layer : *customLayers) {
321             size_t layerIndex = layersToMove.find(layer);
322             if (layerIndex != notFound)
323                 layersToMove.remove(layerIndex);
324         }
325     }
326
327     setSublayers(layersToMove);
328 }
329
330 void PlatformCALayerRemote::addAnimationForKey(const String& key, PlatformCAAnimation& animation)
331 {
332     auto addResult = m_animations.set(key, &animation);
333     if (addResult.isNewEntry)
334         m_properties.addedAnimations.append(std::pair<String, PlatformCAAnimationRemote::Properties>(key, downcast<PlatformCAAnimationRemote>(animation).properties()));
335     else {
336         for (auto& keyAnimationPair : m_properties.addedAnimations) {
337             if (keyAnimationPair.first == key) {
338                 keyAnimationPair.second = downcast<PlatformCAAnimationRemote>(animation).properties();
339                 break;
340             }
341         }
342     }
343     
344     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::AnimationsChanged);
345
346     if (m_context)
347         m_context->willStartAnimationOnLayer(*this);
348 }
349
350 void PlatformCALayerRemote::removeAnimationForKey(const String& key)
351 {
352     if (m_animations.remove(key)) {
353         m_properties.addedAnimations.removeFirstMatching([&key] (const std::pair<String, PlatformCAAnimationRemote::Properties>& pair) {
354             return pair.first == key;
355         });
356     }
357     m_properties.keyPathsOfAnimationsToRemove.add(key);
358     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::AnimationsChanged);
359 }
360
361 PassRefPtr<PlatformCAAnimation> PlatformCALayerRemote::animationForKey(const String& key)
362 {
363     return m_animations.get(key);
364 }
365
366 static inline bool isEquivalentLayer(const PlatformCALayer* layer, GraphicsLayer::PlatformLayerID layerID)
367 {
368     GraphicsLayer::PlatformLayerID newLayerID = layer ? layer->layerID() : 0;
369     return layerID == newLayerID;
370 }
371
372 void PlatformCALayerRemote::animationStarted(const String& key, CFTimeInterval beginTime)
373 {
374     auto it = m_animations.find(key);
375     if (it != m_animations.end())
376         downcast<PlatformCAAnimationRemote>(*it->value).didStart(beginTime);
377     
378     if (m_owner)
379         m_owner->platformCALayerAnimationStarted(key, beginTime);
380 }
381
382 void PlatformCALayerRemote::animationEnded(const String& key)
383 {
384     if (m_owner)
385         m_owner->platformCALayerAnimationEnded(key);
386 }
387
388 void PlatformCALayerRemote::setMask(PlatformCALayer* layer)
389 {
390     if (isEquivalentLayer(layer, m_properties.maskLayerID))
391         return;
392     
393     if (layer) {
394         m_maskLayer = downcast<PlatformCALayerRemote>(layer);
395         m_properties.maskLayerID = m_maskLayer->layerID();
396     } else {
397         m_maskLayer = nullptr;
398         m_properties.maskLayerID = 0;
399     }
400
401     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::MaskLayerChanged);
402 }
403
404 void PlatformCALayerRemote::setClonedLayer(const PlatformCALayer* layer)
405 {
406     if (isEquivalentLayer(layer, m_properties.clonedLayerID))
407         return;
408
409     if (layer)
410         m_properties.clonedLayerID = layer->layerID();
411     else
412         m_properties.clonedLayerID = 0;
413
414     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ClonedContentsChanged);
415 }
416
417 bool PlatformCALayerRemote::isOpaque() const
418 {
419     return m_properties.opaque;
420 }
421
422 void PlatformCALayerRemote::setOpaque(bool value)
423 {
424     m_properties.opaque = value;
425     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::OpaqueChanged);
426
427     updateBackingStore();
428 }
429
430 FloatRect PlatformCALayerRemote::bounds() const
431 {
432     return m_properties.bounds;
433 }
434
435 void PlatformCALayerRemote::setBounds(const FloatRect& value)
436 {
437     if (value == m_properties.bounds)
438         return;
439
440     m_properties.bounds = value;
441     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BoundsChanged);
442     
443     if (requiresCustomAppearanceUpdateOnBoundsChange())
444         m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CustomAppearanceChanged);
445
446     updateBackingStore();
447 }
448
449 FloatPoint3D PlatformCALayerRemote::position() const
450 {
451     return m_properties.position;
452 }
453
454 void PlatformCALayerRemote::setPosition(const FloatPoint3D& value)
455 {
456     if (value == m_properties.position)
457         return;
458
459     m_properties.position = value;
460     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::PositionChanged);
461 }
462
463 FloatPoint3D PlatformCALayerRemote::anchorPoint() const
464 {
465     return m_properties.anchorPoint;
466 }
467
468 void PlatformCALayerRemote::setAnchorPoint(const FloatPoint3D& value)
469 {
470     if (value == m_properties.anchorPoint)
471         return;
472
473     m_properties.anchorPoint = value;
474     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::AnchorPointChanged);
475 }
476
477 TransformationMatrix PlatformCALayerRemote::transform() const
478 {
479     return m_properties.transform ? *m_properties.transform : TransformationMatrix();
480 }
481
482 void PlatformCALayerRemote::setTransform(const TransformationMatrix& value)
483 {
484     m_properties.transform = std::make_unique<TransformationMatrix>(value);
485     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::TransformChanged);
486 }
487
488 TransformationMatrix PlatformCALayerRemote::sublayerTransform() const
489 {
490     return m_properties.sublayerTransform ? *m_properties.sublayerTransform : TransformationMatrix();
491 }
492
493 void PlatformCALayerRemote::setSublayerTransform(const TransformationMatrix& value)
494 {
495     m_properties.sublayerTransform = std::make_unique<TransformationMatrix>(value);
496     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::SublayerTransformChanged);
497 }
498
499 void PlatformCALayerRemote::setHidden(bool value)
500 {
501     m_properties.hidden = value;
502     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::HiddenChanged);
503 }
504
505 void PlatformCALayerRemote::setBackingStoreAttached(bool value)
506 {
507     if (m_properties.backingStoreAttached == value)
508         return;
509
510     m_properties.backingStoreAttached = value;
511     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreAttachmentChanged);
512 }
513
514 bool PlatformCALayerRemote::backingStoreAttached() const
515 {
516     return m_properties.backingStoreAttached;
517 }
518
519 void PlatformCALayerRemote::setGeometryFlipped(bool value)
520 {
521     m_properties.geometryFlipped = value;
522     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::GeometryFlippedChanged);
523 }
524
525 bool PlatformCALayerRemote::isDoubleSided() const
526 {
527     return m_properties.doubleSided;
528 }
529
530 void PlatformCALayerRemote::setDoubleSided(bool value)
531 {
532     m_properties.doubleSided = value;
533     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::DoubleSidedChanged);
534 }
535
536 bool PlatformCALayerRemote::masksToBounds() const
537 {
538     return m_properties.masksToBounds;
539 }
540
541 void PlatformCALayerRemote::setMasksToBounds(bool value)
542 {
543     if (value == m_properties.masksToBounds)
544         return;
545
546     m_properties.masksToBounds = value;
547     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::MasksToBoundsChanged);
548 }
549
550 bool PlatformCALayerRemote::acceleratesDrawing() const
551 {
552     return m_acceleratesDrawing;
553 }
554
555 void PlatformCALayerRemote::setAcceleratesDrawing(bool acceleratesDrawing)
556 {
557     m_acceleratesDrawing = acceleratesDrawing;
558     updateBackingStore();
559 }
560
561 CFTypeRef PlatformCALayerRemote::contents() const
562 {
563     return nullptr;
564 }
565
566 void PlatformCALayerRemote::setContents(CFTypeRef value)
567 {
568 }
569
570 void PlatformCALayerRemote::setContentsRect(const FloatRect& value)
571 {
572     m_properties.contentsRect = value;
573     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ContentsRectChanged);
574 }
575
576 void PlatformCALayerRemote::setMinificationFilter(FilterType value)
577 {
578     m_properties.minificationFilter = value;
579     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::MinificationFilterChanged);
580 }
581
582 void PlatformCALayerRemote::setMagnificationFilter(FilterType value)
583 {
584     m_properties.magnificationFilter = value;
585     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::MagnificationFilterChanged);
586 }
587
588 Color PlatformCALayerRemote::backgroundColor() const
589 {
590     return m_properties.backgroundColor;
591 }
592
593 void PlatformCALayerRemote::setBackgroundColor(const Color& value)
594 {
595     m_properties.backgroundColor = value;
596     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackgroundColorChanged);
597 }
598
599 void PlatformCALayerRemote::setBorderWidth(float value)
600 {
601     if (value == m_properties.borderWidth)
602         return;
603
604     m_properties.borderWidth = value;
605     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BorderWidthChanged);
606 }
607
608 void PlatformCALayerRemote::setBorderColor(const Color& value)
609 {
610     if (value == m_properties.borderColor)
611         return;
612
613     m_properties.borderColor = value;
614     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BorderColorChanged);
615 }
616
617 float PlatformCALayerRemote::opacity() const
618 {
619     return m_properties.opacity;
620 }
621
622 void PlatformCALayerRemote::setOpacity(float value)
623 {
624     m_properties.opacity = value;
625     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::OpacityChanged);
626 }
627
628 void PlatformCALayerRemote::setFilters(const FilterOperations& filters)
629 {
630     m_properties.filters = std::make_unique<FilterOperations>(filters);
631     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::FiltersChanged);
632 }
633
634 void PlatformCALayerRemote::copyFiltersFrom(const PlatformCALayer& sourceLayer)
635 {
636     if (const FilterOperations* filters = downcast<PlatformCALayerRemote>(sourceLayer).m_properties.filters.get())
637         setFilters(*filters);
638     else if (m_properties.filters)
639         m_properties.filters = nullptr;
640
641     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::FiltersChanged);
642 }
643
644 #if ENABLE(CSS_COMPOSITING)
645 void PlatformCALayerRemote::setBlendMode(BlendMode blendMode)
646 {
647     m_properties.blendMode = blendMode;
648     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BlendModeChanged);
649 }
650 #endif
651
652 bool PlatformCALayerRemote::filtersCanBeComposited(const FilterOperations& filters)
653 {
654     return PlatformCALayerMac::filtersCanBeComposited(filters);
655 }
656
657 void PlatformCALayerRemote::setName(const String& value)
658 {
659     m_properties.name = value;
660     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::NameChanged);
661 }
662
663 void PlatformCALayerRemote::setSpeed(float value)
664 {
665     m_properties.speed = value;
666     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::SpeedChanged);
667 }
668
669 void PlatformCALayerRemote::setTimeOffset(CFTimeInterval value)
670 {
671     m_properties.timeOffset = value;
672     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::TimeOffsetChanged);
673 }
674
675 float PlatformCALayerRemote::contentsScale() const
676 {
677     return m_properties.contentsScale;
678 }
679
680 void PlatformCALayerRemote::setContentsScale(float value)
681 {
682     m_properties.contentsScale = value;
683     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ContentsScaleChanged);
684
685     updateBackingStore();
686 }
687
688 float PlatformCALayerRemote::cornerRadius() const
689 {
690     return m_properties.cornerRadius;
691 }
692
693 void PlatformCALayerRemote::setCornerRadius(float value)
694 {
695     if (m_properties.cornerRadius == value)
696         return;
697
698     m_properties.cornerRadius = value;
699     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CornerRadiusChanged);
700 }
701
702 void PlatformCALayerRemote::setEdgeAntialiasingMask(unsigned value)
703 {
704     m_properties.edgeAntialiasingMask = value;
705     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged);
706 }
707
708 FloatRoundedRect PlatformCALayerRemote::shapeRoundedRect() const
709 {
710     return m_properties.shapeRoundedRect ? *m_properties.shapeRoundedRect : FloatRoundedRect(FloatRect());
711 }
712
713 void PlatformCALayerRemote::setShapeRoundedRect(const FloatRoundedRect& roundedRect)
714 {
715     if (m_properties.shapeRoundedRect && *m_properties.shapeRoundedRect == roundedRect)
716         return;
717
718     m_properties.shapeRoundedRect = std::make_unique<FloatRoundedRect>(roundedRect);
719     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ShapeRoundedRectChanged);
720 }
721
722 Path PlatformCALayerRemote::shapePath() const
723 {
724     ASSERT(m_layerType == LayerTypeShapeLayer);
725     return m_properties.shapePath;
726 }
727
728 void PlatformCALayerRemote::setShapePath(const Path& path)
729 {
730     ASSERT(m_layerType == LayerTypeShapeLayer);
731     m_properties.shapePath = path;
732     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ShapePathChanged);
733 }
734
735 WindRule PlatformCALayerRemote::shapeWindRule() const
736 {
737     ASSERT(m_layerType == LayerTypeShapeLayer);
738     return m_properties.windRule;
739 }
740
741 void PlatformCALayerRemote::setShapeWindRule(WindRule windRule)
742 {
743     ASSERT(m_layerType == LayerTypeShapeLayer);
744     m_properties.windRule = windRule;
745     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::WindRuleChanged);
746 }
747
748 bool PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange() const
749 {
750     return m_properties.customAppearance == GraphicsLayer::ScrollingShadow;
751 }
752
753 GraphicsLayer::CustomAppearance PlatformCALayerRemote::customAppearance() const
754 {
755     return m_properties.customAppearance;
756 }
757
758 void PlatformCALayerRemote::updateCustomAppearance(GraphicsLayer::CustomAppearance customAppearance)
759 {
760     m_properties.customAppearance = customAppearance;
761     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CustomAppearanceChanged);
762 }
763
764 PassRefPtr<PlatformCALayer> PlatformCALayerRemote::createCompatibleLayer(PlatformCALayer::LayerType layerType, PlatformCALayerClient* client) const
765 {
766     return PlatformCALayerRemote::create(layerType, client, *m_context);
767 }
768
769 void PlatformCALayerRemote::enumerateRectsBeingDrawn(CGContextRef context, void (^block)(CGRect))
770 {
771     m_properties.backingStore->enumerateRectsBeingDrawn(context, block);
772 }
773
774 uint32_t PlatformCALayerRemote::hostingContextID()
775 {
776     ASSERT_NOT_REACHED();
777     return 0;
778 }
779
780 LayerPool& PlatformCALayerRemote::layerPool()
781 {
782     return m_context->layerPool();
783 }
784
785 } // namespace WebKit