Backed out 4 changesets (bug 1658856, bug 1592031) for bustages on ScreenshotGrabber.h . CLOSED TREE

Backed out changeset 6d54a1050bbd (bug 1658856)
Backed out changeset 19145f742503 (bug 1592031)
Backed out changeset 5db68a6a5bc2 (bug 1592031)
Backed out changeset 925e3b179b9b (bug 1592031)
This commit is contained in:
Narcis Beleuzu 2020-08-22 02:06:39 +03:00
parent 418d5452f5
commit c259d84931
13 changed files with 165 additions and 594 deletions

View File

@ -30,7 +30,6 @@ namespace layers {
class NativeLayer;
class NativeLayerCA;
class NativeLayerRootSnapshotter;
class ScreenshotGrabber;
class SurfacePoolHandle;
// NativeLayerRoot and NativeLayer allow building up a flat layer "tree" of
@ -92,12 +91,6 @@ class NativeLayerRootSnapshotter {
virtual bool ReadbackPixels(const gfx::IntSize& aReadbackSize,
gfx::SurfaceFormat aReadbackFormat,
const Range<uint8_t>& aReadbackBuffer) = 0;
// Calls aScreenshotGrabber->MaybeGrabScreenshot(), to allow capturing the
// composited result as profiler screenshots.
virtual void MaybeGrabProfilerScreenshot(
ScreenshotGrabber* aScreenshotGrabber,
const gfx::IntSize& aWindowSize) = 0;
};
// Represents a native layer. Native layers, such as CoreAnimation layers on

View File

@ -150,8 +150,6 @@ class NativeLayerRootCA : public NativeLayerRoot {
bool mCommitPending = false;
};
class RenderSourceNLRS;
class NativeLayerRootSnapshotterCA final : public NativeLayerRootSnapshotter {
public:
static UniquePtr<NativeLayerRootSnapshotterCA> Create(
@ -161,20 +159,16 @@ class NativeLayerRootSnapshotterCA final : public NativeLayerRootSnapshotter {
bool ReadbackPixels(const gfx::IntSize& aReadbackSize,
gfx::SurfaceFormat aReadbackFormat,
const Range<uint8_t>& aReadbackBuffer) override;
void MaybeGrabProfilerScreenshot(ScreenshotGrabber* aScreenshotGrabber,
const gfx::IntSize& aWindowSize) override;
protected:
NativeLayerRootSnapshotterCA(NativeLayerRootCA* aLayerRoot,
RefPtr<gl::GLContext>&& aGL,
CALayer* aRootCALayer);
void UpdateSnapshot(const gfx::IntSize& aSize);
RefPtr<NativeLayerRootCA> mLayerRoot;
RefPtr<gl::GLContext> mGL;
// Can be null. Created and updated in UpdateSnapshot.
RefPtr<RenderSourceNLRS> mSnapshot;
UniquePtr<gl::MozFramebuffer>
mFB; // can be null, recreated when aReadbackSize changes
CARenderer* mRenderer = nullptr; // strong
};

View File

@ -18,8 +18,6 @@
#include "GLContextCGL.h"
#include "GLContextProvider.h"
#include "MozFramebuffer.h"
#include "mozilla/gfx/Swizzle.h"
#include "mozilla/layers/ScreenshotGrabber.h"
#include "mozilla/layers/SurfacePoolCA.h"
#include "mozilla/webrender/RenderMacIOSurfaceTextureHostOGL.h"
#include "ScopedGLHelpers.h"
@ -35,68 +33,11 @@ using gfx::IntPoint;
using gfx::IntSize;
using gfx::IntRect;
using gfx::IntRegion;
using gfx::DataSourceSurface;
using gfx::Matrix4x4;
using gfx::SurfaceFormat;
using gl::GLContext;
using gl::GLContextCGL;
// Utility classes for NativeLayerRootSnapshotter (NLRS) profiler screenshots.
class WindowNLRS : public profiler_screenshots::Window {
public:
WindowNLRS(gl::GLContext* aGL, RenderSourceNLRS* aSnapshot) : mGL(aGL), mSnapshot(aSnapshot) {}
already_AddRefed<profiler_screenshots::RenderSource> GetWindowContents() override;
already_AddRefed<profiler_screenshots::DownscaleTarget> CreateDownscaleTarget(
const IntSize& aSize) override;
already_AddRefed<profiler_screenshots::AsyncReadbackBuffer> CreateAsyncReadbackBuffer(
const IntSize& aSize) override;
protected:
RefPtr<gl::GLContext> mGL;
RefPtr<RenderSourceNLRS> mSnapshot;
};
class RenderSourceNLRS : public profiler_screenshots::RenderSource {
public:
explicit RenderSourceNLRS(UniquePtr<gl::MozFramebuffer>&& aFramebuffer)
: RenderSource(aFramebuffer->mSize), mFramebuffer(std::move(aFramebuffer)) {}
auto& FB() { return *mFramebuffer; }
protected:
UniquePtr<gl::MozFramebuffer> mFramebuffer;
};
class DownscaleTargetNLRS : public profiler_screenshots::DownscaleTarget {
public:
DownscaleTargetNLRS(gl::GLContext* aGL, UniquePtr<gl::MozFramebuffer>&& aFramebuffer)
: profiler_screenshots::DownscaleTarget(aFramebuffer->mSize),
mGL(aGL),
mRenderSource(new RenderSourceNLRS(std::move(aFramebuffer))) {}
already_AddRefed<profiler_screenshots::RenderSource> AsRenderSource() override {
return do_AddRef(mRenderSource);
};
bool DownscaleFrom(profiler_screenshots::RenderSource* aSource, const IntRect& aSourceRect,
const IntRect& aDestRect) override;
protected:
RefPtr<gl::GLContext> mGL;
RefPtr<RenderSourceNLRS> mRenderSource;
};
class AsyncReadbackBufferNLRS : public profiler_screenshots::AsyncReadbackBuffer {
public:
AsyncReadbackBufferNLRS(gl::GLContext* aGL, const IntSize& aSize, GLuint aBufferHandle)
: profiler_screenshots::AsyncReadbackBuffer(aSize), mGL(aGL), mBufferHandle(aBufferHandle) {}
void CopyFrom(profiler_screenshots::RenderSource* aSource) override;
bool MapAndCopyInto(DataSourceSurface* aSurface, const IntSize& aReadSize) override;
protected:
virtual ~AsyncReadbackBufferNLRS();
RefPtr<gl::GLContext> mGL;
GLuint mBufferHandle = 0;
};
// Needs to be on the stack whenever CALayer mutations are performed.
// (Mutating CALayers outside of a transaction can result in permanently stuck rendering, because
// such mutations create an implicit transaction which never auto-commits if the current thread does
@ -355,8 +296,14 @@ NativeLayerRootSnapshotterCA::~NativeLayerRootSnapshotterCA() {
[mRenderer release];
}
void NativeLayerRootSnapshotterCA::UpdateSnapshot(const IntSize& aSize) {
CGRect bounds = CGRectMake(0, 0, aSize.width, aSize.height);
bool NativeLayerRootSnapshotterCA::ReadbackPixels(const IntSize& aReadbackSize,
SurfaceFormat aReadbackFormat,
const Range<uint8_t>& aReadbackBuffer) {
if (aReadbackFormat != SurfaceFormat::B8G8R8A8) {
return false;
}
CGRect bounds = CGRectMake(0, 0, aReadbackSize.width, aReadbackSize.height);
{
// Set the correct bounds and scale on the renderer and its root layer. CARenderer always
@ -376,25 +323,23 @@ void NativeLayerRootSnapshotterCA::UpdateSnapshot(const IntSize& aSize) {
mGL->MakeCurrent();
bool needToRedrawEverything = false;
if (!mSnapshot || mSnapshot->Size() != aSize) {
mSnapshot = nullptr;
auto fb = gl::MozFramebuffer::Create(mGL, aSize, 0, false);
if (!fb) {
return;
if (!mFB || mFB->mSize != aReadbackSize) {
mFB = gl::MozFramebuffer::Create(mGL, aReadbackSize, 0, false);
if (!mFB) {
return false;
}
mSnapshot = new RenderSourceNLRS(std::move(fb));
needToRedrawEverything = true;
}
const gl::ScopedBindFramebuffer bindFB(mGL, mSnapshot->FB().mFB);
mGL->fViewport(0.0, 0.0, aSize.width, aSize.height);
const gl::ScopedBindFramebuffer bindFB(mGL, mFB->mFB);
mGL->fViewport(0.0, 0.0, aReadbackSize.width, aReadbackSize.height);
// These legacy OpenGL function calls are part of CARenderer's API contract, see CARenderer.h.
// The size passed to glOrtho must be the device pixel size of the render target, otherwise
// CARenderer will produce incorrect results.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, aSize.width, 0.0, aSize.height, -1, 1);
glOrtho(0.0, aReadbackSize.width, 0.0, aReadbackSize.height, -1, 1);
float mediaTime = CACurrentMediaTime();
[mRenderer beginFrameAtTime:mediaTime timeStamp:nullptr];
@ -421,21 +366,7 @@ void NativeLayerRootSnapshotterCA::UpdateSnapshot(const IntSize& aSize) {
}
[mRenderer render];
[mRenderer endFrame];
}
bool NativeLayerRootSnapshotterCA::ReadbackPixels(const IntSize& aReadbackSize,
SurfaceFormat aReadbackFormat,
const Range<uint8_t>& aReadbackBuffer) {
if (aReadbackFormat != SurfaceFormat::B8G8R8A8) {
return false;
}
UpdateSnapshot(aReadbackSize);
if (!mSnapshot) {
return false;
}
const gl::ScopedBindFramebuffer bindFB(mGL, mSnapshot->FB().mFB);
gl::ScopedPackState safePackState(mGL);
mGL->fReadPixels(0.0f, 0.0f, aReadbackSize.width, aReadbackSize.height, LOCAL_GL_BGRA,
LOCAL_GL_UNSIGNED_BYTE, &aReadbackBuffer[0]);
@ -443,14 +374,6 @@ bool NativeLayerRootSnapshotterCA::ReadbackPixels(const IntSize& aReadbackSize,
return true;
}
void NativeLayerRootSnapshotterCA::MaybeGrabProfilerScreenshot(
ScreenshotGrabber* aScreenshotGrabber, const gfx::IntSize& aWindowSize) {
UpdateSnapshot(aWindowSize);
WindowNLRS window(mGL, mSnapshot);
aScreenshotGrabber->MaybeGrabScreenshot(window);
}
NativeLayerCA::NativeLayerCA(const IntSize& aSize, bool aIsOpaque,
SurfacePoolHandleCA* aSurfacePoolHandle)
: mMutex("NativeLayerCA"),
@ -996,103 +919,5 @@ Maybe<NativeLayerCA::SurfaceWithInvalidRegion> NativeLayerCA::GetUnusedSurfaceAn
return unusedSurface;
}
already_AddRefed<profiler_screenshots::RenderSource> WindowNLRS::GetWindowContents() {
return do_AddRef(mSnapshot);
}
already_AddRefed<profiler_screenshots::DownscaleTarget> WindowNLRS::CreateDownscaleTarget(
const IntSize& aSize) {
auto fb = gl::MozFramebuffer::Create(mGL, aSize, 0, false);
if (!fb) {
return nullptr;
}
RefPtr<profiler_screenshots::DownscaleTarget> dt = new DownscaleTargetNLRS(mGL, std::move(fb));
return dt.forget();
}
already_AddRefed<profiler_screenshots::AsyncReadbackBuffer> WindowNLRS::CreateAsyncReadbackBuffer(
const IntSize& aSize) {
size_t bufferByteCount = aSize.width * aSize.height * 4;
GLuint bufferHandle = 0;
mGL->fGenBuffers(1, &bufferHandle);
gl::ScopedPackState scopedPackState(mGL);
mGL->fBindBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, bufferHandle);
mGL->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 1);
mGL->fBufferData(LOCAL_GL_PIXEL_PACK_BUFFER, bufferByteCount, nullptr, LOCAL_GL_STREAM_READ);
return MakeAndAddRef<AsyncReadbackBufferNLRS>(mGL, aSize, bufferHandle);
}
bool DownscaleTargetNLRS::DownscaleFrom(profiler_screenshots::RenderSource* aSource,
const IntRect& aSourceRect, const IntRect& aDestRect) {
mGL->BlitHelper()->BlitFramebufferToFramebuffer(static_cast<RenderSourceNLRS*>(aSource)->FB().mFB,
mRenderSource->FB().mFB, aSourceRect, aDestRect,
LOCAL_GL_LINEAR);
return true;
}
void AsyncReadbackBufferNLRS::CopyFrom(profiler_screenshots::RenderSource* aSource) {
IntSize size = aSource->Size();
MOZ_RELEASE_ASSERT(Size() == size);
gl::ScopedPackState scopedPackState(mGL);
mGL->fBindBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, mBufferHandle);
mGL->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 1);
const gl::ScopedBindFramebuffer bindFB(mGL, static_cast<RenderSourceNLRS*>(aSource)->FB().mFB);
mGL->fReadPixels(0, 0, size.width, size.height, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, 0);
}
bool AsyncReadbackBufferNLRS::MapAndCopyInto(DataSourceSurface* aSurface,
const IntSize& aReadSize) {
MOZ_RELEASE_ASSERT(aReadSize <= aSurface->GetSize());
if (!mGL || !mGL->MakeCurrent()) {
return false;
}
gl::ScopedPackState scopedPackState(mGL);
mGL->fBindBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, mBufferHandle);
mGL->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 1);
const uint8_t* srcData = nullptr;
if (mGL->IsSupported(gl::GLFeature::map_buffer_range)) {
srcData = static_cast<uint8_t*>(mGL->fMapBufferRange(LOCAL_GL_PIXEL_PACK_BUFFER, 0,
aReadSize.height * aReadSize.width * 4,
LOCAL_GL_MAP_READ_BIT));
} else {
srcData =
static_cast<uint8_t*>(mGL->fMapBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, LOCAL_GL_READ_ONLY));
}
if (!srcData) {
return false;
}
int32_t srcStride = mSize.width * 4; // Bind() sets an alignment of 1
DataSourceSurface::ScopedMap map(aSurface, DataSourceSurface::WRITE);
uint8_t* destData = map.GetData();
int32_t destStride = map.GetStride();
SurfaceFormat destFormat = aSurface->GetFormat();
for (int32_t destRow = 0; destRow < aReadSize.height; destRow++) {
// Turn srcData upside down during the copy.
int32_t srcRow = aReadSize.height - 1 - destRow;
const uint8_t* src = &srcData[srcRow * srcStride];
uint8_t* dest = &destData[destRow * destStride];
SwizzleData(src, srcStride, SurfaceFormat::R8G8B8A8, dest, destStride, destFormat,
IntSize(aReadSize.width, 1));
}
mGL->fUnmapBuffer(LOCAL_GL_PIXEL_PACK_BUFFER);
return true;
}
AsyncReadbackBufferNLRS::~AsyncReadbackBufferNLRS() {
if (mGL && mGL->MakeCurrent()) {
mGL->fDeleteBuffers(1, &mBufferHandle);
}
}
} // namespace layers
} // namespace mozilla

