c68cbc3a26ae5c91c95180e7111e7c1c99a18097
[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.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::setGeometryFlipped(bool value)
506 {
507     m_properties.geometryFlipped = value;
508     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::GeometryFlippedChanged);
509 }
510
511 bool PlatformCALayerRemote::isDoubleSided() const
512 {
513     return m_properties.doubleSided;
514 }
515
516 void PlatformCALayerRemote::setDoubleSided(bool value)
517 {
518     m_properties.doubleSided = value;
519     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::DoubleSidedChanged);
520 }
521
522 bool PlatformCALayerRemote::masksToBounds() const
523 {
524     return m_properties.masksToBounds;
525 }
526
527 void PlatformCALayerRemote::setMasksToBounds(bool value)
528 {
529     if (value == m_properties.masksToBounds)
530         return;
531
532     m_properties.masksToBounds = value;
533     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::MasksToBoundsChanged);
534 }
535
536 bool PlatformCALayerRemote::acceleratesDrawing() const
537 {
538     return m_acceleratesDrawing;
539 }
540
541 void PlatformCALayerRemote::setAcceleratesDrawing(bool acceleratesDrawing)
542 {
543     m_acceleratesDrawing = acceleratesDrawing;
544     updateBackingStore();
545 }
546
547 CFTypeRef PlatformCALayerRemote::contents() const
548 {
549     return nullptr;
550 }
551
552 void PlatformCALayerRemote::setContents(CFTypeRef value)
553 {
554 }
555
556 void PlatformCALayerRemote::setContentsRect(const FloatRect& value)
557 {
558     m_properties.contentsRect = value;
559     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ContentsRectChanged);
560 }
561
562 void PlatformCALayerRemote::setMinificationFilter(FilterType value)
563 {
564     m_properties.minificationFilter = value;
565     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::MinificationFilterChanged);
566 }
567
568 void PlatformCALayerRemote::setMagnificationFilter(FilterType value)
569 {
570     m_properties.magnificationFilter = value;
571     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::MagnificationFilterChanged);
572 }
573
574 Color PlatformCALayerRemote::backgroundColor() const
575 {
576     return m_properties.backgroundColor;
577 }
578
579 void PlatformCALayerRemote::setBackgroundColor(const Color& value)
580 {
581     m_properties.backgroundColor = value;
582     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackgroundColorChanged);
583 }
584
585 void PlatformCALayerRemote::setBorderWidth(float value)
586 {
587     if (value == m_properties.borderWidth)
588         return;
589
590     m_properties.borderWidth = value;
591     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BorderWidthChanged);
592 }
593
594 void PlatformCALayerRemote::setBorderColor(const Color& value)
595 {
596     if (value == m_properties.borderColor)
597         return;
598
599     m_properties.borderColor = value;
600     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BorderColorChanged);
601 }
602
603 float PlatformCALayerRemote::opacity() const
604 {
605     return m_properties.opacity;
606 }
607
608 void PlatformCALayerRemote::setOpacity(float value)
609 {
610     m_properties.opacity = value;
611     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::OpacityChanged);
612 }
613
614 void PlatformCALayerRemote::setFilters(const FilterOperations& filters)
615 {
616     m_properties.filters = std::make_unique<FilterOperations>(filters);
617     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::FiltersChanged);
618 }
619
620 void PlatformCALayerRemote::copyFiltersFrom(const PlatformCALayer& sourceLayer)
621 {
622     if (const FilterOperations* filters = downcast<PlatformCALayerRemote>(sourceLayer).m_properties.filters.get())
623         setFilters(*filters);
624     else if (m_properties.filters)
625         m_properties.filters = nullptr;
626
627     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::FiltersChanged);
628 }
629
630 #if ENABLE(CSS_COMPOSITING)
631 void PlatformCALayerRemote::setBlendMode(BlendMode blendMode)
632 {
633     m_properties.blendMode = blendMode;
634     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BlendModeChanged);
635 }
636 #endif
637
638 bool PlatformCALayerRemote::filtersCanBeComposited(const FilterOperations& filters)
639 {
640     return PlatformCALayerMac::filtersCanBeComposited(filters);
641 }
642
643 void PlatformCALayerRemote::setName(const String& value)
644 {
645     m_properties.name = value;
646     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::NameChanged);
647 }
648
649 void PlatformCALayerRemote::setSpeed(float value)
650 {
651     m_properties.speed = value;
652     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::SpeedChanged);
653 }
654
655 void PlatformCALayerRemote::setTimeOffset(CFTimeInterval value)
656 {
657     m_properties.timeOffset = value;
658     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::TimeOffsetChanged);
659 }
660
661 float PlatformCALayerRemote::contentsScale() const
662 {
663     return m_properties.contentsScale;
664 }
665
666 void PlatformCALayerRemote::setContentsScale(float value)
667 {
668     m_properties.contentsScale = value;
669     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ContentsScaleChanged);
670
671     updateBackingStore();
672 }
673
674 float PlatformCALayerRemote::cornerRadius() const
675 {
676     return m_properties.cornerRadius;
677 }
678
679 void PlatformCALayerRemote::setCornerRadius(float value)
680 {
681     if (m_properties.cornerRadius == value)
682         return;
683
684     m_properties.cornerRadius = value;
685     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CornerRadiusChanged);
686 }
687
688 void PlatformCALayerRemote::setEdgeAntialiasingMask(unsigned value)
689 {
690     m_properties.edgeAntialiasingMask = value;
691     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged);
692 }
693
694 FloatRoundedRect PlatformCALayerRemote::shapeRoundedRect() const
695 {
696     return m_properties.shapeRoundedRect ? *m_properties.shapeRoundedRect : FloatRoundedRect(FloatRect());
697 }
698
699 void PlatformCALayerRemote::setShapeRoundedRect(const FloatRoundedRect& roundedRect)
700 {
701     if (m_properties.shapeRoundedRect && *m_properties.shapeRoundedRect == roundedRect)
702         return;
703
704     m_properties.shapeRoundedRect = std::make_unique<FloatRoundedRect>(roundedRect);
705     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ShapeRoundedRectChanged);
706 }
707
708 Path PlatformCALayerRemote::shapePath() const
709 {
710     ASSERT(m_layerType == LayerTypeShapeLayer);
711     return m_properties.shapePath;
712 }
713
714 void PlatformCALayerRemote::setShapePath(const Path& path)
715 {
716     ASSERT(m_layerType == LayerTypeShapeLayer);
717     m_properties.shapePath = path;
718     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ShapePathChanged);
719 }
720
721 WindRule PlatformCALayerRemote::shapeWindRule() const
722 {
723     ASSERT(m_layerType == LayerTypeShapeLayer);
724     return m_properties.windRule;
725 }
726
727 void PlatformCALayerRemote::setShapeWindRule(WindRule windRule)
728 {
729     ASSERT(m_layerType == LayerTypeShapeLayer);
730     m_properties.windRule = windRule;
731     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::WindRuleChanged);
732 }
733
734 bool PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange() const
735 {
736     return m_properties.customAppearance == GraphicsLayer::ScrollingShadow;
737 }
738
739 GraphicsLayer::CustomAppearance PlatformCALayerRemote::customAppearance() const
740 {
741     return m_properties.customAppearance;
742 }
743
744 void PlatformCALayerRemote::updateCustomAppearance(GraphicsLayer::CustomAppearance customAppearance)
745 {
746     m_properties.customAppearance = customAppearance;
747     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CustomAppearanceChanged);
748 }
749
750 PassRefPtr<PlatformCALayer> PlatformCALayerRemote::createCompatibleLayer(PlatformCALayer::LayerType layerType, PlatformCALayerClient* client) const
751 {
752     return PlatformCALayerRemote::create(layerType, client, *m_context);
753 }
754
755 void PlatformCALayerRemote::enumerateRectsBeingDrawn(CGContextRef context, void (^block)(CGRect))
756 {
757     m_properties.backingStore->enumerateRectsBeingDrawn(context, block);
758 }
759
760 uint32_t PlatformCALayerRemote::hostingContextID()
761 {
762     ASSERT_NOT_REACHED();
763     return 0;
764 }
765
766 LayerPool& PlatformCALayerRemote::layerPool()
767 {
768     return m_context->layerPool();
769 }
770
771 } // namespace WebKit