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

This commit is contained in:
Nicolas Silva 2015-02-14 12:14:54 +01:00
Родитель 62064bcb83
Коммит 0e7c4b0468
5 изменённых файлов: 32 добавлений и 41 удалений

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

@ -544,7 +544,7 @@ TiledLayerBuffer<Derived, Tile>::Update(const nsIntRegion& newValidRegion,
// in which case it's up to the derived class's ValidateTile() // in which case it's up to the derived class's ValidateTile()
// implementation to allocate a new tile before drawing // implementation to allocate a new tile before drawing
nsIntPoint tileOrigin(tileStartX, tileStartY); nsIntPoint tileOrigin(tileStartX, tileStartY);
newTile = AsDerived().ValidateTile(newTile, nsIntPoint(tileStartX, tileStartY), AsDerived().ValidateTile(newTile, nsIntPoint(tileStartX, tileStartY),
tileDrawRegion); tileDrawRegion);
NS_ASSERTION(!newTile.IsPlaceholderTile(), "Unexpected placeholder tile - failed to allocate?"); NS_ASSERTION(!newTile.IsPlaceholderTile(), "Unexpected placeholder tile - failed to allocate?");
#ifdef GFX_TILEDLAYER_PREF_WARNINGS #ifdef GFX_TILEDLAYER_PREF_WARNINGS

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

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

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

@ -440,15 +440,15 @@ public:
SurfaceDescriptorTiles GetSurfaceDescriptorTiles(); SurfaceDescriptorTiles GetSurfaceDescriptorTiles();
protected: protected:
TileClient ValidateTile(TileClient aTile, void ValidateTile(TileClient& aTile,
const nsIntPoint& aTileRect, const nsIntPoint& aTileRect,
const nsIntRegion& dirtyRect); const nsIntRegion& dirtyRect);
void PostValidate(const nsIntRegion& aPaintRegion); 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); } void SwapTiles(TileClient& aTileA, TileClient& aTileB) { std::swap(aTileA, aTileB); }

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

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

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

@ -164,7 +164,7 @@ public:
static void RecycleCallback(TextureHost* textureHost, void* aClosure); static void RecycleCallback(TextureHost* textureHost, void* aClosure);
protected: protected:
TileHost ValidateTile(TileHost aTile, void ValidateTile(TileHost& aTile,
const nsIntPoint& aTileRect, const nsIntPoint& aTileRect,
const nsIntRegion& dirtyRect); const nsIntRegion& dirtyRect);