Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed PrimitiveMetadata inside Primitive struct. #2965

Merged
merged 11 commits into from Aug 12, 2018

Conversation

@gw3583
Copy link
Collaborator

gw3583 commented Aug 10, 2018

This is another small step to moving primitives to be stored inside Picture structs, which will simplify some of the picture caching work.

While making that change, I also tidied up some of the prim_store code by moving several of the methods into the Primitive struct. I've done each of these as a separate commit to make it easier to review.

There's no functional changes here - just moving code around to make the picture caching work easier. There's also quite a few array indexing operations removed, which might be a small performance win.


This change is Reviewable

@gw3583
Copy link
Collaborator Author

gw3583 commented Aug 10, 2018

r? @kvark

This looks like a big PR, but most of it is just moving methods around as a result of the first commit. I tried to separate each method change into a single commit to make it easier to review.

Try run here:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=9ee64481c801ff2df8b85fa01e915a598fac9e13

There's a few orange items, but I think they are all unrelated - probably best to take a quick look to make sure though.

@kvark
kvark approved these changes Aug 10, 2018
Copy link
Member

kvark left a comment

There is a ton of things moved around, making it difficult to review. But overall I believe the changes are straightforward and improving our code. :lgtm:

Reviewed 5 of 5 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4, 1 of 1 files at r5, 1 of 1 files at r6, 1 of 1 files at r7, 1 of 1 files at r8, 1 of 1 files at r9, 1 of 1 files at r10.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @gw3583)


webrender/src/batch.rs, line 1573 at r1 (raw file):

}

trait AlphaBatchHelpers {

glad to see this going away :)


webrender/src/picture.rs, line 225 at r1 (raw file):

    }

    pub fn update_local_rect(

re-assigning the runs here goes across the name of the method, need to think of a better name


webrender/src/prim_store.rs, line 1196 at r1 (raw file):

pub enum PrimitiveDetails {
    Brush(BrushPrimitive),
    TextRun(TextRunPrimitiveCpu),

Would be nice to make this more consistent: either BrushPrimitiveCpu or TextRunPrimitive


webrender/src/prim_store.rs, line 1201 at r1 (raw file):

pub struct Primitive {
    pub metadata: PrimitiveMetadata,
    pub details: PrimitiveDetails,

I'm a tiny bit worried that putting those together (as in - going with array of structures versus structure of arrays) would hurt our data locality.


webrender/src/prim_store.rs, line 1207 at r1 (raw file):

    pub fn as_pic(&self) -> &PicturePrimitive {
        match self.details {
            PrimitiveDetails::Brush(ref brush) => {

nit: could do in a single match: PrimitiveDerails::Brush(BrushPrimitive { kind: BrushKind::Picture(), .. })


webrender/src/prim_store.rs, line 1442 at r1 (raw file):

        // the collapsed primitive will be drawn directly into the
        // parent picture.
        self.get_pic_mut(pic_prim_index).composite_mode = None;

Sounds like we can move it into the match arm and call an prim itself. Perhaps, we'll not need the get_pic_mut wrapper at all then?


webrender/src/prim_store.rs, line 2640 at r2 (raw file):

}

fn write_brush_segment_description(

eh, it's hard to review this function since it's moved


webrender/src/prim_store.rs, line 2348 at r5 (raw file):

    fn prepare_prim_for_render_inner(
        &mut self,
        prim_index: PrimitiveIndex,

a bit strange now that this function requires the primitive index


webrender/src/prim_store.rs, line 2377 at r5 (raw file):

            }
            PrimitiveDetails::Brush(ref mut brush) => {

nit: extra line?


webrender/src/prim_store.rs, line 2388 at r5 (raw file):

                        ref mut visible_tiles,
                        ..
                    } => {

we need to refactor this match arm in the future, it has too much logic


webrender/src/prim_store.rs, line 2722 at r7 (raw file):

        if let BrushKind::Border { ref mut source, .. } = brush.kind {
            if let BorderSource::Border {

nit: can combine in a single if let to reduce indentation

@kvark
Copy link
Member

kvark commented Aug 10, 2018

@gw3583 feel free to r=me if having no desire to address the nits :)

@bors-servo
Copy link
Contributor

bors-servo commented Aug 10, 2018

The latest upstream changes (presumably #2966) made this pull request unmergeable. Please resolve the merge conflicts.

@gw3583 gw3583 force-pushed the gw3583:embed-metadata branch from 4c6bc52 to b8b6406 Aug 12, 2018
Copy link
Collaborator Author

gw3583 left a comment

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @kvark and @gw3583)


webrender/src/batch.rs, line 1573 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

glad to see this going away :)

Done.


webrender/src/picture.rs, line 225 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

re-assigning the runs here goes across the name of the method, need to think of a better name

Done.


webrender/src/prim_store.rs, line 1196 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

Would be nice to make this more consistent: either BrushPrimitiveCpu or TextRunPrimitive

Done.


webrender/src/prim_store.rs, line 1201 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

I'm a tiny bit worried that putting those together (as in - going with array of structures versus structure of arrays) would hurt our data locality.

It's possible - we don't do a huge amount of work that operates only on one struct and not the other. But it's something we could reconsider after profiling when the prims are embedded in the picture structs.


webrender/src/prim_store.rs, line 1207 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

nit: could do in a single match: PrimitiveDerails::Brush(BrushPrimitive { kind: BrushKind::Picture(), .. })

Done


webrender/src/prim_store.rs, line 1442 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

Sounds like we can move it into the match arm and call an prim itself. Perhaps, we'll not need the get_pic_mut wrapper at all then?

We have a mutable borrow on a different primitive in that array inside the match.


webrender/src/prim_store.rs, line 2640 at r2 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

eh, it's hard to review this function since it's moved

It's the same functionality, just with more self :)


webrender/src/prim_store.rs, line 2348 at r5 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

a bit strange now that this function requires the primitive index

Yea - it's used as part of the cache key for pictures. Not ideal, but needed for now.


webrender/src/prim_store.rs, line 2377 at r5 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

nit: extra line?

Done


webrender/src/prim_store.rs, line 2388 at r5 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

we need to refactor this match arm in the future, it has too much logic

Agreed


webrender/src/prim_store.rs, line 2722 at r7 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

nit: can combine in a single if let to reduce indentation

Done

@gw3583
Copy link
Collaborator Author

gw3583 commented Aug 12, 2018

Addressed all comments. Merging now since this is prone to rebase issues.

@bors-servo r=kvark

@bors-servo
Copy link
Contributor

bors-servo commented Aug 12, 2018

📌 Commit b8b6406 has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Aug 12, 2018

Testing commit b8b6406 with merge a16e311...

bors-servo added a commit that referenced this pull request Aug 12, 2018
Embed PrimitiveMetadata inside Primitive struct.

This is another small step to moving primitives to be stored inside Picture structs, which will simplify some of the picture caching work.

While making that change, I also tidied up some of the prim_store code by moving several of the methods into the Primitive struct. I've done each of these as a separate commit to make it easier to review.

There's no functional changes here - just moving code around to make the picture caching work easier. There's also quite a few array indexing operations removed, which might be a small performance win.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2965)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 12, 2018

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: kvark
Pushing a16e311 to master...

@bors-servo bors-servo merged commit b8b6406 into servo:master Aug 12, 2018
3 of 4 checks passed
3 of 4 checks passed
code-review/reviewable 3 files, 8 discussions left (kvark)
Details
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Aug 12, 2018
0 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.