mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Clear webrender image id when resizing a canvas.
This commit is contained in:
parent
07f6e11485
commit
4e04daa9d0
5 changed files with 76 additions and 1 deletions
|
@ -547,6 +547,10 @@ impl<'a> CanvasPaintThread<'a> {
|
||||||
|
|
||||||
fn recreate(&mut self, size: Size2D<i32>) {
|
fn recreate(&mut self, size: Size2D<i32>) {
|
||||||
self.drawtarget = CanvasPaintThread::create(size);
|
self.drawtarget = CanvasPaintThread::create(size);
|
||||||
|
// Webrender doesn't let images change size, so we clear the webrender image key.
|
||||||
|
if let Some(image_key) = self.image_key.take() {
|
||||||
|
self.webrender_api.delete_image(image_key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_pixels(&mut self, chan: IpcSender<Option<Vec<u8>>>) {
|
fn send_pixels(&mut self, chan: IpcSender<Option<Vec<u8>>>) {
|
||||||
|
|
|
@ -291,7 +291,7 @@ impl WebGLPaintThread {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn recreate(&mut self, size: Size2D<i32>) -> Result<(), &'static str> {
|
fn recreate(&mut self, size: Size2D<i32>) -> Result<(), &'static str> {
|
||||||
match self.data {
|
match self.data {
|
||||||
WebGLPaintTaskData::Readback(ref mut context, _, _) => {
|
WebGLPaintTaskData::Readback(ref mut context, ref webrender_api, ref mut image_key) => {
|
||||||
if size.width > self.size.width ||
|
if size.width > self.size.width ||
|
||||||
size.height > self.size.height {
|
size.height > self.size.height {
|
||||||
self.size = try!(context.resize(size));
|
self.size = try!(context.resize(size));
|
||||||
|
@ -299,6 +299,10 @@ impl WebGLPaintThread {
|
||||||
self.size = size;
|
self.size = size;
|
||||||
context.gl().scissor(0, 0, size.width, size.height);
|
context.gl().scissor(0, 0, size.width, size.height);
|
||||||
}
|
}
|
||||||
|
// Webrender doesn't let images change size, so we clear the webrender image key.
|
||||||
|
if let Some(image_key) = image_key.take() {
|
||||||
|
webrender_api.delete_image(image_key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WebGLPaintTaskData::WebRender(ref api, id) => {
|
WebGLPaintTaskData::WebRender(ref api, id) => {
|
||||||
let device_size = webrender_traits::DeviceIntSize::from_untyped(&size);
|
let device_size = webrender_traits::DeviceIntSize::from_untyped(&size);
|
||||||
|
|
|
@ -6449,6 +6449,18 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"mozilla/canvas/set_dimensions.html": [
|
||||||
|
[
|
||||||
|
"/_mozilla/mozilla/canvas/set_dimensions.html",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"/_mozilla/mozilla/canvas/set_dimensions_ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"mozilla/details_ui_closed.html": [
|
"mozilla/details_ui_closed.html": [
|
||||||
[
|
[
|
||||||
"/_mozilla/mozilla/details_ui_closed.html",
|
"/_mozilla/mozilla/details_ui_closed.html",
|
||||||
|
@ -9570,6 +9582,11 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"mozilla/canvas/set_dimensions_ref.html": [
|
||||||
|
[
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"mozilla/click_prevent.html": [
|
"mozilla/click_prevent.html": [
|
||||||
[
|
[
|
||||||
{}
|
{}
|
||||||
|
@ -25493,6 +25510,14 @@
|
||||||
"794dd75566d0e2086deb0dcfc727dfe1834ca17e",
|
"794dd75566d0e2086deb0dcfc727dfe1834ca17e",
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
|
"mozilla/canvas/set_dimensions.html": [
|
||||||
|
"db6e4fa9b3480609a9a3a582430c64fb49b2b047",
|
||||||
|
"reftest"
|
||||||
|
],
|
||||||
|
"mozilla/canvas/set_dimensions_ref.html": [
|
||||||
|
"dd9ab8e1a360063d40e5155c1228e69154fa0966",
|
||||||
|
"support"
|
||||||
|
],
|
||||||
"mozilla/caption.html": [
|
"mozilla/caption.html": [
|
||||||
"51ed2927d2f3910fb9c2dc4bb1ea4d41c261c8c1",
|
"51ed2927d2f3910fb9c2dc4bb1ea4d41c261c8c1",
|
||||||
"testharness"
|
"testharness"
|
||||||
|
|
25
tests/wpt/mozilla/tests/mozilla/canvas/set_dimensions.html
Normal file
25
tests/wpt/mozilla/tests/mozilla/canvas/set_dimensions.html
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<head>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
<title>Resizing a canvas</title>
|
||||||
|
<link rel=match href=/_mozilla/mozilla/canvas/set_dimensions_ref.html>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<canvas width="50px" height="50px"></canvas>
|
||||||
|
<script>
|
||||||
|
var canvas = document.getElementsByTagName('canvas')[0];
|
||||||
|
var ctx = canvas.getContext('2d');
|
||||||
|
ctx.fillStyle = "red";
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
setTimeout(function() {
|
||||||
|
canvas.width = 100;
|
||||||
|
canvas.height = 100;
|
||||||
|
ctx.fillStyle = "green";
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
document.documentElement.classList.remove("reftest-wait");
|
||||||
|
}, 0);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
<title>Resizing a canvas reference</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<canvas width="100px" height="100px"></canvas>
|
||||||
|
<script>
|
||||||
|
var canvas = document.getElementsByTagName('canvas')[0];
|
||||||
|
var ctx = canvas.getContext('2d');
|
||||||
|
ctx.fillStyle = "green";
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue