Closed Bug 1345907 Opened 7 years ago Closed 7 years ago

Add WebRender bindings for ClipRegion

Categories

(Core :: Graphics: WebRender, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55

People

(Reporter: rhunt, Assigned: rhunt)

References

Details

(Whiteboard: [gfx-noted])

Attachments

(2 files)

Only simple ClipRegions are supported by bindings. We should expose the full ClipRegion interface.
This adds ClipRegion to the bindings, but doesn't hook it up for DisplayList construction.

An ugly part of this patch that I am up for suggestions on is the representation of Option<ImageMask> in the ClipRegion bindings. I don't think that Maybe<T> is guaranteed to be compatible with Option<T>, so I chose to use a bool flag explictly.
Attachment #8845508 - Flags: review?(bugmail)
This patch switches DisplayList construction to use WrClipRegion instead of a WrRect.

The only two parts that weren't converted were PushStackingContext and PushScrollLayer as they aren't trivial conversions.
Attachment #8845511 - Flags: review?(bugmail)
Comment on attachment 8845508 [details] [diff] [review]
clip_region-1.patch

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

::: gfx/webrender_bindings/WebRenderAPI.cpp
@@ +583,5 @@
> +{
> +  return wr_dp_new_clip_region(mWrState,
> +                               aMain,
> +                               nullptr, 0,
> +                               nullptr);

This last nullptr should be aMask

::: gfx/webrender_bindings/src/bindings.rs
@@ +918,5 @@
> +            start: self.start,
> +            length: self.length,
> +        }
> +    }
> +    fn from_item_range(item_range: ItemRange) -> WrItemRange

This doesn't matter much but I think it would be more idiomatic Rust to implement these "from" methods as From trait implementations - https://doc.rust-lang.org/std/convert/trait.From.html

So you'd do:

impl From<ItemRange> for WrItemRange {
  pub fn from(item_range: ItemRange) -> Self {
    ...
  }
}

That should allow you to implicitly convert from ItemRange to WrItemRange in places, without having to explicitly call from_item_range.
Attachment #8845508 - Flags: review?(bugmail) → review+
(In reply to Ryan Hunt [:rhunt] from comment #1)
> An ugly part of this patch that I am up for suggestions on is the
> representation of Option<ImageMask> in the ClipRegion bindings. I don't
> think that Maybe<T> is guaranteed to be compatible with Option<T>, so I
> chose to use a bool flag explictly.

I think the way you did it is good (and safe). I agree that we shouldn't assume Maybe<T> is compatible with Option<T>.
Comment on attachment 8845511 [details] [diff] [review]
clip_region-2.patch

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

::: gfx/webrender_bindings/WebRenderAPI.cpp
@@ +582,5 @@
>  {
>    return wr_dp_new_clip_region(mWrState,
>                                 aMain,
>                                 nullptr, 0,
> +                               aMask);

Oh here it is :)
Attachment #8845511 - Flags: review?(bugmail) → review+
Pushed by rhunt@eqrion.net:
https://hg.mozilla.org/projects/graphics/rev/b5e63c017148
Add bindings for ClipRegion r=kats
https://hg.mozilla.org/projects/graphics/rev/e659fa15902a
Use clip region instead of clip rect r=kats
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #6)
> Comment on attachment 8845511 [details] [diff] [review]
> clip_region-2.patch
> 
> Review of attachment 8845511 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: gfx/webrender_bindings/WebRenderAPI.cpp
> @@ +582,5 @@
> >  {
> >    return wr_dp_new_clip_region(mWrState,
> >                                 aMain,
> >                                 nullptr, 0,
> > +                               aMask);
> 
> Oh here it is :)

Ah, histedit fail. I fixed this in the patch I push.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: