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

Add a ClearRectangle item type. #1929

Merged
merged 1 commit into from Oct 31, 2017
Merged

Add a ClearRectangle item type. #1929

merged 1 commit into from Oct 31, 2017

Conversation

@mstange
Copy link
Contributor

mstange commented Oct 24, 2017

Fixes #1926.

I haven't extensively tested this yet. This draws ClearRectangle items as Rectangle primitives with opaque black and operator destination out.
I'm not really sure how to optimize the case where we don't need blending, because the color is set on the primitive before we decide how to blend it. But if there's no blending, we need to set the color to transparent black instead of opaque black.


This change is Reviewable

@bors-servo
Copy link
Contributor

bors-servo commented Oct 24, 2017

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

@mstange mstange force-pushed the mstange:clear-rect branch 4 times, most recently from fdfac1e to a7af4aa Oct 25, 2017
@mstange
Copy link
Contributor Author

mstange commented Oct 25, 2017

Somehow this change causes my back button's white fill to ignore the rounded clip. Will investigate.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 25, 2017

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

@@ -385,7 +385,7 @@ impl FrameBuilder {
self.add_solid_rectangle(
clip_and_scroll,
&info,
&border.top.color,
&FillOrClear::Fill(border.top.color),

This comment has been minimized.

@kvark

kvark Oct 26, 2017

Member

"XxxxOrYyy" pattern sounds a bit awkward to me. Perhaps, we could go with something like Fill::Color versus Fill::Clear ?

return;
}
let prim = match operation {
&FillOrClear::Fill(ref color) => {

This comment has been minimized.

@kvark

kvark Oct 26, 2017

Member

Could also be RectangleContent::Fill/Clear

This comment has been minimized.

@mstange

mstange Oct 28, 2017

Author Contributor

I went with this suggestion, RectangleContent::Fill/Clear. Thanks!

&FillOrClear::Fill(ref color) => {
// Don't add transparent rectangles to the draw list, but do consider them for hit
// testing. This allows specifying invisible hit testing areas.
if color.a == 0.0 {

This comment has been minimized.

@kvark

kvark Oct 26, 2017

Member

should probably move this condition up into the matching, maybe even turn it into an if/let i.e.

if let &FillOrClear::Fill(ColorF{a: 0.0, ..}) = operation {
   (something something return)
}
let prim = RectanglePrimitive { operation: *operation };
@mstange mstange force-pushed the mstange:clear-rect branch from a7af4aa to 6ce56c5 Oct 28, 2017
@mstange
Copy link
Contributor Author

mstange commented Oct 28, 2017

I've addressed the comments. I added a TODO for the missing optimization but didn't address it. I suppose I could make AlphaRenderItem::add_to_batch (which knows the chosen blend mode, and whether blending is needed) write a piece of information into the data that's passed to the shader, and then I could modify the rectangle shader to respect that piece of information to switch between opaque black and transparency... but that seems awful.

r? @glennw

@mstange mstange changed the title [WIP] Add a ClearRectangle item type. Add a ClearRectangle item type. Oct 28, 2017
Copy link
Member

glennw left a comment

A couple of minor changes, otherwise this looks great!

}
}
SpecificDisplayItem::ClearRectangle => {
if !self.try_to_add_rectangle_splitting_on_clip(

This comment has been minimized.

@glennw

glennw Oct 29, 2017

Member

Let's not bother trying to split clear rectangles - we can just directly call add_solid_rectangle here.

@@ -138,6 +138,7 @@ pub struct PrimitiveMetadata {
pub cpu_prim_index: SpecificPrimitiveIndex,
pub gpu_location: GpuCacheHandle,
pub clip_task_id: Option<RenderTaskId>,
pub is_clear: bool,

This comment has been minimized.

@glennw

glennw Oct 29, 2017

Member

This should be in the RectanglePrimitive type since it's not common to all primitives.

This comment has been minimized.

@mstange

mstange Oct 29, 2017

Author Contributor

How do I get access to the RectanglePrimitive inside get_blend_mode?

This comment has been minimized.

@glennw

glennw Oct 30, 2017

Member

Something like:

let rect = &self.cpu_rectangles[metadata.cpu_prim_index.0];

should work. The TextRun primitive in the same function does something similar.

This comment has been minimized.

@mstange

mstange Oct 30, 2017

Author Contributor

Thanks!

@bors-servo
Copy link
Contributor

bors-servo commented Oct 30, 2017

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

@mstange mstange force-pushed the mstange:clear-rect branch from 6ce56c5 to fb8b6b3 Oct 30, 2017
@mstange
Copy link
Contributor Author

mstange commented Oct 30, 2017

I've addressed the comments.

@mstange
Copy link
Contributor Author

mstange commented Oct 31, 2017

r? @glennw

@glennw
glennw approved these changes Oct 31, 2017
@glennw
Copy link
Member

glennw commented Oct 31, 2017

@bors-servo r+

I think the opacity type for a clear rectangle does work - we can easily change it if required, since this is a new interface.

It would be good to add some wrench reftests as a follow up.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 31, 2017

📌 Commit fb8b6b3 has been approved by glennw

@bors-servo
Copy link
Contributor

bors-servo commented Oct 31, 2017

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

@bors-servo
Copy link
Contributor

bors-servo commented Oct 31, 2017

🔒 Merge conflict

@mstange mstange force-pushed the mstange:clear-rect branch from fb8b6b3 to 52da7ba Oct 31, 2017
@mstange
Copy link
Contributor Author

mstange commented Oct 31, 2017

Rebased. r? @glennw

@glennw
Copy link
Member

glennw commented Oct 31, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Oct 31, 2017

📌 Commit 52da7ba has been approved by glennw

@bors-servo
Copy link
Contributor

bors-servo commented Oct 31, 2017

Testing commit 52da7ba with merge c0194de...

bors-servo added a commit that referenced this pull request Oct 31, 2017
Add a ClearRectangle item type.

Fixes #1926.

I haven't extensively tested this yet. This draws ClearRectangle items as Rectangle primitives with opaque black and operator destination out.
I'm not really sure how to optimize the case where we don't need blending, because the color is set on the primitive before we decide how to blend it. But if there's no blending, we need to set the color to transparent black instead of opaque black.

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

bors-servo commented Oct 31, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: glennw
Pushing c0194de to master...

@bors-servo bors-servo merged commit 52da7ba into servo:master Oct 31, 2017
4 checks passed
4 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
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

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