servo: Merge #17916 - Use AntialiasMode in CanvasPaintThread::new (from DarkDrek:Use_AntialiasMode_in_CanvasPaintThread_new); r=emilio

Change suggested in #17661

<!-- Please describe your changes on the following line: -->
I only changed `canvas_paint_thread.rs` since `CanvasPaintThread::start` is used outside of the current crate and `azure::azure_hl::AntialiasMode` isn't available there.

---
<!-- 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 #17661 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because @jdm said so

<!-- 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. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 0337ebb5a936a5fefb69a552c9d54b084f21ddc2

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : d4e8d9634126158a71114ae17f5dd76f44d4ac8c
This commit is contained in:
DarkDrek 2017-07-29 09:01:09 -05:00
Родитель 7792722d19
Коммит a764197b83
1 изменённых файлов: 8 добавлений и 9 удалений

Просмотреть файл

@ -80,13 +80,7 @@ struct CanvasPaintState<'a> {
}
impl<'a> CanvasPaintState<'a> {
fn new(antialias: bool) -> CanvasPaintState<'a> {
let antialias = if antialias {
AntialiasMode::Default
} else {
AntialiasMode::None
};
fn new(antialias: AntialiasMode) -> CanvasPaintState<'a> {
CanvasPaintState {
draw_options: DrawOptions::new(1.0, CompositionOp::Over, antialias),
fill_style: Pattern::Color(ColorPattern::new(Color::black())),
@ -104,7 +98,7 @@ impl<'a> CanvasPaintState<'a> {
impl<'a> CanvasPaintThread<'a> {
fn new(size: Size2D<i32>,
webrender_api_sender: webrender_api::RenderApiSender,
antialias: bool) -> CanvasPaintThread<'a> {
antialias: AntialiasMode) -> CanvasPaintThread<'a> {
let draw_target = CanvasPaintThread::create(size);
let path_builder = draw_target.create_path_builder();
let webrender_api = webrender_api_sender.create_api();
@ -127,6 +121,11 @@ impl<'a> CanvasPaintThread<'a> {
antialias: bool)
-> IpcSender<CanvasMsg> {
let (sender, receiver) = ipc::channel::<CanvasMsg>().unwrap();
let antialias = if antialias {
AntialiasMode::Default
} else {
AntialiasMode::None
};
thread::Builder::new().name("CanvasThread".to_owned()).spawn(move || {
let mut painter = CanvasPaintThread::new(size, webrender_api_sender, antialias);
loop {
@ -550,7 +549,7 @@ impl<'a> CanvasPaintThread<'a> {
fn recreate(&mut self, size: Size2D<i32>) {
self.drawtarget = CanvasPaintThread::create(size);
self.state = CanvasPaintState::new(self.state.draw_options.antialias == AntialiasMode::Default);
self.state = CanvasPaintState::new(self.state.draw_options.antialias);
self.saved_states.clear();
// Webrender doesn't let images change size, so we clear the webrender image key.
if let Some(image_key) = self.image_key.take() {