View File

@ -1,132 +0,0 @@
/* -*- 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/. */
#ifndef mozilla_layers_ScreenshotGrabber_h
#define mozilla_layers_ScreenshotGrabber_h
#include "mozilla/UniquePtr.h"
namespace mozilla {
namespace layers {
namespace profiler_screenshots {
class Window;
class RenderSource;
class DownscaleTarget;
class AsyncReadbackBuffer;
class ScreenshotGrabberImpl;
} // namespace profiler_screenshots
/**
* Used by various renderers / layer managers to grab snapshots from the window
* and submit them to the Gecko profiler.
* Doesn't do any work if the profiler is not running or the "screenshots"
* feature is not enabled.
* Screenshots are scaled down to fit within a fixed size, and read back to
* main memory using async readback. Scaling is done in multiple scale-by-0.5x
* steps using DownscaleTarget::CopyFrom, and readback is done using
* AsyncReadbackBuffers.
*/
class ScreenshotGrabber final {
public:
ScreenshotGrabber();
~ScreenshotGrabber();
// Scale the contents of aWindow's current render target into an
// appropriately sized DownscaleTarget and read its contents into an
// AsyncReadbackBuffer. The AsyncReadbackBuffer is not mapped into main
// memory until the second call to MaybeProcessQueue() after this call to
// MaybeGrabScreenshot().
void MaybeGrabScreenshot(profiler_screenshots::Window& aWindow);
// Map the contents of any outstanding AsyncReadbackBuffers from previous
// composites into main memory and submit each screenshot to the profiler.
void MaybeProcessQueue();
// Insert a special profiler marker for a composite that didn't do any actual
// compositing, so that the profiler knows why no screenshot was taken for
// this frame.
void NotifyEmptyFrame();
// Destroy all Window-related resources that this class is holding on to.
void Destroy();
private:
// non-null while ProfilerScreenshots::IsEnabled() returns true
UniquePtr<profiler_screenshots::ScreenshotGrabberImpl> mImpl;
};
// Interface definitions.
namespace profiler_screenshots {
class Window {
public:
virtual already_AddRefed<RenderSource> GetWindowContents() = 0;
virtual already_AddRefed<DownscaleTarget> CreateDownscaleTarget(
const gfx::IntSize& aSize) = 0;
virtual already_AddRefed<AsyncReadbackBuffer> CreateAsyncReadbackBuffer(
const gfx::IntSize& aSize) = 0;
protected:
virtual ~Window() {}
};
class RenderSource {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RenderSource)
const auto& Size() const { return mSize; }
protected:
explicit RenderSource(const gfx::IntSize& aSize) : mSize(aSize) {}
virtual ~RenderSource() {}
const gfx::IntSize mSize;
};
class DownscaleTarget {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DownscaleTarget)
virtual already_AddRefed<RenderSource> AsRenderSource() = 0;
const auto& Size() const { return mSize; }
virtual bool DownscaleFrom(RenderSource* aSource,
const gfx::IntRect& aSourceRect,
const gfx::IntRect& aDestRect) = 0;
protected:
explicit DownscaleTarget(const gfx::IntSize& aSize) : mSize(aSize) {}
virtual ~DownscaleTarget() {}
const gfx::IntSize mSize;
};
class AsyncReadbackBuffer {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(
mozilla::layers::profiler_screenshots::AsyncReadbackBuffer)
const auto& Size() const { return mSize; }
virtual void CopyFrom(RenderSource* aSource) = 0;
virtual bool MapAndCopyInto(gfx::DataSourceSurface* aSurface,
const gfx::IntSize& aReadSize) = 0;
protected:
explicit AsyncReadbackBuffer(const gfx::IntSize& aSize) : mSize(aSize) {}
virtual ~AsyncReadbackBuffer() {}
const gfx::IntSize mSize;
};
} // namespace profiler_screenshots
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_ScreenshotGrabber_h

