Bug 1143575. Reimplement ImageContainer::GetPaintCount to be composition-aware. r=nical

--HG--
extra : commitid : EmOEK6v27UF
extra : rebase_source : 671c06aa942ad87716ab9a998dd55103b1270b66
This commit is contained in:
Robert O'Callahan 2015-06-15 14:45:59 +12:00
Родитель 8baa86248d
Коммит 478bb5668d
5 изменённых файлов: 8 добавлений и 46 удалений

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

@ -50,7 +50,9 @@ function onTimeUpdate_Video(e) {
return;
}
t.removeEventListener("timeupdate", onTimeUpdate_Video);
ok(t.mozPaintedFrames > 0, t.name + ": mozPaintedFrames should be positive, is " + t.mozPaintedFrames + ".");
// There's no guarantee that a video frame composite notification reaches
// us before timeupdate fires.
ok(t.mozPaintedFrames >= 0, t.name + ": mozPaintedFrames should be positive or zero, is " + t.mozPaintedFrames + ".");
ok(t.mozFrameDelay >= 0, t.name + ": mozFrameDelay should be positive or zero, is " + t.mozFrameDelay + ".");
if (t._firstTime) {

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

@ -171,7 +171,6 @@ ImageContainer::ImageContainer(Mode flag)
mGenerationCounter(++sGenerationCounter),
mPaintCount(0),
mDroppedImageCount(0),
mPreviousImagePainted(false),
mCurrentImageComposited(false),
mImageFactory(new ImageFactory()),
mRecycleBin(new BufferRecycleBin()),
@ -251,7 +250,6 @@ ImageContainer::SetCurrentImageInternal(Image *aImage,
mActiveImage = aImage;
mCurrentImageTimeStamp = aTimeStamp;
}
CurrentImageChanged();
}
void
@ -353,6 +351,11 @@ ImageContainer::NotifyCompositeInternal(const ImageCompositeNotification& aNotif
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// An image composition notification is sent the first time a particular
// image is composited by an ImageHost. Thus, every time we receive such
// a notification, a new image has been painted.
++mPaintCount;
while (!mFrameIDsNotYetComposited.IsEmpty()) {
if (mFrameIDsNotYetComposited[0] <= aNotification.frameID()) {
if (mFrameIDsNotYetComposited[0] < aNotification.frameID()) {

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

@ -466,29 +466,6 @@ public:
return mDroppedImageCount;
}
/**
* Increments mPaintCount if this is the first time aPainted has been
* painted, and sets mPaintTime if the painted image is the current image.
* current image. Can be called from any thread.
*/
void NotifyPaintedImage(Image* aPainted) {
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsRefPtr<Image> current = mActiveImage;
if (aPainted == current) {
if (mPaintTime.IsNull()) {
mPaintTime = TimeStamp::Now();
mPaintCount++;
}
} else if (!mPreviousImagePainted) {
// While we were painting this image, the current image changed. We
// still must count it as painted, but can't set mPaintTime, since we're
// no longer the current image.
mPaintCount++;
mPreviousImagePainted = true;
}
}
PImageContainerChild* GetPImageContainerChild();
static void NotifyComposite(const ImageCompositeNotification& aNotification);
@ -508,15 +485,6 @@ private:
void NotifyCompositeInternal(const ImageCompositeNotification& aNotification);
// Performs necessary housekeeping to ensure the painted frame statistics
// are accurate. Must be called by SetCurrentImage() implementations with
// mReentrantMonitor held.
void CurrentImageChanged() {
mReentrantMonitor.AssertCurrentThreadIn();
mPreviousImagePainted = !mPaintTime.IsNull();
mPaintTime = TimeStamp();
}
// ReentrantMonitor to protect thread safe access to the "current
// image", and any other state which is shared between threads.
ReentrantMonitor mReentrantMonitor;
@ -532,19 +500,12 @@ private:
// threadsafe.
uint32_t mPaintCount;
// Time stamp at which the current image was first painted. It's up to the
// ImageContainer implementation to ensure accesses to this are threadsafe.
TimeStamp mPaintTime;
// See GetPaintDelay. Accessed only with mReentrantMonitor held.
TimeDuration mPaintDelay;
// See GetDroppedImageCount. Accessed only with mReentrantMonitor held.
uint32_t mDroppedImageCount;
// Denotes whether the previous image was painted.
bool mPreviousImagePainted;
bool mCurrentImageComposited;
// This is the image factory used by this container, layer managers using

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

@ -91,7 +91,6 @@ BasicImageLayer::Paint(DrawTarget* aDT,
aMaskLayer);
mContainer->SetImageFactory(originalIF);
GetContainer()->NotifyPaintedImage(image);
}
already_AddRefed<SourceSurface>

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

@ -257,7 +257,6 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag
newBuf->mImageSerial = image->GetSerial();
newBuf->mTextureClient = texture;
aContainer->NotifyPaintedImage(image);
texture->SyncWithObject(GetForwarder()->GetSyncObject());
}
@ -310,8 +309,6 @@ ImageClientBridge::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag
}
mAsyncContainerID = aContainer->GetAsyncContainerID();
static_cast<ShadowLayerForwarder*>(GetForwarder())->AttachAsyncCompositable(mAsyncContainerID, mLayer);
AutoLockImage autoLock(aContainer);
aContainer->NotifyPaintedImage(autoLock.GetImage());
return true;
}