Skip to content

Commit

Permalink
Bug 1130802 - Always prefer decoded surfaces when substituting surfac…
Browse files Browse the repository at this point in the history
…es for downscale-during-decode. r=dholbert
  • Loading branch information
sethfowler committed Feb 10, 2015
1 parent b1a7349 commit 401812b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions image/src/SurfaceCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class CachedSurface
CostEntry GetCostEntry() { return image::CostEntry(this, mCost); }
nsExpirationState* GetExpirationState() { return &mExpirationState; }
Lifetime GetLifetime() const { return mLifetime; }
bool IsDecoded() const { return mSurface->IsImageComplete(); }

// A helper type used by SurfaceCacheImpl::SizeOfSurfacesSum.
struct SizeOfSurfacesSum
Expand Down Expand Up @@ -315,6 +316,17 @@ class ImageSurfaceCache
}

MOZ_ASSERT(context->mBestMatch, "Should have a current best match");

// Always prefer completely decoded surfaces.
bool bestMatchIsDecoded = context->mBestMatch->IsDecoded();
if (bestMatchIsDecoded && !aSurface->IsDecoded()) {
return PL_DHASH_NEXT;
}
if (!bestMatchIsDecoded && aSurface->IsDecoded()) {
context->mBestMatch = aSurface;
return PL_DHASH_NEXT;
}

SurfaceKey bestMatchKey = context->mBestMatch->GetSurfaceKey();

// Compare sizes. We use an area-based heuristic here instead of computing a
Expand Down

0 comments on commit 401812b

Please sign in to comment.