View File

@ -4,7 +4,7 @@
* 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/. */
#include "ScreenshotGrabber.h"
#include "CompositorScreenshotGrabber.h"
#include "mozilla/RefPtr.h"
#include "mozilla/TimeStamp.h"
@ -21,38 +21,37 @@ namespace mozilla {
using namespace gfx;
namespace layers {
namespace profiler_screenshots {
/**
* The actual implementation of screenshot grabbing.
* The ScreenshotGrabberImpl object is destroyed if the profiler is
* The CompositorScreenshotGrabberImpl object is destroyed if the profiler is
* disabled and MaybeGrabScreenshot notices it.
*/
class ScreenshotGrabberImpl final {
class CompositorScreenshotGrabberImpl final {
public:
explicit ScreenshotGrabberImpl(const IntSize& aBufferSize);
~ScreenshotGrabberImpl();
explicit CompositorScreenshotGrabberImpl(const IntSize& aBufferSize);
~CompositorScreenshotGrabberImpl();
void GrabScreenshot(Window& aWindow);
void GrabScreenshot(Compositor* aCompositor);
void ProcessQueue();
private:
struct QueueItem final {
mozilla::TimeStamp mTimeStamp;
RefPtr<AsyncReadbackBuffer> mScreenshotBuffer;
IntSize mScreenshotSize;
IntSize mWindowSize;
gfx::IntSize mScreenshotSize;
gfx::IntSize mWindowSize;
uintptr_t mWindowIdentifier;
};
RefPtr<RenderSource> ScaleDownWindowRenderSourceToSize(
Window& aWindow, const IntSize& aDestSize,
RenderSource* aWindowRenderSource, size_t aLevel);
RefPtr<CompositingRenderTarget> ScaleDownWindowTargetToSize(
Compositor* aCompositor, const gfx::IntSize& aDestSize,
CompositingRenderTarget* aWindowTarget, size_t aLevel);
already_AddRefed<AsyncReadbackBuffer> TakeNextBuffer(Window& aWindow);
already_AddRefed<AsyncReadbackBuffer> TakeNextBuffer(Compositor* aCompositor);
void ReturnBuffer(AsyncReadbackBuffer* aBuffer);
nsTArray<RefPtr<DownscaleTarget>> mCachedLevels;
nsTArray<RefPtr<CompositingRenderTarget>> mTargets;
nsTArray<RefPtr<AsyncReadbackBuffer>> mAvailableBuffers;
Maybe<QueueItem> mCurrentFrameQueueItem;
nsTArray<QueueItem> mQueue;
@ -60,29 +59,26 @@ class ScreenshotGrabberImpl final {
const IntSize mBufferSize;
};
} // namespace profiler_screenshots
CompositorScreenshotGrabber::CompositorScreenshotGrabber() = default;
ScreenshotGrabber::ScreenshotGrabber() = default;
CompositorScreenshotGrabber::~CompositorScreenshotGrabber() = default;
ScreenshotGrabber::~ScreenshotGrabber() = default;
void ScreenshotGrabber::MaybeGrabScreenshot(
profiler_screenshots::Window& aWindow) {
void CompositorScreenshotGrabber::MaybeGrabScreenshot(Compositor* aCompositor) {
if (ProfilerScreenshots::IsEnabled()) {
if (!mImpl) {
mImpl = MakeUnique<profiler_screenshots::ScreenshotGrabberImpl>(
mImpl = MakeUnique<CompositorScreenshotGrabberImpl>(
ProfilerScreenshots::ScreenshotSize());
}
mImpl->GrabScreenshot(aWindow);
mImpl->GrabScreenshot(aCompositor);
} else if (mImpl) {
Destroy();
}
}
void ScreenshotGrabber::MaybeProcessQueue() {
void CompositorScreenshotGrabber::MaybeProcessQueue() {
if (ProfilerScreenshots::IsEnabled()) {
if (!mImpl) {
mImpl = MakeUnique<profiler_screenshots::ScreenshotGrabberImpl>(
mImpl = MakeUnique<CompositorScreenshotGrabberImpl>(
ProfilerScreenshots::ScreenshotSize());
}
mImpl->ProcessQueue();
@ -91,62 +87,66 @@ void ScreenshotGrabber::MaybeProcessQueue() {
}
}
void ScreenshotGrabber::NotifyEmptyFrame() {
void CompositorScreenshotGrabber::NotifyEmptyFrame() {
#ifdef MOZ_GECKO_PROFILER
PROFILER_ADD_MARKER("NoCompositorScreenshot because nothing changed",
GRAPHICS);
#endif
}
void ScreenshotGrabber::Destroy() { mImpl = nullptr; }
void CompositorScreenshotGrabber::Destroy() { mImpl = nullptr; }
namespace profiler_screenshots {
ScreenshotGrabberImpl::ScreenshotGrabberImpl(const IntSize& aBufferSize)
CompositorScreenshotGrabberImpl::CompositorScreenshotGrabberImpl(
const IntSize& aBufferSize)
: mBufferSize(aBufferSize) {}
ScreenshotGrabberImpl::~ScreenshotGrabberImpl() {
CompositorScreenshotGrabberImpl::~CompositorScreenshotGrabberImpl() {
// 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.
// Scale down aWindowTarget into a CompositingRenderTarget of size
// mBufferSize * (1 << aLevel) and return that CompositingRenderTarget.
// 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)));
RefPtr<CompositingRenderTarget>
CompositorScreenshotGrabberImpl::ScaleDownWindowTargetToSize(
Compositor* aCompositor, const IntSize& aDestSize,
CompositingRenderTarget* aWindowTarget, size_t aLevel) {
if (aLevel == mTargets.Length()) {
mTargets.AppendElement(aCompositor->CreateRenderTarget(
IntRect(IntPoint(), mBufferSize * (1 << aLevel)), INIT_MODE_NONE));
}
MOZ_RELEASE_ASSERT(aLevel < mCachedLevels.Length());
MOZ_RELEASE_ASSERT(aLevel < mTargets.Length());
RefPtr<RenderSource> renderSource = aWindowRenderSource;
IntSize sourceSize = aWindowRenderSource->Size();
if (sourceSize.width > aDestSize.width * 2) {
RefPtr<CompositingRenderTarget> sourceTarget = aWindowTarget;
IntSize sourceSize = aWindowTarget->GetSize();
if (aWindowTarget->GetSize().width > aDestSize.width * 2) {
sourceSize = aDestSize * 2;
renderSource = ScaleDownWindowRenderSourceToSize(
aWindow, sourceSize, aWindowRenderSource, aLevel + 1);
sourceTarget = ScaleDownWindowTargetToSize(aCompositor, sourceSize,
aWindowTarget, aLevel + 1);
}
if (renderSource) {
if (mCachedLevels[aLevel]->DownscaleFrom(
renderSource, IntRect({}, sourceSize), IntRect({}, aDestSize))) {
return mCachedLevels[aLevel]->AsRenderSource();
if (sourceTarget) {
aCompositor->SetRenderTarget(mTargets[aLevel]);
if (aCompositor->BlitRenderTarget(sourceTarget, sourceSize, aDestSize)) {
return mTargets[aLevel];
}
}
return nullptr;
}
void ScreenshotGrabberImpl::GrabScreenshot(Window& aWindow) {
RefPtr<RenderSource> windowRenderSource = aWindow.GetWindowContents();
void CompositorScreenshotGrabberImpl::GrabScreenshot(Compositor* aCompositor) {
RefPtr<CompositingRenderTarget> previousTarget =
aCompositor->GetCurrentRenderTarget();
if (!windowRenderSource) {
RefPtr<CompositingRenderTarget> windowTarget =
aCompositor->GetWindowRenderTarget();
if (!windowTarget) {
PROFILER_ADD_MARKER(
"NoCompositorScreenshot because of unsupported compositor "
"configuration",
@ -154,22 +154,24 @@ void ScreenshotGrabberImpl::GrabScreenshot(Window& aWindow) {
return;
}
Size windowSize(windowRenderSource->Size());
Size windowSize(windowTarget->GetSize());
float scale = std::min(mBufferSize.width / windowSize.width,
mBufferSize.height / windowSize.height);
IntSize scaledSize = IntSize::Round(windowSize * scale);
RefPtr<RenderSource> scaledTarget = ScaleDownWindowRenderSourceToSize(
aWindow, scaledSize, windowRenderSource, 0);
RefPtr<CompositingRenderTarget> scaledTarget =
ScaleDownWindowTargetToSize(aCompositor, scaledSize, windowTarget, 0);
// Restore the old render target.
aCompositor->SetRenderTarget(previousTarget);
if (!scaledTarget) {
PROFILER_ADD_MARKER(
"NoCompositorScreenshot because ScaleDownWindowRenderSourceToSize "
"failed",
"NoCompositorScreenshot because ScaleDownWindowTargetToSize failed",
GRAPHICS);
return;
}
RefPtr<AsyncReadbackBuffer> buffer = TakeNextBuffer(aWindow);
RefPtr<AsyncReadbackBuffer> buffer = TakeNextBuffer(aCompositor);
if (!buffer) {
PROFILER_ADD_MARKER(
"NoCompositorScreenshot because AsyncReadbackBuffer creation failed",
@ -177,32 +179,32 @@ void ScreenshotGrabberImpl::GrabScreenshot(Window& aWindow) {
return;
}
buffer->CopyFrom(scaledTarget);
aCompositor->ReadbackRenderTarget(scaledTarget, buffer);
// 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(),
reinterpret_cast<uintptr_t>(static_cast<void*>(this))});
mCurrentFrameQueueItem = Some(QueueItem{
TimeStamp::Now(), std::move(buffer), scaledSize, windowTarget->GetSize(),
reinterpret_cast<uintptr_t>(static_cast<void*>(this))});
}
already_AddRefed<AsyncReadbackBuffer> ScreenshotGrabberImpl::TakeNextBuffer(
Window& aWindow) {
already_AddRefed<AsyncReadbackBuffer>
CompositorScreenshotGrabberImpl::TakeNextBuffer(Compositor* aCompositor) {
if (!mAvailableBuffers.IsEmpty()) {
RefPtr<AsyncReadbackBuffer> buffer = mAvailableBuffers[0];
mAvailableBuffers.RemoveElementAt(0);
return buffer.forget();
}
return aWindow.CreateAsyncReadbackBuffer(mBufferSize);
return aCompositor->CreateAsyncReadbackBuffer(mBufferSize);
}
void ScreenshotGrabberImpl::ReturnBuffer(AsyncReadbackBuffer* aBuffer) {
void CompositorScreenshotGrabberImpl::ReturnBuffer(
AsyncReadbackBuffer* aBuffer) {
mAvailableBuffers.AppendElement(aBuffer);
}
void ScreenshotGrabberImpl::ProcessQueue() {
void CompositorScreenshotGrabberImpl::ProcessQueue() {
if (!mQueue.IsEmpty()) {
if (!mProfilerScreenshots) {
mProfilerScreenshots = new ProfilerScreenshots();
@ -225,6 +227,5 @@ void ScreenshotGrabberImpl::ProcessQueue() {
}
}
} // namespace profiler_screenshots
} // namespace layers
} // namespace mozilla

View File

@ -0,0 +1,60 @@
/* -*- 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/. */
#ifndef mozilla_layers_CompositorScreenshotGrabber_h
#define mozilla_layers_CompositorScreenshotGrabber_h
#include "mozilla/UniquePtr.h"
namespace mozilla {
namespace layers {
class Compositor;
class CompositorScreenshotGrabberImpl;
/**
* Used by LayerManagerComposite to grab snapshots from the compositor and
* submit them to the Gecko profiler.
* Doesn't do any work if the profiler is not running or the "screenshots"
* feature is not enabled.
* Screenshots are scaled down to fit within a fixed size, and read back to
* main memory using async readback. Scaling is done in multiple scale-by-0.5x
* steps using CompositingRenderTargets and Compositor::BlitFromRenderTarget,
* and readback is done using AsyncReadbackBuffers.
*/
class CompositorScreenshotGrabber final {
public:
CompositorScreenshotGrabber();
~CompositorScreenshotGrabber();
// Scale the contents of aCompositor's current render target into an
// approapriately sized CompositingRenderTarget and read its contents into an
// AsyncReadbackBuffer. The AsyncReadbackBuffer is not mapped into main
// memory until the second call to MaybeProcessQueue() after this call to
// MaybeGrabScreenshot().
void MaybeGrabScreenshot(Compositor* aCompositor);
// Map the contents of any outstanding AsyncReadbackBuffers from previous
// composites into main memory and submit each screenshot to the profiler.
void MaybeProcessQueue();
// Insert a special profiler marker for a composite that didn't do any actual
// compositing, so that the profiler knows why no screenshot was taken for
// this frame.
void NotifyEmptyFrame();
// Destroy all Compositor-related resources that this class is holding on to.
void Destroy();
private:
// non-null while ProfilerScreenshots::IsEnabled() returns true
UniquePtr<CompositorScreenshotGrabberImpl> mImpl;
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_CompositorScreenshotGrabber_h

View File

@ -89,21 +89,6 @@ class ImageLayer;
using namespace mozilla::gfx;
using namespace mozilla::gl;
class WindowLMC : public profiler_screenshots::Window {
public:
explicit WindowLMC(Compositor* aCompositor) : mCompositor(aCompositor) {}
already_AddRefed<profiler_screenshots::RenderSource> GetWindowContents()
override;
already_AddRefed<profiler_screenshots::DownscaleTarget> CreateDownscaleTarget(
const IntSize& aSize) override;
already_AddRefed<profiler_screenshots::AsyncReadbackBuffer>
CreateAsyncReadbackBuffer(const IntSize& aSize) override;
protected:
Compositor* mCompositor;
};
static LayerComposite* ToLayerComposite(Layer* aLayer) {
return static_cast<LayerComposite*>(aLayer->ImplData());
}
@ -954,7 +939,6 @@ LayerManagerComposite::PushGroupForLayerEffects() {
mCompositor->SetRenderTarget(mTwoPassTmpTarget);
return previousTarget;
}
void LayerManagerComposite::PopGroupForLayerEffects(
RefPtr<CompositingRenderTarget> aPreviousTarget, IntRect aClipRect,
bool aGrayscaleEffect, bool aInvertEffect, float aContrastEffect) {
@ -1249,8 +1233,7 @@ bool LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion,
RootLayer()->Cleanup();
WindowLMC window(mCompositor);
mProfilerScreenshotGrabber.MaybeGrabScreenshot(window);
mProfilerScreenshotGrabber.MaybeGrabScreenshot(mCompositor);
if (mCompositionRecorder) {
bool hasContentPaint = std::any_of(
@ -1680,106 +1663,5 @@ void LayerManagerComposite::PlatformSyncBeforeReplyUpdate() {}
#endif // !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS)
class RenderSourceLMC : public profiler_screenshots::RenderSource {
public:
explicit RenderSourceLMC(CompositingRenderTarget* aRT)
: RenderSource(aRT->GetSize()), mRT(aRT) {}
const auto& RenderTarget() { return mRT; }
protected:
virtual ~RenderSourceLMC() {}
RefPtr<CompositingRenderTarget> mRT;
};
class DownscaleTargetLMC : public profiler_screenshots::DownscaleTarget {
public:
explicit DownscaleTargetLMC(CompositingRenderTarget* aRT, Compositor* aCompositor)
: profiler_screenshots::DownscaleTarget(aRT->GetSize()),
mRenderSource(new RenderSourceLMC(aRT)),
mCompositor(aCompositor) {}
already_AddRefed<profiler_screenshots::RenderSource> AsRenderSource()
override {
return do_AddRef(mRenderSource);
}
bool DownscaleFrom(profiler_screenshots::RenderSource* aSource,
const IntRect& aSourceRect,
const IntRect& aDestRect) override {
MOZ_RELEASE_ASSERT(aSourceRect.TopLeft() == IntPoint());
MOZ_RELEASE_ASSERT(aDestRect.TopLeft() == IntPoint());
RefPtr<CompositingRenderTarget> previousTarget =
mCompositor->GetCurrentRenderTarget();
mCompositor->SetRenderTarget(mRenderSource->RenderTarget());
bool result = mCompositor->BlitRenderTarget(
static_cast<RenderSourceLMC*>(aSource)->RenderTarget(),
aSourceRect.Size(), aDestRect.Size());
// Restore the old render target.
mCompositor->SetRenderTarget(previousTarget);
return result;
}
protected:
virtual ~DownscaleTargetLMC() {}
RefPtr<RenderSourceLMC> mRenderSource;
Compositor* mCompositor;
};
class AsyncReadbackBufferLMC
: public profiler_screenshots::AsyncReadbackBuffer {
public:
AsyncReadbackBufferLMC(mozilla::layers::AsyncReadbackBuffer* aARB,
Compositor* aCompositor)
: profiler_screenshots::AsyncReadbackBuffer(aARB->GetSize()),
mARB(aARB),
mCompositor(aCompositor) {}
void CopyFrom(profiler_screenshots::RenderSource* aSource) override {
mCompositor->ReadbackRenderTarget(
static_cast<RenderSourceLMC*>(aSource)->RenderTarget(), mARB);
}
bool MapAndCopyInto(DataSourceSurface* aSurface,
const IntSize& aReadSize) override {
return mARB->MapAndCopyInto(aSurface, aReadSize);
}
protected:
virtual ~AsyncReadbackBufferLMC() {}
RefPtr<mozilla::layers::AsyncReadbackBuffer> mARB;
Compositor* mCompositor;
};
already_AddRefed<profiler_screenshots::RenderSource>
WindowLMC::GetWindowContents() {
RefPtr<CompositingRenderTarget> rt = mCompositor->GetWindowRenderTarget();
if (!rt) {
return nullptr;
}
return MakeAndAddRef<RenderSourceLMC>(rt);
}
already_AddRefed<profiler_screenshots::DownscaleTarget>
WindowLMC::CreateDownscaleTarget(const IntSize& aSize) {
RefPtr<CompositingRenderTarget> rt =
mCompositor->CreateRenderTarget(IntRect({}, aSize), INIT_MODE_NONE);
return MakeAndAddRef<DownscaleTargetLMC>(rt, mCompositor);
}
already_AddRefed<profiler_screenshots::AsyncReadbackBuffer>
WindowLMC::CreateAsyncReadbackBuffer(const IntSize& aSize) {
RefPtr<AsyncReadbackBuffer> carb =
mCompositor->CreateAsyncReadbackBuffer(aSize);
if (!carb) {
return nullptr;
}
return MakeAndAddRef<AsyncReadbackBufferLMC>(carb, mCompositor);
}
} // namespace layers
} // namespace mozilla

View File

@ -36,7 +36,7 @@
#include "nsRegion.h" // for nsIntRegion
#include "nscore.h" // for nsAString, etc
#include "LayerTreeInvalidation.h"
#include "mozilla/layers/ScreenshotGrabber.h"
#include "mozilla/layers/CompositorScreenshotGrabber.h"
class gfxContext;
@ -491,7 +491,7 @@ class LayerManagerComposite final : public HostLayerManager {
bool mIsCompositorReady;
RefPtr<CompositingRenderTarget> mTwoPassTmpTarget;
ScreenshotGrabber mProfilerScreenshotGrabber;
CompositorScreenshotGrabber mProfilerScreenshotGrabber;
RefPtr<TextRenderer> mTextRenderer;
RefPtr<NativeLayerRoot> mNativeLayerRoot;
RefPtr<SurfacePoolHandle> mSurfacePoolHandle;

View File

@ -150,6 +150,7 @@ EXPORTS.mozilla.layers += [
'composite/AsyncCompositionManager.h',
'composite/CanvasLayerComposite.h',
'composite/ColorLayerComposite.h',
'composite/CompositorScreenshotGrabber.h',
'composite/ContainerLayerComposite.h',
'composite/ContentHost.h',
'composite/Diagnostics.h',
@ -245,7 +246,6 @@ EXPORTS.mozilla.layers += [
'RepaintRequest.h',
'RotatedBuffer.h',
'SampleTime.h',
'ScreenshotGrabber.h',
'ScrollableLayerGuid.h',
'ShareableCanvasRenderer.h',
'SourceSurfaceSharedData.h',
@ -429,6 +429,7 @@ UNIFIED_SOURCES += [
'composite/CanvasLayerComposite.cpp',
'composite/ColorLayerComposite.cpp',
'composite/CompositableHost.cpp',
'composite/CompositorScreenshotGrabber.cpp',
'composite/ContainerLayerComposite.cpp',
'composite/ContentHost.cpp',
'composite/Diagnostics.cpp',
@ -524,7 +525,6 @@ UNIFIED_SOURCES += [
'RenderTrace.cpp',
'RotatedBuffer.cpp',
'SampleTime.cpp',
'ScreenshotGrabber.cpp',
'ShareableCanvasRenderer.cpp',
'SourceSurfaceSharedData.cpp',
'SourceSurfaceVolatileData.cpp',

View File

@ -136,10 +136,6 @@ class RenderCompositor {
bool* aNeedsYFlip) {
return false;
}
virtual bool MaybeGrabScreenshot(const gfx::IntSize& aWindowSize) {
return false;
}
virtual bool MaybeProcessScreenshotQueue() { return false; }
protected:
// We default this to 2, so that mLatestRenderFrameId.Prev() is always valid.

View File

@ -35,7 +35,6 @@ RenderCompositorNative::RenderCompositorNative(
}
RenderCompositorNative::~RenderCompositorNative() {
mProfilerScreenshotGrabber.Destroy();
mNativeLayerRoot->SetLayers({});
mNativeLayerForEntireWindow = nullptr;
mNativeLayerRootSnapshotter = nullptr;
@ -122,39 +121,6 @@ bool RenderCompositorNative::MaybeReadback(
return success;
}
bool RenderCompositorNative::MaybeGrabScreenshot(
const gfx::IntSize& aWindowSize) {
if (!ShouldUseNativeCompositor()) {
return false;
}
if (!mNativeLayerRootSnapshotter) {
mNativeLayerRootSnapshotter = mNativeLayerRoot->CreateSnapshotter();
}
mNativeLayerRootSnapshotter->MaybeGrabProfilerScreenshot(
&mProfilerScreenshotGrabber, aWindowSize);
// MaybeGrabScreenshot might have changed the current context. Make sure our
// context is current again.
MakeCurrent();
return true;
}
bool RenderCompositorNative::MaybeProcessScreenshotQueue() {
if (!ShouldUseNativeCompositor()) {
return false;
}
mProfilerScreenshotGrabber.MaybeProcessQueue();
// MaybeProcessQueue might have changed the current context. Make sure our
// context is current again.
MakeCurrent();
return true;
}
uint32_t RenderCompositorNative::GetMaxUpdateRects() {
if (ShouldUseNativeCompositor() &&
StaticPrefs::gfx_webrender_compositor_max_update_rects_AtStartup() > 0) {
@ -165,7 +131,7 @@ uint32_t RenderCompositorNative::GetMaxUpdateRects() {
void RenderCompositorNative::CompositorBeginFrame() {
mAddedLayers.Clear();
mAddedTilePixelCount = 0;
mAddedPixelCount = 0;
mAddedClippedPixelCount = 0;
mBeginFrameTimeStamp = TimeStamp::NowUnfuzzed();
mSurfacePoolHandle->OnBeginFrame();
@ -187,10 +153,10 @@ void RenderCompositorNative::CompositorEndFrame() {
int(mDrawnPixelCount * 100 / windowPixelCount),
int(mAddedClippedPixelCount * 100 / windowPixelCount),
int(mAddedLayers.Length()),
int(mAddedTilePixelCount * 100 / windowPixelCount),
int(mAddedPixelCount * 100 / windowPixelCount),
int(nativeLayerCount - mAddedLayers.Length()),
int((mTotalTilePixelCount - mAddedTilePixelCount) *
100 / windowPixelCount)),
int((mTotalPixelCount - mAddedPixelCount) * 100 /
windowPixelCount)),
JS::ProfilingCategoryPair::GRAPHICS, mBeginFrameTimeStamp,
TimeStamp::NowUnfuzzed());
}
@ -270,10 +236,8 @@ void RenderCompositorNative::DestroySurface(NativeSurfaceId aId) {
MOZ_RELEASE_ASSERT(surfaceCursor != mSurfaces.end());
Surface& surface = surfaceCursor->second;
if (!surface.mIsExternal) {
for (const auto& iter : surface.mNativeLayers) {
mTotalTilePixelCount -= gfx::IntRect({}, iter.second->GetSize()).Area();
}
for (const auto& iter : surface.mNativeLayers) {
mTotalPixelCount -= gfx::IntRect({}, iter.second->GetSize()).Area();
}
mSurfaces.erase(surfaceCursor);
@ -289,7 +253,7 @@ void RenderCompositorNative::CreateTile(wr::NativeSurfaceId aId, int aX,
RefPtr<layers::NativeLayer> layer = mNativeLayerRoot->CreateLayer(
surface.TileSize(), surface.mIsOpaque, mSurfacePoolHandle);
surface.mNativeLayers.insert({TileKey(aX, aY), layer});
mTotalTilePixelCount += gfx::IntRect({}, layer->GetSize()).Area();
mTotalPixelCount += gfx::IntRect({}, layer->GetSize()).Area();
}
void RenderCompositorNative::DestroyTile(wr::NativeSurfaceId aId, int aX,
@ -303,7 +267,7 @@ void RenderCompositorNative::DestroyTile(wr::NativeSurfaceId aId, int aX,
MOZ_RELEASE_ASSERT(layerCursor != surface.mNativeLayers.end());
RefPtr<layers::NativeLayer> layer = std::move(layerCursor->second);
surface.mNativeLayers.erase(layerCursor);
mTotalTilePixelCount -= gfx::IntRect({}, layer->GetSize()).Area();
mTotalPixelCount -= gfx::IntRect({}, layer->GetSize()).Area();
// If the layer is currently present in mNativeLayerRoot, it will be destroyed
// once CompositorEndFrame() replaces mNativeLayerRoot's layers and drops that
@ -352,13 +316,9 @@ void RenderCompositorNative::AddSurface(
layer->SetSamplingFilter(ToSamplingFilter(aImageRendering));
mAddedLayers.AppendElement(layer);
if (!surface.mIsExternal) {
mAddedTilePixelCount += layerSize.width * layerSize.height;
}
gfx::Rect r = transform.TransformBounds(
gfx::Rect(layer->CurrentSurfaceDisplayRect()));
mAddedPixelCount += layerSize.width * layerSize.height;
gfx::IntRect visibleRect =
clipRect.Intersect(RoundedToInt(r) + layerPosition);
clipRect.Intersect(layer->CurrentSurfaceDisplayRect() + layerPosition);
mAddedClippedPixelCount += visibleRect.Area();
}
}

View File

@ -8,7 +8,6 @@
#define MOZILLA_GFX_RENDERCOMPOSITOR_NATIVE_H
#include "GLTypes.h"
#include "mozilla/layers/ScreenshotGrabber.h"
#include "mozilla/webrender/RenderCompositor.h"
#include "mozilla/TimeStamp.h"
@ -46,8 +45,6 @@ class RenderCompositorNative : public RenderCompositor {
const wr::ImageFormat& aReadbackFormat,
const Range<uint8_t>& aReadbackBuffer,
bool* aNeedsYFlip) override;
bool MaybeGrabScreenshot(const gfx::IntSize& aWindowSize) override;
bool MaybeProcessScreenshotQueue() override;
// Interface for wr::Compositor
void CompositorBeginFrame() override;
@ -87,7 +84,6 @@ class RenderCompositorNative : public RenderCompositor {
// Can be null.
RefPtr<layers::NativeLayerRoot> mNativeLayerRoot;
UniquePtr<layers::NativeLayerRootSnapshotter> mNativeLayerRootSnapshotter;
layers::ScreenshotGrabber mProfilerScreenshotGrabber;
RefPtr<layers::NativeLayer> mNativeLayerForEntireWindow;
RefPtr<layers::SurfacePoolHandle> mSurfacePoolHandle;
@ -123,8 +119,8 @@ class RenderCompositorNative : public RenderCompositor {
// Used in native compositor mode:
RefPtr<layers::NativeLayer> mCurrentlyBoundNativeLayer;
nsTArray<RefPtr<layers::NativeLayer>> mAddedLayers;
uint64_t mTotalTilePixelCount = 0;
uint64_t mAddedTilePixelCount = 0;
uint64_t mTotalPixelCount = 0;
uint64_t mAddedPixelCount = 0;
uint64_t mAddedClippedPixelCount = 0;
uint64_t mDrawnPixelCount = 0;
gfx::IntRect mVisibleBounds;

View File

@ -180,9 +180,7 @@ RenderedFrameId RendererOGL::UpdateAndRender(
}
}
if (!mCompositor->MaybeGrabScreenshot(size.ToUnknownSize())) {
mScreenshotGrabber.MaybeGrabScreenshot(this, size.ToUnknownSize());
}
mScreenshotGrabber.MaybeGrabScreenshot(this, size.ToUnknownSize());
RenderedFrameId frameId = mCompositor->EndFrame(dirtyRects);
@ -198,9 +196,7 @@ RenderedFrameId RendererOGL::UpdateAndRender(
mFrameStartTime = TimeStamp();
#endif
if (!mCompositor->MaybeProcessScreenshotQueue()) {
mScreenshotGrabber.MaybeProcessQueue(this);
}
mScreenshotGrabber.MaybeProcessQueue(this);
// TODO: Flush pending actions such as texture deletions/unlocks and
// textureHosts recycling.