Bug 1057222 - Do partial tile uploads on desktop. r=BenWa

--HG--
extra : rebase_source : 47ef135eeb5a2f1c9b97594fa7bc7bcd90360cd2
This commit is contained in:
Matt Woodrow 2014-08-27 18:51:37 +12:00
parent 09c2e5f2d6
commit 7b1157f5a9
3 changed files with 35 additions and 5 deletions

View File

@ -592,7 +592,8 @@ CopyFrontToBack(TextureClient* aFront,
void
TileClient::ValidateBackBufferFromFront(const nsIntRegion& aDirtyRegion,
bool aCanRerasterizeValidRegion)
bool aCanRerasterizeValidRegion,
nsIntRegion& aAddPaintedRegion)
{
if (mBackBuffer && mFrontBuffer) {
gfx::IntSize tileSize = mFrontBuffer->GetSize();
@ -608,6 +609,8 @@ TileClient::ValidateBackBufferFromFront(const nsIntRegion& aDirtyRegion,
regionToCopy.Sub(regionToCopy, aDirtyRegion);
aAddPaintedRegion = regionToCopy;
if (regionToCopy.IsEmpty() ||
(aCanRerasterizeValidRegion &&
regionToCopy.Area() < tileSize.width * tileSize.height * MINIMUM_TILE_COPY_AREA)) {
@ -725,6 +728,7 @@ TileClient::GetBackBuffer(const nsIntRegion& aDirtyRegion,
gfxContentType aContent,
SurfaceMode aMode,
bool *aCreatedTextureClient,
nsIntRegion& aAddPaintedRegion,
bool aCanRerasterizeValidRegion,
RefPtr<TextureClient>* aBackBufferOnWhite)
{
@ -772,7 +776,7 @@ TileClient::GetBackBuffer(const nsIntRegion& aDirtyRegion,
mInvalidBack = nsIntRect(0, 0, mBackBuffer->GetSize().width, mBackBuffer->GetSize().height);
}
ValidateBackBufferFromFront(aDirtyRegion, aCanRerasterizeValidRegion);
ValidateBackBufferFromFront(aDirtyRegion, aCanRerasterizeValidRegion, aAddPaintedRegion);
*aBackBufferOnWhite = mBackBufferOnWhite;
return mBackBuffer;
@ -949,6 +953,7 @@ ClientTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion,
PROFILER_LABEL("ClientTiledLayerBuffer", "PaintThebesUpdate",
js::ProfileEntry::Category::GRAPHICS);
mNewValidRegion = aNewValidRegion;
Update(aNewValidRegion, aPaintRegion);
#ifdef GFX_TILEDLAYER_PREF_WARNINGS
@ -1095,13 +1100,19 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
bool usingSinglePaintBuffer = !!mSinglePaintDrawTarget;
SurfaceMode mode;
gfxContentType content = GetContentType(&mode);
nsIntRegion extraPainted;
RefPtr<TextureClient> backBufferOnWhite;
RefPtr<TextureClient> backBuffer =
aTile.GetBackBuffer(offsetScaledDirtyRegion,
content, mode,
&createdTextureClient, !usingSinglePaintBuffer,
&createdTextureClient, extraPainted,
!usingSinglePaintBuffer && !gfxPrefs::TiledDrawTargetEnabled(),
&backBufferOnWhite);
extraPainted.MoveBy(aTileOrigin);
extraPainted.And(extraPainted, mNewValidRegion);
mPaintedRegion.Or(mPaintedRegion, extraPainted);
// the back buffer may have been already locked in ValidateBackBufferFromFront
if (!backBuffer->IsLocked()) {
if (!backBuffer->Lock(OpenMode::OPEN_READ_WRITE)) {

View File

@ -222,10 +222,15 @@ struct TileClient
* data to the tile. This may flip the front-buffer to the back-buffer if
* the front-buffer is still locked by the host, or does not have an
* internal buffer (and so will always be locked).
*
* If getting the back buffer required copying pixels from the front buffer
* then the copied region is stored in aAddPaintedRegion so the host side
* knows to upload it.
*/
TextureClient* GetBackBuffer(const nsIntRegion& aDirtyRegion,
gfxContentType aContent, SurfaceMode aMode,
bool *aCreatedTextureClient,
nsIntRegion& aAddPaintedRegion,
bool aCanRerasterizeValidRegion,
RefPtr<TextureClient>* aTextureClientOnWhite);
@ -263,8 +268,11 @@ struct TileClient
nsExpirationState mExpirationState;
private:
// Copies dirty pixels from the front buffer into the back buffer,
// and records the copied region in aAddPaintedRegion.
void ValidateBackBufferFromFront(const nsIntRegion &aDirtyRegion,
bool aCanRerasterizeValidRegion);
bool aCanRerasterizeValidRegion,
nsIntRegion& aAddPaintedRegion);
};
/**
@ -455,6 +463,10 @@ private:
gfxContentType mLastPaintContentType;
SurfaceMode mLastPaintSurfaceMode;
// The region that will be made valid during Update(). Once Update() is
// completed then this is identical to mValidRegion.
nsIntRegion mNewValidRegion;
// The DrawTarget we use when UseSinglePaintBuffer() above is true.
RefPtr<gfx::DrawTarget> mSinglePaintDrawTarget;
nsIntPoint mSinglePaintBufferOffset;

View File

@ -147,14 +147,21 @@ TiledLayerBufferComposite::ValidateTile(TileHost aTile,
#endif
MOZ_ASSERT(aTile.mTextureHost->GetFlags() & TextureFlags::IMMEDIATE_UPLOAD);
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
MOZ_ASSERT(!aTile.mTextureHostOnWhite);
// We possibly upload the entire texture contents here. This is a purposeful
// decision, as sub-image upload can often be slow and/or unreliable, but
// we may want to reevaluate this in the future.
// For !HasInternalBuffer() textures, this is likely a no-op.
aTile.mTextureHost->Updated(nullptr);
#else
nsIntRegion tileUpdated = aDirtyRect.MovedBy(-aTileOrigin);
aTile.mTextureHost->Updated(&tileUpdated);
if (aTile.mTextureHostOnWhite) {
aTile.mTextureHostOnWhite->Updated(nullptr);
aTile.mTextureHostOnWhite->Updated(&tileUpdated);
}
#endif
#ifdef GFX_TILEDLAYER_PREF_WARNINGS
if (PR_IntervalNow() - start > 1) {