Skip to content

Commit

Permalink
Backed out 3 changesets (bug 1722258) for causing Bug 1722935. a=backout
Browse files Browse the repository at this point in the history
Backed out changeset cf8a1175abd1 (bug 1722258)
Backed out changeset 41176d476eb7 (bug 1722258)
Backed out changeset 4149d596d03d (bug 1722258)
  • Loading branch information
ncsoregi committed Jul 29, 2021
1 parent 86fe252 commit bc4c680
Show file tree
Hide file tree
Showing 28 changed files with 228 additions and 418 deletions.
5 changes: 3 additions & 2 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,9 @@ nsDOMWindowUtils::UpdateLayerTree() {
RefPtr<nsViewManager> vm = presShell->GetViewManager();
if (nsView* view = vm->GetRootView()) {
nsAutoScriptBlocker scriptBlocker;
presShell->Paint(view, view->GetBounds(),
PaintFlags::PaintSyncDecodeImages);
presShell->Paint(
view, view->GetBounds(),
PaintFlags::PaintLayers | PaintFlags::PaintSyncDecodeImages);
presShell->GetWindowRenderer()->WaitOnTransactionProcessed();
}
}
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/BrowserBridgeParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void BrowserBridgeParent::Destroy() {
}

IPCResult BrowserBridgeParent::RecvShow(const OwnerShowInfo& aOwnerInfo) {
mBrowserParent->AttachWindowRenderer();
mBrowserParent->AttachLayerManager();
Unused << mBrowserParent->SendShow(mBrowserParent->GetShowInfo(), aOwnerInfo);
return IPC_OK();
}
Expand Down
53 changes: 24 additions & 29 deletions dom/ipc/BrowserChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2672,12 +2672,12 @@ mozilla::ipc::IPCResult BrowserChild::RecvRenderLayers(
MOZ_ASSERT(mPuppetWidget);
RefPtr<LayerManager> lm =
mPuppetWidget->GetWindowRenderer()->AsLayerManager();
if (lm) {
// We send the current layer observer epoch to the compositor so that
// BrowserParent knows whether a layer update notification corresponds to
// the latest RecvRenderLayers request that was made.
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
}
MOZ_ASSERT(lm);

// We send the current layer observer epoch to the compositor so that
// BrowserParent knows whether a layer update notification corresponds to
// the latest RecvRenderLayers request that was made.
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
}

mRenderLayers = aEnabled;
Expand Down Expand Up @@ -2732,7 +2732,7 @@ mozilla::ipc::IPCResult BrowserChild::RecvRenderLayers(
} else {
RefPtr<nsViewManager> vm = presShell->GetViewManager();
if (nsView* view = vm->GetRootView()) {
presShell->Paint(view, view->GetBounds(), PaintFlags::None);
presShell->Paint(view, view->GetBounds(), PaintFlags::PaintLayers);
}
}
presShell->SuppressDisplayport(false);
Expand Down Expand Up @@ -2855,9 +2855,8 @@ void BrowserChild::InitRenderingState(
InitAPZState();
RefPtr<LayerManager> lm =
mPuppetWidget->GetWindowRenderer()->AsLayerManager();
if (lm) {
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
}
MOZ_ASSERT(lm);
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
} else {
NS_WARNING("Fallback to BasicLayerManager");
mLayersConnected = Some(false);
Expand Down Expand Up @@ -3155,9 +3154,7 @@ void BrowserChild::DidComposite(mozilla::layers::TransactionId aTransactionId,
mPuppetWidget->GetWindowRenderer()->AsLayerManager();
MOZ_ASSERT(lm);

if (lm) {
lm->DidComposite(aTransactionId, aCompositeStart, aCompositeEnd);
}
lm->DidComposite(aTransactionId, aCompositeStart, aCompositeEnd);
}

void BrowserChild::DidRequestComposite(const TimeStamp& aCompositeReqStart,
Expand Down Expand Up @@ -3188,9 +3185,9 @@ void BrowserChild::ClearCachedResources() {
MOZ_ASSERT(mPuppetWidget);
RefPtr<LayerManager> lm =
mPuppetWidget->GetWindowRenderer()->AsLayerManager();
if (lm) {
lm->ClearCachedResources();
}
MOZ_ASSERT(lm);

lm->ClearCachedResources();

if (nsCOMPtr<Document> document = GetTopLevelDocument()) {
nsPresContext* presContext = document->GetPresContext();
Expand All @@ -3204,9 +3201,9 @@ void BrowserChild::InvalidateLayers() {
MOZ_ASSERT(mPuppetWidget);
RefPtr<LayerManager> lm =
mPuppetWidget->GetWindowRenderer()->AsLayerManager();
if (lm) {
FrameLayerBuilder::InvalidateAllLayers(lm);
}
MOZ_ASSERT(lm);

FrameLayerBuilder::InvalidateAllLayers(lm);
}

void BrowserChild::SchedulePaint() {
Expand Down Expand Up @@ -3262,9 +3259,8 @@ void BrowserChild::ReinitRendering() {
InitAPZState();
RefPtr<LayerManager> lm =
mPuppetWidget->GetWindowRenderer()->AsLayerManager();
if (lm) {
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
}
MOZ_ASSERT(lm);
lm->SetLayersObserverEpoch(mLayersObserverEpoch);

nsCOMPtr<Document> doc(GetTopLevelDocument());
doc->NotifyLayerManagerRecreated();
Expand All @@ -3275,10 +3271,10 @@ void BrowserChild::ReinitRenderingForDeviceReset() {

RefPtr<LayerManager> lm =
mPuppetWidget->GetWindowRenderer()->AsLayerManager();
if (lm && lm->AsWebRenderLayerManager()) {
lm->AsWebRenderLayerManager()->DoDestroy(/* aIsSync */ true);
} else if (lm && lm->AsClientLayerManager()) {
if (ShadowLayerForwarder* fwd = lm->AsShadowForwarder()) {
if (WebRenderLayerManager* wlm = lm->AsWebRenderLayerManager()) {
wlm->DoDestroy(/* aIsSync */ true);
} else if (ClientLayerManager* clm = lm->AsClientLayerManager()) {
if (ShadowLayerForwarder* fwd = clm->AsShadowForwarder()) {
// Force the LayerTransactionChild to synchronously shutdown. It is
// okay to do this early, we'll simply stop sending messages. This
// step is necessary since otherwise the compositor will think we
Expand Down Expand Up @@ -3316,9 +3312,8 @@ void BrowserChild::NotifyJankedAnimations(
MOZ_ASSERT(mPuppetWidget);
RefPtr<LayerManager> lm =
mPuppetWidget->GetWindowRenderer()->AsLayerManager();
if (lm) {
lm->UpdatePartialPrerenderedAnimations(aJankedAnimations);
}
MOZ_ASSERT(lm);
lm->UpdatePartialPrerenderedAnimations(aJankedAnimations);
}

mozilla::ipc::IPCResult BrowserChild::RecvRequestNotifyAfterRemotePaint() {
Expand Down
6 changes: 3 additions & 3 deletions dom/ipc/BrowserParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,8 @@ void BrowserParent::InitRendering() {
#endif
}

bool BrowserParent::AttachWindowRenderer() {
return mRemoteLayerTreeOwner.AttachWindowRenderer();
bool BrowserParent::AttachLayerManager() {
return !!mRemoteLayerTreeOwner.AttachLayerManager();
}

void BrowserParent::MaybeShowFrame() {
Expand All @@ -931,7 +931,7 @@ bool BrowserParent::Show(const OwnerShowInfo& aOwnerInfo) {
}

MOZ_ASSERT(mRemoteLayerTreeOwner.IsInitialized());
if (!mRemoteLayerTreeOwner.AttachWindowRenderer()) {
if (!mRemoteLayerTreeOwner.AttachLayerManager()) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/BrowserParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ class BrowserParent final : public PBrowserParent,
void ResumeLoad(uint64_t aPendingSwitchID);

void InitRendering();
bool AttachWindowRenderer();
bool AttachLayerManager();
void MaybeShowFrame();

bool Show(const OwnerShowInfo&);
Expand Down
18 changes: 17 additions & 1 deletion gfx/layers/LayerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class DidCompositeObserver {
* root layer, and each container layer holds a reference to its children.
*/
class LayerManager : public WindowRenderer {
NS_INLINE_DECL_REFCOUNTING(LayerManager)

protected:
typedef mozilla::gfx::DrawTarget DrawTarget;
typedef mozilla::gfx::IntSize IntSize;
Expand All @@ -158,7 +160,7 @@ class LayerManager : public WindowRenderer {
* for its widget going away. After this call, only user data calls
* are valid on the layer manager.
*/
void Destroy() override;
virtual void Destroy();
bool IsDestroyed() { return mDestroyed; }

virtual LayerManager* AsLayerManager() override { return this; }
Expand Down Expand Up @@ -505,6 +507,15 @@ class LayerManager : public WindowRenderer {
static bool IsLogEnabled();
static mozilla::LogModule* GetLog();

bool IsCompositingCheap(LayersBackend aBackend) {
// LayersBackend::LAYERS_NONE is an error state, but in that case we should
// try to avoid loading the compositor!
return LayersBackend::LAYERS_BASIC != aBackend &&
LayersBackend::LAYERS_NONE != aBackend;
}

virtual bool IsCompositingCheap() { return true; }

bool IsInTransaction() const { return mInTransaction; }

virtual void SetRegionToClear(const nsIntRegion& aRegion) {
Expand All @@ -513,6 +524,8 @@ class LayerManager : public WindowRenderer {

virtual float RequestProperty(const nsAString& property) { return -1; }

const TimeStamp& GetAnimationReadyTime() const { return mAnimationReadyTime; }

virtual bool AsyncPanZoomEnabled() const { return false; }

static void LayerUserDataDestroy(void* data);
Expand Down Expand Up @@ -587,6 +600,9 @@ class LayerManager : public WindowRenderer {

// Used for tracking CONTENT_FRAME_TIME_WITH_SVG
bool mContainsSVG;
// The time when painting most recently finished. This is recorded so that
// we can time any play-pending animations from this point.
TimeStamp mAnimationReadyTime;
// The count of pixels that were painted in the current transaction.
uint32_t mPaintedPixelCount;
// The payload associated with currently pending painting work, for
Expand Down
6 changes: 2 additions & 4 deletions gfx/layers/client/ClientLayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,8 @@ ShadowableLayer* ClientLayerManager::Hold(Layer* aLayer) {
bool ClientLayerManager::IsCompositingCheap() {
// Whether compositing is cheap depends on the parent backend.
return mForwarder->mShadowManager &&
(mForwarder->GetCompositorBackendType() !=
LayersBackend::LAYERS_NONE &&
mForwarder->GetCompositorBackendType() !=
LayersBackend::LAYERS_BASIC);
LayerManager::IsCompositingCheap(
mForwarder->GetCompositorBackendType());
}

bool ClientLayerManager::AreComponentAlphaLayersEnabled() {
Expand Down
66 changes: 23 additions & 43 deletions layout/base/PresShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6239,36 +6239,6 @@ class nsAutoNotifyDidPaint {
PaintFlags mFlags;
};

bool PresShell::Composite(nsView* aViewToPaint) {
nsCString url;
nsIURI* uri = mDocument->GetDocumentURI();
Document* contentRoot = GetPrimaryContentDocument();
if (contentRoot) {
uri = contentRoot->GetDocumentURI();
}
url = uri ? uri->GetSpecOrDefault() : "N/A"_ns;
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING("PresShell::Composite", GRAPHICS, url);

nsIFrame* frame = aViewToPaint->GetFrame();
WindowRenderer* renderer = aViewToPaint->GetWidget()->GetWindowRenderer();
NS_ASSERTION(renderer, "Must be in paint event");

if (!renderer->BeginTransaction(url)) {
// If we can't begin a transaction and paint, then there's not
// much the caller can do.
return true;
}

if (frame) {
if (renderer->EndEmptyTransaction()) {
GetPresContext()->NotifyDidPaintForSubtree();
return true;
}
NS_WARNING("Must complete empty transaction when compositing!");
}
return false;
}

void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
PaintFlags aFlags) {
nsCString url;
Expand Down Expand Up @@ -6347,6 +6317,20 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
}

if (frame) {
// Try to do an empty transaction, if the frame tree does not
// need to be updated. Do not try to do an empty transaction on
// a non-retained layer manager (like the BasicLayerManager that
// draws the window title bar on Mac), because a) it won't work
// and b) below we don't want to clear NS_FRAME_UPDATE_LAYER_TREE,
// that will cause us to forget to update the real layer manager!

if (!(aFlags & PaintFlags::PaintLayers)) {
if (renderer->EndEmptyTransaction()) {
return;
}
NS_WARNING("Must complete empty transaction when compositing!");
}

if (!(aFlags & PaintFlags::PaintSyncDecodeImages) &&
!frame->HasAnyStateBits(NS_FRAME_UPDATE_LAYER_TREE) &&
!mNextPaintCompressed) {
Expand Down Expand Up @@ -6438,23 +6422,17 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
return;
}

bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor);

if (!layerManager) {
FallbackRenderer* fallback = renderer->AsFallback();
MOZ_ASSERT(fallback);

if (aFlags & PaintFlags::PaintComposite) {
nsIntRect bounds = presContext->GetVisibleArea().ToOutsidePixels(
presContext->AppUnitsPerDevPixel());
fallback->EndTransactionWithColor(bounds, ToDeviceColor(bgcolor));
}
// TODO: Once we support WindowRenderers that aren't a LayerManager,
// then we need to handle this single color case for them.
return;
}

if (layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
nsPresContext* pc = GetPresContext();
LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
presContext->GetVisibleArea(), presContext->AppUnitsPerDevPixel());
pc->GetVisibleArea(), pc->AppUnitsPerDevPixel());
bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor);
WebRenderBackgroundData data(wr::ToLayoutRect(bounds),
wr::ToColorF(ToDeviceColor(bgcolor)));
WrFiltersHolder wrFilters;
Expand All @@ -6467,8 +6445,10 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,

RefPtr<ColorLayer> root = layerManager->CreateColorLayer();
if (root) {
nsIntRect bounds = presContext->GetVisibleArea().ToOutsidePixels(
presContext->AppUnitsPerDevPixel());
nsPresContext* pc = GetPresContext();
nsIntRect bounds =
pc->GetVisibleArea().ToOutsidePixels(pc->AppUnitsPerDevPixel());
bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor);
root->SetColor(ToDeviceColor(bgcolor));
root->SetVisibleRegion(LayerIntRegion::FromUnknownRegion(bounds));
layerManager->SetRoot(root);
Expand Down
2 changes: 0 additions & 2 deletions layout/base/PresShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -1268,8 +1268,6 @@ class PresShell final : public nsStubDocumentObserver,
void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
PaintFlags aFlags);

bool Composite(nsView* aViewToPaint);

/**
* Notify that we're going to call Paint with PaintFlags::PaintLayers
* on the pres shell for a widget (which might not be this one, since
Expand Down
4 changes: 4 additions & 0 deletions layout/base/PresShellForwards.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AddCanvasBackgroundColorFlags)

enum class PaintFlags {
None = 0,
/* Update the layer tree and paint PaintedLayers. If this is not specified,
* we may still have to do it if the layer tree lost PaintedLayer contents
* we need for compositing. */
PaintLayers = 1 << 0,
/* Composite layers to the window. */
PaintComposite = 1 << 1,
/* Sync-decode images. */
Expand Down
Loading

0 comments on commit bc4c680

Please sign in to comment.