#ifndef CCProxy_h
#define CCProxy_h
#include "IntRect.h"
#include <public/WebCompositorOutputSurface.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
namespace cc {
class CCThread;
struct CCRenderingStats;
struct RendererCapabilities;
class CCProxy {
WTF_MAKE_NONCOPYABLE(CCProxy);
public:
static void setMainThread(CCThread*);
static CCThread* mainThread();
static bool hasImplThread();
static void setImplThread(CCThread*);
static CCThread* implThread();
static CCThread* currentThread();
virtual ~CCProxy();
virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0;
virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec) = 0;
virtual void finishAllRendering() = 0;
virtual bool isStarted() const = 0;
virtual bool initializeContext() = 0;
virtual void setSurfaceReady() = 0;
virtual void setVisible(bool) = 0;
virtual bool initializeRenderer() = 0;
virtual bool recreateContext() = 0;
virtual void implSideRenderingStats(CCRenderingStats&) = 0;
virtual const RendererCapabilities& rendererCapabilities() const = 0;
virtual void setNeedsAnimate() = 0;
virtual void setNeedsCommit() = 0;
virtual void setNeedsRedraw() = 0;
virtual void didAddAnimation() = 0;
virtual bool commitRequested() const = 0;
virtual void start() = 0;
virtual void stop() = 0;
virtual void forceSerializeOnSwapBuffers() = 0;
virtual size_t maxPartialTextureUpdates() const = 0;
virtual void acquireLayerTextures() = 0;
#ifndef NDEBUG
static bool isMainThread();
static bool isImplThread();
static bool isMainThreadBlocked();
static void setMainThreadBlocked(bool);
#endif
virtual void loseContext() = 0;
#ifndef NDEBUG
static void setCurrentThreadIsImplThread(bool);
#endif
protected:
CCProxy();
friend class DebugScopedSetImplThread;
friend class DebugScopedSetMainThreadBlocked;
};
class DebugScopedSetMainThreadBlocked {
public:
DebugScopedSetMainThreadBlocked()
{
#if !ASSERT_DISABLED
ASSERT(!CCProxy::isMainThreadBlocked());
CCProxy::setMainThreadBlocked(true);
#endif
}
~DebugScopedSetMainThreadBlocked()
{
#if !ASSERT_DISABLED
ASSERT(CCProxy::isMainThreadBlocked());
CCProxy::setMainThreadBlocked(false);
#endif
}
};
}
#endif