mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 11:38:16 +00:00
Bug 1309082 - Part 2: Rename some ImageTracker members. r=bholley
MozReview-Commit-ID: 6yOIKKl8npT --HG-- extra : rebase_source : 247787a0e18640c878e461c4b600bc36a40bad6d
This commit is contained in:
parent
58c32a9088
commit
c1f0ee12ba
@ -13,39 +13,39 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
ImageTracker::ImageTracker()
|
||||
: mLockingImages(false)
|
||||
, mAnimatingImages(true)
|
||||
: mLocking(false)
|
||||
, mAnimating(true)
|
||||
{
|
||||
}
|
||||
|
||||
ImageTracker::~ImageTracker()
|
||||
{
|
||||
SetImageLockingState(false);
|
||||
SetLockingState(false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
ImageTracker::AddImage(imgIRequest* aImage)
|
||||
ImageTracker::Add(imgIRequest* aImage)
|
||||
{
|
||||
MOZ_ASSERT(aImage);
|
||||
|
||||
// See if the image is already in the hashtable. If it is, get the old count.
|
||||
uint32_t oldCount = 0;
|
||||
mImageTracker.Get(aImage, &oldCount);
|
||||
mImages.Get(aImage, &oldCount);
|
||||
|
||||
// Put the image in the hashtable, with the proper count.
|
||||
mImageTracker.Put(aImage, oldCount + 1);
|
||||
mImages.Put(aImage, oldCount + 1);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// If this is the first insertion and we're locking images, lock this image
|
||||
// too.
|
||||
if (oldCount == 0 && mLockingImages) {
|
||||
if (oldCount == 0 && mLocking) {
|
||||
rv = aImage->LockImage();
|
||||
}
|
||||
|
||||
// If this is the first insertion and we're animating images, request
|
||||
// that this image be animated too.
|
||||
if (oldCount == 0 && mAnimatingImages) {
|
||||
if (oldCount == 0 && mAnimating) {
|
||||
nsresult rv2 = aImage->IncrementAnimationConsumers();
|
||||
rv = NS_SUCCEEDED(rv) ? rv2 : rv;
|
||||
}
|
||||
@ -54,13 +54,13 @@ ImageTracker::AddImage(imgIRequest* aImage)
|
||||
}
|
||||
|
||||
nsresult
|
||||
ImageTracker::RemoveImage(imgIRequest* aImage, uint32_t aFlags)
|
||||
ImageTracker::Remove(imgIRequest* aImage, uint32_t aFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aImage);
|
||||
|
||||
// Get the old count. It should exist and be > 0.
|
||||
uint32_t count = 0;
|
||||
DebugOnly<bool> found = mImageTracker.Get(aImage, &count);
|
||||
DebugOnly<bool> found = mImages.Get(aImage, &count);
|
||||
MOZ_ASSERT(found, "Removing image that wasn't in the tracker!");
|
||||
MOZ_ASSERT(count > 0, "Entry in the cache tracker with count 0!");
|
||||
|
||||
@ -70,29 +70,29 @@ ImageTracker::RemoveImage(imgIRequest* aImage, uint32_t aFlags)
|
||||
// If the count is now zero, remove from the tracker.
|
||||
// Otherwise, set the new value.
|
||||
if (count != 0) {
|
||||
mImageTracker.Put(aImage, count);
|
||||
mImages.Put(aImage, count);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mImageTracker.Remove(aImage);
|
||||
mImages.Remove(aImage);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Now that we're no longer tracking this image, unlock it if we'd
|
||||
// previously locked it.
|
||||
if (mLockingImages) {
|
||||
if (mLocking) {
|
||||
rv = aImage->UnlockImage();
|
||||
}
|
||||
|
||||
// If we're animating images, remove our request to animate this one.
|
||||
if (mAnimatingImages) {
|
||||
if (mAnimating) {
|
||||
nsresult rv2 = aImage->DecrementAnimationConsumers();
|
||||
rv = NS_SUCCEEDED(rv) ? rv2 : rv;
|
||||
}
|
||||
|
||||
if (aFlags & REQUEST_DISCARD) {
|
||||
// Request that the image be discarded if nobody else holds a lock on it.
|
||||
// Do this even if !mLockingImages, because even if we didn't just unlock
|
||||
// Do this even if !mLocking, because even if we didn't just unlock
|
||||
// this image, it might still be a candidate for discarding.
|
||||
aImage->RequestDiscard();
|
||||
}
|
||||
@ -101,7 +101,7 @@ ImageTracker::RemoveImage(imgIRequest* aImage, uint32_t aFlags)
|
||||
}
|
||||
|
||||
nsresult
|
||||
ImageTracker::SetImageLockingState(bool aLocked)
|
||||
ImageTracker::SetLockingState(bool aLocked)
|
||||
{
|
||||
if (XRE_IsContentProcess() &&
|
||||
!Preferences::GetBool("image.mem.allow_locking_in_content_processes", true)) {
|
||||
@ -109,11 +109,11 @@ ImageTracker::SetImageLockingState(bool aLocked)
|
||||
}
|
||||
|
||||
// If there's no change, there's nothing to do.
|
||||
if (mLockingImages == aLocked)
|
||||
if (mLocking == aLocked)
|
||||
return NS_OK;
|
||||
|
||||
// Otherwise, iterate over our images and perform the appropriate action.
|
||||
for (auto iter = mImageTracker.Iter(); !iter.Done(); iter.Next()) {
|
||||
for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
|
||||
imgIRequest* image = iter.Key();
|
||||
if (aLocked) {
|
||||
image->LockImage();
|
||||
@ -123,20 +123,20 @@ ImageTracker::SetImageLockingState(bool aLocked)
|
||||
}
|
||||
|
||||
// Update state.
|
||||
mLockingImages = aLocked;
|
||||
mLocking = aLocked;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
ImageTracker::SetImagesNeedAnimating(bool aAnimating)
|
||||
ImageTracker::SetAnimatingState(bool aAnimating)
|
||||
{
|
||||
// If there's no change, there's nothing to do.
|
||||
if (mAnimatingImages == aAnimating)
|
||||
if (mAnimating == aAnimating)
|
||||
return;
|
||||
|
||||
// Otherwise, iterate over our images and perform the appropriate action.
|
||||
for (auto iter = mImageTracker.Iter(); !iter.Done(); iter.Next()) {
|
||||
for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
|
||||
imgIRequest* image = iter.Key();
|
||||
if (aAnimating) {
|
||||
image->IncrementAnimationConsumers();
|
||||
@ -146,13 +146,13 @@ ImageTracker::SetImagesNeedAnimating(bool aAnimating)
|
||||
}
|
||||
|
||||
// Update state.
|
||||
mAnimatingImages = aAnimating;
|
||||
mAnimating = aAnimating;
|
||||
}
|
||||
|
||||
void
|
||||
ImageTracker::RequestDiscardAll()
|
||||
{
|
||||
for (auto iter = mImageTracker.Iter(); !iter.Done(); iter.Next()) {
|
||||
for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
|
||||
iter.Key()->RequestDiscard();
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace dom {
|
||||
* they are and are not visible. When an image is on-screen, we want to call
|
||||
* LockImage() on it so that it doesn't do things like discarding frame data
|
||||
* to save memory. The PresShell informs its document's image tracker whether
|
||||
* its images should be locked or not via SetImageLockingState().
|
||||
* its images should be locked or not via SetLockingState().
|
||||
*
|
||||
* See bug 512260.
|
||||
*/
|
||||
@ -39,28 +39,28 @@ public:
|
||||
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageTracker)
|
||||
|
||||
nsresult AddImage(imgIRequest* aImage);
|
||||
nsresult Add(imgIRequest* aImage);
|
||||
|
||||
enum { REQUEST_DISCARD = 0x1 };
|
||||
nsresult RemoveImage(imgIRequest* aImage, uint32_t aFlags = 0);
|
||||
nsresult Remove(imgIRequest* aImage, uint32_t aFlags = 0);
|
||||
|
||||
// Makes the images on this document locked/unlocked. By default, the locking
|
||||
// state is unlocked/false.
|
||||
nsresult SetImageLockingState(bool aLocked);
|
||||
nsresult SetLockingState(bool aLocked);
|
||||
|
||||
// Makes the images on this document capable of having their animation
|
||||
// active or suspended. An Image will animate as long as at least one of its
|
||||
// owning Documents needs it to animate; otherwise it can suspend.
|
||||
void SetImagesNeedAnimating(bool aAnimating);
|
||||
void SetAnimatingState(bool aAnimating);
|
||||
|
||||
void RequestDiscardAll();
|
||||
|
||||
private:
|
||||
~ImageTracker();
|
||||
|
||||
nsDataHashtable<nsPtrHashKey<imgIRequest>, uint32_t> mImageTracker;
|
||||
bool mLockingImages;
|
||||
bool mAnimatingImages;
|
||||
nsDataHashtable<nsPtrHashKey<imgIRequest>, uint32_t> mImages;
|
||||
bool mLocking;
|
||||
bool mAnimating;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -8714,7 +8714,7 @@ nsDocument::OnPageShow(bool aPersisted,
|
||||
}
|
||||
|
||||
if (aPersisted) {
|
||||
ImageTracker()->SetImagesNeedAnimating(true);
|
||||
ImageTracker()->SetAnimatingState(true);
|
||||
}
|
||||
|
||||
UpdateVisibilityState();
|
||||
@ -8809,7 +8809,7 @@ nsDocument::OnPageHide(bool aPersisted,
|
||||
// when the page is refreshing while being dragged out
|
||||
nsDocShell* docShell = mDocumentContainer.get();
|
||||
if (aPersisted && !(docShell && docShell->InFrameSwap())) {
|
||||
ImageTracker()->SetImagesNeedAnimating(false);
|
||||
ImageTracker()->SetAnimatingState(false);
|
||||
}
|
||||
|
||||
ExitPointerLock();
|
||||
|
@ -1476,11 +1476,11 @@ nsImageLoadingContent::TrackImage(imgIRequest* aImage)
|
||||
|
||||
if (aImage == mCurrentRequest && !(mCurrentRequestFlags & REQUEST_IS_TRACKED)) {
|
||||
mCurrentRequestFlags |= REQUEST_IS_TRACKED;
|
||||
doc->ImageTracker()->AddImage(mCurrentRequest);
|
||||
doc->ImageTracker()->Add(mCurrentRequest);
|
||||
}
|
||||
if (aImage == mPendingRequest && !(mPendingRequestFlags & REQUEST_IS_TRACKED)) {
|
||||
mPendingRequestFlags |= REQUEST_IS_TRACKED;
|
||||
doc->ImageTracker()->AddImage(mPendingRequest);
|
||||
doc->ImageTracker()->Add(mPendingRequest);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1503,7 +1503,7 @@ nsImageLoadingContent::UntrackImage(imgIRequest* aImage,
|
||||
if (aImage == mCurrentRequest) {
|
||||
if (doc && (mCurrentRequestFlags & REQUEST_IS_TRACKED)) {
|
||||
mCurrentRequestFlags &= ~REQUEST_IS_TRACKED;
|
||||
doc->ImageTracker()->RemoveImage(
|
||||
doc->ImageTracker()->Remove(
|
||||
mCurrentRequest,
|
||||
aNonvisibleAction == Some(OnNonvisible::DISCARD_IMAGES)
|
||||
? ImageTracker::REQUEST_DISCARD
|
||||
@ -1516,7 +1516,7 @@ nsImageLoadingContent::UntrackImage(imgIRequest* aImage,
|
||||
if (aImage == mPendingRequest) {
|
||||
if (doc && (mPendingRequestFlags & REQUEST_IS_TRACKED)) {
|
||||
mPendingRequestFlags &= ~REQUEST_IS_TRACKED;
|
||||
doc->ImageTracker()->RemoveImage(
|
||||
doc->ImageTracker()->Remove(
|
||||
mPendingRequest,
|
||||
aNonvisibleAction == Some(OnNonvisible::DISCARD_IMAGES)
|
||||
? ImageTracker::REQUEST_DISCARD
|
||||
|
@ -171,7 +171,7 @@ gfxSVGGlyphsDocument::SetupPresentation()
|
||||
if (controller) {
|
||||
controller->Resume(nsSMILTimeContainer::PAUSE_IMAGE);
|
||||
}
|
||||
mDocument->ImageTracker()->SetImagesNeedAnimating(true);
|
||||
mDocument->ImageTracker()->SetAnimatingState(true);
|
||||
|
||||
mViewer = viewer;
|
||||
mPresShell = presShell;
|
||||
|
@ -155,7 +155,7 @@ SVGDocumentWrapper::StartAnimation()
|
||||
if (controller) {
|
||||
controller->Resume(nsSMILTimeContainer::PAUSE_IMAGE);
|
||||
}
|
||||
doc->ImageTracker()->SetImagesNeedAnimating(true);
|
||||
doc->ImageTracker()->SetAnimatingState(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ SVGDocumentWrapper::StopAnimation()
|
||||
if (controller) {
|
||||
controller->Pause(nsSMILTimeContainer::PAUSE_IMAGE);
|
||||
}
|
||||
doc->ImageTracker()->SetImagesNeedAnimating(false);
|
||||
doc->ImageTracker()->SetAnimatingState(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10943,7 +10943,7 @@ PresShell::UpdateImageLockingState()
|
||||
// We're locked if we're both thawed and active.
|
||||
bool locked = !mFrozen && mIsActive;
|
||||
|
||||
nsresult rv = mDocument->ImageTracker()->SetImageLockingState(locked);
|
||||
nsresult rv = mDocument->ImageTracker()->SetLockingState(locked);
|
||||
|
||||
if (locked) {
|
||||
// Request decodes for visible image frames; we want to start decoding as
|
||||
|
@ -2012,7 +2012,7 @@ nsStyleImage::TrackImage(nsPresContext* aContext)
|
||||
// Register the image with the document
|
||||
nsIDocument* doc = aContext->Document();
|
||||
if (doc) {
|
||||
doc->ImageTracker()->AddImage(mImage);
|
||||
doc->ImageTracker()->Add(mImage);
|
||||
}
|
||||
|
||||
// Mark state
|
||||
@ -2032,7 +2032,7 @@ nsStyleImage::UntrackImage(nsPresContext* aContext)
|
||||
// Unregister the image with the document
|
||||
nsIDocument* doc = aContext->Document();
|
||||
if (doc) {
|
||||
doc->ImageTracker()->RemoveImage(mImage);
|
||||
doc->ImageTracker()->Remove(mImage);
|
||||
}
|
||||
|
||||
// Mark state
|
||||
@ -3439,7 +3439,7 @@ nsStyleContentData::TrackImage(nsPresContext* aContext)
|
||||
// Register the image with the document
|
||||
nsIDocument* doc = aContext->Document();
|
||||
if (doc) {
|
||||
doc->ImageTracker()->AddImage(mContent.mImage);
|
||||
doc->ImageTracker()->Add(mContent.mImage);
|
||||
}
|
||||
|
||||
// Mark state
|
||||
@ -3461,7 +3461,7 @@ nsStyleContentData::UntrackImage(nsPresContext* aContext)
|
||||
// Unregister the image with the document
|
||||
nsIDocument* doc = aContext->Document();
|
||||
if (doc) {
|
||||
doc->ImageTracker()->RemoveImage(mContent.mImage);
|
||||
doc->ImageTracker()->Remove(mContent.mImage);
|
||||
}
|
||||
|
||||
// Mark state
|
||||
|
Loading…
x
Reference in New Issue
Block a user