#ifndef LegacyTileGrid_h
#define LegacyTileGrid_h
#if PLATFORM(IOS)
#include "IntPoint.h"
#include "IntPointHash.h"
#include "IntRect.h"
#include "IntSize.h"
#include "LegacyTileCache.h"
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RetainPtr.h>
#define LOG_TILING 0
@class CALayer;
namespace WebCore {
class LegacyTileGridTile;
class LegacyTileGrid {
WTF_MAKE_NONCOPYABLE(LegacyTileGrid);
public:
typedef IntPoint TileIndex;
static PassOwnPtr<LegacyTileGrid> create(LegacyTileCache* cache, const IntSize& tileSize) { return adoptPtr(new LegacyTileGrid(cache, tileSize)); }
~LegacyTileGrid();
LegacyTileCache* tileCache() const { return m_tileCache; }
CALayer *tileHostLayer() const;
IntRect bounds() const;
unsigned tileCount() const;
float scale() const { return m_scale; }
void setScale(float scale) { m_scale = scale; }
IntRect visibleRect() const;
void createTiles(LegacyTileCache::SynchronousTileCreationMode);
void dropAllTiles();
void dropInvalidTiles();
void dropTilesOutsideRect(const IntRect&);
void dropTilesIntersectingRect(const IntRect&);
void dropTilesBetweenRects(const IntRect& dropRect, const IntRect& keepRect);
bool dropDistantTiles(unsigned tilesNeeded, double shortestDistance);
void addTilesCoveringRect(const IntRect&);
bool tilesCover(const IntRect&) const;
void centerTileGridOrigin(const IntRect& visibleRect);
void invalidateTiles(const IntRect& dirtyRect);
void updateTileOpacity();
void updateTileBorderVisibility();
void updateHostLayerSize();
bool checkDoSingleTileLayout();
bool hasTiles() const { return !m_tiles.isEmpty(); }
IntRect calculateCoverRect(const IntRect& visibleRect, bool& centerGrid);
void dumpTiles();
private:
double tileDistance2(const IntRect& visibleRect, const IntRect& tileRect) const;
unsigned tileByteSize() const;
void addTileForIndex(const TileIndex&);
PassRefPtr<LegacyTileGridTile> tileForIndex(const TileIndex&) const;
IntRect tileRectForIndex(const TileIndex&) const;
PassRefPtr<LegacyTileGridTile> tileForPoint(const IntPoint&) const;
TileIndex tileIndexForPoint(const IntPoint&) const;
IntRect adjustCoverRectForPageBounds(const IntRect&) const;
bool shouldUseMinimalTileCoverage() const;
private:
LegacyTileGrid(LegacyTileCache*, const IntSize&);
LegacyTileCache* m_tileCache;
RetainPtr<CALayer> m_tileHostLayer;
IntPoint m_origin;
IntSize m_tileSize;
float m_scale;
typedef HashMap<TileIndex, RefPtr<LegacyTileGridTile>> TileMap;
TileMap m_tiles;
IntRect m_validBounds;
};
static inline IntPoint topLeft(const IntRect& rect)
{
return rect.location();
}
static inline IntPoint bottomRight(const IntRect& rect)
{
return IntPoint(rect.maxX() - 1, rect.maxY() - 1);
}
}
#endif // PLATFORM(IOS)
#endif // TileGrid_h