#ifndef UpdateAtlas_h
#define UpdateAtlas_h
#include "AreaAllocator.h"
#include <WebCore/CoordinatedSurface.h>
#include <WebCore/IntSize.h>
#include <wtf/RefPtr.h>
#if USE(COORDINATED_GRAPHICS)
namespace WebCore {
class GraphicsContext;
class IntPoint;
}
namespace WebKit {
class UpdateAtlas {
WTF_MAKE_NONCOPYABLE(UpdateAtlas);
public:
class Client {
public:
virtual void createUpdateAtlas(uint32_t , RefPtr<WebCore::CoordinatedSurface>&&) = 0;
virtual void removeUpdateAtlas(uint32_t ) = 0;
};
UpdateAtlas(Client&, int dimension, WebCore::CoordinatedSurface::Flags);
~UpdateAtlas();
inline WebCore::IntSize size() const { return m_surface->size(); }
bool paintOnAvailableBuffer(const WebCore::IntSize&, uint32_t& atlasID, WebCore::IntPoint& offset, WebCore::CoordinatedSurface::Client&);
void didSwapBuffers();
bool supportsAlpha() const { return m_surface->supportsAlpha(); }
void addTimeInactive(double seconds)
{
ASSERT(!isInUse());
m_inactivityInSeconds += seconds;
}
bool isInactive() const
{
const double inactiveSecondsTolerance = 3;
return m_inactivityInSeconds > inactiveSecondsTolerance;
}
bool isInUse() const { return !!m_areaAllocator; }
private:
void buildLayoutIfNeeded();
private:
Client& m_client;
std::unique_ptr<GeneralAreaAllocator> m_areaAllocator;
RefPtr<WebCore::CoordinatedSurface> m_surface;
double m_inactivityInSeconds { 0 };
uint32_t m_ID { 0 };
};
}
#endif // USE(COORDINATED_GRAPHICS)
#endif // UpdateAtlas_h