2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
28 #include "GraphicsLayer.h"
29 #include "PlatformCAAnimation.h"
30 #include "PlatformCALayer.h"
31 #include "PlatformCALayerClient.h"
32 #include <wtf/HashMap.h>
33 #include <wtf/RetainPtr.h>
34 #include <wtf/text/StringHash.h>
36 // Enable this to add a light red wash over the visible portion of Tiled Layers, as computed
37 // by flushCompositingState().
38 // #define VISIBLE_TILE_WASH
42 namespace DisplayList {
46 class FloatRoundedRect;
50 class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient {
53 WEBCORE_EXPORT explicit GraphicsLayerCA(Type, GraphicsLayerClient&);
54 WEBCORE_EXPORT virtual ~GraphicsLayerCA();
56 WEBCORE_EXPORT void initialize(Type) override;
58 WEBCORE_EXPORT void setName(const String&) override;
60 WEBCORE_EXPORT PlatformLayerID primaryLayerID() const override;
62 WEBCORE_EXPORT PlatformLayer* platformLayer() const override;
63 PlatformCALayer* platformCALayer() const { return primaryLayer(); }
65 WEBCORE_EXPORT bool setChildren(const Vector<GraphicsLayer*>&) override;
66 WEBCORE_EXPORT void addChild(GraphicsLayer*) override;
67 WEBCORE_EXPORT void addChildAtIndex(GraphicsLayer*, int index) override;
68 WEBCORE_EXPORT void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling) override;
69 WEBCORE_EXPORT void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling) override;
70 WEBCORE_EXPORT bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild) override;
72 WEBCORE_EXPORT void removeFromParent() override;
74 WEBCORE_EXPORT void setMaskLayer(GraphicsLayer*) override;
75 WEBCORE_EXPORT void setReplicatedLayer(GraphicsLayer*) override;
77 WEBCORE_EXPORT void setPosition(const FloatPoint&) override;
78 WEBCORE_EXPORT void syncPosition(const FloatPoint&) override;
79 WEBCORE_EXPORT void setApproximatePosition(const FloatPoint&) override;
80 WEBCORE_EXPORT void setAnchorPoint(const FloatPoint3D&) override;
81 WEBCORE_EXPORT void setSize(const FloatSize&) override;
82 WEBCORE_EXPORT void setBoundsOrigin(const FloatPoint&) override;
83 WEBCORE_EXPORT void syncBoundsOrigin(const FloatPoint&) override;
85 WEBCORE_EXPORT void setTransform(const TransformationMatrix&) override;
87 WEBCORE_EXPORT void setChildrenTransform(const TransformationMatrix&) override;
89 WEBCORE_EXPORT void setPreserves3D(bool) override;
90 WEBCORE_EXPORT void setMasksToBounds(bool) override;
91 WEBCORE_EXPORT void setDrawsContent(bool) override;
92 WEBCORE_EXPORT void setContentsVisible(bool) override;
93 WEBCORE_EXPORT void setAcceleratesDrawing(bool) override;
94 WEBCORE_EXPORT void setUsesDisplayListDrawing(bool) override;
95 WEBCORE_EXPORT void setUserInteractionEnabled(bool) override;
97 WEBCORE_EXPORT void setBackgroundColor(const Color&) override;
99 WEBCORE_EXPORT void setContentsOpaque(bool) override;
100 WEBCORE_EXPORT void setSupportsSubpixelAntialiasedText(bool) override;
102 WEBCORE_EXPORT void setBackfaceVisibility(bool) override;
104 // return true if we started an animation
105 WEBCORE_EXPORT void setOpacity(float) override;
107 WEBCORE_EXPORT bool setFilters(const FilterOperations&) override;
108 virtual bool filtersCanBeComposited(const FilterOperations&);
110 WEBCORE_EXPORT bool setBackdropFilters(const FilterOperations&) override;
111 WEBCORE_EXPORT void setBackdropFiltersRect(const FloatRoundedRect&) override;
113 #if ENABLE(CSS_COMPOSITING)
114 WEBCORE_EXPORT void setBlendMode(BlendMode) override;
117 WEBCORE_EXPORT void setNeedsDisplay() override;
118 WEBCORE_EXPORT void setNeedsDisplayInRect(const FloatRect&, ShouldClipToLayer = ClipToLayer) override;
119 WEBCORE_EXPORT void setContentsNeedsDisplay() override;
121 WEBCORE_EXPORT void setContentsRect(const FloatRect&) override;
122 WEBCORE_EXPORT void setContentsClippingRect(const FloatRoundedRect&) override;
123 WEBCORE_EXPORT bool setMasksToBoundsRect(const FloatRoundedRect&) override;
125 WEBCORE_EXPORT void setShapeLayerPath(const Path&) override;
126 WEBCORE_EXPORT void setShapeLayerWindRule(WindRule) override;
128 WEBCORE_EXPORT void suspendAnimations(MonotonicTime) override;
129 WEBCORE_EXPORT void resumeAnimations() override;
131 WEBCORE_EXPORT bool addAnimation(const KeyframeValueList&, const FloatSize& boxSize, const Animation*, const String& animationName, double timeOffset) override;
132 WEBCORE_EXPORT void pauseAnimation(const String& animationName, double timeOffset) override;
133 WEBCORE_EXPORT void seekAnimation(const String& animationName, double timeOffset) override;
134 WEBCORE_EXPORT void removeAnimation(const String& animationName) override;
136 WEBCORE_EXPORT void setContentsToImage(Image*) override;
138 WEBCORE_EXPORT PlatformLayer* contentsLayerForMedia() const override;
140 WEBCORE_EXPORT void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) override;
141 WEBCORE_EXPORT void setContentsToSolidColor(const Color&) override;
143 bool usesContentsLayer() const override { return m_contentsLayerPurpose != NoContentsLayer; }
145 WEBCORE_EXPORT void setShowDebugBorder(bool) override;
146 WEBCORE_EXPORT void setShowRepaintCounter(bool) override;
148 WEBCORE_EXPORT void setDebugBackgroundColor(const Color&) override;
149 WEBCORE_EXPORT void setDebugBorder(const Color&, float borderWidth) override;
151 WEBCORE_EXPORT void setCustomAppearance(CustomAppearance) override;
153 WEBCORE_EXPORT void deviceOrPageScaleFactorChanged() override;
155 FloatSize pixelAlignmentOffset() const override { return m_pixelAlignmentOffset; }
159 bool ancestorHadChanges { false };
160 bool ancestorHasTransformAnimation { false };
161 bool ancestorStartedOrEndedTransformAnimation { false };
162 bool ancestorWithTransformAnimationIntersectsCoverageRect { false };
163 bool ancestorIsViewportConstrained { false };
165 bool needsCommit(const CommitState&);
166 void recursiveCommitChanges(const CommitState&, const TransformState&, float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false);
168 WEBCORE_EXPORT void flushCompositingState(const FloatRect&) override;
169 WEBCORE_EXPORT void flushCompositingStateForThisLayerOnly() override;
171 WEBCORE_EXPORT bool visibleRectChangeRequiresFlush(const FloatRect& visibleRect) const override;
173 WEBCORE_EXPORT TiledBacking* tiledBacking() const override;
176 WEBCORE_EXPORT void setOpacityInternal(float) override;
178 WEBCORE_EXPORT bool animationCanBeAccelerated(const KeyframeValueList&, const Animation*) const;
181 bool isGraphicsLayerCA() const override { return true; }
183 WEBCORE_EXPORT void willBeDestroyed() override;
185 // PlatformCALayerClient overrides
186 void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) override { }
187 bool platformCALayerRespondsToLayoutChanges() const override { return false; }
188 WEBCORE_EXPORT void platformCALayerCustomSublayersChanged(PlatformCALayer*) override;
190 WEBCORE_EXPORT void platformCALayerAnimationStarted(const String& animationKey, MonotonicTime beginTime) override;
191 WEBCORE_EXPORT void platformCALayerAnimationEnded(const String& animationKey) override;
192 CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return contentsOrientation(); }
193 WEBCORE_EXPORT void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& clip, GraphicsLayerPaintBehavior) override;
194 bool platformCALayerShowDebugBorders() const override { return isShowingDebugBorder(); }
195 WEBCORE_EXPORT bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override;
196 int platformCALayerRepaintCount(PlatformCALayer*) const override { return repaintCount(); }
197 int platformCALayerIncrementRepaintCount(PlatformCALayer*) override { return incrementRepaintCount(); }
199 bool platformCALayerContentsOpaque() const override { return contentsOpaque(); }
200 bool platformCALayerDrawsContent() const override { return drawsContent(); }
201 void platformCALayerLayerDidDisplay(PlatformCALayer* layer) override { return layerDidDisplay(layer); }
202 WEBCORE_EXPORT void platformCALayerSetNeedsToRevalidateTiles() override;
203 WEBCORE_EXPORT float platformCALayerDeviceScaleFactor() const override;
204 WEBCORE_EXPORT float platformCALayerContentsScaleMultiplierForNewTiles(PlatformCALayer*) const override;
205 WEBCORE_EXPORT bool platformCALayerShouldAggressivelyRetainTiles(PlatformCALayer*) const override;
206 WEBCORE_EXPORT bool platformCALayerShouldTemporarilyRetainTileCohorts(PlatformCALayer*) const override;
207 WEBCORE_EXPORT bool platformCALayerUseGiantTiles() const override;
208 WEBCORE_EXPORT void platformCALayerLogFilledVisibleFreshTile(unsigned) override;
210 bool isCommittingChanges() const override { return m_isCommittingChanges; }
211 bool isUsingDisplayListDrawing(PlatformCALayer*) const override { return m_usesDisplayListDrawing; }
213 WEBCORE_EXPORT void setIsViewportConstrained(bool) override;
214 bool isViewportConstrained() const override { return m_isViewportConstrained; }
216 WEBCORE_EXPORT String displayListAsText(DisplayList::AsTextFlags) const override;
218 WEBCORE_EXPORT void setIsTrackingDisplayListReplay(bool) override;
219 WEBCORE_EXPORT String replayDisplayListAsText(DisplayList::AsTextFlags) const override;
221 WEBCORE_EXPORT double backingStoreMemoryEstimate() const override;
223 WEBCORE_EXPORT bool shouldRepaintOnSizeChange() const override;
225 WEBCORE_EXPORT void layerDidDisplay(PlatformCALayer*);
227 virtual Ref<PlatformCALayer> createPlatformCALayer(PlatformCALayer::LayerType, PlatformCALayerClient* owner);
228 virtual Ref<PlatformCALayer> createPlatformCALayer(PlatformLayer*, PlatformCALayerClient* owner);
229 virtual Ref<PlatformCAAnimation> createPlatformCAAnimation(PlatformCAAnimation::AnimationType, const String& keyPath);
231 PlatformCALayer* primaryLayer() const { return m_structuralLayer.get() ? m_structuralLayer.get() : m_layer.get(); }
232 PlatformCALayer* hostLayerForSublayers() const;
233 PlatformCALayer* layerForSuperlayer() const;
234 PlatformCALayer* animatedLayer(AnimatedPropertyID) const;
236 typedef String CloneID; // Identifier for a given clone, based on original/replica branching down the tree.
237 static bool isReplicatedRootClone(const CloneID& cloneID) { return cloneID[0U] & 1; }
239 typedef HashMap<CloneID, RefPtr<PlatformCALayer>> LayerMap;
240 LayerMap* primaryLayerClones() const { return m_structuralLayer.get() ? m_structuralLayerClones.get() : m_layerClones.get(); }
241 LayerMap* animatedLayerClones(AnimatedPropertyID) const;
243 bool createAnimationFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset);
244 bool createTransformAnimationsFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset, const FloatSize& boxSize);
245 bool createFilterAnimationsFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset);
247 // Return autoreleased animation (use RetainPtr?)
248 Ref<PlatformCAAnimation> createBasicAnimation(const Animation*, const String& keyPath, bool additive);
249 Ref<PlatformCAAnimation> createKeyframeAnimation(const Animation*, const String&, bool additive);
250 Ref<PlatformCAAnimation> createSpringAnimation(const Animation*, const String&, bool additive);
251 void setupAnimation(PlatformCAAnimation*, const Animation*, bool additive);
253 const TimingFunction& timingFunctionForAnimationValue(const AnimationValue&, const Animation&);
255 bool setAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformCAAnimation*);
256 bool setAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformCAAnimation*);
258 bool setTransformAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformCAAnimation*, int functionIndex, TransformOperation::OperationType, bool isMatrixAnimation, const FloatSize& boxSize);
259 bool setTransformAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformCAAnimation*, int functionIndex, TransformOperation::OperationType, bool isMatrixAnimation, const FloatSize& boxSize);
261 bool setFilterAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformCAAnimation*, int functionIndex, int internalFilterPropertyIndex);
262 bool setFilterAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformCAAnimation*, int functionIndex, int internalFilterPropertyIndex, FilterOperation::OperationType);
264 bool isRunningTransformAnimation() const;
266 WEBCORE_EXPORT bool backingStoreAttached() const override;
268 bool animationIsRunning(const String& animationName) const
270 return m_runningAnimations.find(animationName) != m_runningAnimations.end();
273 void commitLayerChangesBeforeSublayers(CommitState&, float pageScaleFactor, const FloatPoint& positionRelativeToBase);
274 void commitLayerChangesAfterSublayers(CommitState&);
276 FloatPoint computePositionRelativeToBase(float& pageScale) const;
278 bool requiresTiledLayer(float pageScaleFactor) const;
279 void changeLayerTypeTo(PlatformCALayer::LayerType);
281 CompositingCoordinatesOrientation defaultContentsOrientation() const;
283 void setupContentsLayer(PlatformCALayer*);
284 PlatformCALayer* contentsLayer() const { return m_contentsLayer.get(); }
286 void updateClippingStrategy(PlatformCALayer&, RefPtr<PlatformCALayer>& shapeMaskLayer, const FloatRoundedRect&);
288 WEBCORE_EXPORT void setReplicatedByLayer(GraphicsLayer*) override;
290 WEBCORE_EXPORT bool canThrottleLayerFlush() const override;
292 WEBCORE_EXPORT void getDebugBorderInfo(Color&, float& width) const override;
293 WEBCORE_EXPORT void dumpAdditionalProperties(WTF::TextStream&, LayerTreeAsTextBehavior) const override;
295 void computePixelAlignment(float contentsScale, const FloatPoint& positionRelativeToBase,
296 FloatPoint& position, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset) const;
298 TransformationMatrix layerTransform(const FloatPoint& position, const TransformationMatrix* customTransform = 0) const;
300 enum ComputeVisibleRectFlag { RespectAnimatingTransforms = 1 << 0 };
301 typedef unsigned ComputeVisibleRectFlags;
303 struct VisibleAndCoverageRects {
304 FloatRect visibleRect;
305 FloatRect coverageRect;
306 TransformationMatrix animatingTransform;
309 VisibleAndCoverageRects computeVisibleAndCoverageRect(TransformState&, bool accumulateTransform, ComputeVisibleRectFlags = RespectAnimatingTransforms) const;
310 bool adjustCoverageRect(VisibleAndCoverageRects&, const FloatRect& oldVisibleRect) const;
312 const FloatRect& visibleRect() const { return m_visibleRect; }
313 const FloatRect& coverageRect() const { return m_coverageRect; }
315 void setVisibleAndCoverageRects(const VisibleAndCoverageRects&, bool isViewportConstrained);
317 static FloatRect adjustTiledLayerVisibleRect(TiledBacking*, const FloatRect& oldVisibleRect, const FloatRect& newVisibleRect, const FloatSize& oldSize, const FloatSize& newSize);
319 bool recursiveVisibleRectChangeRequiresFlush(const CommitState&, const TransformState&) const;
321 bool isPageTiledBackingLayer() const { return type() == Type::PageTiledBacking; }
323 // Used to track the path down the tree for replica layers.
324 struct ReplicaState {
325 static const size_t maxReplicaDepth = 16;
326 enum ReplicaBranchType { ChildBranch = 0, ReplicaBranch = 1 };
327 ReplicaState(ReplicaBranchType firstBranch)
333 // Called as we walk down the tree to build replicas.
334 void push(ReplicaBranchType branchType)
336 m_replicaBranches.append(branchType);
337 if (branchType == ReplicaBranch)
341 void setBranchType(ReplicaBranchType branchType)
343 ASSERT(!m_replicaBranches.isEmpty());
345 if (m_replicaBranches.last() != branchType) {
346 if (branchType == ReplicaBranch)
352 m_replicaBranches.last() = branchType;
357 if (m_replicaBranches.last() == ReplicaBranch)
359 m_replicaBranches.removeLast();
362 size_t depth() const { return m_replicaBranches.size(); }
363 size_t replicaDepth() const { return m_replicaDepth; }
365 CloneID cloneID() const;
368 Vector<ReplicaBranchType> m_replicaBranches;
369 size_t m_replicaDepth;
371 RefPtr<PlatformCALayer>replicatedLayerRoot(ReplicaState&);
373 enum CloneLevel { RootCloneLevel, IntermediateCloneLevel };
374 RefPtr<PlatformCALayer> fetchCloneLayers(GraphicsLayer* replicaRoot, ReplicaState&, CloneLevel);
376 Ref<PlatformCALayer> cloneLayer(PlatformCALayer *, CloneLevel);
377 RefPtr<PlatformCALayer> findOrMakeClone(CloneID, PlatformCALayer *, LayerMap*, CloneLevel);
379 void ensureCloneLayers(CloneID, RefPtr<PlatformCALayer>& primaryLayer, RefPtr<PlatformCALayer>& structuralLayer,
380 RefPtr<PlatformCALayer>& contentsLayer, RefPtr<PlatformCALayer>& contentsClippingLayer, RefPtr<PlatformCALayer>& contentsShapeMaskLayer,
381 RefPtr<PlatformCALayer>& shapeMaskLayer, RefPtr<PlatformCALayer>& backdropLayer, RefPtr<PlatformCALayer>& backdropClippingLayer,
384 static void clearClones(std::unique_ptr<LayerMap>&);
386 bool hasCloneLayers() const { return !!m_layerClones; }
387 void removeCloneLayers();
388 FloatPoint positionForCloneRootLayer() const;
390 // All these "update" methods will be called inside a BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS block.
392 void updateSublayerList(bool maxLayerDepthReached = false);
393 void updateGeometry(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
394 void updateTransform();
395 void updateChildrenTransform();
396 void updateMasksToBounds();
397 void updateContentsVisibility();
398 void updateContentsOpaque(float pageScaleFactor);
399 void updateBackfaceVisibility();
400 void updateStructuralLayer();
401 void updateDrawsContent();
402 void updateCoverage(const CommitState&);
403 void updateBackgroundColor();
404 void updateUserInteractionEnabled();
406 void updateContentsImage();
407 void updateContentsPlatformLayer();
408 void updateContentsColorLayer();
409 void updateContentsRects();
410 void updateMasksToBoundsRect();
411 void updateMaskLayer();
412 void updateReplicatedLayers();
414 void updateAnimations();
415 void updateContentsNeedsDisplay();
416 void updateAcceleratesDrawing();
417 void updateSupportsSubpixelAntialiasedText();
418 void updateDebugIndicators();
420 void updateContentsScale(float pageScaleFactor);
421 void updateCustomAppearance();
423 void updateOpacityOnLayer();
424 void updateFilters();
425 void updateBackdropFilters();
426 void updateBackdropFiltersRect();
428 #if ENABLE(CSS_COMPOSITING)
429 void updateBlendMode();
433 void updateWindRule();
435 enum StructuralLayerPurpose {
436 NoStructuralLayer = 0,
437 StructuralLayerForPreserves3D,
438 StructuralLayerForReplicaFlattening,
439 StructuralLayerForBackdrop
441 void ensureStructuralLayer(StructuralLayerPurpose);
442 StructuralLayerPurpose structuralLayerPurpose() const;
444 void setAnimationOnLayer(PlatformCAAnimation&, AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
445 bool removeCAAnimationFromLayer(AnimatedPropertyID, const String& animationName, int index, int subINdex);
446 void pauseCAAnimationOnLayer(AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
447 void seekCAAnimationOnLayer(AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
449 enum MoveOrCopy { Move, Copy };
450 static void moveOrCopyLayerAnimation(MoveOrCopy, const String& animationIdentifier, PlatformCALayer *fromLayer, PlatformCALayer *toLayer);
451 void moveOrCopyAnimations(MoveOrCopy, PlatformCALayer* fromLayer, PlatformCALayer* toLayer);
453 void moveAnimations(PlatformCALayer* fromLayer, PlatformCALayer* toLayer)
455 moveOrCopyAnimations(Move, fromLayer, toLayer);
457 void copyAnimations(PlatformCALayer* fromLayer, PlatformCALayer* toLayer)
459 moveOrCopyAnimations(Copy, fromLayer, toLayer);
462 // This represents the animation of a single property. There may be multiple transform animations for
463 // a single transition or keyframe animation, so index is used to distinguish these.
464 struct LayerPropertyAnimation {
465 LayerPropertyAnimation(Ref<PlatformCAAnimation>&& caAnimation, const String& animationName, AnimatedPropertyID property, int index, int subIndex, Seconds timeOffset)
466 : m_animation(WTFMove(caAnimation))
467 , m_name(animationName)
468 , m_property(property)
470 , m_subIndex(subIndex)
471 , m_timeOffset(timeOffset)
474 RefPtr<PlatformCAAnimation> m_animation;
476 AnimatedPropertyID m_property;
479 Seconds m_timeOffset;
482 bool appendToUncommittedAnimations(const KeyframeValueList&, const TransformOperations*, const Animation*, const String& animationName, const FloatSize& boxSize, int animationIndex, Seconds timeOffset, bool isMatrixAnimation);
483 bool appendToUncommittedAnimations(const KeyframeValueList&, const FilterOperation*, const Animation*, const String& animationName, int animationIndex, Seconds timeOffset);
484 void appendToUncommittedAnimations(LayerPropertyAnimation&&);
486 enum LayerChange : uint64_t {
488 NameChanged = 1LLU << 1,
489 ChildrenChanged = 1LLU << 2, // also used for content layer, and preserves-3d, and size if tiling changes?
490 GeometryChanged = 1LLU << 3,
491 TransformChanged = 1LLU << 4,
492 ChildrenTransformChanged = 1LLU << 5,
493 Preserves3DChanged = 1LLU << 6,
494 MasksToBoundsChanged = 1LLU << 7,
495 DrawsContentChanged = 1LLU << 8,
496 BackgroundColorChanged = 1LLU << 9,
497 ContentsOpaqueChanged = 1LLU << 10,
498 BackfaceVisibilityChanged = 1LLU << 11,
499 OpacityChanged = 1LLU << 12,
500 AnimationChanged = 1LLU << 13,
501 DirtyRectsChanged = 1LLU << 14,
502 ContentsImageChanged = 1LLU << 15,
503 ContentsPlatformLayerChanged = 1LLU << 16,
504 ContentsColorLayerChanged = 1LLU << 17,
505 ContentsRectsChanged = 1LLU << 18,
506 MasksToBoundsRectChanged = 1LLU << 19,
507 MaskLayerChanged = 1LLU << 20,
508 ReplicatedLayerChanged = 1LLU << 21,
509 ContentsNeedsDisplay = 1LLU << 22,
510 AcceleratesDrawingChanged = 1LLU << 23,
511 SupportsSubpixelAntialiasedTextChanged = 1LLU << 24,
512 ContentsScaleChanged = 1LLU << 25,
513 ContentsVisibilityChanged = 1LLU << 26,
514 CoverageRectChanged = 1LLU << 27,
515 FiltersChanged = 1LLU << 28,
516 BackdropFiltersChanged = 1LLU << 29,
517 BackdropFiltersRectChanged = 1LLU << 30,
518 TilingAreaChanged = 1LLU << 31,
519 TilesAdded = 1LLU << 32,
520 DebugIndicatorsChanged = 1LLU << 33,
521 CustomAppearanceChanged = 1LLU << 34,
522 BlendModeChanged = 1LLU << 35,
523 ShapeChanged = 1LLU << 36,
524 WindRuleChanged = 1LLU << 37,
525 UserInteractionEnabledChanged = 1LLU << 38,
526 NeedsComputeVisibleAndCoverageRect = 1LLU << 39,
528 typedef uint64_t LayerChangeFlags;
529 void addUncommittedChanges(LayerChangeFlags);
530 bool hasDescendantsWithUncommittedChanges() const { return m_hasDescendantsWithUncommittedChanges; }
531 void setHasDescendantsWithUncommittedChanges(bool);
532 enum ScheduleFlushOrNot { ScheduleFlush, DontScheduleFlush };
533 void noteLayerPropertyChanged(LayerChangeFlags, ScheduleFlushOrNot = ScheduleFlush);
534 void noteSublayersChanged(ScheduleFlushOrNot = ScheduleFlush);
535 void noteChangesForScaleSensitiveProperties();
537 bool hasDescendantsWithRunningTransformAnimations() const { return m_hasDescendantsWithRunningTransformAnimations; }
538 void setHasDescendantsWithRunningTransformAnimations(bool b) { m_hasDescendantsWithRunningTransformAnimations = b; }
540 void propagateLayerChangeToReplicas(ScheduleFlushOrNot = ScheduleFlush);
542 void repaintLayerDirtyRects();
544 enum Action { Remove, Pause, Seek };
545 struct AnimationProcessingAction {
546 AnimationProcessingAction(Action action = Remove, Seconds timeOffset = 0_s)
548 , timeOffset(timeOffset)
552 Seconds timeOffset; // Only used for pause.
554 void addProcessingActionForAnimation(const String&, AnimationProcessingAction);
556 RefPtr<PlatformCALayer> m_layer; // The main layer
557 RefPtr<PlatformCALayer> m_structuralLayer; // A layer used for structural reasons, like preserves-3d or replica-flattening. Is the parent of m_layer.
558 RefPtr<PlatformCALayer> m_contentsClippingLayer; // A layer used to clip inner content
559 RefPtr<PlatformCALayer> m_shapeMaskLayer; // Used to clip with non-trivial corner radii.
560 RefPtr<PlatformCALayer> m_backdropClippingLayer; // Used to clip the backdrop layer with corner radii.
561 RefPtr<PlatformCALayer> m_contentsLayer; // A layer used for inner content, like image and video
562 RefPtr<PlatformCALayer> m_contentsShapeMaskLayer; // Used to clip the content layer with non-trivial corner radii.
563 RefPtr<PlatformCALayer> m_backdropLayer; // The layer used for backdrop rendering, if necessary.
565 // References to clones of our layers, for replicated layers.
566 std::unique_ptr<LayerMap> m_layerClones;
567 std::unique_ptr<LayerMap> m_structuralLayerClones;
568 std::unique_ptr<LayerMap> m_contentsLayerClones;
569 std::unique_ptr<LayerMap> m_contentsClippingLayerClones;
570 std::unique_ptr<LayerMap> m_contentsShapeMaskLayerClones;
571 std::unique_ptr<LayerMap> m_shapeMaskLayerClones;
572 std::unique_ptr<LayerMap> m_backdropLayerClones;
573 std::unique_ptr<LayerMap> m_backdropClippingLayerClones;
575 #ifdef VISIBLE_TILE_WASH
576 RefPtr<PlatformCALayer> m_visibleTileWashLayer;
578 FloatRect m_visibleRect;
579 FloatSize m_sizeAtLastCoverageRectUpdate;
581 FloatRect m_coverageRect; // Area for which we should maintain backing store, in the coordinate space of this layer.
583 ContentsLayerPurpose m_contentsLayerPurpose { NoContentsLayer };
584 bool m_needsFullRepaint { false };
585 bool m_usingBackdropLayerType { false };
586 bool m_isViewportConstrained { false };
587 bool m_intersectsCoverageRect { false };
588 bool m_hasEverPainted { false };
589 bool m_hasDescendantsWithRunningTransformAnimations { false };
591 Color m_contentsSolidColor;
593 RetainPtr<CGImageRef> m_uncorrectedContentsImage;
594 RetainPtr<CGImageRef> m_pendingContentsImage;
596 // Uncommitted transitions and animations.
597 Vector<LayerPropertyAnimation> m_uncomittedAnimations;
599 typedef HashMap<String, Vector<AnimationProcessingAction>> AnimationsToProcessMap;
600 AnimationsToProcessMap m_animationsToProcess;
602 // Map of animation names to their associated lists of property animations, so we can remove/pause them.
603 typedef HashMap<String, Vector<LayerPropertyAnimation>> AnimationsMap;
604 AnimationsMap m_runningAnimations;
606 Vector<FloatRect> m_dirtyRects;
608 std::unique_ptr<DisplayList::DisplayList> m_displayList;
610 FloatSize m_pixelAlignmentOffset;
613 // FIXME: when initializing m_uncommittedChanges to a non-zero value, nothing is painted on Windows, see https://bugs.webkit.org/show_bug.cgi?id=168666.
614 LayerChangeFlags m_uncommittedChanges { 0 };
616 LayerChangeFlags m_uncommittedChanges { CoverageRectChanged };
618 bool m_hasDescendantsWithUncommittedChanges { false };
620 bool m_isCommittingChanges { false };
621 FloatRect m_previousCommittedVisibleRect;
624 } // namespace WebCore
626 SPECIALIZE_TYPE_TRAITS_GRAPHICSLAYER(WebCore::GraphicsLayerCA, isGraphicsLayerCA())