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