Bug 1557368 [wpt PR 16856] - Update error type test for attachInternals(), a=testonly
[gecko.git] / gfx / webrender_bindings / RendererScreenshotGrabber.h
blobbdc85a77dc81d053654926686955256907e22e79
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 "nsTArray.h"
14 namespace mozilla {
15 namespace wr {
17 /**
18 * Used by |RendererOGL| to grab screenshots from WebRender and submit them to
19 * the Gecko profiler.
21 * If the profiler is not running or the screenshots feature is disabled, no
22 * work will be done.
24 class RendererScreenshotGrabber final {
25 public:
26 RendererScreenshotGrabber();
28 /**
29 * Grab a screenshot from WebRender if we are profiling and screenshots are
30 * enabled.
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);
38 /**
39 * Process the screenshots pending in the queue if we are profiling and
40 * screenshots are enabled.
42 void MaybeProcessQueue(Renderer* aRenderer);
44 private:
45 /**
46 * Drop all our allocated memory when we are no longer profiling.
48 * This will also instruct WebRender to drop all its Gecko profiler
49 * associated memory.
51 void Destroy(Renderer* aRenderer);
53 /**
54 * Actually grab a screenshot from WebRender.
56 void GrabScreenshot(Renderer* aRenderer, const gfx::IntSize& aWindowSize);
58 /**
59 * Process the screenshots pending in the queue.
61 void ProcessQueue(Renderer* aRenderer);
63 struct QueueItem {
64 mozilla::TimeStamp mTimeStamp;
65 AsyncScreenshotHandle mHandle;
66 gfx::IntSize mScreenshotSize;
67 gfx::IntSize mWindowSize;
68 uintptr_t mWindowIdentifier;
71 /**
72 * The maximum size for screenshots, as dictated by
73 * |ProfilerScrenshots::ScreenshotSize|.
75 gfx::IntSize mMaxScreenshotSize;
77 /**
78 * The queue of screenshots waiting to be processed and submitted.
80 nsTArray<QueueItem> mQueue;
82 /**
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
85 * the next frame.
87 Maybe<QueueItem> mCurrentFrameQueueItem;
89 /**
90 * Our handle to the profiler screenshots object.
92 RefPtr<mozilla::layers::ProfilerScreenshots> mProfilerScreenshots;
95 } // namespace wr
96 } // namespace mozilla
98 #endif // mozilla_layers_RendererScreenshotGrabber_h