CCSingleThreadProxy.h [plain text]
#ifndef CCSingleThreadProxy_h
#define CCSingleThreadProxy_h
#include "cc/CCAnimationEvents.h"
#include "cc/CCCompletionEvent.h"
#include "cc/CCLayerTreeHostImpl.h"
#include "cc/CCProxy.h"
#include <limits>
#include <wtf/OwnPtr.h>
namespace WebCore {
class CCLayerTreeHost;
class CCSingleThreadProxy : public CCProxy, CCLayerTreeHostImplClient {
public:
static PassOwnPtr<CCProxy> create(CCLayerTreeHost*);
virtual ~CCSingleThreadProxy();
virtual bool compositeAndReadback(void *pixels, const IntRect&) OVERRIDE;
virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration) OVERRIDE;
virtual GraphicsContext3D* context() OVERRIDE;
virtual void finishAllRendering() OVERRIDE;
virtual bool isStarted() const OVERRIDE;
virtual bool initializeContext() OVERRIDE;
virtual void setSurfaceReady() OVERRIDE;
virtual bool initializeLayerRenderer() OVERRIDE;
virtual bool recreateContext() OVERRIDE;
virtual int compositorIdentifier() const OVERRIDE { return m_compositorIdentifier; }
virtual const LayerRendererCapabilities& layerRendererCapabilities() const OVERRIDE;
virtual void loseContext() OVERRIDE;
virtual void setNeedsAnimate() OVERRIDE;
virtual void setNeedsCommit() OVERRIDE;
virtual void setNeedsRedraw() OVERRIDE;
virtual bool commitRequested() const OVERRIDE;
virtual void setVisible(bool) OVERRIDE;
virtual void start() OVERRIDE;
virtual void stop() OVERRIDE;
virtual size_t maxPartialTextureUpdates() const OVERRIDE { return std::numeric_limits<size_t>::max(); }
virtual void acquireLayerTextures() OVERRIDE { }
virtual void setFontAtlas(PassOwnPtr<CCFontAtlas>) OVERRIDE;
virtual void forceSerializeOnSwapBuffers() OVERRIDE;
virtual void didLoseContextOnImplThread() OVERRIDE { }
virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { ASSERT_NOT_REACHED(); }
virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_layerTreeHost->setNeedsCommit(); }
virtual void setNeedsCommitOnImplThread() OVERRIDE { m_layerTreeHost->setNeedsCommit(); }
virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE;
virtual void postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThread(size_t) OVERRIDE;
void compositeImmediately();
private:
explicit CCSingleThreadProxy(CCLayerTreeHost*);
bool commitAndComposite();
void doCommit(CCTextureUpdater&);
bool doComposite();
void didSwapFrame();
CCLayerTreeHost* m_layerTreeHost;
bool m_contextLost;
int m_compositorIdentifier;
RefPtr<GraphicsContext3D> m_contextBeforeInitialization;
OwnPtr<CCLayerTreeHostImpl> m_layerTreeHostImpl;
bool m_layerRendererInitialized;
LayerRendererCapabilities m_layerRendererCapabilitiesForMainThread;
bool m_nextFrameIsNewlyCommittedFrame;
};
class DebugScopedSetImplThread {
public:
DebugScopedSetImplThread()
{
#if !ASSERT_DISABLED
CCProxy::setCurrentThreadIsImplThread(true);
#endif
}
~DebugScopedSetImplThread()
{
#if !ASSERT_DISABLED
CCProxy::setCurrentThreadIsImplThread(false);
#endif
}
};
class DebugScopedSetMainThread {
public:
DebugScopedSetMainThread()
{
#if !ASSERT_DISABLED
CCProxy::setCurrentThreadIsImplThread(false);
#endif
}
~DebugScopedSetMainThread()
{
#if !ASSERT_DISABLED
CCProxy::setCurrentThreadIsImplThread(true);
#endif
}
};
}
#endif