1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_layers_CompositionRecorder_h
8 #define mozilla_layers_CompositionRecorder_h
10 #include "mozilla/RefPtr.h"
11 #include "mozilla/TimeStamp.h"
12 #include "mozilla/layers/PCompositorBridgeTypes.h"
13 #include "nsISupportsImpl.h"
20 class DataSourceSurface
;
26 * A captured frame from a |LayerManager|.
30 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RecordedFrame
)
32 // The resulting DataSourceSurface must not be kept alive beyond the lifetime
33 // of the RecordedFrame object, since it may refer to data owned by the frame.
34 virtual already_AddRefed
<gfx::DataSourceSurface
> GetSourceSurface() = 0;
35 TimeStamp
GetTimeStamp() { return mTimeStamp
; }
38 virtual ~RecordedFrame() = default;
39 RecordedFrame(const TimeStamp
& aTimeStamp
) : mTimeStamp(aTimeStamp
) {}
46 * A recorder for composited frames.
48 * This object collects frames sent to it by a |LayerManager| and writes them
49 * out as a series of images until recording has finished.
51 * If GPU-accelerated rendering is used, the frames will not be mapped into
52 * memory until |WriteCollectedFrames| is called.
54 class CompositionRecorder
{
56 explicit CompositionRecorder(TimeStamp aRecordingStart
);
59 * Record a composited frame.
61 void RecordFrame(RecordedFrame
* aFrame
);
64 * Get the array of frames that were recorded since the last call to
65 * GetRecording(), where each frame consists of a presentation time and
66 * the PNG-encoded contents as an array of bytes
68 Maybe
<FrameRecording
> GetRecording();
71 nsTArray
<RefPtr
<RecordedFrame
>> mRecordedFrames
;
72 TimeStamp mRecordingStart
;
76 } // namespace mozilla
78 #endif // mozilla_layers_CompositionRecorder_h