[GTK][WPE] Remove UpdateAtlas
[WebKit-https.git] / Source / WebCore / platform / graphics / texmap / coordinated / CoordinatedGraphicsLayer.h
index a6a58f3..e6ca865 100644 (file)
 #ifndef CoordinatedGraphicsLayer_h
 #define CoordinatedGraphicsLayer_h
 
+#if USE(COORDINATED_GRAPHICS)
+
 #include "CoordinatedGraphicsState.h"
 #include "CoordinatedImageBacking.h"
-#include "CoordinatedTile.h"
 #include "FloatPoint3D.h"
 #include "GraphicsLayer.h"
-#include "GraphicsLayerAnimation.h"
 #include "GraphicsLayerTransform.h"
 #include "Image.h"
 #include "IntSize.h"
+#include "NicosiaBuffer.h"
+#include "TextureMapperAnimation.h"
 #include "TiledBackingStore.h"
 #include "TiledBackingStoreClient.h"
 #include "TransformationMatrix.h"
-#if USE(GRAPHICS_SURFACE)
-#include "GraphicsSurfaceToken.h"
-#endif
 #include <wtf/text/StringHash.h>
 
-#if USE(COORDINATED_GRAPHICS)
+namespace Nicosia {
+class PaintingEngine;
+}
 
 namespace WebCore {
 class CoordinatedGraphicsLayer;
-class GraphicsLayerAnimations;
-class ScrollableArea;
+class TextureMapperAnimations;
 
 class CoordinatedGraphicsLayerClient {
 public:
     virtual bool isFlushingLayerChanges() const = 0;
     virtual FloatRect visibleContentsRect() const = 0;
-    virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) = 0;
+    virtual Ref<CoordinatedImageBacking> createImageBackingIfNeeded(Image&) = 0;
     virtual void detachLayer(CoordinatedGraphicsLayer*) = 0;
-    virtual bool paintToSurface(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0;
+    virtual Nicosia::PaintingEngine& paintingEngine() = 0;
 
     virtual void syncLayerState(CoordinatedLayerID, CoordinatedGraphicsLayerState&) = 0;
 };
 
-class CoordinatedGraphicsLayer : public GraphicsLayer
+class WEBCORE_EXPORT CoordinatedGraphicsLayer : public GraphicsLayer
     , public TiledBackingStoreClient
-    , public CoordinatedImageBacking::Host
-    , public CoordinatedTileClient {
+    , public CoordinatedImageBacking::Host {
 public:
-    explicit CoordinatedGraphicsLayer(GraphicsLayerClient&);
+    explicit CoordinatedGraphicsLayer(Type, GraphicsLayerClient&);
     virtual ~CoordinatedGraphicsLayer();
 
+    PlatformLayerID primaryLayerID() const override { return id(); }
+
     // Reimplementations from GraphicsLayer.h.
-    virtual bool setChildren(const Vector<GraphicsLayer*>&) override;
-    virtual void addChild(GraphicsLayer*) override;
-    virtual void addChildAtIndex(GraphicsLayer*, int) override;
-    virtual void addChildAbove(GraphicsLayer*, GraphicsLayer*) override;
-    virtual void addChildBelow(GraphicsLayer*, GraphicsLayer*) override;
-    virtual bool replaceChild(GraphicsLayer*, GraphicsLayer*) override;
-    virtual void removeFromParent() override;
-    virtual void setPosition(const FloatPoint&) override;
-    virtual void setAnchorPoint(const FloatPoint3D&) override;
-    virtual void setSize(const FloatSize&) override;
-    virtual void setTransform(const TransformationMatrix&) override;
-    virtual void setChildrenTransform(const TransformationMatrix&) override;
-    virtual void setPreserves3D(bool) override;
-    virtual void setMasksToBounds(bool) override;
-    virtual void setDrawsContent(bool) override;
-    virtual void setContentsVisible(bool) override;
-    virtual void setContentsOpaque(bool) override;
-    virtual void setBackfaceVisibility(bool) override;
-    virtual void setOpacity(float) override;
-    virtual void setContentsRect(const FloatRect&) override;
-    virtual void setContentsTilePhase(const FloatPoint&) override;
-    virtual void setContentsTileSize(const FloatSize&) override;
-    virtual void setContentsToImage(Image*) override;
-    virtual void setContentsToSolidColor(const Color&) override;
-    virtual void setShowDebugBorder(bool) override;
-    virtual void setShowRepaintCounter(bool) override;
-    virtual bool shouldDirectlyCompositeImage(Image*) const override;
-    virtual void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) override;
-    virtual void setMaskLayer(GraphicsLayer*) override;
-    virtual void setReplicatedByLayer(GraphicsLayer*) override;
-    virtual void setNeedsDisplay() override;
-    virtual void setNeedsDisplayInRect(const FloatRect&, ShouldClipToLayer = ClipToLayer) override;
-    virtual void setContentsNeedsDisplay() override;
-    virtual void deviceOrPageScaleFactorChanged() override;
-    virtual void flushCompositingState(const FloatRect&) override;
-    virtual void flushCompositingStateForThisLayerOnly() override;
-#if ENABLE(CSS_FILTERS)
-    virtual bool setFilters(const FilterOperations&) override;
-#endif
-    virtual bool addAnimation(const KeyframeValueList&, const FloatSize&, const Animation*, const String&, double) override;
-    virtual void pauseAnimation(const String&, double) override;
-    virtual void removeAnimation(const String&) override;
-    virtual void suspendAnimations(double time) override;
-    virtual void resumeAnimations() override;
-    virtual bool usesContentsLayer() const override { return m_platformLayer || m_compositedImage; }
+    bool setChildren(const Vector<GraphicsLayer*>&) override;
+    void addChild(GraphicsLayer*) override;
+    void addChildAtIndex(GraphicsLayer*, int) override;
+    void addChildAbove(GraphicsLayer*, GraphicsLayer*) override;
+    void addChildBelow(GraphicsLayer*, GraphicsLayer*) override;
+    bool replaceChild(GraphicsLayer*, GraphicsLayer*) override;
+    void removeFromParent() override;
+    void setPosition(const FloatPoint&) override;
+    void setAnchorPoint(const FloatPoint3D&) override;
+    void setSize(const FloatSize&) override;
+    void setTransform(const TransformationMatrix&) override;
+    void setChildrenTransform(const TransformationMatrix&) override;
+    void setPreserves3D(bool) override;
+    void setMasksToBounds(bool) override;
+    void setDrawsContent(bool) override;
+    void setContentsVisible(bool) override;
+    void setContentsOpaque(bool) override;
+    void setBackfaceVisibility(bool) override;
+    void setOpacity(float) override;
+    void setContentsRect(const FloatRect&) override;
+    void setContentsTilePhase(const FloatSize&) override;
+    void setContentsTileSize(const FloatSize&) override;
+    void setContentsToImage(Image*) override;
+    void setContentsToSolidColor(const Color&) override;
+    void setShowDebugBorder(bool) override;
+    void setShowRepaintCounter(bool) override;
+    bool shouldDirectlyCompositeImage(Image*) const override;
+    void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) override;
+    void setMaskLayer(GraphicsLayer*) override;
+    void setReplicatedByLayer(GraphicsLayer*) override;
+    void setNeedsDisplay() override;
+    void setNeedsDisplayInRect(const FloatRect&, ShouldClipToLayer = ClipToLayer) override;
+    void setContentsNeedsDisplay() override;
+    void deviceOrPageScaleFactorChanged() override;
+    void flushCompositingState(const FloatRect&) override;
+    void flushCompositingStateForThisLayerOnly() override;
+    bool setFilters(const FilterOperations&) override;
+    bool addAnimation(const KeyframeValueList&, const FloatSize&, const Animation*, const String&, double) override;
+    void pauseAnimation(const String&, double) override;
+    void removeAnimation(const String&) override;
+    void suspendAnimations(MonotonicTime) override;
+    void resumeAnimations() override;
+    bool usesContentsLayer() const override { return m_platformLayer || m_compositedImage; }
 
     void syncPendingStateChangesIncludingSubLayers();
     void updateContentBuffersIncludingSubLayers();
@@ -119,56 +118,33 @@ public:
 
     void setVisibleContentRectTrajectoryVector(const FloatPoint&);
 
-    void setScrollableArea(ScrollableArea*);
-    bool isScrollable() const { return !!m_scrollableArea; }
-    void commitScrollOffset(const IntSize&);
-
-    CoordinatedLayerID id() const;
+    CoordinatedLayerID id() const { return m_id; }
 
     void setFixedToViewport(bool isFixed);
 
     IntRect coverRect() const { return m_mainBackingStore ? m_mainBackingStore->mapToContents(m_mainBackingStore->coverRect()) : IntRect(); }
+    IntRect transformedVisibleRect();
 
     // TiledBackingStoreClient
-    virtual void tiledBackingStorePaintBegin() override;
-    virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&) override;
-    virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea) override;
-    virtual void tiledBackingStoreHasPendingTileCreation() override;
-    virtual IntRect tiledBackingStoreContentsRect() override;
-    virtual IntRect tiledBackingStoreVisibleRect() override;
-    virtual Color tiledBackingStoreBackgroundColor() const override;
-
-    // CoordinatedTileClient
-    virtual void createTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) override;
-    virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) override;
-    virtual void removeTile(uint32_t tileID) override;
-    virtual bool paintToSurface(const IntSize&, uint32_t& /* atlasID */, IntPoint&, CoordinatedSurface::Client*) override;
+    void tiledBackingStoreHasPendingTileCreation() override;
+    void createTile(uint32_t tileID, float) override;
+    void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) override;
+    void removeTile(uint32_t tileID) override;
 
     void setCoordinator(CoordinatedGraphicsLayerClient*);
 
     void setNeedsVisibleRectAdjustment();
     void purgeBackingStores();
 
