Bug 1842773 - Part 11: Make DataView byteOffset and byteLength accessors aware of...
[gecko.git] / gfx / webrender_bindings / RendererScreenshotGrabber.h
blob81f11a392d9dde84624d775128dba1809de15782
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"
13 #include "nsTArray.h"
15 namespace mozilla {
16 namespace wr {
18 struct Renderer;
19 class RendererOGL;
21 /**
22 * Used by |RendererOGL| to grab screenshots from WebRender and submit them to
23 * the Gecko profiler.
25 * If the profiler is not running or the screenshots feature is disabled, no
26 * work will be done.
28 class RendererScreenshotGrabber final {
29 public:
30 RendererScreenshotGrabber();
32 /**
33 * Grab a screenshot from WebRender if we are profiling and screenshots are
34 * enabled.
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);
42 /**
43 * Process the screenshots pending in the queue if we are profiling and
44 * screenshots are enabled.
46 void MaybeProcessQueue(RendererOGL* aRenderer);
48 private:
49 /**
50 * Drop all our allocated memory when we are no longer profiling.
52 * This will also instruct WebRender to drop all its Gecko profiler
53 * associated memory.
55 void Destroy(Renderer* aRenderer);
57 /**
58 * Actually grab a screenshot from WebRender.
60 void GrabScreenshot(Renderer* aRenderer, const gfx::IntSize& aWindowSize);
62 /**
63 * Process the screenshots pending in the queue.
65 void ProcessQueue(Renderer* aRenderer);
67 struct QueueItem {
68 mozilla::TimeStamp mTimeStamp;
69 AsyncScreenshotHandle mHandle;
70 gfx::IntSize mScreenshotSize;
71 gfx::IntSize mWindowSize;
74 /**
75 * The maximum size for screenshots, as dictated by
76 * |ProfilerScrenshots::ScreenshotSize|.
78 gfx::IntSize mMaxScreenshotSize;
80 /**
81 * The queue of screenshots waiting to be processed and submitted.
83 nsTArray<QueueItem> mQueue;
85 /**
86 * The queue item for the current frame. This will be inserted into the queue
87 * after a call to |MaybeProcessQueue| so it will be not be processed until
88 * the next frame.
90 Maybe<QueueItem> mCurrentFrameQueueItem;
92 /**
93 * Our handle to the profiler screenshots object.
95 RefPtr<mozilla::layers::ProfilerScreenshots> mProfilerScreenshots;
98 } // namespace wr
99 } // namespace mozilla
101 #endif // mozilla_layers_RendererScreenshotGrabber_h