1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_layers_RendererScreenshotGrabber_h
6 #define mozilla_layers_RendererScreenshotGrabber_h
8 #include "mozilla/TimeStamp.h"
9 #include "mozilla/UniquePtr.h"
10 #include "mozilla/gfx/Point.h"
11 #include "mozilla/layers/ProfilerScreenshots.h"
18 * Used by |RendererOGL| to grab screenshots from WebRender and submit them to
21 * If the profiler is not running or the screenshots feature is disabled, no
24 class RendererScreenshotGrabber final
{
26 RendererScreenshotGrabber();
29 * Grab a screenshot from WebRender if we are profiling and screenshots are
32 * The captured screenshot will not be mapped until the second call to
33 * |MaybeProcessQueue| after this call to |MaybeGrabScreenshot|.
35 void MaybeGrabScreenshot(Renderer
* aRenderer
,
36 const gfx::IntSize
& aWindowSize
);
39 * Process the screenshots pending in the queue if we are profiling and
40 * screenshots are enabled.
42 void MaybeProcessQueue(Renderer
* aRenderer
);
46 * Drop all our allocated memory when we are no longer profiling.
48 * This will also instruct WebRender to drop all its Gecko profiler
51 void Destroy(Renderer
* aRenderer
);
54 * Actually grab a screenshot from WebRender.
56 void GrabScreenshot(Renderer
* aRenderer
, const gfx::IntSize
& aWindowSize
);
59 * Process the screenshots pending in the queue.
61 void ProcessQueue(Renderer
* aRenderer
);
64 mozilla::TimeStamp mTimeStamp
;
65 AsyncScreenshotHandle mHandle
;
66 gfx::IntSize mScreenshotSize
;
67 gfx::IntSize mWindowSize
;
68 uintptr_t mWindowIdentifier
;
72 * The maximum size for screenshots, as dictated by
73 * |ProfilerScrenshots::ScreenshotSize|.
75 gfx::IntSize mMaxScreenshotSize
;
78 * The queue of screenshots waiting to be processed and submitted.
80 nsTArray
<QueueItem
> mQueue
;
83 * The queue item for the current frame. This will be inserted into the queue
84 * after a call to |MaybeProcessQueue| so it will be not be processed until
87 Maybe
<QueueItem
> mCurrentFrameQueueItem
;
90 * Our handle to the profiler screenshots object.
92 RefPtr
<mozilla::layers::ProfilerScreenshots
> mProfilerScreenshots
;
96 } // namespace mozilla
98 #endif // mozilla_layers_RendererScreenshotGrabber_h