Auto merge of #11750 - emilio:canvas-leaks, r=glennw

canvas: Deallocate WebRender images on canvas

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

- [x] These changes do not require tests because it's wr-only.

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

r? @glennw

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11750)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-07-10 20:09:48 -07:00 committed by GitHub
commit 1ff8d875dd
2 changed files with 16 additions and 0 deletions

View file

@ -706,6 +706,14 @@ impl<'a> CanvasPaintThread<'a> {
}
}
impl<'a> Drop for CanvasPaintThread<'a> {
fn drop(&mut self) {
if let Some(ref mut wr) = self.webrender_api {
wr.delete_image(self.webrender_image_key.unwrap());
}
}
}
/// Used by drawImage to get rid of the extra pixels of the image data that
/// won't be copied to the canvas
/// image_data: Color pixel data of the image

View file

@ -195,3 +195,11 @@ impl WebGLPaintThread {
}
}
}
impl Drop for WebGLPaintThread {
fn drop(&mut self) {
if let WebGLPaintTaskData::Readback(_, Some((ref mut wr, image_key))) = self.data {
wr.delete_image(image_key);
}
}
}