Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRefactor how text shadows and elements are handled. #1498
Merged
+380
−447
Conversation
|
r? @kvark Sorry for another large patch on this stuff! |
|
Looks like a great cleanup! |
| @@ -22,7 +33,7 @@ void main(void) { | |||
| vec2 size = res.uv_rect.zw - res.uv_rect.xy; | |||
| vec2 local_pos = glyph.offset + vec2(res.offset.x, -res.offset.y) / uDevicePixelRatio; | |||
| vec2 origin = prim.task.render_target_origin + | |||
| uDevicePixelRatio * (text.offset + local_pos); | |||
| uDevicePixelRatio * (local_pos + shadow.offset - shadow_geom.local_rect.p0); | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
webrender/src/frame_builder.rs
Outdated
| local_clip, | ||
| clip_and_scroll); | ||
| } else if color.a > 0.0 { | ||
| let mut shadows = Vec::new(); |
This comment has been minimized.
This comment has been minimized.
| for shadow_prim_index in &self.shadow_prim_stack { | ||
| let shadow_metadata = &self.prim_store.cpu_metadata[shadow_prim_index.0]; | ||
| let shadow_prim = &self.prim_store.cpu_text_shadows[shadow_metadata.cpu_prim_index.0]; | ||
| if shadow_prim.shadow.blur_radius == 0.0 { |
This comment has been minimized.
This comment has been minimized.
kvark
Jul 19, 2017
Member
somewhat unfortunate that we already have the same loop at the start of the function, maybe we could combine them?
This comment has been minimized.
This comment has been minimized.
glennw
Jul 19, 2017
Author
Member
Unfortunately, we need to do part of it before adding the prim and part afterwards.
webrender/src/prim_store.rs
Outdated
| // text shadow primitives. Consider restructuring this code to | ||
| // avoid borrow checker issues. | ||
| match prim_kind { | ||
| PrimitiveKind::TextShadow => { |
This comment has been minimized.
This comment has been minimized.
|
r=me whether or not the notes are addressed |
While working on adding line decorations, I kept running into issues and extra complexity. Instead, I've refactored how text shadow contexts are handled. The implementation is a bit complex in parts, but conceptually this fits in much better with how the frame builder, prim store and GPU cache work. Now, text-shadow primitives add text runs and decorations as sub-primitives, using an index buffer of primitives. This means: * The code to manage the text-element stack and maintain correct paint order is much simpler. * The GPU cache layouts are much simpler. Text runs and decorations within a text-shadow element have the same layout as normal primitives (no weird offsets and packed layouts). * Text primitives that have both visual and shadows (which is the common case) share the same GPU primitive - so they only get built and uploaded once. This is quite a large performance win on pages with a lot of shadows. * The code to truncate glyph positions is moved from the CPU to the vertex shader, which is a significant performance win. * The paint order of shadows is reversed from the previous implementation, back to what it was originally.
|
@kvark Thanks, issued addressed or explained above. @bors-servo r=kvark |
|
|
bors-servo
added a commit
that referenced
this pull request
Jul 19, 2017
Refactor how text shadows and elements are handled. While working on adding line decorations, I kept running into issues and extra complexity. Instead, I've refactored how text shadow contexts are handled. The implementation is a bit complex in parts, but conceptually this fits in much better with how the frame builder, prim store and GPU cache work. Now, text-shadow primitives add text runs and decorations as sub-primitives, using an index buffer of primitives. This means: * The code to manage the text-element stack and maintain correct paint order is much simpler. * The GPU cache layouts are much simpler. Text runs and decorations within a text-shadow element have the same layout as normal primitives (no weird offsets and packed layouts). * Text primitives that have both visual and shadows (which is the common case) share the same GPU primitive - so they only get built and uploaded once. This is quite a large performance win on pages with a lot of shadows. * The code to truncate glyph positions is moved from the CPU to the vertex shader, which is a significant performance win. * The paint order of shadows is reversed from the previous implementation, back to what it was originally. <!-- 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/1498) <!-- Reviewable:end -->
|
|
This was referenced Jul 19, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
glennw commentedJul 19, 2017
•
edited by larsbergstrom
While working on adding line decorations, I kept running into
issues and extra complexity. Instead, I've refactored how
text shadow contexts are handled. The implementation is a bit
complex in parts, but conceptually this fits in much better with
how the frame builder, prim store and GPU cache work.
Now, text-shadow primitives add text runs and decorations as
sub-primitives, using an index buffer of primitives. This means:
paint order is much simpler.
within a text-shadow element have the same layout as normal
primitives (no weird offsets and packed layouts).
common case) share the same GPU primitive - so they only get
built and uploaded once. This is quite a large performance win
on pages with a lot of shadows.
to the vertex shader, which is a significant performance win.
implementation, back to what it was originally.
This change is