TiledCoreAnimationDrawingArea.h [plain text]
#pragma once
#if PLATFORM(MAC)
#include "CallbackID.h"
#include "DrawingArea.h"
#include "LayerTreeContext.h"
#include <WebCore/FloatRect.h>
#include <WebCore/TransformationMatrix.h>
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
#include <wtf/RunLoop.h>
OBJC_CLASS CALayer;
namespace WebCore {
class FrameView;
class PlatformCALayer;
class RunLoopObserver;
class TiledBacking;
}
namespace WebKit {
class LayerHostingContext;
class TiledCoreAnimationDrawingArea : public DrawingArea, public CanMakeWeakPtr<TiledCoreAnimationDrawingArea> {
public:
TiledCoreAnimationDrawingArea(WebPage&, const WebPageCreationParameters&);
virtual ~TiledCoreAnimationDrawingArea();
private:
void setNeedsDisplay() override;
void setNeedsDisplayInRect(const WebCore::IntRect&) override;
void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override { }
void forceRepaint() override;
void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) override;
void setLayerTreeStateIsFrozen(bool) override;
bool layerTreeStateIsFrozen() const override;
void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
void triggerRenderingUpdate() override;
void updatePreferences(const WebPreferencesStore&) override;
void mainFrameContentSizeChanged(const WebCore::IntSize&) override;
void setViewExposedRect(Optional<WebCore::FloatRect>) override;
Optional<WebCore::FloatRect> viewExposedRect() const override { return m_viewExposedRect; }
WebCore::FloatRect exposedContentRect() const override;
void setExposedContentRect(const WebCore::FloatRect&) override;
bool supportsAsyncScrolling() const override { return true; }
void dispatchAfterEnsuringUpdatedScrollPosition(WTF::Function<void ()>&&) override;
bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const override;
void activityStateDidChange(OptionSet<WebCore::ActivityState::Flag> changed, ActivityStateChangeID, const Vector<CallbackID>&) override;
void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) override;
bool addMilestonesToDispatch(OptionSet<WebCore::LayoutMilestone> paintMilestones) override;
void addCommitHandlers();
enum class UpdateRenderingType { Normal, TransientZoom };
void updateRendering(UpdateRenderingType = UpdateRenderingType::Normal);
void updateGeometry(const WebCore::IntSize& viewSize, bool flushSynchronously, const WTF::MachSendRight& fencePort) override;
void setDeviceScaleFactor(float) override;
void suspendPainting();
void resumePainting();
void setLayerHostingMode(LayerHostingMode) override;
void setColorSpace(const ColorSpaceData&) override;
void addFence(const WTF::MachSendRight&) override;
void addTransactionCallbackID(CallbackID) override;
void setShouldScaleViewToFitDocument(bool) override;
void sendEnterAcceleratedCompositingModeIfNeeded() override;
void sendDidFirstLayerFlushIfNeeded();
void handleActivityStateChangeCallbacksIfNeeded();
void handleActivityStateChangeCallbacks();
void adjustTransientZoom(double scale, WebCore::FloatPoint origin) override;
void commitTransientZoom(double scale, WebCore::FloatPoint origin) override;
void applyTransientZoomToPage(double scale, WebCore::FloatPoint origin);
WebCore::PlatformCALayer* layerForTransientZoom() const;
WebCore::PlatformCALayer* shadowLayerForTransientZoom() const;
void applyTransientZoomToLayers(double scale, WebCore::FloatPoint origin);
void updateLayerHostingContext();
void setRootCompositingLayer(CALayer *);
void updateRootLayers();
WebCore::TiledBacking* mainFrameTiledBacking() const;
void updateDebugInfoLayer(bool showLayer);
void scaleViewToFitDocumentIfNeeded();
void sendPendingNewlyReachedPaintingMilestones();
void updateRenderingRunLoopCallback();
void invalidateRenderingUpdateRunLoopObserver();
void scheduleRenderingUpdateRunLoopObserver();
void startRenderThrottlingTimer();
void renderThrottlingTimerFired();
std::unique_ptr<LayerHostingContext> m_layerHostingContext;
RetainPtr<CALayer> m_hostingLayer;
RetainPtr<CALayer> m_rootLayer;
RetainPtr<CALayer> m_debugInfoLayer;
RetainPtr<CALayer> m_pendingRootLayer;
Optional<WebCore::FloatRect> m_viewExposedRect;
WebCore::IntSize m_lastViewSizeForScaleToFit;
WebCore::IntSize m_lastDocumentSizeForScaleToFit;
double m_transientZoomScale { 1 };
WebCore::FloatPoint m_transientZoomOrigin;
Vector<CallbackID> m_nextActivityStateChangeCallbackIDs;
ActivityStateChangeID m_activityStateChangeID { ActivityStateChangeAsynchronous };
RefPtr<WebCore::GraphicsLayer> m_viewOverlayRootLayer;
OptionSet<WebCore::LayoutMilestone> m_pendingNewlyReachedPaintingMilestones;
Vector<CallbackID> m_pendingCallbackIDs;
std::unique_ptr<WebCore::RunLoopObserver> m_renderUpdateRunLoopObserver;
bool m_isPaintingSuspended { false };
bool m_inUpdateGeometry { false };
bool m_layerTreeStateIsFrozen { false };
bool m_shouldScaleViewToFitDocument { false };
bool m_isScalingViewToFitDocument { false };
bool m_needsSendEnterAcceleratedCompositingMode { true };
bool m_needsSendDidFirstLayerFlush { true };
bool m_shouldHandleActivityStateChangeCallbacks { false };
};
inline bool TiledCoreAnimationDrawingArea::addMilestonesToDispatch(OptionSet<WebCore::LayoutMilestone> paintMilestones)
{
m_pendingNewlyReachedPaintingMilestones.add(paintMilestones);
return true;
}
}
SPECIALIZE_TYPE_TRAITS_DRAWING_AREA(TiledCoreAnimationDrawingArea, DrawingAreaTypeTiledCoreAnimation)
#endif // PLATFORM(MAC)