Bug 1330919 - Pass RefreshDriver timestamp to captured frames from canvas. r=jesup

MozReview-Commit-ID: 75L94Y5VcsQ

--HG--
extra : rebase_source : adb150b4a874cf8ac762146773c955f9dbf989d1
This commit is contained in:
Andreas Pehrson 2017-01-13 11:56:03 +01:00
Родитель d3cd678596
Коммит 231a5e70d4
4 изменённых файлов: 22 добавлений и 16 удалений

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

@ -148,7 +148,7 @@ public:
{
PROFILER_LABEL("HTMLCanvasElement", "SetFrame", js::ProfileEntry::Category::OTHER);
mOwningElement->SetFrameCapture(copy.forget());
mOwningElement->SetFrameCapture(copy.forget(), aTime);
mOwningElement->MarkContextCleanForFrameCapture();
}
}
@ -1274,7 +1274,8 @@ HTMLCanvasElement::ProcessDestroyedFrameListeners()
}
void
HTMLCanvasElement::SetFrameCapture(already_AddRefed<SourceSurface> aSurface)
HTMLCanvasElement::SetFrameCapture(already_AddRefed<SourceSurface> aSurface,
const TimeStamp& aTime)
{
RefPtr<SourceSurface> surface = aSurface;
RefPtr<SourceSurfaceImage> image = new SourceSurfaceImage(surface->GetSize(), surface);
@ -1285,7 +1286,7 @@ HTMLCanvasElement::SetFrameCapture(already_AddRefed<SourceSurface> aSurface)
}
RefPtr<Image> imageRefCopy = image.get();
listener->NewFrame(imageRefCopy.forget());
listener->NewFrame(imageRefCopy.forget(), aTime);
}
}

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

@ -105,7 +105,8 @@ public:
* Interface through which new video frames will be provided while
* `mFrameCaptureRequested` is `true`.
*/
virtual void NewFrame(already_AddRefed<layers::Image> aImage) = 0;
virtual void NewFrame(already_AddRefed<layers::Image> aImage,
const TimeStamp& aTime) = 0;
protected:
virtual ~FrameCaptureListener() {}
@ -283,7 +284,8 @@ public:
* Makes a copy of the provided surface and hands it to all
* FrameCaptureListeners having requested frame capture.
*/
void SetFrameCapture(already_AddRefed<gfx::SourceSurface> aSurface);
void SetFrameCapture(already_AddRefed<gfx::SourceSurface> aSurface,
const TimeStamp& aTime);
virtual bool ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,

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

@ -31,7 +31,6 @@ public:
, mTrackId(aTrackId)
, mPrincipalHandle(aPrincipalHandle)
, mMutex("CanvasCaptureMediaStream OutputStreamDriver::StreamListener")
, mImage(nullptr)
{
MOZ_ASSERT(mSourceStream);
}
@ -40,24 +39,26 @@ public:
mEnded = true;
}
void SetImage(const RefPtr<layers::Image>& aImage)
void SetImage(const RefPtr<layers::Image>& aImage, const TimeStamp& aTime)
{
MutexAutoLock lock(mMutex);
mImage = aImage;
mImageTime = aTime;
}
void NotifyPull(MediaStreamGraph* aGraph, StreamTime aDesiredTime) override
{
// Called on the MediaStreamGraph thread.
MOZ_ASSERT(mSourceStream);
StreamTime delta = aDesiredTime - mSourceStream->GetEndOfAppendedData(mTrackId);
if (delta > 0) {
MutexAutoLock lock(mMutex);
MOZ_ASSERT(mSourceStream);
RefPtr<Image> image = mImage;
IntSize size = image ? image->GetSize() : IntSize(0, 0);
VideoSegment segment;
segment.AppendFrame(image.forget(), delta, size, mPrincipalHandle);
segment.AppendFrame(image.forget(), delta, size, mPrincipalHandle, false,
mImageTime);
mSourceStream->AppendToTrack(mTrackId, &segment);
}
@ -79,6 +80,7 @@ private:
Mutex mMutex;
// The below members are protected by mMutex.
RefPtr<layers::Image> mImage;
TimeStamp mImageTime;
};
OutputStreamDriver::OutputStreamDriver(SourceMediaStream* aSourceStream,
@ -111,10 +113,11 @@ OutputStreamDriver::~OutputStreamDriver()
}
void
OutputStreamDriver::SetImage(const RefPtr<layers::Image>& aImage)
OutputStreamDriver::SetImage(const RefPtr<layers::Image>& aImage,
const TimeStamp& aTime)
{
if (mStreamListener) {
mStreamListener->SetImage(aImage);
mStreamListener->SetImage(aImage, aTime);
}
}
@ -150,7 +153,7 @@ public:
driver->RequestFrameCapture();
}
void NewFrame(already_AddRefed<Image> aImage) override
void NewFrame(already_AddRefed<Image> aImage, const TimeStamp& aTime) override
{
RefPtr<Image> image = aImage;
@ -159,7 +162,7 @@ public:
}
mFrameCaptureRequested = false;
SetImage(image.forget());
SetImage(image.forget(), aTime);
}
void Forget() override
@ -188,7 +191,7 @@ public:
const PrincipalHandle& aPrincipalHandle)
: OutputStreamDriver(aSourceStream, aTrackId, aPrincipalHandle) {}
void NewFrame(already_AddRefed<Image> aImage) override
void NewFrame(already_AddRefed<Image> aImage, const TimeStamp& aTime) override
{
// Don't reset `mFrameCaptureRequested` since AutoDriver shall always have
// `mFrameCaptureRequested` set to true.
@ -196,7 +199,7 @@ public:
// after something changed.
RefPtr<Image> image = aImage;
SetImage(image.forget());
SetImage(image.forget(), aTime);
}
protected:

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

@ -79,7 +79,7 @@ public:
* Sub classes can SetImage() to update the image being appended to the
* output stream. It will be appended on the next NotifyPull from MSG.
*/
void SetImage(const RefPtr<layers::Image>& aImage);
void SetImage(const RefPtr<layers::Image>& aImage, const TimeStamp& aTime);
/*
* Makes sure any internal resources this driver is holding that may create