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

Implement paint worklets rendering context #17326

Merged

Conversation

asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Jun 14, 2017

Implement the rendering context for paint worklets. They really paint things now!


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes do not require tests because the existing reftest now passes

This change is Reviewable

@asajeffrey asajeffrey added A-content/css Interacting with CSS from web content (parsing, serializing, introspection) A-content/script Related to the script thread labels Jun 14, 2017
@highfive
Copy link

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/paintrenderingcontext2d.rs, components/script/dom/bindings/refcounted.rs, components/script/dom/webidls/PaintWorkletGlobalScope.webidl, components/script/dom/workletglobalscope.rs, components/script/dom/canvasrenderingcontext2d.rs and 14 more
  • @fitzgen: components/script/dom/paintrenderingcontext2d.rs, components/script/dom/bindings/refcounted.rs, components/script/dom/webidls/PaintWorkletGlobalScope.webidl, components/script/dom/workletglobalscope.rs, components/script/dom/canvasrenderingcontext2d.rs and 14 more
  • @emilio: components/layout/display_list_builder.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 14, 2017
@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@asajeffrey
Copy link
Member Author

The commit "Implemented paint worklets invoking worklet scripts." is #17239.

@asajeffrey
Copy link
Member Author

cc @jdm @metajack @tschneidereit

return self.send_invalid_image(size, sender);
}
// Step 5.4
entry.insert(Heap::new(paint_instance.get()));
Copy link
Member

Choose a reason for hiding this comment

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

I'm just going to flag this now - we must not introduce any new uses of Heap::new into Servo due to servo/rust-mozjs#343 . Use Heap::default to create a Heap value and ensure it will never move after that point before calling Heap::set. This hashtable looks very scary to me for this reason :(

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh good point.

Copy link
Member Author

Choose a reason for hiding this comment

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

My proposed fix: 660d8dd

