/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * The actual implementation of screenshot grabbing. * The ScreenshotGrabberImpl object is destroyed if the profiler is * disabled and MaybeGrabScreenshot notices it.
*/ class ScreenshotGrabberImpl final { public: explicit ScreenshotGrabberImpl(const IntSize& aBufferSize);
~ScreenshotGrabberImpl();
ScreenshotGrabberImpl::~ScreenshotGrabberImpl() { // Any queue items in mQueue or mCurrentFrameQueueItem will be lost. // That's ok: Either the profiler has stopped and we don't care about these // screenshots, or the window is closing and we don't really need the last // few frames from the window.
}
// Scale down aWindowRenderSource into a RenderSource of size // mBufferSize * (1 << aLevel) and return that RenderSource. // Don't scale down by more than a factor of 2 with a single scaling operation, // because it'll look bad. If higher scales are needed, use another // intermediate target by calling this function recursively with aLevel + 1.
RefPtr<RenderSource> ScreenshotGrabberImpl::ScaleDownWindowRenderSourceToSize(
Window& aWindow, const IntSize& aDestSize,
RenderSource* aWindowRenderSource, size_t aLevel) { if (aLevel == mCachedLevels.Length()) {
mCachedLevels.AppendElement(
aWindow.CreateDownscaleTarget(mBufferSize * (1 << aLevel)));
}
MOZ_RELEASE_ASSERT(aLevel < mCachedLevels.Length());
if (!scaledTarget) {
PROFILER_MARKER_UNTYPED( "NoCompositorScreenshot because ScaleDownWindowRenderSourceToSize " "failed",
GRAPHICS); return;
}
RefPtr<AsyncReadbackBuffer> buffer = TakeNextBuffer(aWindow); if (!buffer) {
PROFILER_MARKER_UNTYPED( "NoCompositorScreenshot because AsyncReadbackBuffer creation failed",
GRAPHICS); return;
}
buffer->CopyFrom(scaledTarget);
// This QueueItem will be added to the queue at the end of the next call to // ProcessQueue(). This ensures that the buffer isn't mapped into main memory // until the next frame. If we did it in this frame, we'd block on the GPU.
mCurrentFrameQueueItem =
Some(QueueItem{TimeStamp::Now(), std::move(buffer), scaledSize,
windowRenderSource->Size()});
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.