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 upImprove rendering of transformed 2d paths #21310
Conversation
|
r? @pcwalton |
| @@ -183,36 +185,50 @@ impl<'a> CanvasData<'a> { | |||
| } | |||
|
|
|||
| pub fn begin_path(&mut self) { | |||
| self.path_builder = self.drawtarget.create_path_builder() | |||
| self.path_builder = self.drawtarget.create_path_builder(); | |||
| self.path = None; | |||
This comment has been minimized.
This comment has been minimized.
pcwalton
Aug 1, 2018
Contributor
Shouldn't all functions that touch the path builder also invalidate this cached Path?
Maybe we should have an accessor for &mut path_builder that first invalidates the cached Path, and redirect all direct mutable access to self.path_builder through that.
| /// User-space path builder. | ||
| path_builder: Option<PathBuilder>, | ||
| /// Device-space path builder, if transforms are added during path building. | ||
| device_space_path_builder: Option<PathBuilder>, |
This comment has been minimized.
This comment has been minimized.
pcwalton
Aug 1, 2018
Contributor
Why do we need to store the user-space path? Could we just store the path in device space?
|
Comments addressed and the resulting state machine is much nicer to reason about than the collection of members. |
| Some(PathState::UserSpacePathBuilder(_, ref mut transform)) | | ||
| Some(PathState::UserSpacePath(_, ref mut transform)) => { | ||
| if transform.is_none() { | ||
| *transform = Some(self.drawtarget.get_transform()); |
This comment has been minimized.
This comment has been minimized.
pcwalton
Aug 7, 2018
Contributor
So if you call set_transform twice in a row, only the first one will take effect on the PathState (because on the second one, the transform will not be None anymore). Is that correct behavior?
This comment has been minimized.
This comment has been minimized.
jdm
Feb 7, 2019
Author
Member
This is correct. The transform that is stored is the transform that applies to all existing points on the path and needs to be applied to those points when creating the device space path builder.
|
|
|
All review comments addressed. |
|
r=me. Looks good! |
|
@bors-servo r=pcwalton |
|
|
Improve rendering of transformed 2d paths This makes http://webglreport.com/ render correctly by porting the [equivalent code](https://searchfox.org/mozilla-central/rev/196560b95f191b48ff7cba7c2ba9237bba6b5b6a/dom/canvas/CanvasRenderingContext2D.h#847-875) from Gecko's 2d canvas implementation that handles paths with transformations. The first commit fixes the rendering issue, and the second commit fixes some new test failures that were exposed by that change. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #21169 - [x] There are tests for these changes <!-- 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/21310) <!-- Reviewable:end -->
|
|
jdm commentedAug 1, 2018
•
edited
This makes http://webglreport.com/ render correctly by porting the equivalent code from Gecko's 2d canvas implementation that handles paths with transformations. The first commit fixes the rendering issue, and the second commit fixes some new test failures that were exposed by that change.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is