ThreadedCompositor.h [plain text]
#ifndef ThreadedCompositor_h
#define ThreadedCompositor_h
#if USE(COORDINATED_GRAPHICS_THREADED)
#include "CompositingRunLoop.h"
#include "CoordinatedGraphicsScene.h"
#include <WebCore/GLContext.h>
#include <WebCore/IntSize.h>
#include <WebCore/TextureMapper.h>
#include <wtf/FastMalloc.h>
#include <wtf/Noncopyable.h>
#include <wtf/ThreadSafeRefCounted.h>
namespace WebCore {
struct CoordinatedGraphicsState;
}
namespace WebKit {
class CoordinatedGraphicsScene;
class CoordinatedGraphicsSceneClient;
class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
WTF_MAKE_NONCOPYABLE(ThreadedCompositor);
WTF_MAKE_FAST_ALLOCATED;
public:
class Client {
public:
virtual void renderNextFrame() = 0;
virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) = 0;
};
enum class ShouldDoFrameSync { No, Yes };
static Ref<ThreadedCompositor> create(Client&, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
virtual ~ThreadedCompositor();
void setNativeSurfaceHandleForCompositing(uint64_t);
void setScaleFactor(float);
void setScrollPosition(const WebCore::IntPoint&, float scale);
void setViewportSize(const WebCore::IntSize&, float scale);
void setDrawsBackground(bool);
void updateSceneState(const WebCore::CoordinatedGraphicsState&);
void invalidate();
void forceRepaint();
private:
ThreadedCompositor(Client&, uint64_t nativeSurfaceHandle, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
void renderNextFrame() override;
void updateViewport() override;
void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override;
void renderLayerTree();
void scheduleDisplayImmediately();
bool makeContextCurrent();
Client& m_client;
RefPtr<CoordinatedGraphicsScene> m_scene;
std::unique_ptr<WebCore::GLContext> m_context;
WebCore::IntSize m_viewportSize;
WebCore::IntPoint m_scrollPosition;
float m_scaleFactor { 1 };
bool m_drawsBackground { true };
uint64_t m_nativeSurfaceHandle;
ShouldDoFrameSync m_doFrameSync;
WebCore::TextureMapper::PaintFlags m_paintFlags { 0 };
bool m_needsResize { false };
std::unique_ptr<CompositingRunLoop> m_compositingRunLoop;
};
}
#endif
#endif // ThreadedCompositor_h