Bug 1830741 - Add tests for mach try perf comparators. r=perftest-reviewers,Alexandru...
[gecko.git] / gfx / layers / CompositionRecorder.h
blob5f5ec34b48f763b667f51baf958c3e883a82e962
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"
14 #include "nsTArray.h"
15 #include "nsString.h"
17 namespace mozilla {
19 namespace gfx {
20 class DataSourceSurface;
23 namespace layers {
25 /**
26 * A captured frame from a |LayerManager|.
28 class RecordedFrame {
29 public:
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; }
37 protected:
38 virtual ~RecordedFrame() = default;
39 RecordedFrame(const TimeStamp& aTimeStamp) : mTimeStamp(aTimeStamp) {}
41 private:
42 TimeStamp mTimeStamp;
45 /**
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 {
55 public:
56 explicit CompositionRecorder(TimeStamp aRecordingStart);
58 /**
59 * Record a composited frame.
61 void RecordFrame(RecordedFrame* aFrame);
63 /**
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();
70 private:
71 nsTArray<RefPtr<RecordedFrame>> mRecordedFrames;
72 TimeStamp mRecordingStart;
75 } // namespace layers
76 } // namespace mozilla
78 #endif // mozilla_layers_CompositionRecorder_h