-    static void setShouldSupportContentsTiling(bool);
     CoordinatedGraphicsLayer* findFirstDescendantWithContentsRecursively();
 
 private:
-#if USE(GRAPHICS_SURFACE)
-    enum PendingPlatformLayerOperation {
-        None = 0x00,
-        CreatePlatformLayer = 0x01,
-        DestroyPlatformLayer = 0x02,
-        SyncPlatformLayer = 0x04,
-        CreateAndSyncPlatformLayer = CreatePlatformLayer | SyncPlatformLayer,
-        RecreatePlatformLayer = CreateAndSyncPlatformLayer | DestroyPlatformLayer
-    };
+    bool isCoordinatedGraphicsLayer() const override { return true; }
 
     void syncPlatformLayer();
-    void destroyPlatformLayerIfNeeded();
-    void createPlatformLayerIfNeeded();
-#endif
+    void updatePlatformLayer();
 
-    virtual void setDebugBorder(const Color&, float width) override;
+    void setDebugBorder(const Color&, float width) override;
 
     bool fixedToViewport() const { return m_fixedToViewport; }
 
@@ -176,18 +152,15 @@ private:
     void didChangeAnimations();
     void didChangeGeometry();
     void didChangeChildren();
-#if ENABLE(CSS_FILTERS)
     void didChangeFilters();
