Closed Bug 1574592 Opened 5 years ago Closed 5 years ago

Put LayerManagerComposite in charge of creating and drawing to NativeLayers

Categories

(Core :: Graphics: Layers, task)

All
macOS
task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: mstange, Assigned: mstange)

References

Details

Attachments

(7 files, 8 obsolete files)

(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details

At the moment (after bug 1491442), the NativeLayer object for the window is created and placed by nsChildView. On every composite, nsChildView hijacks the GL context's default framebuffer to trick CompositorOGL into drawing into the layer.

In this bug, I'm going to change things around so that nsChildView does not create a NativeLayer. Instead, the layer will be created and placed by LayerManagerComposite. And then CompositorOGL will know that it renders into a NativeLayer and it will create a CompositingRenderTargetOGL for the layer.

We need this because we want to composite separate parts of the window into separate framebuffers. The easiest way to do that is to make LayerManagerComposite create multiple NativeLayers and invoke compositing separately for each NativeLayer object.

This will give the layer manager direct access to the native layers.

This lets LayerManagerComposite and RendererOGL set the correct opaque region
on the native layer.

Depends on D42400

It looks like a big patch but it's mostly just moved code, with some duplication:

  • Layer creation and destruction moves to LayerManagerComposite and RendererOGL.
  • BasicCompositor IOSurface setup code moves to BasicCompositor.cpp.
  • OpenGL IOSurface setup code moves to CompositorOGL and RenderCompositorOGL.

The duplication is a bit unfortunate but the LayerManagerComposite code will
diverge from the WebRender code soon.

BeginFrame gets a new argument aNativeLayer. This argument will go away again
over the course of this patch queue. But for now, BeginFrame is the best place
to do the layer setup because it's a very close place to PreRender which is
where that code was previously.

I wasn't able to think of a nice way to give CompositorOGL and BasicCompositor
platform-specific behavior without #ifdefs. So now LayerManagerComposite uses
the "cross-platform" NativeLayer interface, but CompositorOGL and
BasicCompositor use NativeLayerCA because they actually need the IOSurface, and
they do that in #ifdef'd code.
Luckily, NativeLayerCA.h can be included in both .cpp files and in .mm files.

Depends on D42401

This makes CompositorOGL always render into offscreen render targets.
CompositorOGL no longer expects the GLContext to have a default framebuffer.
This duplicates a bunch of code from GLContextCGL, but that code can be removed
from GLContextCGL once WebRender no longer needs it.
This also makes it so that we don't recreate render targets on every frame;
instead, we create one render target for every IOSurface in the native layer's
"swap chain" and cycle through those render targets. We only throw away the
render targets when the window is resized or closed.

Depends on D42404

On platforms that don't use native layers for rendering, we usually want reftests
to see exactly what's going to end up in the window. It's conceivable that
rendering into offscreen framebuffers might miss bugs on those platforms (though
I'm not sure if we've seen any evidence of this).
But when we're rendering to native layers, we have non-default framebuffers either
way, so we might as well create our own framebuffer rather than asking a native
layer for one. We're not interested in getting this rendering to the screen, so
it's better to leave the native layer out of this.

Depends on D42405

The goal is to have three methods: BeginRenderingToWindow,
BeginRenderingToTarget, and BeginRenderingToLayer. All three of them would have
a corresponding EndRenderingToXYZ method. They'd be called between BeginFrame
and EndFrame.
This is the first step.

Depends on D42406

This means that the compositors now never have a target and a native layer at
the same time. So on platforms with native layers, "target" rendering won't go
to the screen anymore.

Depends on D42407

All these transformations should be completely behavior-preserving under the
current call paths. aClipRectOut is always non-null if aClipRectIn is null and
vise-versa.

Depends on D42408

This removes the aNativeLayer argument from BeginRenderingToWindow.

This duplicates quite a bit of code. I intend to clean up that duplication in
the future. But for now I want to allow these paths to diverge. It'll be easier
to share code once we see how the pieces fall into place.

Depends on D42410

It turns out there's not much benefit to creating the DrawTarget at the beginning of the frame.
It's only needed between NormalDrawingDone() and EndFrame().

Depends on D42411

This makes it clear that the other callers of CreateRenderTargetForWindow
never use a back buffer. (They always passed in BufferMode::BUFFER_NONE.)

Depends on D42412

Depends on D42413

Blocks: 1574745
Attachment #9086222 - Attachment is obsolete: true
Attachment #9086223 - Attachment is obsolete: true
Attachment #9086224 - Attachment is obsolete: true
Attachment #9086225 - Attachment is obsolete: true
Attachment #9086226 - Attachment is obsolete: true
Attachment #9086228 - Attachment is obsolete: true
Attachment #9086229 - Attachment is obsolete: true
Attachment #9086230 - Attachment is obsolete: true
Pushed by mstange@themasta.com:
https://hg.mozilla.org/integration/autoland/rev/de0c56e1ffad
Add CompositorWidget::GetNativeLayerRoot. r=mattwoodrow
https://hg.mozilla.org/integration/autoland/rev/c6d52b09f158
Add CompositorWidget::GetOpaqueWidgetRegion. r=mattwoodrow
https://hg.mozilla.org/integration/autoland/rev/a63deabe60b2
Move NativeLayer management out of nsChildView and into LayerManagerComposite and RendererOGL. r=mattwoodrow
https://hg.mozilla.org/integration/autoland/rev/587f31c95710
Remove now-unused CompositorWidget::DoCompositorCleanup again. r=mattwoodrow
https://hg.mozilla.org/integration/autoland/rev/2067452a1f90
Remove unused CompositorWidget::DrawWindowUnderlay. r=mattwoodrow
https://hg.mozilla.org/integration/autoland/rev/31348057830b
Create a render target per IOSurface, laying the groundwork for multiple native layers. r=mattwoodrow
https://hg.mozilla.org/integration/autoland/rev/717f127c6729
When rendering into a copy target with CompositorOGL, and the window uses native layers for rendering, render into an offscreen RenderTarget instead of using a native layer. r=mattwoodrow
Blocks: 1578099
Regressions: 1578330
Regressions: 1580736
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: