[chromium] Compute occlusion during paint loop
[WebKit-https.git] / Source / WebCore / platform / graphics / chromium / cc / CCLayerTreeHost.h
index 8224724..f58203d 100644 (file)
@@ -48,12 +48,14 @@ class CCLayerTreeHostImpl;
 class CCTextureUpdater;
 class GraphicsContext3D;
 class LayerPainterChromium;
+class Region;
 class TextureAllocator;
 class TextureManager;
 
 class CCLayerTreeHostClient {
 public:
-    virtual void animateAndLayout(double frameBeginTime) = 0;
+    virtual void updateAnimations(double frameBeginTime) = 0;
+    virtual void layout() = 0;
     virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0;
     virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() = 0;
     virtual void didRecreateGraphicsContext(bool success) = 0;
@@ -73,13 +75,19 @@ struct CCSettings {
             , compositeOffscreen(false)
             , showFPSCounter(false)
             , showPlatformLayerTree(false)
-            , refreshRate(0) { }
+            , refreshRate(0)
+            , perTilePainting(false)
+            , partialSwapEnabled(false)
+            , partialTextureUpdates(true) { }
 
     bool acceleratePainting;
     bool compositeOffscreen;
     bool showFPSCounter;
     bool showPlatformLayerTree;
     double refreshRate;
+    bool perTilePainting;
+    bool partialSwapEnabled;
+    bool partialTextureUpdates;
 };
 
 // Provides information on an Impl's rendering capabilities back to the CCLayerTreeHost
@@ -92,6 +100,8 @@ struct LayerRendererCapabilities {
         , usingAcceleratedPainting(false)
         , usingSetVisibility(false)
         , usingSwapCompleteCallback(false)
+        , usingTextureUsageHint(false)
+        , usingTextureStorageExtension(false)
         , maxTextureSize(0) { }
 
     GC3Denum bestTextureFormat;
@@ -101,6 +111,8 @@ struct LayerRendererCapabilities {
     bool usingAcceleratedPainting;
     bool usingSetVisibility;
     bool usingSwapCompleteCallback;
+    bool usingTextureUsageHint;
+    bool usingTextureStorageExtension;
     int maxTextureSize;
 };
 
@@ -113,7 +125,8 @@ public:
     static bool anyLayerTreeHostInstanceExists();
 
     // CCLayerTreeHost interface to CCProxy.
-    void animateAndLayout(double frameBeginTime);
+    void updateAnimations(double frameBeginTime);
+    void layout();
     void beginCommitOnImplThread(CCLayerTreeHostImpl*);
     void finishCommitOnImplThread(CCLayerTreeHostImpl*);
     void commitComplete();
@@ -125,10 +138,6 @@ public:
     void didCompleteSwapBuffers() { m_client->didCompleteSwapBuffers(); }
     void deleteContentsTexturesOnImplThread(TextureAllocator*);
 
-    // CCLayerTreeHost interface to WebView.
-    bool animating() const { return m_animating; }
-    void setAnimating(bool animating) { m_animating = animating; } // Can be removed when non-threaded scheduling moves inside.
-
     CCLayerTreeHostClient* client() { return m_client; }
 
     int compositorIdentifier() const { return m_compositorIdentifier; }
@@ -147,24 +156,23 @@ public:
 
     int frameNumber() const { return m_frameNumber; }
 
-    void setZoomAnimatorTransform(const TransformationMatrix&);
-
     const LayerRendererCapabilities& layerRendererCapabilities() const;
 
     // Test-only hook
     void loseCompositorContext(int numTimes);
 
     void setNeedsAnimate();
-    void setNeedsCommit();
+    // virtual for testing
+    virtual void setNeedsCommit();
     void setNeedsRedraw();
 
     LayerChromium* rootLayer() { return m_rootLayer.get(); }
     const LayerChromium* rootLayer() const { return m_rootLayer.get(); }
-    void setRootLayer(PassRefPtr<LayerChromium> rootLayer) { m_rootLayer = rootLayer; }
+    void setRootLayer(PassRefPtr<LayerChromium>);
 
     const CCSettings& settings() const { return m_settings; }
 
-    void setViewport(const IntSize& viewportSize);
+    void setViewportSize(const IntSize&);
 
     const IntSize& viewportSize() const { return m_viewportSize; }
 
@@ -187,17 +195,24 @@ public:
     void startRateLimiter(GraphicsContext3D*);
     void stopRateLimiter(GraphicsContext3D*);
 
+    void deleteTextureAfterCommit(PassOwnPtr<ManagedTexture>);
+
 protected:
     CCLayerTreeHost(CCLayerTreeHostClient*, const CCSettings&);
     bool initialize();
 
 private:
     typedef Vector<RefPtr<LayerChromium> > LayerList;
+    typedef Vector<OwnPtr<ManagedTexture> > TextureList;
 
-    void paintLayerContents(const LayerList&);
-    void paintMaskAndReplicaForRenderSurface(LayerChromium*);
+    enum PaintType { PaintVisible, PaintIdle };
+    static void paintContentsIfDirty(LayerChromium*, PaintType, const Region& occludedScreenSpace);
+    void paintLayerContents(const LayerList&, PaintType);
+    void paintMaskAndReplicaForRenderSurface(LayerChromium*, PaintType);
 
     void updateLayers(LayerChromium*);
+    // Pre-reserve textures for any layer marked "always reserve textures"
+    void reserveTextures();
     void clearPendingUpdate();
 
     int m_compositorIdentifier;
@@ -218,7 +233,6 @@ private:
     CCSettings m_settings;
 
     IntSize m_viewportSize;
-    TransformationMatrix m_zoomAnimatorTransform;
     bool m_visible;
     bool m_haveWheelEventHandlers;
     typedef HashMap<GraphicsContext3D*, RefPtr<RateLimiter> > RateLimiterMap;
@@ -226,6 +240,9 @@ private:
 
     float m_pageScale;
     float m_minPageScale, m_maxPageScale;
+    bool m_triggerIdlePaints;
+
+    TextureList m_deleteTextureAfterCommitList;
 };
 
 }