Closed Bug 961887 Opened 11 years ago Closed 10 years ago

Make FindOpaqueBackgroundColorFor search parent layers for a background color

Categories

(Core :: Layout, defect, P4)

defect

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed
b2g-v2.2 --- wontfix
b2g-master --- fixed

People

(Reporter: mattwoodrow, Assigned: mstange)

References

(Depends on 1 open bug)

Details

(Keywords: perf)

Attachments

(3 files, 6 obsolete files)

Currently FindOpaqueBackgroundColorFor only searches ThebesLayer within the same ContainerLayer. It would be nice if we could also walk up the layer tree and find siblings of an ancestor to use as the background color. A simple example that would benefit from this is: <div style="opacity:0.5; will-change:opacity;>Text</div> This will force an active ContainerLayer for the opacity, and the text will have no background color, resulting in requiring component alpha.
Should this bug block bug 961871 perhaps?
Keywords: perf
OS: Mac OS X → All
Priority: -- → P4
Hardware: x86 → All
I don't think it needs to, the same effect can be had with transitions/animations too. will-change was just the easiest to write for an example.
Attached patch something like this (obsolete) — Splinter Review
Assignee: nobody → mstange
Status: NEW → ASSIGNED
This patch applies on top of the ones in bug 1018464.
Attached patch v1 (obsolete) — Splinter Review
This gives each ContainerLayer a backdrop color that it can pull up into its ThebesLayers, but only if the ContainerLayer itself has a uniform opaque color behind it. This should address the most important use cases. One thing I hope this will achieve (but which I haven't actually tested yet) is pulling colors through nsDisplayScrollLayer ContainerLayers. As far as I can tell, scrollboxes with display ports have never been able to benefit from the background color optimization.
Attachment #8431930 - Attachment is obsolete: true
Attachment #8432215 - Flags: review?(roc)
Comment on attachment 8432215 [details] [diff] [review] v1 Looks like I need to debug some reftest failures on Windows first.
Attachment #8432215 - Flags: review?(roc)
Attached patch v2 (obsolete) — Splinter Review
Attachment #8432215 - Attachment is obsolete: true
Attachment #8439873 - Flags: review?(roc)
Comment on attachment 8439873 [details] [diff] [review] v2 Review of attachment 8439873 [details] [diff] [review]: ----------------------------------------------------------------- Seems to me we could simplify this patch a lot if we made it work only when we're pulling a background color into the first layer of its container. And wouldn't that catch most of the cases we care about? ::: layout/base/FrameLayerBuilder.cpp @@ +732,5 @@ > AutoLayersArray mNewChildLayers; > nsTArray<nsRefPtr<ThebesLayer> > mRecycledThebesLayers; > nsDataHashtable<nsPtrHashKey<Layer>, nsRefPtr<ImageLayer> > > mRecycledMaskImageLayers; > + nsIntRegion mVisibleAboveBackgroundRegion; Add a comment explaining what this means @@ +737,3 @@ > uint32_t mNextFreeRecycledThebesLayer; > nscoord mAppUnitsPerDevPixel; > + nscolor mContainerUniformBackgroundColor; and this @@ +740,2 @@ > bool mSnappingEnabled; > + bool mAllDrawingAboveBackground; and this @@ +2541,5 @@ > } > > + // Prerendered transform items can be updated without layer building > + // (async animations or an empty transaction). > + bool mayChangeTransform = item->GetType() == nsDisplayItem::TYPE_TRANSFORM && use itemType @@ +2548,5 @@ > + false); > + // 3D-transformed layers don't necessarily draw in the order in which > + // they're added to their parent container layer. > + bool mayDrawOutOfOrder = (item->Frame()->Preserves3D() || > + item->Frame()->Preserves3DChildren()); can we condition this on the item being TYPE_TRANSFORM first? These might not be cheap.
Attachment #8439873 - Flags: review?(roc) → review-
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #9) > Seems to me we could simplify this patch a lot if we made it work only when > we're pulling a background color into the first layer of its container. And > wouldn't that catch most of the cases we care about? My initial motivation for this patch came from the iframe.svg test that's part of tscrollx, which has a display list tree that looks like this: [...] CanvasBackgroundColor 11b735b28(Canvas(svg)(-1)) (rgba 255,255,255,255) nsDisplayTransform 11ba6ad68(Block(foreignObject)(5)) Border 11ba6b0d0(FrameOuter(iframe src=drac.htm)(1)) SubDocument 11c83a458(Viewport(-1)) CanvasBackgroundColor 11c83b070(Canvas(html)(-1)) (rgba 0,0,0,0) [...] I'd like to be able to pull the white canvas background of the outer document into the scrolled layer of the iframe document, and the ContainerLayer of the iframe's nsDisplaySubDocument is the second child layer of the foreignObject transform ContainerLayer because there's a ThebesLayer for the iframe's border in between. So pulling only into the first layer of a container wouldn't fix this case.
I'm going to attach new patches that are on top of the patch in bug 1134311.
Depends on: 1134311
Attachment #8439873 - Attachment is obsolete: true
Attachment #8566257 - Flags: review?(roc)
Comment on attachment 8566258 [details] [diff] [review] part 2: make FindOpaqueBackgroundColorFor take a region instead of a PaintedLayerData Review of attachment 8566258 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/base/FrameLayerBuilder.cpp @@ +736,1 @@ > * has a single opaque color behind it, over the entire bounds of its visible Need to say what coordinate system this region is in.
Attachment #8566258 - Flags: review?(roc) → review+
Comment on attachment 8566259 [details] [diff] [review] part 3: find uniform opaque background colors under ContainerLayers Review of attachment 8566259 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/base/FrameLayerBuilder.cpp @@ +2999,5 @@ > > + // 3D-transformed layers don't necessarily draw in the order in which > + // they're added to their parent container layer. > + bool mayDrawOutOfOrder = itemType == nsDisplayItem::TYPE_TRANSFORM && > + (item->Frame()->Preserves3D() || item->Frame()->Preserves3DChildren()); What if the container layer has a possibly async transform on it? That should prevent us from pulling up a background color, right? I don't see how that is prevented.
Attachment #8566259 - Flags: review?(roc) → review-
Comment on attachment 8566259 [details] [diff] [review] part 3: find uniform opaque background colors under ContainerLayers Review of attachment 8566259 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/base/FrameLayerBuilder.cpp @@ +3002,5 @@ > + bool mayDrawOutOfOrder = itemType == nsDisplayItem::TYPE_TRANSFORM && > + (item->Frame()->Preserves3D() || item->Frame()->Preserves3DChildren()); > + > + // Pull up a uniform background color into the layer if possible. > + mParameters.mBackgroundColor = (prerenderedTransform || mayDrawOutOfOrder) The prerenderedTransform check here should at least cover the OMTA transform case. But I haven't really thought about the interaction with APZ. I'll think about that some more. I also need to think about how this interacts with blend modes. I think it's possible that we pull a color into a container layer that has a non-OVER blend mode, and then we see different results after blending with that background color vs. blending with transparent background.
This fixes the blend mode case. I haven't added any checks for async scrolling. There are existing ones that prevent us from pulling background colors *from* async scrolled painted layers, but none that prevent pulling *into* async scrolled layers. So it looks like the latter needs to be fixed for painted layers anyway.
Attachment #8566259 - Attachment is obsolete: true
Attachment #8567422 - Flags: review?(roc)
I had missed one "break;" here, which caused a bug. I'm adding a reftest for that bug in the part 3 patch.
Attachment #8566258 - Attachment is obsolete: true
Attachment #8567422 - Attachment is obsolete: true
Repushed with a slightly tweaked test: https://hg.mozilla.org/integration/mozilla-inbound/rev/88283631c931 https://hg.mozilla.org/integration/mozilla-inbound/rev/0c87822f9ae6 https://hg.mozilla.org/integration/mozilla-inbound/rev/70dbb97a096d If the test still fails, please ping me before backing out and I'll just fuzz it. The test is not worth wasting more time and try hours on.
Flags: needinfo?(mstange)
Added a little fuzz: https://hg.mozilla.org/integration/mozilla-inbound/rev/01d879d05fa1 Apparently we're missing one pixel of text subpixel antialiasing when calculating the text's bounds.
Depends on: 1139019
No longer depends on: 1139019
Setting status-b2g-v2.2 to wontfix, because the actual change here is in part 3, which was not uplifted in the rollup patch for bug 1146137. Only part 1 was, which only was a refactoring. I didn't uplift the other two patches because they cause a regression with overlay scrollbars and async scrolling, which was now fixed on firefox 40 / b2g 3.0 in bug 1136304.
Depends on: 1220459
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: