Bug 1129871 - Pass tiles by ref rather than copy part 1. r=BenWa

This commit is contained in:
Nicolas Silva 2015-02-05 18:16:05 +01:00
Родитель 38bd36d34c
Коммит 6f4d3546bc
5 изменённых файлов: 32 добавлений и 41 удалений

Просмотреть файл

@ -532,8 +532,8 @@ TiledLayerBuffer<Derived, Tile>::Update(const nsIntRegion& aNewValidRegion,
// in which case it's up to the derived class's ValidateTile()
// implementation to allocate a new tile before drawing
nsIntPoint tileOrigin(tileStartX, tileStartY);
newTile = AsDerived().ValidateTile(newTile, nsIntPoint(tileStartX, tileStartY),
tileDrawRegion);
AsDerived().ValidateTile(newTile, nsIntPoint(tileStartX, tileStartY),
tileDrawRegion);
NS_ASSERTION(!IsPlaceholder(newTile), "Unexpected placeholder tile - failed to allocate?");
#ifdef GFX_TILEDLAYER_PREF_WARNINGS
printf_stderr("Store Validate tile %i, %i -> %i\n", tileStartX, tileStartY, index);

Просмотреть файл

@ -1086,7 +1086,7 @@ ClientTiledLayerBuffer::PostValidate(const nsIntRegion& aPaintRegion)
}
void
ClientTiledLayerBuffer::UnlockTile(TileClient aTile)
ClientTiledLayerBuffer::UnlockTile(TileClient& aTile)
{
// We locked the back buffer, and flipped so we now need to unlock the front
if (aTile.mFrontBuffer && aTile.mFrontBuffer->IsLocked()) {
@ -1105,8 +1105,8 @@ ClientTiledLayerBuffer::UnlockTile(TileClient aTile)
}
}
TileClient
ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
void
ClientTiledLayerBuffer::ValidateTile(TileClient& aTile,
const nsIntPoint& aTileOrigin,
const nsIntRegion& aDirtyRegion)
{
@ -1147,27 +1147,24 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
if (!backBuffer) {
NS_WARNING("Failed to allocate a tile TextureClient");
aTile.DiscardBackBuffer();
aTile.DiscardFrontBuffer();
return TileClient();
aTile.Release();
return;
}
// the back buffer may have been already locked in ValidateBackBufferFromFront
if (!backBuffer->IsLocked()) {
if (!backBuffer->Lock(OpenMode::OPEN_READ_WRITE)) {
NS_WARNING("Failed to lock a tile TextureClient");
aTile.DiscardBackBuffer();
aTile.DiscardFrontBuffer();
return TileClient();
aTile.Release();
return;
}
}
if (backBufferOnWhite && !backBufferOnWhite->IsLocked()) {
if (!backBufferOnWhite->Lock(OpenMode::OPEN_READ_WRITE)) {
NS_WARNING("Failed to lock tile TextureClient for updating.");
aTile.DiscardBackBuffer();
aTile.DiscardFrontBuffer();
return TileClient();
aTile.Release();
return;
}
}
@ -1177,15 +1174,13 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
if (createdTextureClient) {
if (!mCompositableClient->AddTextureClient(backBuffer)) {
NS_WARNING("Failed to add tile TextureClient.");
aTile.DiscardFrontBuffer();
aTile.DiscardBackBuffer();
return aTile;
aTile.Release();
return;
}
if (backBufferOnWhite && !mCompositableClient->AddTextureClient(backBufferOnWhite)) {
NS_WARNING("Failed to add tile TextureClient.");
aTile.DiscardFrontBuffer();
aTile.DiscardBackBuffer();
return aTile;
aTile.Release();
return;
}
}
@ -1201,9 +1196,9 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
}
moz2DTile.mTileOrigin = gfx::IntPoint(aTileOrigin.x, aTileOrigin.y);
if (!dt || (backBufferOnWhite && !dtOnWhite)) {
aTile.DiscardFrontBuffer();
aTile.DiscardBackBuffer();
return aTile;
NS_WARNING("Failed to get a DrawTarget from a tile");
aTile.Release();
return;
}
mMoz2DTiles.push_back(moz2DTile);
@ -1236,7 +1231,7 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
aTile.Flip();
return aTile;
return;
}
// Single paint buffer case:
@ -1299,9 +1294,8 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
if (createdTextureClient) {
if (!mCompositableClient->AddTextureClient(backBuffer)) {
NS_WARNING("Failed to add tile TextureClient.");
aTile.DiscardFrontBuffer();
aTile.DiscardBackBuffer();
return aTile;
aTile.Release();
return;
}
}
@ -1315,8 +1309,6 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
// TextureClient around unnecessarily, so discard the back-buffer.
aTile.DiscardBackBuffer();
}
return aTile;
}
/**

Просмотреть файл

@ -442,15 +442,15 @@ public:
SurfaceDescriptorTiles GetSurfaceDescriptorTiles();
protected:
TileClient ValidateTile(TileClient aTile,
const nsIntPoint& aTileRect,
const nsIntRegion& dirtyRect);
void ValidateTile(TileClient& aTile,
const nsIntPoint& aTileRect,
const nsIntRegion& dirtyRect);
void PostValidate(const nsIntRegion& aPaintRegion);
void UnlockTile(TileClient aTile);
void UnlockTile(TileClient& aTile);
void ReleaseTile(TileClient aTile) { aTile.Release(); }
void ReleaseTile(TileClient& aTile) { aTile.Release(); }
void SwapTiles(TileClient& aTileA, TileClient& aTileB) { std::swap(aTileA, aTileB); }

Просмотреть файл

@ -168,14 +168,14 @@ TiledLayerBufferComposite::Upload()
ClearPaintedRegion();
}
TileHost
TiledLayerBufferComposite::ValidateTile(TileHost aTile,
void
TiledLayerBufferComposite::ValidateTile(TileHost& aTile,
const nsIntPoint& aTileOrigin,
const nsIntRegion& aDirtyRect)
{
if (aTile.IsPlaceholderTile()) {
NS_WARNING("Placeholder tile encountered in painted region");
return aTile;
return;
}
#ifdef GFX_TILEDLAYER_PREF_WARNINGS
@ -205,7 +205,6 @@ TiledLayerBufferComposite::ValidateTile(TileHost aTile,
printf_stderr("Tile Time to upload %i\n", PR_IntervalNow() - start);
}
#endif
return aTile;
}
void

Просмотреть файл

@ -164,9 +164,9 @@ public:
static void RecycleCallback(TextureHost* textureHost, void* aClosure);
protected:
TileHost ValidateTile(TileHost aTile,
const nsIntPoint& aTileRect,
const nsIntRegion& dirtyRect);
void ValidateTile(TileHost& aTile,
const nsIntPoint& aTileRect,
const nsIntRegion& dirtyRect);
// do nothing, the desctructor in the texture host takes care of releasing resources
void ReleaseTile(TileHost aTile) {}