let context = PaintRenderingContext2D::new(self);
let definition = PaintDefinition {
class_constructor: Heap::new(ObjectValue(paint_obj.get())),
paint_function: Heap::new(paint_function),
Copy link
Member

Choose a reason for hiding this comment

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

These also need to be changed.

@bors-servo
Copy link
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 16, 2017
@asajeffrey asajeffrey force-pushed the script-paint-worklets-rendering-context branch from 660d8dd to 137760e Compare June 20, 2017 16:21
@bors-servo
Copy link
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 22, 2017
@asajeffrey asajeffrey force-pushed the script-paint-worklets-rendering-context branch from 137760e to ab8024d Compare June 22, 2017 21:56
asajeffrey pushed a commit to asajeffrey/servo that referenced this pull request Jun 23, 2017
asajeffrey pushed a commit to asajeffrey/servo that referenced this pull request Jun 28, 2017
@asajeffrey asajeffrey force-pushed the script-paint-worklets-rendering-context branch 2 times, most recently from 74c3026 to 4fcf2d7 Compare June 30, 2017 15:56
@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Jun 30, 2017
@asajeffrey
Copy link
Member Author

#17239 landed, so this PR is now unblocked. @jdm?

@@ -347,7 +358,7 @@ impl CanvasRenderingContext2D {

let smoothing_enabled = self.state.borrow().image_smoothing_enabled;

if &*self.canvas == canvas {
if self.canvas.as_ref().map(|c| &**c == canvas).unwrap_or(false) {
Copy link
Member

Choose a reason for hiding this comment

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

map_or instead of map.unwrap_or

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

self.context.Save()
}

#[allow(unrooted_must_root)]
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed. Serves me right cutting-and-pasting from CanvasRenderingContext2D.

{
// TODO: document paint definitions.
self.invoke_a_paint_callback(name, size, sender);
}

/// https://drafts.css-houdini.org/css-paint-api/#invoke-a-paint-callback
#[allow(unrooted_must_root)]
Copy link
Member

Choose a reason for hiding this comment

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

What's this for?

Copy link
Member Author

Choose a reason for hiding this comment

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

Apparently nothing, I removed it.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jun 30, 2017
asajeffrey pushed a commit to asajeffrey/servo that referenced this pull request Jun 30, 2017
@asajeffrey
Copy link
Member Author

@bors-servo: r=jdm

@bors-servo
Copy link
Contributor

📌 Commit e32817c has been approved by jdm

@highfive highfive assigned jdm and unassigned emilio Jun 30, 2017
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jun 30, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit e32817c with merge f129f38...

bors-servo pushed a commit that referenced this pull request Jun 30, 2017
…text, r=jdm

Implement paint worklets rendering context

<!-- Please describe your changes on the following line: -->

Implement the rendering context for paint worklets. They really paint things now!

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because the existing reftest now passes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

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

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jun 30, 2017
@asajeffrey asajeffrey force-pushed the script-paint-worklets-rendering-context branch from e32817c to 328fb25 Compare June 30, 2017 21:41
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Jun 30, 2017
@asajeffrey
Copy link
Member Author

Updated test expectations. @bors-servo r=jdm

@bors-servo
Copy link
Contributor

📌 Commit 328fb25 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jun 30, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit 328fb25 with merge a9fea06...

bors-servo pushed a commit that referenced this pull request Jun 30, 2017
…text, r=jdm

Implement paint worklets rendering context

<!-- Please describe your changes on the following line: -->

Implement the rendering context for paint worklets. They really paint things now!

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because the existing reftest now passes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

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

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: jdm
Pushing a9fea06 to master...

@bors-servo bors-servo merged commit 328fb25 into servo:master Jun 30, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 30, 2017
bors-servo pushed a commit that referenced this pull request Jul 11, 2017
…=jdm

Implement paint worklet properties

<!-- Please describe your changes on the following line: -->

This is the final PR to get basic paint worklet support. It adds support for paint worklet properties (https://drafts.css-houdini.org/css-paint-api/#paint-definition-input-properties). When a paint worklet is registered, it specifies a list of CSS properties, and is provided with their computed values when it is invoked.

This is a dependent PR:
* "Implemented paint worklets invoking worklet scripts" is #17239.
* "Implemented paint worklets rendering contexts" is #17326.

There should be tests added for this, hopefully the existing wpt houdini tests.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #16839
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17364)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Jul 11, 2017
…=jdm

Implement paint worklet properties

<!-- Please describe your changes on the following line: -->

This is the final PR to get basic paint worklet support. It adds support for paint worklet properties (https://drafts.css-houdini.org/css-paint-api/#paint-definition-input-properties). When a paint worklet is registered, it specifies a list of CSS properties, and is provided with their computed values when it is invoked.

This is a dependent PR:
* "Implemented paint worklets invoking worklet scripts" is #17239.
* "Implemented paint worklets rendering contexts" is #17326.

There should be tests added for this, hopefully the existing wpt houdini tests.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #16839
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17364)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Jul 20, 2017
Fixed scaling artefacts in paint worklets caused by zoom and hidpi

<!-- Please describe your changes on the following line: -->

This PR renders paint worklet canvases at the device pixel resolution, rather than the CSS pixel resolution.

It's a dependent PR, building on #17239, #17326 and #17364.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #17454
- [X] These changes do not require tests because we don't run reftests with zoom enabled

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17499)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Jul 21, 2017
Fixed scaling artefacts in paint worklets caused by zoom and hidpi

<!-- Please describe your changes on the following line: -->

This PR renders paint worklet canvases at the device pixel resolution, rather than the CSS pixel resolution.

It's a dependent PR, building on #17239, #17326 and #17364.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #17454
- [X] These changes do not require tests because we don't run reftests with zoom enabled

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17499)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/css Interacting with CSS from web content (parsing, serializing, introspection) A-content/script Related to the script thread
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants