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 != ContentsLayerPurpose::None; }
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;
241 LayerMap* animatedLayerClones(AnimatedPropertyID) const;
242 static void clearClones(LayerMap&);
244 bool createAnimationFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset);
245 bool createTransformAnimationsFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset, const FloatSize& boxSize);
246 bool createFilterAnimationsFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset);
248 // Return autoreleased animation (use RetainPtr?)
249 Ref<PlatformCAAnimation> createBasicAnimation(const Animation*, const String& keyPath, bool additive);
250 Ref<PlatformCAAnimation> createKeyframeAnimation(const Animation*, const String&, bool additive);
251 Ref<PlatformCAAnimation> createSpringAnimation(const Animation*, const String&, bool additive);
252 void setupAnimation(PlatformCAAnimation*, const Animation*, bool additive);
254 const TimingFunction& timingFunctionForAnimationValue(const AnimationValue&, const Animation&);
256 bool setAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformCAAnimation*);
257 bool setAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformCAAnimation*);
259 bool setTransformAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformCAAnimation*, int functionIndex, TransformOperation::OperationType, bool isMatrixAnimation, const FloatSize& boxSize);
260 bool setTransformAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformCAAnimation*, int functionIndex, TransformOperation::OperationType, bool isMatrixAnimation, const FloatSize& boxSize);
262 bool setFilterAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformCAAnimation*, int functionIndex, int internalFilterPropertyIndex);
263 bool setFilterAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformCAAnimation*, int functionIndex, int internalFilterPropertyIndex, FilterOperation::OperationType);
265 bool isRunningTransformAnimation() const;
267 WEBCORE_EXPORT bool backingStoreAttached() const override;
268 WEBCORE_EXPORT bool backingStoreAttachedForTesting() const override;
270 bool hasAnimations() const { return m_animations.get(); }
271 bool animationIsRunning(const String& animationName) const
273 return m_animations && m_animations->runningAnimations.contains(animationName);
276 void commitLayerChangesBeforeSublayers(CommitState&, float pageScaleFactor, const FloatPoint& positionRelativeToBase);
277 void commitLayerChangesAfterSublayers(CommitState&);
279 FloatPoint computePositionRelativeToBase(float& pageScale) const;
281 bool requiresTiledLayer(float pageScaleFactor) const;
282 void changeLayerTypeTo(PlatformCALayer::LayerType);
284 CompositingCoordinatesOrientation defaultContentsOrientation() const;
286 void setupContentsLayer(PlatformCALayer*);
287 PlatformCALayer* contentsLayer() const { return m_contentsLayer.get(); }
289 void updateClippingStrategy(PlatformCALayer&, RefPtr<PlatformCALayer>& shapeMaskLayer, const FloatRoundedRect&);
291 WEBCORE_EXPORT void setReplicatedByLayer(GraphicsLayer*) override;
293 WEBCORE_EXPORT bool canThrottleLayerFlush() const override;
295 WEBCORE_EXPORT void getDebugBorderInfo(Color&, float& width) const override;
296 WEBCORE_EXPORT void dumpAdditionalProperties(WTF::TextStream&, LayerTreeAsTextBehavior) const override;
298 void computePixelAlignment(float contentsScale, const FloatPoint& positionRelativeToBase,
299 FloatPoint& position, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset) const;
301 TransformationMatrix layerTransform(const FloatPoint& position, const TransformationMatrix* customTransform = 0) const;
303 enum ComputeVisibleRectFlag { RespectAnimatingTransforms = 1 << 0 };
304 typedef unsigned ComputeVisibleRectFlags;
306 struct VisibleAndCoverageRects {
307 FloatRect visibleRect;
308 FloatRect coverageRect;
309 TransformationMatrix animatingTransform;
312 VisibleAndCoverageRects computeVisibleAndCoverageRect(TransformState&, bool accumulateTransform, ComputeVisibleRectFlags = RespectAnimatingTransforms) const;
313 bool adjustCoverageRect(VisibleAndCoverageRects&, const FloatRect& oldVisibleRect) const;
315 const FloatRect& visibleRect() const { return m_visibleRect; }
316 const FloatRect& coverageRect() const { return m_coverageRect; }
318 void setVisibleAndCoverageRects(const VisibleAndCoverageRects&, bool isViewportConstrained);
320 static FloatRect adjustTiledLayerVisibleRect(TiledBacking*, const FloatRect& oldVisibleRect, const FloatRect& newVisibleRect, const FloatSize& oldSize, const FloatSize& newSize);
322 bool recursiveVisibleRectChangeRequiresFlush(const CommitState&, const TransformState&) const;
324 bool isPageTiledBackingLayer() const { return type() == Type::PageTiledBacking; }
326 // Used to track the path down the tree for replica layers.
327 struct ReplicaState {
328 static const size_t maxReplicaDepth = 16;
329 enum ReplicaBranchType { ChildBranch = 0, ReplicaBranch = 1 };
330 ReplicaState(ReplicaBranchType firstBranch)
336 // Called as we walk down the tree to build replicas.
337 void push(ReplicaBranchType branchType)
339 m_replicaBranches.append(branchType);
340 if (branchType == ReplicaBranch)
344 void setBranchType(ReplicaBranchType branchType)
346 ASSERT(!m_replicaBranches.isEmpty());
348 if (m_replicaBranches.last() != branchType) {
349 if (branchType == ReplicaBranch)
355 m_replicaBranches.last() = branchType;
360 if (m_replicaBranches.last() == ReplicaBranch)
362 m_replicaBranches.removeLast();
365 size_t depth() const { return m_replicaBranches.size(); }
366 size_t replicaDepth() const { return m_replicaDepth; }
368 CloneID cloneID() const;
371 Vector<ReplicaBranchType> m_replicaBranches;
372 size_t m_replicaDepth;
374 RefPtr<PlatformCALayer>replicatedLayerRoot(ReplicaState&);
376 enum CloneLevel { RootCloneLevel, IntermediateCloneLevel };
377 RefPtr<PlatformCALayer> fetchCloneLayers(GraphicsLayer* replicaRoot, ReplicaState&, CloneLevel);
379 Ref<PlatformCALayer> cloneLayer(PlatformCALayer *, CloneLevel);
380 RefPtr<PlatformCALayer> findOrMakeClone(CloneID, PlatformCALayer *, LayerMap&, CloneLevel);
382 void ensureCloneLayers(CloneID, RefPtr<PlatformCALayer>& primaryLayer, RefPtr<PlatformCALayer>& structuralLayer,
383 RefPtr<PlatformCALayer>& contentsLayer, RefPtr<PlatformCALayer>& contentsClippingLayer, RefPtr<PlatformCALayer>& contentsShapeMaskLayer,
384 RefPtr<PlatformCALayer>& shapeMaskLayer, RefPtr<PlatformCALayer>& backdropLayer, RefPtr<PlatformCALayer>& backdropClippingLayer,
387 bool hasCloneLayers() const { return !!m_layerClones; }
388 void removeCloneLayers();
389 FloatPoint positionForCloneRootLayer() const;
391 // All these "update" methods will be called inside a BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS block.
393 void updateSublayerList(bool maxLayerDepthReached = false);
394 void updateGeometry(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
395 void updateTransform();
396 void updateChildrenTransform();
397 void updateMasksToBounds();
398 void updateContentsVisibility();
399 void updateContentsOpaque(float pageScaleFactor);
400 void updateBackfaceVisibility();
401 void updateStructuralLayer();
402 void updateDrawsContent();
403 void updateCoverage(const CommitState&);
404 void updateBackgroundColor();
405 void updateUserInteractionEnabled();
407 void updateContentsImage();
408 void updateContentsPlatformLayer();
409 void updateContentsColorLayer();
410 void updateContentsRects();
411 void updateMasksToBoundsRect();
412 void updateMaskLayer();
413 void updateReplicatedLayers();
415 void updateAnimations();
416 void updateContentsNeedsDisplay();
417 void updateAcceleratesDrawing();
418 void updateSupportsSubpixelAntialiasedText();
419 void updateDebugIndicators();
421 void updateContentsScale(float pageScaleFactor);
422 void updateCustomAppearance();
424 void updateOpacityOnLayer();
425 void updateFilters();
426 void updateBackdropFilters();
427 void updateBackdropFiltersRect();
429 #if ENABLE(CSS_COMPOSITING)
430 void updateBlendMode();
434 void updateWindRule();
436 enum StructuralLayerPurpose {
437 NoStructuralLayer = 0,
438 StructuralLayerForPreserves3D,
439 StructuralLayerForReplicaFlattening,
440 StructuralLayerForBackdrop
442 void ensureStructuralLayer(StructuralLayerPurpose);
443 StructuralLayerPurpose structuralLayerPurpose() const;
445 void ensureLayerAnimations();
447 void setAnimationOnLayer(PlatformCAAnimation&, AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
448 bool removeCAAnimationFromLayer(AnimatedPropertyID, const String& animationName, int index, int subINdex);
449 void pauseCAAnimationOnLayer(AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
450 void seekCAAnimationOnLayer(AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
452 enum MoveOrCopy { Move, Copy };
453 static void moveOrCopyLayerAnimation(MoveOrCopy, const String& animationIdentifier, PlatformCALayer *fromLayer, PlatformCALayer *toLayer);
454 void moveOrCopyAnimations(MoveOrCopy, PlatformCALayer* fromLayer, PlatformCALayer* toLayer);
456 void moveAnimations(PlatformCALayer* fromLayer, PlatformCALayer* toLayer)
458 moveOrCopyAnimations(Move, fromLayer, toLayer);
460 void copyAnimations(PlatformCALayer* fromLayer, PlatformCALayer* toLayer)
462 moveOrCopyAnimations(Copy, fromLayer, toLayer);
465 // This represents the animation of a single property. There may be multiple transform animations for
466 // a single transition or keyframe animation, so index is used to distinguish these.
467 struct LayerPropertyAnimation {
468 LayerPropertyAnimation(Ref<PlatformCAAnimation>&& caAnimation, const String& animationName, AnimatedPropertyID property, int index, int subIndex, Seconds timeOffset)
469 : m_animation(WTFMove(caAnimation))
470 , m_name(animationName)
471 , m_property(property)
473 , m_subIndex(subIndex)
474 , m_timeOffset(timeOffset)
477 RefPtr<PlatformCAAnimation> m_animation;
479 AnimatedPropertyID m_property;
482 Seconds m_timeOffset;
485 bool appendToUncommittedAnimations(const KeyframeValueList&, const TransformOperations*, const Animation*, const String& animationName, const FloatSize& boxSize, int animationIndex, Seconds timeOffset, bool isMatrixAnimation);
486 bool appendToUncommittedAnimations(const KeyframeValueList&, const FilterOperation*, const Animation*, const String& animationName, int animationIndex, Seconds timeOffset);
487 void appendToUncommittedAnimations(LayerPropertyAnimation&&);
489 enum LayerChange : uint64_t {
491 NameChanged = 1LLU << 1,
492 ChildrenChanged = 1LLU << 2, // also used for content layer, and preserves-3d, and size if tiling changes?
493 GeometryChanged = 1LLU << 3,
494 TransformChanged = 1LLU << 4,
495 ChildrenTransformChanged = 1LLU << 5,
496 Preserves3DChanged = 1LLU << 6,
497 MasksToBoundsChanged = 1LLU << 7,
498 DrawsContentChanged = 1LLU << 8,
499 BackgroundColorChanged = 1LLU << 9,
500 ContentsOpaqueChanged = 1LLU << 10,
501 BackfaceVisibilityChanged = 1LLU << 11,
502 OpacityChanged = 1LLU << 12,
503 AnimationChanged = 1LLU << 13,
504 DirtyRectsChanged = 1LLU << 14,
505 ContentsImageChanged = 1LLU << 15,
506 ContentsPlatformLayerChanged = 1LLU << 16,
507 ContentsColorLayerChanged = 1LLU << 17,
508 ContentsRectsChanged = 1LLU << 18,
509 MasksToBoundsRectChanged = 1LLU << 19,
510 MaskLayerChanged = 1LLU << 20,
511 ReplicatedLayerChanged = 1LLU << 21,
512 ContentsNeedsDisplay = 1LLU << 22,
513 AcceleratesDrawingChanged = 1LLU << 23,
514 SupportsSubpixelAntialiasedTextChanged = 1LLU << 24,
515 ContentsScaleChanged = 1LLU << 25,
516 ContentsVisibilityChanged = 1LLU << 26,
517 CoverageRectChanged = 1LLU << 27,
518 FiltersChanged = 1LLU << 28,
519 BackdropFiltersChanged = 1LLU << 29,
520 BackdropFiltersRectChanged = 1LLU << 30,
521 TilingAreaChanged = 1LLU << 31,
522 TilesAdded = 1LLU << 32,
523 DebugIndicatorsChanged = 1LLU << 33,
524 CustomAppearanceChanged = 1LLU << 34,
525 BlendModeChanged = 1LLU << 35,
526 ShapeChanged = 1LLU << 36,
527 WindRuleChanged = 1LLU << 37,
528 UserInteractionEnabledChanged = 1LLU << 38,
529 NeedsComputeVisibleAndCoverageRect = 1LLU << 39,
531 typedef uint64_t LayerChangeFlags;
532 void addUncommittedChanges(LayerChangeFlags);
533 bool hasDescendantsWithUncommittedChanges() const { return m_hasDescendantsWithUncommittedChanges; }
534 void setHasDescendantsWithUncommittedChanges(bool);
535 enum ScheduleFlushOrNot { ScheduleFlush, DontScheduleFlush };
536 void noteLayerPropertyChanged(LayerChangeFlags, ScheduleFlushOrNot = ScheduleFlush);
537 void noteSublayersChanged(ScheduleFlushOrNot = ScheduleFlush);
538 void noteChangesForScaleSensitiveProperties();
540 bool hasDescendantsWithRunningTransformAnimations() const { return m_hasDescendantsWithRunningTransformAnimations; }
541 void setHasDescendantsWithRunningTransformAnimations(bool b) { m_hasDescendantsWithRunningTransformAnimations = b; }
543 void propagateLayerChangeToReplicas(ScheduleFlushOrNot = ScheduleFlush);
545 void repaintLayerDirtyRects();
547 enum Action { Remove, Pause, Seek };
548 struct AnimationProcessingAction {
549 AnimationProcessingAction(Action action = Remove, Seconds timeOffset = 0_s)
551 , timeOffset(timeOffset)
555 Seconds timeOffset; // Only used for pause.
557 void addProcessingActionForAnimation(const String&, AnimationProcessingAction);
560 // 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.
561 LayerChangeFlags m_uncommittedChanges { 0 };
563 LayerChangeFlags m_uncommittedChanges { CoverageRectChanged };
566 RefPtr<PlatformCALayer> m_layer; // The main layer
567 RefPtr<PlatformCALayer> m_structuralLayer; // A layer used for structural reasons, like preserves-3d or replica-flattening. Is the parent of m_layer.
568 RefPtr<PlatformCALayer> m_contentsClippingLayer; // A layer used to clip inner content
569 RefPtr<PlatformCALayer> m_shapeMaskLayer; // Used to clip with non-trivial corner radii.
570 RefPtr<PlatformCALayer> m_backdropClippingLayer; // Used to clip the backdrop layer with corner radii.
571 RefPtr<PlatformCALayer> m_contentsLayer; // A layer used for inner content, like image and video
572 RefPtr<PlatformCALayer> m_contentsShapeMaskLayer; // Used to clip the content layer with non-trivial corner radii.
573 RefPtr<PlatformCALayer> m_backdropLayer; // The layer used for backdrop rendering, if necessary.
575 // References to clones of our layers, for replicated layers.
577 LayerMap primaryLayerClones;
578 LayerMap structuralLayerClones;
579 LayerMap contentsLayerClones;
580 LayerMap contentsClippingLayerClones;
581 LayerMap contentsShapeMaskLayerClones;
582 LayerMap shapeMaskLayerClones;
583 LayerMap backdropLayerClones;
584 LayerMap backdropClippingLayerClones;
587 std::unique_ptr<LayerClones> m_layerClones;
589 #ifdef VISIBLE_TILE_WASH
590 RefPtr<PlatformCALayer> m_visibleTileWashLayer;
592 FloatRect m_visibleRect;
593 FloatRect m_previousCommittedVisibleRect;
594 FloatRect m_coverageRect; // Area for which we should maintain backing store, in the coordinate space of this layer.
595 FloatSize m_sizeAtLastCoverageRectUpdate;
596 FloatSize m_pixelAlignmentOffset;
598 Color m_contentsSolidColor;
600 RetainPtr<CGImageRef> m_uncorrectedContentsImage;
601 RetainPtr<CGImageRef> m_pendingContentsImage;
603 typedef HashMap<String, Vector<AnimationProcessingAction>> AnimationsToProcessMap;
604 typedef HashMap<String, Vector<LayerPropertyAnimation>> AnimationsMap;
605 struct LayerAnimations {
606 Vector<LayerPropertyAnimation> uncomittedAnimations;
607 AnimationsToProcessMap animationsToProcess;
608 AnimationsMap runningAnimations;
611 std::unique_ptr<LayerAnimations> m_animations;
613 Vector<FloatRect> m_dirtyRects;
615 std::unique_ptr<DisplayList::DisplayList> m_displayList;
617 ContentsLayerPurpose m_contentsLayerPurpose { ContentsLayerPurpose::None };
618 bool m_isCommittingChanges { false };
620 bool m_needsFullRepaint : 1;
621 bool m_usingBackdropLayerType : 1;
622 bool m_isViewportConstrained : 1;
623 bool m_intersectsCoverageRect : 1;
624 bool m_hasEverPainted : 1;
625 bool m_hasDescendantsWithRunningTransformAnimations : 1;
626 bool m_hasDescendantsWithUncommittedChanges : 1;
629 } // namespace WebCore
631 SPECIALIZE_TYPE_TRAITS_GRAPHICSLAYER(WebCore::GraphicsLayerCA, isGraphicsLayerCA())