Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear webrender image id when resizing a canvas. #17278

Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -547,6 +547,10 @@ impl<'a> CanvasPaintThread<'a> {

fn recreate(&mut self, size: Size2D<i32>) {
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);
}

This comment has been minimized.

@emilio

emilio Jun 12, 2017

Member

r=me, but could you do the same in the webgl_paint_thread? Right now the readback path suffers the same problem afaict.

This comment has been minimized.

@emilio

emilio Jun 12, 2017

Member

(Or filing an issue is fine too)

This comment has been minimized.

@asajeffrey

asajeffrey Jun 13, 2017

Author Member

Will do.

}

fn send_pixels(&mut self, chan: IpcSender<Option<Vec<u8>>>) {
@@ -291,14 +291,18 @@ impl WebGLPaintThread {
#[allow(unsafe_code)]
fn recreate(&mut self, size: Size2D<i32>) -> Result<(), &'static str> {
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 ||
size.height > self.size.height {
self.size = try!(context.resize(size));
} else {
self.size = size;
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) => {
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/mozilla/details_ui_closed.html",
@@ -9570,6 +9582,11 @@
{}
]
],
"mozilla/canvas/set_dimensions_ref.html": [
[
{}
]
],
"mozilla/click_prevent.html": [
[
{}
"794dd75566d0e2086deb0dcfc727dfe1834ca17e",
"testharness"
],
"mozilla/canvas/set_dimensions.html": [
"db6e4fa9b3480609a9a3a582430c64fb49b2b047",
"reftest"
],
"mozilla/canvas/set_dimensions_ref.html": [
"dd9ab8e1a360063d40e5155c1228e69154fa0966",
"support"
],
"mozilla/caption.html": [
"51ed2927d2f3910fb9c2dc4bb1ea4d41c261c8c1",
"testharness"
@@ -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>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.