mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Don't bother with the global in ImageData::get_image_data
This commit is contained in:
parent
854a3dff68
commit
2400b91d05
4 changed files with 6 additions and 8 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue