LegacyTileLayerPool.h [plain text]
#ifndef LegacyTileLayerPool_h
#define LegacyTileLayerPool_h
#if PLATFORM(IOS)
#include "IntSize.h"
#include "IntSizeHash.h"
#include "Timer.h"
#include <wtf/Deque.h>
#include <wtf/HashMap.h>
#include <wtf/Lock.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/RetainPtr.h>
#include <wtf/Threading.h>
#include <wtf/Vector.h>
@class LegacyTileLayer;
namespace WebCore {
class LegacyTileLayerPool {
WTF_MAKE_NONCOPYABLE(LegacyTileLayerPool);
public:
static LegacyTileLayerPool* sharedPool();
void addLayer(const RetainPtr<LegacyTileLayer>&);
RetainPtr<LegacyTileLayer> takeLayerWithSize(const IntSize&);
unsigned capacity() const { return m_capacity; }
void setCapacity(unsigned);
void drain();
unsigned decayedCapacity() const;
static unsigned bytesBackingLayerWithPixelSize(const IntSize&);
private:
LegacyTileLayerPool();
typedef Deque<RetainPtr<LegacyTileLayer> > LayerList;
bool canReuseLayerWithSize(const IntSize& size) const { return m_capacity && !size.isEmpty(); }
void schedulePrune();
void prune();
typedef enum { LeaveUnchanged, MarkAsUsed } AccessType;
LayerList& listOfLayersWithSize(const IntSize&, AccessType = LeaveUnchanged);
HashMap<IntSize, LayerList> m_reuseLists;
Vector<IntSize> m_sizesInPruneOrder;
unsigned m_totalBytes;
unsigned m_capacity;
Lock m_layerPoolMutex;
double m_lastAddTime;
bool m_needsPrune;
friend NeverDestroyed<LegacyTileLayerPool>;
};
}
#endif // PLATFORM(IOS)
#endif // TileLayerPool_h