Closed Bug 1452620 Opened 6 years ago Closed 6 years ago

Make reading from WrPipelineInfo more ergonomic

Categories

(Core :: Graphics: WebRender, enhancement, P3)

Other Branch
enhancement

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: kats, Assigned: kats)

References

Details

(Whiteboard: [gfx-noted])

Attachments

(3 files)

Right now reading a WrPipelineInfo in C++ code means using wr_pipeline_info_next_epoch and wr_pipeline_info_next_removed_pipeline to iterate through the items, which is kinda clunky. We should just copy the structure over and expose it in c++ as an equivalent struct or something. This will also remove the awkward lifetime management where C++ code has to call wr_pipeline_info_delete to free the pointer when it's done with it.
Assignee: nobody → bugmail
This also needs documentation to indicate what exactly is being produced in the structure. (See halfway down bug 1449982 comment 30)
Comment on attachment 8966676 [details]
Bug 1452620 - Add an FfiVec structure.

https://reviewboard.mozilla.org/r/235372/#review241090

just a code-style nit

::: gfx/webrender_bindings/src/bindings.rs:188
(Diff revision 1)
> +impl<T> Drop for FfiVec<T> {
> +    fn drop(&mut self) {
> +        // turn the stuff back into a Vec and let it be freed normally
> +        let _ = unsafe {
> +            Vec::from_raw_parts(
> +                mem::transmute::<*const T, *mut T>(self.data),

transmute is an overpowered laser cannon that should be avoided, use `self.data as *mut T`
Attachment #8966676 - Flags: review?(a.beingessner) → review+
Comment on attachment 8966677 [details]
Bug 1452620 - Use FfiVec to clean up WrPipelineInfo usage in C++.

https://reviewboard.mozilla.org/r/235374/#review241118

one style nit

::: gfx/webrender_bindings/src/bindings.rs:659
(Diff revision 1)
>  }
>  
> -#[no_mangle]
> -pub unsafe extern "C" fn wr_pipeline_info_next_epoch(
> -    info: &mut WrPipelineInfo,
> -    out_pipeline: &mut WrPipelineId,
> +impl WrPipelineInfo {
> +    fn new(info: PipelineInfo) -> Self {
> +        WrPipelineInfo {
> +            epochs: FfiVec::from_vec(info.epochs.into_iter().map(|x| x.into()).collect()),

minor style/clarity nit: this *I think* could be .map(WrPipelineEpoch::from)
Attachment #8966677 - Flags: review?(a.beingessner) → review+
(In reply to Alexis Beingessner [:Gankro] from comment #7)
> > +            epochs: FfiVec::from_vec(info.epochs.into_iter().map(|x| x.into()).collect()),
> 
> minor style/clarity nit: this *I think* could be .map(WrPipelineEpoch::from)

For some reason this didn't work with my Into impl. I had to replace the Into impl with the corresponding From impl and then it worked. I thought there was Magic that automatically converted between the two but maybe not?
Comment on attachment 8966677 [details]
Bug 1452620 - Use FfiVec to clean up WrPipelineInfo usage in C++.

https://reviewboard.mozilla.org/r/235374/#review241300
Attachment #8966677 - Flags: review?(nical.bugzilla) → review+
Comment on attachment 8966678 [details]
Bug 1452620 - Document the WrPipelineInfo structure.

https://reviewboard.mozilla.org/r/235376/#review241304
Attachment #8966678 - Flags: review?(nical.bugzilla) → review+
Comment on attachment 8966678 [details]
Bug 1452620 - Document the WrPipelineInfo structure.

https://reviewboard.mozilla.org/r/235376/#review241566

Thanks!
Attachment #8966678 - Flags: review?(botond) → review+
Pushed by kgupta@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/62c96f73b6c3
Add an FfiVec structure. r=Gankro
https://hg.mozilla.org/integration/autoland/rev/fc3122cb0725
Use FfiVec to clean up WrPipelineInfo usage in C++. r=Gankro,nical
https://hg.mozilla.org/integration/autoland/rev/cfc40d3357e1
Document the WrPipelineInfo structure. r=botond,nical
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: