mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
Use push_layer_with_blend() only when necessary
push_layer_with_blend() comes at a performance cost, so we only use it on blend modes that require it.
This commit is contained in:
parent
a02daef7b2
commit
04e9523e5f
1 changed files with 36 additions and 5 deletions
|
@ -329,11 +329,42 @@ impl GenericDrawTarget for raqote::DrawTarget {
|
||||||
warn!("no support for drawing shadows");
|
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) {
|
||||||
let mut options = draw_options.as_raqote().clone();
|
match draw_options.as_raqote().blend_mode {
|
||||||
self.push_layer_with_blend(1., options.blend_mode);
|
raqote::BlendMode::Src => {
|
||||||
options.blend_mode = raqote::BlendMode::SrcOver;
|
self.clear(raqote::SolidSource::from_unpremultiplied_argb(0, 0, 0, 0));
|
||||||
self.fill(path.as_raqote(), pattern.as_raqote(), &options);
|
self.fill(
|
||||||
self.pop_layer();
|
path.as_raqote(),
|
||||||
|
pattern.as_raqote(),
|
||||||
|
draw_options.as_raqote(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
raqote::BlendMode::SrcAtop |
|
||||||
|
raqote::BlendMode::DstOut |
|
||||||
|
raqote::BlendMode::Add |
|
||||||
|
raqote::BlendMode::Xor |
|
||||||
|
raqote::BlendMode::DstOver |
|
||||||
|
raqote::BlendMode::SrcOver => {
|
||||||
|
self.fill(
|
||||||
|
path.as_raqote(),
|
||||||
|
pattern.as_raqote(),
|
||||||
|
draw_options.as_raqote(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
raqote::BlendMode::SrcIn |
|
||||||
|
raqote::BlendMode::SrcOut |
|
||||||
|
raqote::BlendMode::DstIn |
|
||||||
|
raqote::BlendMode::DstAtop => {
|
||||||
|
let mut options = draw_options.as_raqote().clone();
|
||||||
|
self.push_layer_with_blend(1., options.blend_mode);
|
||||||
|
options.blend_mode = raqote::BlendMode::SrcOver;
|
||||||
|
self.fill(path.as_raqote(), pattern.as_raqote(), &options);
|
||||||
|
self.pop_layer();
|
||||||
|
},
|
||||||
|
_ => warn!(
|
||||||
|
"unrecognized blend mode: {:?}",
|
||||||
|
draw_options.as_raqote().blend_mode
|
||||||
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn fill_rect(
|
fn fill_rect(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue