mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1461786 - Rename references to tile positions to tile coords. r=nical
This is the other half of the commit renaming the TileUnit to TileCoordUnit. It also includes some small style cleanups. --HG-- extra : rebase_source : ebf7a275bed518d1419a2e3c23b67f36601a1089
This commit is contained in:
parent
29301de2b0
commit
7f81c73bae
@ -87,15 +87,15 @@ typedef gfx::IntPointTyped<TileCoordUnit> TileCoordIntPoint;
|
||||
|
||||
/**
|
||||
* Stores the origin and size of a tile buffer and handles switching between
|
||||
* tile indices and tile positions.
|
||||
* tile indices and tile coordinates.
|
||||
*
|
||||
* Tile positions in TileCoordIntPoint take the first tile offset into account which
|
||||
* Tile coordinates in TileCoordIntPoint take the first tile offset into account which
|
||||
* means that two TilesPlacement of the same layer and resolution give tile
|
||||
* positions in the same coordinate space (useful when changing the offset and/or
|
||||
* coordinates in the same coordinate space (useful when changing the offset and/or
|
||||
* size of a tile buffer).
|
||||
*/
|
||||
struct TilesPlacement {
|
||||
// in tiles
|
||||
struct TilesPlacement
|
||||
{
|
||||
TileCoordIntPoint mFirst;
|
||||
TileCoordIntSize mSize;
|
||||
|
||||
@ -103,28 +103,32 @@ struct TilesPlacement {
|
||||
int aRetainedWidth, int aRetainedHeight)
|
||||
: mFirst(aFirstX, aFirstY)
|
||||
, mSize(aRetainedWidth, aRetainedHeight)
|
||||
{}
|
||||
{ }
|
||||
|
||||
int TileIndex(TileCoordIntPoint aPosition) const {
|
||||
return (aPosition.x - mFirst.x) * mSize.height + aPosition.y - mFirst.y;
|
||||
int TileIndex(TileCoordIntPoint aCoord) const
|
||||
{
|
||||
return (aCoord.x - mFirst.x) * mSize.height + aCoord.y - mFirst.y;
|
||||
}
|
||||
|
||||
TileCoordIntPoint TilePosition(size_t aIndex) const {
|
||||
TileCoordIntPoint TileCoord(size_t aIndex) const
|
||||
{
|
||||
return TileCoordIntPoint(
|
||||
mFirst.x + aIndex / mSize.height,
|
||||
mFirst.y + aIndex % mSize.height
|
||||
);
|
||||
}
|
||||
|
||||
bool HasTile(TileCoordIntPoint aPosition) const {
|
||||
return aPosition.x >= mFirst.x && aPosition.x < mFirst.x + mSize.width &&
|
||||
aPosition.y >= mFirst.y && aPosition.y < mFirst.y + mSize.height;
|
||||
bool HasTile(TileCoordIntPoint aCoord) const
|
||||
{
|
||||
return aCoord.x >= mFirst.x && aCoord.x < mFirst.x + mSize.width &&
|
||||
aCoord.y >= mFirst.y && aCoord.y < mFirst.y + mSize.height;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Given a position i, this function returns the position inside the current tile.
|
||||
inline int GetTileStart(int i, int aTileLength) {
|
||||
inline int GetTileStart(int i, int aTileLength)
|
||||
{
|
||||
return (i >= 0) ? (i % aTileLength)
|
||||
: ((aTileLength - (-i % aTileLength)) %
|
||||
aTileLength);
|
||||
@ -145,7 +149,8 @@ public:
|
||||
|
||||
~TiledLayerBuffer() {}
|
||||
|
||||
gfx::IntPoint GetTileOffset(TileCoordIntPoint aPosition) const {
|
||||
gfx::IntPoint GetTileOffset(TileCoordIntPoint aPosition) const
|
||||
{
|
||||
gfx::IntSize scaledTileSize = GetScaledTileSize();
|
||||
return gfx::IntPoint(aPosition.x * scaledTileSize.width,
|
||||
aPosition.y * scaledTileSize.height) + mTileOrigin;
|
||||
@ -200,8 +205,8 @@ TiledLayerBuffer<Derived, Tile>::Dump(std::stringstream& aStream,
|
||||
TextureDumpMode aCompress)
|
||||
{
|
||||
for (size_t i = 0; i < mRetainedTiles.Length(); ++i) {
|
||||
const TileCoordIntPoint tilePosition = mTiles.TilePosition(i);
|
||||
gfx::IntPoint tileOffset = GetTileOffset(tilePosition);
|
||||
const TileCoordIntPoint tileCoord = mTiles.TileCoord(i);
|
||||
gfx::IntPoint tileOffset = GetTileOffset(tileCoord);
|
||||
|
||||
aStream << "\n" << aPrefix << "Tile (x=" <<
|
||||
tileOffset.x << ", y=" << tileOffset.y << "): ";
|
||||
|
@ -243,11 +243,11 @@ void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion,
|
||||
mRetainedTiles.SetLength(newTileCount);
|
||||
|
||||
for (size_t oldIndex = 0; oldIndex < oldTileCount; oldIndex++) {
|
||||
const TileCoordIntPoint tilePosition = oldTiles.TilePosition(oldIndex);
|
||||
const size_t newIndex = newTiles.TileIndex(tilePosition);
|
||||
const TileCoordIntPoint tileCoord = oldTiles.TileCoord(oldIndex);
|
||||
const size_t newIndex = newTiles.TileIndex(tileCoord);
|
||||
// First, get the already existing tiles to the right place in the new array.
|
||||
// Leave placeholders (default constructor) where there was no tile.
|
||||
if (newTiles.HasTile(tilePosition)) {
|
||||
if (newTiles.HasTile(tileCoord)) {
|
||||
mRetainedTiles[newIndex] = oldRetainedTiles[oldIndex];
|
||||
} else {
|
||||
// release tiles that we are not going to reuse before allocating new ones
|
||||
@ -263,9 +263,9 @@ void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion,
|
||||
if (!paintRegion.IsEmpty()) {
|
||||
MOZ_ASSERT(mPaintStates.size() == 0);
|
||||
for (size_t i = 0; i < newTileCount; ++i) {
|
||||
const TileCoordIntPoint tilePosition = newTiles.TilePosition(i);
|
||||
const TileCoordIntPoint tileCoord = newTiles.TileCoord(i);
|
||||
|
||||
IntPoint tileOffset = GetTileOffset(tilePosition);
|
||||
IntPoint tileOffset = GetTileOffset(tileCoord);
|
||||
nsIntRegion tileDrawRegion = IntRect(tileOffset, scaledTileSize);
|
||||
tileDrawRegion.AndWith(paintRegion);
|
||||
|
||||
@ -274,7 +274,7 @@ void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion,
|
||||
}
|
||||
|
||||
TileClient& tile = mRetainedTiles[i];
|
||||
if (!ValidateTile(tile, GetTileOffset(tilePosition), tileDrawRegion, aFlags)) {
|
||||
if (!ValidateTile(tile, GetTileOffset(tileCoord), tileDrawRegion, aFlags)) {
|
||||
gfxCriticalError() << "ValidateTile failed";
|
||||
}
|
||||
|
||||
@ -336,8 +336,8 @@ void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion,
|
||||
if (edgePaddingEnabled && mResolution == 1 &&
|
||||
tile.mFrontBuffer && tile.mFrontBuffer->IsLocked()) {
|
||||
|
||||
const TileCoordIntPoint tilePosition = newTiles.TilePosition(i);
|
||||
IntPoint tileOffset = GetTileOffset(tilePosition);
|
||||
const TileCoordIntPoint tileCoord = newTiles.TileCoord(i);
|
||||
IntPoint tileOffset = GetTileOffset(tileCoord);
|
||||
// Strictly speakig we want the unscaled rect here, but it doesn't matter
|
||||
// because we only run this code when the resolution is equal to 1.
|
||||
IntRect tileRect = IntRect(tileOffset.x, tileOffset.y,
|
||||
|
@ -97,8 +97,8 @@ TiledLayerBufferComposite::AddAnimationInvalidation(nsIntRegion& aRegion)
|
||||
// process of fading in.
|
||||
for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
|
||||
if (!mRetainedTiles[i].mFadeStart.IsNull()) {
|
||||
TileCoordIntPoint position = mTiles.TilePosition(i);
|
||||
IntPoint offset = GetTileOffset(position);
|
||||
TileCoordIntPoint coord = mTiles.TileCoord(i);
|
||||
IntPoint offset = GetTileOffset(coord);
|
||||
nsIntRegion tileRegion = IntRect(offset, GetScaledTileSize());
|
||||
aRegion.OrWith(tileRegion);
|
||||
}
|
||||
@ -333,7 +333,7 @@ TiledLayerBufferComposite::UseTiles(const SurfaceDescriptorTiles& aTiles,
|
||||
}
|
||||
}
|
||||
|
||||
tile.mTilePosition = newTiles.TilePosition(i);
|
||||
tile.mTileCoord = newTiles.TileCoord(i);
|
||||
|
||||
// If this same tile texture existed in the old tile set then this will move the texture
|
||||
// source into our new tile.
|
||||
@ -610,11 +610,11 @@ TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
|
||||
continue;
|
||||
}
|
||||
|
||||
TileCoordIntPoint tilePosition = aLayerBuffer.GetPlacement().TilePosition(i);
|
||||
TileCoordIntPoint tileCoord = aLayerBuffer.GetPlacement().TileCoord(i);
|
||||
// A sanity check that catches a lot of mistakes.
|
||||
MOZ_ASSERT(tilePosition.x == tile.mTilePosition.x && tilePosition.y == tile.mTilePosition.y);
|
||||
MOZ_ASSERT(tileCoord.x == tile.mTileCoord.x && tileCoord.y == tile.mTileCoord.y);
|
||||
|
||||
IntPoint tileOffset = aLayerBuffer.GetTileOffset(tilePosition);
|
||||
IntPoint tileOffset = aLayerBuffer.GetTileOffset(tileCoord);
|
||||
nsIntRegion tileDrawRegion = IntRect(tileOffset, aLayerBuffer.GetScaledTileSize());
|
||||
tileDrawRegion.AndWith(compositeRegion);
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
mTextureHostOnWhite = o.mTextureHostOnWhite;
|
||||
mTextureSource = o.mTextureSource;
|
||||
mTextureSourceOnWhite = o.mTextureSourceOnWhite;
|
||||
mTilePosition = o.mTilePosition;
|
||||
mTileCoord = o.mTileCoord;
|
||||
}
|
||||
TileHost& operator=(const TileHost& o) {
|
||||
if (this == &o) {
|
||||
@ -77,7 +77,7 @@ public:
|
||||
mTextureHostOnWhite = o.mTextureHostOnWhite;
|
||||
mTextureSource = o.mTextureSource;
|
||||
mTextureSourceOnWhite = o.mTextureSourceOnWhite;
|
||||
mTilePosition = o.mTilePosition;
|
||||
mTileCoord = o.mTileCoord;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ public:
|
||||
mutable CompositableTextureSourceRef mTextureSource;
|
||||
mutable CompositableTextureSourceRef mTextureSourceOnWhite;
|
||||
// This is not strictly necessary but makes debugging whole lot easier.
|
||||
TileCoordIntPoint mTilePosition;
|
||||
TileCoordIntPoint mTileCoord;
|
||||
TimeStamp mFadeStart;
|
||||
};
|
||||
|
||||
|
@ -165,11 +165,11 @@ PaintedLayerMLGPU::AssignTileBufferToView(FrameBuilder* aBuilder,
|
||||
continue;
|
||||
}
|
||||
|
||||
TileCoordIntPoint pos = aTiles.GetPlacement().TilePosition(i);
|
||||
TileCoordIntPoint coord = aTiles.GetPlacement().TileCoord(i);
|
||||
// A sanity check that catches a lot of mistakes.
|
||||
MOZ_ASSERT(pos.x == tile.mTilePosition.x && pos.y == tile.mTilePosition.y);
|
||||
MOZ_ASSERT(coord.x == tile.mTileCoord.x && coord.y == tile.mTileCoord.y);
|
||||
|
||||
IntPoint offset = aTiles.GetTileOffset(pos);
|
||||
IntPoint offset = aTiles.GetTileOffset(coord);
|
||||
|
||||
// Use LayerIntRect here so we don't have to keep re-allocating the region
|
||||
// to change the unit type.
|
||||
|
Loading…
Reference in New Issue
Block a user