TextureMapperPlatformLayerProxy.h [plain text]
#ifndef TextureMapperPlatformLayerProxy_h
#define TextureMapperPlatformLayerProxy_h
#if USE(COORDINATED_GRAPHICS_THREADED)
#include "GraphicsTypes3D.h"
#include <wtf/Function.h>
#include <wtf/Lock.h>
#include <wtf/RunLoop.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/Vector.h>
#ifndef NDEBUG
#include <wtf/Threading.h>
#endif
namespace WebCore {
class IntSize;
class TextureMapperGL;
class TextureMapperLayer;
class TextureMapperPlatformLayerProxy;
class TextureMapperPlatformLayerBuffer;
class TextureMapperPlatformLayerProxyProvider {
public:
virtual RefPtr<TextureMapperPlatformLayerProxy> proxy() const = 0;
virtual void swapBuffersIfNeeded() = 0;
};
class TextureMapperPlatformLayerProxy : public ThreadSafeRefCounted<TextureMapperPlatformLayerProxy> {
WTF_MAKE_FAST_ALLOCATED();
public:
class Compositor {
public:
virtual void onNewBufferAvailable() = 0;
virtual TextureMapperGL* texmapGL() = 0;
};
TextureMapperPlatformLayerProxy();
virtual ~TextureMapperPlatformLayerProxy();
Lock& lock() { return m_lock; }
std::unique_ptr<TextureMapperPlatformLayerBuffer> getAvailableBuffer(const IntSize&, GC3Dint internalFormat);
void pushNextBuffer(std::unique_ptr<TextureMapperPlatformLayerBuffer>);
bool isActive();
void activateOnCompositingThread(Compositor*, TextureMapperLayer*);
void invalidate();
void swapBuffer();
void dropCurrentBufferWhilePreservingTexture();
bool scheduleUpdateOnCompositorThread(Function<void()>&&);
private:
void appendToUnusedBuffers(std::unique_ptr<TextureMapperPlatformLayerBuffer>);
void scheduleReleaseUnusedBuffers();
void releaseUnusedBuffersTimerFired();
Compositor* m_compositor;
TextureMapperLayer* m_targetLayer;
std::unique_ptr<TextureMapperPlatformLayerBuffer> m_currentBuffer;
std::unique_ptr<TextureMapperPlatformLayerBuffer> m_pendingBuffer;
Lock m_lock;
Vector<std::unique_ptr<TextureMapperPlatformLayerBuffer>> m_usedBuffers;
std::unique_ptr<RunLoop::Timer<TextureMapperPlatformLayerProxy>> m_releaseUnusedBuffersTimer;
#ifndef NDEBUG
ThreadIdentifier m_compositorThreadID { 0 };
#endif
void compositorThreadUpdateTimerFired();
std::unique_ptr<RunLoop::Timer<TextureMapperPlatformLayerProxy>> m_compositorThreadUpdateTimer;
Function<void()> m_compositorThreadUpdateFunction;
};
}
#endif // USE(COORDINATED_GRAPHICS_THREADED)
#endif // TextureMapperPlatformLayerProxy_h