diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h')
-rw-r--r-- | Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h b/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h index bb30b0990..e356a3683 100644 --- a/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h +++ b/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h @@ -34,80 +34,83 @@ #include "TextureMapperLayer.h" #include <WebCore/GLContext.h> #include <WebCore/GraphicsLayerClient.h> -#include <wtf/HashMap.h> -#include <wtf/OwnPtr.h> +#include <WebCore/TransformationMatrix.h> +#include <wtf/RunLoop.h> namespace WebKit { -class LayerTreeHostGtk : public LayerTreeHost, WebCore::GraphicsLayerClient { +class AcceleratedSurface; + +class LayerTreeHostGtk final : public LayerTreeHost, WebCore::GraphicsLayerClient { public: - static PassRefPtr<LayerTreeHostGtk> create(WebPage*); + static Ref<LayerTreeHostGtk> create(WebPage&); virtual ~LayerTreeHostGtk(); -protected: - explicit LayerTreeHostGtk(WebPage*); +private: + explicit LayerTreeHostGtk(WebPage&); WebCore::GraphicsLayer* rootLayer() const { return m_rootLayer.get(); } - void initialize(); + // LayerTreeHost + void scheduleLayerFlush() override; + void cancelPendingLayerFlush() override; + void setRootCompositingLayer(WebCore::GraphicsLayer*) override; + void invalidate() override; - // LayerTreeHost. - virtual void invalidate(); - virtual void sizeDidChange(const WebCore::IntSize& newSize); - virtual void deviceOrPageScaleFactorChanged(); - virtual void forceRepaint(); - virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); - virtual void scheduleLayerFlush(); - virtual void setLayerFlushSchedulingEnabled(bool layerFlushingEnabled); - virtual void pageBackgroundTransparencyChanged() override; + void forceRepaint() override; + void sizeDidChange(const WebCore::IntSize& newSize) override; + void deviceOrPageScaleFactorChanged() override; + void pageBackgroundTransparencyChanged() override; -private: - // LayerTreeHost. - virtual const LayerTreeContext& layerTreeContext(); - virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool); + void setNonCompositedContentsNeedDisplay() override; + void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override; + void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override; + void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override; + +#if PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW) + void setNativeSurfaceHandleForCompositing(uint64_t) override; +#endif + + class RenderFrameScheduler { + public: + RenderFrameScheduler(std::function<bool()>); + ~RenderFrameScheduler(); - virtual void setNonCompositedContentsNeedDisplay() override; - virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override; - virtual void scrollNonCompositedContents(const WebCore::IntRect& scrollRect); + void start(); + void stop(); - virtual void didInstallPageOverlay(PageOverlay*) override; - virtual void didUninstallPageOverlay(PageOverlay*) override; - virtual void setPageOverlayNeedsDisplay(PageOverlay*, const WebCore::IntRect&) override; + private: + void renderFrame(); + void nextFrame(); - virtual bool flushPendingLayerChanges(); + std::function<bool()> m_renderer; + RunLoop::Timer<RenderFrameScheduler> m_timer; + double m_fireTime { 0 }; + double m_lastImmediateFlushTime { 0 }; + }; // GraphicsLayerClient - virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); - virtual void notifyFlushRequired(const WebCore::GraphicsLayer*); - virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); - virtual void didCommitChangesForLayer(const WebCore::GraphicsLayer*) const { } + void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& clipRect) override; + float deviceScaleFactor() const override; + float pageScaleFactor() const override; - void createPageOverlayLayer(PageOverlay*); - void destroyPageOverlayLayer(PageOverlay*); + bool flushPendingLayerChanges(); enum CompositePurpose { ForResize, NotForResize }; void compositeLayersToContext(CompositePurpose = NotForResize); void flushAndRenderLayers(); - void cancelPendingLayerFlush(); - - void layerFlushTimerFired(); - static gboolean layerFlushTimerFiredCallback(LayerTreeHostGtk*); - - WebCore::GLContext* glContext(); + bool renderFrame(); + bool makeContextCurrent(); + void createTextureMapper(); - LayerTreeContext m_layerTreeContext; - bool m_isValid; - bool m_notifyAfterScheduledLayerFlush; std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer; std::unique_ptr<WebCore::GraphicsLayer> m_nonCompositedContentLayer; - typedef HashMap<PageOverlay*, std::unique_ptr<WebCore::GraphicsLayer>> PageOverlayLayerMap; - PageOverlayLayerMap m_pageOverlayLayers; - OwnPtr<WebCore::TextureMapper> m_textureMapper; - OwnPtr<WebCore::GLContext> m_context; - double m_lastFlushTime; - bool m_layerFlushSchedulingEnabled; - unsigned m_layerFlushTimerCallbackId; + std::unique_ptr<WebCore::TextureMapper> m_textureMapper; + std::unique_ptr<WebCore::GLContext> m_context; + WebCore::TransformationMatrix m_scaleMatrix; + std::unique_ptr<AcceleratedSurface> m_surface; + RenderFrameScheduler m_renderFrameScheduler; }; } // namespace WebKit |