-#endif
     void didChangeImageBacking();
+    void didUpdateTileBuffers();
 
     void resetLayerState();
     void syncLayerState();
     void syncAnimations();
     void syncChildren();
-#if ENABLE(CSS_FILTERS)
     void syncFilters();
-#endif
     void syncImageBacking();
     void computeTransformedVisibleRect();
     void updateContentBuffers();
@@ -195,10 +168,10 @@ private:
     void createBackingStore();
     void releaseImageBackingIfNeeded();
 
-    bool notifyFlushRequired();
+    void notifyFlushRequired();
 
     // CoordinatedImageBacking::Host
-    virtual bool imageBackingVisible() override;
+    bool imageBackingVisible() override;
     bool shouldHaveBackingStore() const;
     bool selfOrAncestorHasActiveTransformAnimation() const;
     bool selfOrAncestorHaveNonAffineTransforms();
@@ -207,7 +180,9 @@ private:
     void setShouldUpdateVisibleRect();
     float effectiveContentsScale();
 
-    void animationStartedTimerFired(Timer<CoordinatedGraphicsLayer>*);
+    void animationStartedTimerFired();
+
+    bool filtersCanBeComposited(const FilterOperations&) const;
 
     CoordinatedLayerID m_id;
     CoordinatedGraphicsLayerState m_layerState;
@@ -231,34 +206,34 @@ private:
     bool m_movingVisibleRect : 1;
     bool m_pendingContentsScaleAdjustment : 1;
     bool m_pendingVisibleRectAdjustment : 1;
-#if USE(GRAPHICS_SURFACE)
-    bool m_isValidPlatformLayer : 1;
-    unsigned m_pendingPlatformLayerOperation : 3;
+#if USE(COORDINATED_GRAPHICS_THREADED)
+    bool m_shouldSyncPlatformLayer : 1;
+    bool m_shouldUpdatePlatformLayer : 1;
 #endif
 
     CoordinatedGraphicsLayerClient* m_coordinator;
     std::unique_ptr<TiledBackingStore> m_mainBackingStore;
     std::unique_ptr<TiledBackingStore> m_previousBackingStore;
 
+    struct {
+        bool completeLayer { false };
+        Vector<FloatRect, 32> rects;
+    } m_needsDisplay;
+
     RefPtr<Image> m_compositedImage;
     NativeImagePtr m_compositedNativeImagePtr;
     RefPtr<CoordinatedImageBacking> m_coordinatedImageBacking;
 
     PlatformLayer* m_platformLayer;
-#if USE(GRAPHICS_SURFACE)
-    IntSize m_platformLayerSize;
-    GraphicsSurfaceToken m_platformLayerToken;
-#endif
-    Timer<CoordinatedGraphicsLayer> m_animationStartedTimer;
-    GraphicsLayerAnimations m_animations;
-    double m_lastAnimationStartTime;
-
-    ScrollableArea* m_scrollableArea;
+    Timer m_animationStartedTimer;
+    TextureMapperAnimations m_animations;
+    MonotonicTime m_lastAnimationStartTime;
 };
 
-CoordinatedGraphicsLayer* toCoordinatedGraphicsLayer(GraphicsLayer*);
-
 } // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_GRAPHICSLAYER(WebCore::CoordinatedGraphicsLayer, isCoordinatedGraphicsLayer())
+
 #endif // USE(COORDINATED_GRAPHICS)
 
 #endif // CoordinatedGraphicsLayer_h