Bug 1551735 - Ref count and document CompositionRecorder r=kats

The CompositionRecorder was being stored as a UniquePtr on the
CompositorBridgeParent, but was then passed to and stored on the LayerManger as
a raw pointer. This has been updated to use a RefPtr.

Differential Revision: https://phabricator.services.mozilla.com/D32230

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Barret Rennie 2019-05-30 20:17:39 +00:00
Родитель 0698f8bffe
Коммит 76600ea0a2
4 изменённых файлов: 29 добавлений и 10 удалений

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

@ -20,6 +20,9 @@ class DataSourceSurface;
namespace layers {
/**
* A captured frame from a |LayerManager|.
*/
class RecordedFrame {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RecordedFrame)
@ -38,17 +41,33 @@ class RecordedFrame {
};
/**
* A recorder for composited frames.
*
* This object collects frames sent to it by a |LayerManager| and writes them
* out as a series of images until recording has finished.
*
* If GPU-accelerated rendering is used, the frames will not be mapped into
* memory until |WriteCollectedFrames| is called.
*/
class CompositionRecorder final {
NS_INLINE_DECL_REFCOUNTING(CompositionRecorder)
public:
explicit CompositionRecorder(TimeStamp aRecordingStart);
~CompositionRecorder();
/**
* Record a composited frame.
*/
void RecordFrame(RecordedFrame* aFrame);
/**
* Write out the collected frames as a series of timestamped images.
*/
void WriteCollectedFrames();
protected:
~CompositionRecorder();
private:
nsTArray<RefPtr<RecordedFrame>> mCollectedFrames;
TimeStamp mRecordingStart;
@ -57,4 +76,4 @@ class CompositionRecorder final {
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_ProfilerScreenshots_h
#endif // mozilla_layers_CompositionRecorder_h

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

@ -19,6 +19,7 @@
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/gfx/Rect.h" // for Rect
#include "mozilla/gfx/Types.h" // for SurfaceFormat
#include "mozilla/layers/CompositionRecorder.h"
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/Effects.h" // for EffectChain
#include "mozilla/layers/LayersMessages.h"
@ -53,7 +54,6 @@ namespace layers {
class CanvasLayerComposite;
class ColorLayerComposite;
class Compositor;
class CompositionRecorder;
class ContainerLayerComposite;
class Diagnostics;
struct EffectChain;
@ -199,7 +199,7 @@ class HostLayerManager : public LayerManager {
mCompositorBridgeID = aID;
}
void SetCompositionRecorder(CompositionRecorder* aRecorder) {
void SetCompositionRecorder(already_AddRefed<CompositionRecorder> aRecorder) {
mCompositionRecorder = aRecorder;
}
@ -216,7 +216,7 @@ class HostLayerManager : public LayerManager {
bool mWindowOverlayChanged;
TimeDuration mLastPaintTime;
TimeStamp mRenderStartTime;
CompositionRecorder* mCompositionRecorder = nullptr;
RefPtr<CompositionRecorder> mCompositionRecorder = nullptr;
// Render time for the current composition.
TimeStamp mCompositionTime;

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

@ -2609,10 +2609,10 @@ int32_t RecordContentFrameTime(
mozilla::ipc::IPCResult CompositorBridgeParent::RecvBeginRecording(
const TimeStamp& aRecordingStart) {
mCompositionRecorder.reset(new CompositionRecorder(aRecordingStart));
mCompositionRecorder = new CompositionRecorder(aRecordingStart);
if (mLayerManager) {
mLayerManager->SetCompositionRecorder(mCompositionRecorder.get());
mLayerManager->SetCompositionRecorder(do_AddRef(mCompositionRecorder));
}
return IPC_OK();
@ -2623,7 +2623,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvEndRecording() {
mLayerManager->SetCompositionRecorder(nullptr);
}
mCompositionRecorder->WriteCollectedFrames();
mCompositionRecorder.reset(nullptr);
mCompositionRecorder = nullptr;
return IPC_OK();
}

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

@ -27,6 +27,7 @@
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/SharedMemory.h"
#include "mozilla/layers/CompositionRecorder.h"
#include "mozilla/layers/CompositorController.h"
#include "mozilla/layers/CompositorOptions.h"
#include "mozilla/layers/CompositorVsyncSchedulerOwner.h"
@ -72,7 +73,6 @@ class APZSampler;
class APZUpdater;
class AsyncCompositionManager;
class AsyncImagePipelineManager;
class CompositionRecorder;
class Compositor;
class CompositorAnimationStorage;
class CompositorBridgeParent;
@ -767,7 +767,7 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
// mSelfRef is cleared in DeferredDestroy which is scheduled by ActorDestroy.
RefPtr<CompositorBridgeParent> mSelfRef;
RefPtr<CompositorAnimationStorage> mAnimationStorage;
UniquePtr<CompositionRecorder> mCompositionRecorder;
RefPtr<CompositionRecorder> mCompositionRecorder;
TimeDuration mPaintTime;