Bug 1381085 - Remove IsMirror concept in favor of checking forwarders.
- This patch is the same as one from
Bug 1382104 (Remove IsMirror concept
in favor of checking forwarder).
- It is safe to uplift this patch without the rest of
Bug 1382104 as long
as the remaining
Bug 1381084 is also uplifted.
MozReview-Commit-ID: 21YZObeSUa3
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -109,17 +109,16 @@ WebGLContext::WebGLContext()
, mMaxPerfWarnings(gfxPrefs::WebGLMaxPerfWarnings())
, mNumPerfWarnings(0)
, mMaxAcceptableFBStatusInvals(gfxPrefs::WebGLMaxAcceptableFBStatusInvals())
, mDataAllocGLCallCount(0)
, mBufferFetchingIsVerified(false)
, mBufferFetchingHasPerVertex(false)
, mMaxFetchedVertices(0)
, mMaxFetchedInstances(0)
- , mLayerIsMirror(false)
, mBypassShaderValidation(false)
, mEmptyTFO(0)
, mContextLossHandler(this)
, mNeedsFakeNoAlpha(false)
, mNeedsFakeNoDepth(false)
, mNeedsFakeNoStencil(false)
, mNeedsEmulatedLoneDepthStencil(false)
, mAllowFBInvalidation(gfxPrefs::WebGLFBInvalidation())
@@ -1273,17 +1272,16 @@ WebGLContext::UpdateLastUseIndex()
// should never happen with 64-bit; trying to handle this would be riskier than
// not handling it as the handler code would never get exercised.
if (!sIndex.isValid())
MOZ_CRASH("Can't believe it's been 2^64 transactions already!");
mLastUseIndex = sIndex.value();
}
static uint8_t gWebGLLayerUserData;
-static uint8_t gWebGLMirrorLayerUserData;
class WebGLContextUserData : public LayerUserData
{
public:
explicit WebGLContextUserData(HTMLCanvasElement* canvas)
: mCanvas(canvas)
{}
@@ -1310,63 +1308,60 @@ public:
private:
RefPtr<HTMLCanvasElement> mCanvas;
};
already_AddRefed<layers::Layer>
WebGLContext::GetCanvasLayer(nsDisplayListBuilder* builder,
Layer* oldLayer,
LayerManager* manager,
- bool aMirror /*= false*/)
+ bool)
{
if (!mResetLayer && oldLayer &&
- oldLayer->HasUserData(aMirror ? &gWebGLMirrorLayerUserData : &gWebGLLayerUserData)) {
+ oldLayer->HasUserData(&gWebGLLayerUserData))
+ {
RefPtr<layers::Layer> ret = oldLayer;
return ret.forget();
}
RefPtr<CanvasLayer> canvasLayer = manager->CreateCanvasLayer();
if (!canvasLayer) {
NS_WARNING("CreateCanvasLayer returned null!");
return nullptr;
}
WebGLContextUserData* userData = nullptr;
- if (builder->IsPaintingToWindow() && mCanvasElement && !aMirror) {
+ if (builder->IsPaintingToWindow() && mCanvasElement) {
userData = new WebGLContextUserData(mCanvasElement);
}
- canvasLayer->SetUserData(aMirror ? &gWebGLMirrorLayerUserData : &gWebGLLayerUserData, userData);
+ canvasLayer->SetUserData(&gWebGLLayerUserData, userData);
CanvasRenderer* canvasRenderer = canvasLayer->CreateOrGetCanvasRenderer();
- if (!InitializeCanvasRenderer(builder, canvasRenderer, aMirror))
+ if (!InitializeCanvasRenderer(builder, canvasRenderer))
return nullptr;
uint32_t flags = gl->Caps().alpha ? 0 : Layer::CONTENT_OPAQUE;
canvasLayer->SetContentFlags(flags);
mResetLayer = false;
- // We only wish to update mLayerIsMirror when a new layer is returned.
- // If a cached layer is returned above, aMirror is not changing since
- // the last cached layer was created and mLayerIsMirror is still valid.
- mLayerIsMirror = aMirror;
return canvasLayer.forget();
}
bool
WebGLContext::InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
CanvasRenderer* aRenderer,
- bool aMirror)
+ bool)
{
if (IsContextLost())
return false;
CanvasInitializeData data;
- if (aBuilder->IsPaintingToWindow() && mCanvasElement && !aMirror) {
+ if (aBuilder->IsPaintingToWindow() && mCanvasElement) {
// Make the layer tell us whenever a transaction finishes (including
// the current transaction), so we can clear our invalidation state and
// start invalidating again. We need to do this for the layer that is
// being painted to a window (there shouldn't be more than one at a time,
// and if there is, flushing the invalidation state more often than
// necessary is harmless).
// The layer will be destroyed when we tear down the presentation
@@ -1379,17 +1374,16 @@ WebGLContext::InitializeCanvasRenderer(n
data.mDidTransCallback = WebGLContextUserData::DidTransactionCallback;
data.mDidTransCallbackData = this;
}
data.mGLContext = gl;
data.mSize = nsIntSize(mWidth, mHeight);
data.mHasAlpha = gl->Caps().alpha;
data.mIsGLAlphaPremult = IsPremultAlpha() || !data.mHasAlpha;
- data.mIsMirror = aMirror;
aRenderer->Initialize(data);
aRenderer->SetDirty();
return true;
}
layers::LayersBackend
WebGLContext::GetCompositorBackendType() const
@@ -2328,24 +2322,16 @@ WebGLContext::GetUnpackSize(bool isFunc3
totalBytes += usedBytesPerRow;
return totalBytes;
}
already_AddRefed<layers::SharedSurfaceTextureClient>
WebGLContext::GetVRFrame()
{
- if (!mLayerIsMirror) {
- /**
- * Do not allow VR frame submission until a mirroring canvas layer has
- * been returned by GetCanvasLayer
- */
- return nullptr;
- }
-
VRManagerChild* vrmc = VRManagerChild::Get();
if (!vrmc) {
return nullptr;
}
/**
* Swap buffers as though composition has occurred.
* We will then share the resulting front buffer to be submitted to the VR
@@ -2374,17 +2360,17 @@ WebGLContext::GetVRFrame()
destSurf->ProducerAcquire();
SharedSurface::ProdCopy(sharedSurface->Surf(), dest->Surf(),
screen->Factory());
destSurf->ProducerRelease();
return dest.forget();
}
- return sharedSurface.forget();
+ return sharedSurface.forget();
}
bool
WebGLContext::StartVRPresentation()
{
VRManagerChild* vrmc = VRManagerChild::Get();
if (!vrmc) {
return false;
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1433,17 +1433,16 @@ protected:
CheckedUint32 mGeneration;
WebGLContextOptions mOptions;
bool mInvalidated;
bool mCapturedFrameInvalidated;
bool mResetLayer;
- bool mLayerIsMirror;
bool mOptionsFrozen;
bool mDisableExtensions;
bool mIsMesa;
bool mLoseContextOnMemoryPressure;
bool mCanLoseContextInForeground;
bool mRestoreWhenVisible;
bool mShouldPresent;
bool mBackbufferNeedsClear;
--- a/gfx/layers/CanvasRenderer.h
+++ b/gfx/layers/CanvasRenderer.h
@@ -36,17 +36,16 @@ struct CanvasInitializeData {
, mPreTransCallback(nullptr)
, mPreTransCallbackData(nullptr)
, mDidTransCallback(nullptr)
, mDidTransCallbackData(nullptr)
, mFrontbufferGLTex(0)
, mSize(0,0)
, mHasAlpha(false)
, mIsGLAlphaPremult(true)
- , mIsMirror(false)
{ }
// One of these three must be specified for Canvas2D, but never more than one
PersistentBufferProvider* mBufferProvider; // A BufferProvider for the Canvas contents
mozilla::gl::GLContext* mGLContext; // or this, for GL.
AsyncCanvasRenderer* mRenderer; // or this, for OffscreenCanvas
typedef void (* TransactionCallback)(void* closureData);
@@ -61,20 +60,16 @@ struct CanvasInitializeData {
// The size of the canvas content
gfx::IntSize mSize;
// Whether the canvas drawingbuffer has an alpha channel.
bool mHasAlpha;
// Whether mGLContext contains data that is alpha-premultiplied.
bool mIsGLAlphaPremult;
-
- // Whether the canvas front buffer is already being rendered somewhere else.
- // When true, do not swap buffers or Morph() to another factory on mGLContext
- bool mIsMirror;
};
// Based class which used for canvas rendering. There are many derived classes for
// different purposes. such as:
//
// CopyableCanvasRenderer provides a utility which readback canvas content to a
// SourceSurface. BasicCanvasLayer uses CopyableCanvasRenderer.
//
--- a/gfx/layers/CopyableCanvasRenderer.cpp
+++ b/gfx/layers/CopyableCanvasRenderer.cpp
@@ -34,17 +34,16 @@ using namespace mozilla::gl;
CopyableCanvasRenderer::CopyableCanvasRenderer()
: mGLContext(nullptr)
, mBufferProvider(nullptr)
, mGLFrontbuffer(nullptr)
, mAsyncRenderer(nullptr)
, mIsAlphaPremultiplied(true)
, mOriginPos(gl::OriginPos::TopLeft)
- , mIsMirror(false)
, mOpaque(true)
, mCachedTempSurface(nullptr)
{
MOZ_COUNT_CTOR(CopyableCanvasRenderer);
}
CopyableCanvasRenderer::~CopyableCanvasRenderer()
{
@@ -56,17 +55,16 @@ void
CopyableCanvasRenderer::Initialize(const CanvasInitializeData& aData)
{
CanvasRenderer::Initialize(aData);
if (aData.mGLContext) {
mGLContext = aData.mGLContext;
mIsAlphaPremultiplied = aData.mIsGLAlphaPremult;
mOriginPos = gl::OriginPos::BottomLeft;
- mIsMirror = aData.mIsMirror;
MOZ_ASSERT(mGLContext->IsOffscreen(), "canvas gl context isn't offscreen");
if (aData.mFrontbufferGLTex) {
gfx::IntSize size(aData.mSize.width, aData.mSize.height);
mGLFrontbuffer = SharedSurface_Basic::Wrap(aData.mGLContext, size, aData.mHasAlpha,
aData.mFrontbufferGLTex);
mBufferProvider = aData.mBufferProvider;
--- a/gfx/layers/CopyableCanvasRenderer.h
+++ b/gfx/layers/CopyableCanvasRenderer.h
@@ -57,17 +57,16 @@ public:
protected:
RefPtr<gl::GLContext> mGLContext;
RefPtr<PersistentBufferProvider> mBufferProvider;
UniquePtr<gl::SharedSurface> mGLFrontbuffer;
RefPtr<AsyncCanvasRenderer> mAsyncRenderer;
bool mIsAlphaPremultiplied;
gl::OriginPos mOriginPos;
- bool mIsMirror;
bool mOpaque;
RefPtr<gfx::DataSourceSurface> mCachedTempSurface;
gfx::DataSourceSurface* GetTempSurface(const gfx::IntSize& aSize,
const gfx::SurfaceFormat aFormat);
};
--- a/gfx/layers/ShareableCanvasRenderer.cpp
+++ b/gfx/layers/ShareableCanvasRenderer.cpp
@@ -57,17 +57,17 @@ ShareableCanvasRenderer::Initialize(cons
mFlags = TextureFlags::ORIGIN_BOTTOM_LEFT;
if (!aData.mIsGLAlphaPremult) {
mFlags |= TextureFlags::NON_PREMULTIPLIED;
}
UniquePtr<gl::SurfaceFactory> factory =
gl::GLScreenBuffer::CreateFactory(mGLContext, caps, forwarder, mFlags);
- if (mGLFrontbuffer || aData.mIsMirror) {
+ if (mGLFrontbuffer) {
// We're using a source other than the one in the default screen.
// (SkiaGL)
mFactory = Move(factory);
if (!mFactory) {
// Absolutely must have a factory here, so create a basic one
mFactory = MakeUnique<gl::SurfaceFactory_Basic>(mGLContext, caps, mFlags);
}
} else {
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -405,21 +405,16 @@ CanvasClientSharedSurface::UpdateRendere
RefPtr<TextureClient> newFront;
if (canvasRenderer && canvasRenderer->mGLFrontbuffer) {
mShSurfClient = CloneSurface(canvasRenderer->mGLFrontbuffer.get(), canvasRenderer->mFactory.get());
if (!mShSurfClient) {
gfxCriticalError() << "Invalid canvas front buffer";
return;
}
- } else if (canvasRenderer && canvasRenderer->mIsMirror) {
- mShSurfClient = CloneSurface(gl->Screen()->Front()->Surf(), canvasRenderer->mFactory.get());
- if (!mShSurfClient) {
- return;
- }
} else {
mShSurfClient = gl->Screen()->Front();
if (mShSurfClient && mShSurfClient->GetAllocator() &&
mShSurfClient->GetAllocator() != GetForwarder()->GetTextureForwarder()) {
mShSurfClient = CloneSurface(mShSurfClient->Surf(), gl->Screen()->Factory());
}
if (!mShSurfClient) {
return;