Auto merge of #24422 - pylbrecht:raqote, r=jdm

Use raqote for 2D canvas rendering

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

---
<!-- 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 #23431

<!-- Either: -->

<!-- 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/24422)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-10-16 09:12:17 -04:00 committed by GitHub
commit bcd8c5e597
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

8
Cargo.lock generated
View file

@ -3886,8 +3886,8 @@ dependencies = [
[[package]] [[package]]
name = "raqote" name = "raqote"
version = "0.6.5-alpha.0" version = "0.7.4-alpha.0"
source = "git+https://github.com/jrmuizel/raqote#c9d6d9c65ffac5fe91e2699f9854b3fbaa3c85c2" source = "git+https://github.com/jrmuizel/raqote#2a801bca7253e053767ef5ea11b0ee77c52617c9"
dependencies = [ dependencies = [
"euclid", "euclid",
"font-kit", "font-kit",
@ -5090,9 +5090,9 @@ checksum = "c666f0fed8e1e20e057af770af9077d72f3d5a33157b8537c1475dd8ffd6d32b"
[[package]] [[package]]
name = "sw-composite" name = "sw-composite"
version = "0.5.10" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5eba1755094da86216f071f7a28b0453345c3e6e558ea2fd7821c55eef8fb9b2" checksum = "71bd71d7772bdbb7e5fbe37f767c5b2506bd23e72c12186a63f78c0980f64e9b"
[[package]] [[package]]
name = "swapper" name = "swapper"

View file

@ -180,9 +180,11 @@ impl DrawOptions {
impl Path { impl Path {
pub fn transformed_copy_to_builder( pub fn transformed_copy_to_builder(
&self, &self,
_transform: &Transform2D<f32>, transform: &Transform2D<f32>,
) -> Box<dyn GenericPathBuilder> { ) -> Box<dyn GenericPathBuilder> {
unimplemented!() Box::new(PathBuilder(Some(raqote::PathBuilder::from(
self.as_raqote().clone().transform(transform),
))))
} }
pub fn contains_point(&self, x: f64, y: f64, _path_transform: &Transform2D<f32>) -> bool { pub fn contains_point(&self, x: f64, y: f64, _path_transform: &Transform2D<f32>) -> bool {
@ -306,7 +308,7 @@ impl GenericDrawTarget for raqote::DrawTarget {
_sigma: f32, _sigma: f32,
_operator: CompositionOp, _operator: CompositionOp,
) { ) {
unimplemented!(); warn!("no support for drawing shadows");
} }
fn fill(&mut self, path: &Path, pattern: Pattern, draw_options: &DrawOptions) { fn fill(&mut self, path: &Path, pattern: Pattern, draw_options: &DrawOptions) {
self.fill( self.fill(
@ -355,7 +357,7 @@ impl GenericDrawTarget for raqote::DrawTarget {
self.set_transform(matrix); self.set_transform(matrix);
} }
fn snapshot(&self) -> SourceSurface { fn snapshot(&self) -> SourceSurface {
unimplemented!(); SourceSurface::Raqote(self.snapshot_data_owned())
} }
fn stroke( fn stroke(
&mut self, &mut self,
@ -633,11 +635,12 @@ pub trait ToRaqoteGradientStop {
impl ToRaqoteGradientStop for CanvasGradientStop { impl ToRaqoteGradientStop for CanvasGradientStop {
fn to_raqote(&self) -> raqote::GradientStop { fn to_raqote(&self) -> raqote::GradientStop {
let color: u32 = ((self.color.alpha as u32) << 8 * 3 | let color = raqote::Color::new(
(self.color.red as u32) << 8 * 2 | self.color.alpha,
(self.color.green as u32) << 8 * 1 | self.color.red,
(self.color.blue as u32) << 8 * 0) self.color.green,
.into(); self.color.blue,
);
let position = self.offset as f32; let position = self.offset as f32;
raqote::GradientStop { position, color } raqote::GradientStop { position, color }
} }