Skip to content

Change text-shadow to blur entire text run, and clean up texture cache. #546

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

Merged
merged 2 commits into from
Nov 9, 2016

Conversation

glennw
Copy link
Member

@glennw glennw commented Nov 9, 2016

  • Add support for text-shadow to be drawn via render tasks on text runs.
  • Add support for blur render tasks. Uses standard 2 pass separable technique.
  • Remove a large amount of code that was used only for old glyph blur support.
  • Remove blur_radius from GlyphKey, resource cache, texture cache etc.
  • Add gaussian blur shader (cs_blur).
  • Add text run cache shader (cs_text_run).
  • Add generic primitive shader for drawing cache items (ps_cache_image).

This change is Reviewable

* Add support for text-shadow to be drawn via render tasks on text runs.
* Add support for blur render tasks. Uses standard 2 pass separable technique.
* Remove a large amount of code that was used only for old glyph blur support.
* Remove blur_radius from GlyphKey, resource cache, texture cache etc.
* Add gaussian blur shader (cs_blur).
* Add text run cache shader (cs_text_run).
* Add generic primitive shader for drawing cache items (ps_cache_image).
@glennw
Copy link
Member Author

glennw commented Nov 9, 2016

r? @pcwalton

I'm sorry that this ended up as one commit. I can separate them into a couple of commits if you would prefer?

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really appreciate the amount of deleted code in this PR. Way to go! Just a few nits I'd prefer addressed before merging.

}

// Unpremultiply the alpha.
color = vec4(color.rgb / color.a, color.a);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a longer variant of just color.rgb /= color.a

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}

void main(void) {
vec4 color = texture(sCache, vUv) * gauss(0.0, vSigma);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sample is missing alpha pre-multiplication

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

vec4 local_rect = task.data0;

vec2 pos = mix(local_rect.xy,
local_rect.xy + local_rect.zw,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation is broken

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


vec2 pos = mix(local_rect.xy,
local_rect.xy + local_rect.zw,
aPosition.xy);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is any reason not to write this as "aPosition.xy * local_rect.zw + local_rect.xy"

vBlurRadius = int(task.data1.y);
vSigma = task.data1.y * 0.5;

vec4 src_rect;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unused?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

switch (cmd.dir) {
case DIR_HORIZONTAL:
vOffsetScale = vec2(1.0 / texture_size.x, 0.0);
vUvRect = vec4(src_task.data0.xy, src_task.data0.xy + src_task.data0.zw);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any difference in vUvRect, uv0, or uv1 computation between the switch arms

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

vec2 st1 = glyph.uv_rect.zw / texture_size;

vec2 pos = mix(local_rect.xy,
local_rect.xy + local_rect.zw,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation broken

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

// text-shadow, this creates a render task chain
// that implements a 2-pass separable blur on a
// text run.
pub render_task: Option<RenderTask>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should turn it into Vec<RenderTask>. Do we ever need more than one task?..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might do in the future - it's an easy change if/when we do need it.

id: RenderTaskId::Dynamic(RenderTaskKey::VerticalBlur(blur_radius.0, prim_index)),
children: vec![prim_cache_task],
location: RenderTaskLocation::Dynamic(None, blur_target_size),
kind: RenderTaskKind::VerticalBlur(blur_radius, prim_index),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems slightly redundant, as the same info is already stored with the RenderTaskKey

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea - it makes it a bit easier to extract the info (since you don't have to match on all the key kinds). But I do agree it's a bit redundant and we might want to consider changing how this works in the future.

@glennw
Copy link
Member Author

glennw commented Nov 9, 2016

@kvark Thanks for the review, comments addressed.

@pcwalton
Copy link
Contributor

pcwalton commented Nov 9, 2016

@bors-servo: r+

@bors-servo
Copy link
Contributor

📌 Commit fc999d0 has been approved by pcwalton

@bors-servo
Copy link
Contributor

⌛ Testing commit fc999d0 with merge 106c2c8...

bors-servo pushed a commit that referenced this pull request Nov 9, 2016
Change text-shadow to blur entire text run, and clean up texture cache.

* Add support for text-shadow to be drawn via render tasks on text runs.
* Add support for blur render tasks. Uses standard 2 pass separable technique.
* Remove a large amount of code that was used only for old glyph blur support.
* Remove blur_radius from GlyphKey, resource cache, texture cache etc.
* Add gaussian blur shader (cs_blur).
* Add text run cache shader (cs_text_run).
* Add generic primitive shader for drawing cache items (ps_cache_image).

<!-- 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/546)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit fc999d0 into servo:master Nov 9, 2016
@glennw glennw deleted the text-shadow branch December 12, 2016 20:43
glennw pushed a commit to glennw/saltfs that referenced this pull request Dec 13, 2016
kvark has make several important contributions to webrender,
both as a reviewer and committer. He also has significant
Rust experience previously as the author of gfx-rs.

Some examples of recent reviews:

servo/webrender#546
servo/webrender#523
servo/webrender#561
servo/webrender#554
bors-servo pushed a commit to servo/saltfs that referenced this pull request Dec 13, 2016
[Proposal] Give @kvark reviewer privileges.

kvark has make several important contributions to webrender,
both as a reviewer and committer. He also has significant
Rust experience previously as the author of gfx-rs.

Some examples of recent reviews:

servo/webrender#546
servo/webrender#523
servo/webrender#561
servo/webrender#554

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/551)
<!-- Reviewable:end -->
Coder206 pushed a commit to Coder206/saltfs that referenced this pull request Apr 22, 2017
kvark has make several important contributions to webrender,
both as a reviewer and committer. He also has significant
Rust experience previously as the author of gfx-rs.

Some examples of recent reviews:

servo/webrender#546
servo/webrender#523
servo/webrender#561
servo/webrender#554
choudhary001 pushed a commit to choudhary001/saltfs that referenced this pull request May 27, 2017
kvark has make several important contributions to webrender,
both as a reviewer and committer. He also has significant
Rust experience previously as the author of gfx-rs.

Some examples of recent reviews:

servo/webrender#546
servo/webrender#523
servo/webrender#561
servo/webrender#554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants