-
Notifications
You must be signed in to change notification settings - Fork 292
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
Conversation
* 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).
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? |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is broken
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems unused?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation broken
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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?..
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@kvark Thanks for the review, comments addressed. |
@bors-servo: r+ |
📌 Commit fc999d0 has been approved by |
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 -->
☀️ Test successful - status-travis |
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
[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 -->
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
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
This change is