зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1722258 - Split out fallible composite-only path of PresShell::Paint. r=miko
Differential Revision: https://phabricator.services.mozilla.com/D120919
This commit is contained in:
Родитель
e0929c4c22
Коммит
d3dadfe348
|
@ -409,9 +409,8 @@ nsDOMWindowUtils::UpdateLayerTree() {
|
|||
RefPtr<nsViewManager> vm = presShell->GetViewManager();
|
||||
if (nsView* view = vm->GetRootView()) {
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
presShell->Paint(
|
||||
view, view->GetBounds(),
|
||||
PaintFlags::PaintLayers | PaintFlags::PaintSyncDecodeImages);
|
||||
presShell->Paint(view, view->GetBounds(),
|
||||
PaintFlags::PaintSyncDecodeImages);
|
||||
presShell->GetWindowRenderer()->WaitOnTransactionProcessed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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::PaintLayers);
|
||||
presShell->Paint(view, view->GetBounds(), PaintFlags::None);
|
||||
}
|
||||
}
|
||||
presShell->SuppressDisplayport(false);
|
||||
|
|
|
@ -6239,6 +6239,36 @@ 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;
|
||||
|
@ -6317,20 +6347,6 @@ 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) {
|
||||
|
|
|
@ -1268,6 +1268,8 @@ 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
|
||||
|
|
|
@ -188,10 +188,6 @@ 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. */
|
||||
|
|
|
@ -333,7 +333,12 @@ void nsViewManager::Refresh(nsView* aView,
|
|||
if (!renderer->NeedsWidgetInvalidation()) {
|
||||
renderer->FlushRendering();
|
||||
} else {
|
||||
presShell->Paint(aView, damageRegion, PaintFlags::PaintComposite);
|
||||
// Try to just Composite the current WindowRenderer contents. If
|
||||
// that fails then we need tor repaint, and request that it gets
|
||||
// composited as well.
|
||||
if (!presShell->Composite(aView)) {
|
||||
presShell->Paint(aView, damageRegion, PaintFlags::PaintComposite);
|
||||
}
|
||||
}
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
||||
|
@ -456,7 +461,7 @@ void nsViewManager::ProcessPendingUpdatesPaint(nsIWidget* aWidget) {
|
|||
}
|
||||
#endif
|
||||
|
||||
presShell->Paint(view, nsRegion(), PaintFlags::PaintLayers);
|
||||
presShell->Paint(view, nsRegion(), PaintFlags::None);
|
||||
view->SetForcedRepaint(false);
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
|
|
Загрузка…
Ссылка в новой задаче