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"
12 #include "mozilla/webrender/webrender_ffi.h"
22 * Used by |RendererOGL| to grab screenshots from WebRender and submit them to
25 * If the profiler is not running or the screenshots feature is disabled, no
28 class RendererScreenshotGrabber final
{
30 RendererScreenshotGrabber();
33 * Grab a screenshot from WebRender if we are profiling and screenshots are
36 * The captured screenshot will not be mapped until the second call to
37 * |MaybeProcessQueue| after this call to |MaybeGrabScreenshot|.
39 void MaybeGrabScreenshot(RendererOGL
* aRendererOGL
,
40 const gfx::IntSize
& aWindowSize
);
43 * Process the screenshots pending in the queue if we are profiling and
44 * screenshots are enabled.
46 void MaybeProcessQueue(RendererOGL
* aRenderer
);
50 * Drop all our allocated memory when we are no longer profiling.
52 * This will also instruct WebRender to drop all its Gecko profiler
55 void Destroy(Renderer
* aRenderer
);
58 * Actually grab a screenshot from WebRender.
60 void GrabScreenshot(Renderer
* aRenderer
, const gfx::IntSize
& aWindowSize
);
63 * Process the screenshots pending in the queue.
65 void ProcessQueue(Renderer
* aRenderer
);
68 mozilla::TimeStamp mTimeStamp
;
69 AsyncScreenshotHandle mHandle
;
70 gfx::IntSize mScreenshotSize
;
71 gfx::IntSize mWindowSize
;
72 uintptr_t mWindowIdentifier
;
76 * The maximum size for screenshots, as dictated by
77 * |ProfilerScrenshots::ScreenshotSize|.
79 gfx::IntSize mMaxScreenshotSize
;
82 * The queue of screenshots waiting to be processed and submitted.
84 nsTArray
<QueueItem
> mQueue
;
87 * The queue item for the current frame. This will be inserted into the queue
88 * after a call to |MaybeProcessQueue| so it will be not be processed until
91 Maybe
<QueueItem
> mCurrentFrameQueueItem
;
94 * Our handle to the profiler screenshots object.
96 RefPtr
<mozilla::layers::ProfilerScreenshots
> mProfilerScreenshots
;
100 } // namespace mozilla
102 #endif // mozilla_layers_RendererScreenshotGrabber_h