Skip to content

Commit

Permalink
Don't bother with the global in ImageData::get_image_data
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Aug 30, 2016
1 parent 854a3df commit 2400b91
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/script/dom/canvasrenderingcontext2d.rs
Expand Up @@ -1100,7 +1100,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
dirtyY: Finite<f64>,
dirtyWidth: Finite<f64>,
dirtyHeight: Finite<f64>) {
let data = imagedata.get_data_array(&self.global().r());
let data = imagedata.get_data_array();
let offset = Point2D::new(*dx, *dy);
let image_data_size = Size2D::new(imagedata.Width() as f64, imagedata.Height() as f64);

Expand Down
3 changes: 1 addition & 2 deletions components/script/dom/htmlcanvaselement.rs
Expand Up @@ -273,11 +273,10 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement {
// Step 3.
let raw_data = match *self.context.borrow() {
Some(CanvasContext::Context2d(ref context)) => {
let window = window_from_node(self);
let image_data = try!(context.GetImageData(Finite::wrap(0f64), Finite::wrap(0f64),
Finite::wrap(self.Width() as f64),
Finite::wrap(self.Height() as f64)));
image_data.get_data_array(&GlobalRef::Window(window.r()))
image_data.get_data_array()
}
None => {
// Each pixel is fully-transparent black.
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/imagedata.rs
Expand Up @@ -53,12 +53,12 @@ impl ImageData {
}

#[allow(unsafe_code)]
pub fn get_data_array(&self, global: &GlobalRef) -> Vec<u8> {
pub fn get_data_array(&self) -> Vec<u8> {
unsafe {
let cx = global.get_cx();
let mut is_shared = false;
assert!(!self.data.get().is_null());
let data: *const uint8_t =
JS_GetUint8ClampedArrayData(self.Data(cx), &mut is_shared, ptr::null()) as *const uint8_t;
JS_GetUint8ClampedArrayData(self.data.get(), &mut is_shared, ptr::null()) as *const uint8_t;
assert!(!data.is_null());
assert!(!is_shared);
let len = self.Width() * self.Height() * 4;
Expand Down
3 changes: 1 addition & 2 deletions components/script/dom/webglrenderingcontext.rs
Expand Up @@ -305,8 +305,7 @@ impl WebGLRenderingContext {
// complexity is worth it.
let (pixels, size) = match source {
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::ImageData(image_data) => {
let global = self.global();
(image_data.get_data_array(&global.r()), image_data.get_size())
(image_data.get_data_array(), image_data.get_size())
},
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLImageElement(image) => {
let img_url = match image.get_url() {
Expand Down

0 comments on commit 2400b91

Please sign in to comment.