Closed Bug 1345523 Opened 7 years ago Closed 7 years ago

Clean up duplicated WebRenderLayer code

Categories

(Core :: Graphics: WebRender, enhancement)

53 Branch
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55

People

(Reporter: mchang, Assigned: mchang)

Details

Attachments

(4 files, 1 obsolete file)

Lots of the layers have the same duplicated code of get a rect, get clip rect, rel bounds, and dumping the layer info. Refactor it out a bit.
Attachment #8844972 - Flags: review?(bugmail)
Comment on attachment 8844972 [details] [diff] [review]
Refactor out duplicate code in WebRenderLayer

Review of attachment 8844972 [details] [diff] [review]:
-----------------------------------------------------------------

Conceptually ok, but it's hard to review and make sure there's no errors. I found at least one (see below). It might be better to split this patch into a series where you extract one method at a time. It would be much easier to review.

::: gfx/layers/wr/WebRenderLayerManager.cpp
@@ +187,5 @@
>  
> +void
> +WebRenderLayer::DumpLayersInfo(const char* aLayerType)
> +{
> +  Layer* layer = GetLayer();

You can refactor the DumpLayersInfo function to also use the helpers (GetBounds, GetWrClipRect, etc). But more importantly, move the "if (gfxPrefs::LayersDump())" guard up to the top and do an early-exit so we don't spend all this time computing variables we're never going to print.

::: gfx/layers/wr/WebRenderTextLayer.cpp
@@ -26,5 @@
>  
>      gfx::Rect rect = RelativeToParent(GetTransform().TransformBounds(IntRectToRect(mBounds)));
> -    gfx::Rect clip;
> -    if (GetClipRect().isSome()) {
> -      clip = RelativeToParent(IntRectToRect(GetClipRect().ref().ToUnknownRect()));

This one does a RelativeToParent, but GetWrClipRect does a RelativeToVisible with some transform stuff. That seems different.
Attachment #8844972 - Flags: review?(bugmail)
Attachment #8844972 - Attachment is obsolete: true
Attachment #8845018 - Flags: review?(bugmail)
Attachment #8845019 - Flags: review?(bugmail)
Comment on attachment 8845018 [details] [diff] [review]
Part 1: Extract out WrBoundsRect

Review of attachment 8845018 [details] [diff] [review]:
-----------------------------------------------------------------

Patch is backwards but otherwise r+
Attachment #8845018 - Flags: review?(bugmail) → review+
Comment on attachment 8845019 [details] [diff] [review]
Part 2: Extract out WrClipRect

Review of attachment 8845019 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/layers/wr/WebRenderLayerManager.cpp
@@ +162,5 @@
> +      clip = RelativeToVisible(transform.Inverse().TransformBounds(
> +              IntRectToRect(layer->GetClipRect().ref().ToUnknownRect()))
> +             );
> +  } else {
> +      clip = aRect;

nit: fix indent to be 2-spaces
Attachment #8845019 - Flags: review?(bugmail) → review+
Attachment #8845020 - Flags: review?(bugmail) → review+
Comment on attachment 8845022 [details] [diff] [review]
Part 4: Extract out layers logging

Review of attachment 8845022 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/layers/wr/WebRenderBorderLayer.cpp
@@ +33,5 @@
>                                 wr::ToWrRect(overflow),
>                                 nullptr,
>                                 1.0f,
>                                 //GetAnimations(),
> +                               GetLayer()->GetTransform(),

Drop the "GetLayer()->"
Attachment #8845022 - Flags: review?(bugmail) → review+
Pushed by mchang@mozilla.com:
https://hg.mozilla.org/projects/graphics/rev/0820edb5e1f5
Clean up duplicated WebRenderLayer code. r=kats
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: