diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 2add67cfd2a..c3c27925e96 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -117,6 +117,7 @@ impl WebGLThread { /// Handles a generic WebGLMsg message #[inline] fn handle_msg(&mut self, msg: WebGLMsg, webgl_chan: &WebGLChan) -> bool { + trace!("processing {:?}", msg); match msg { WebGLMsg::CreateContext(version, size, attributes, result_sender) => { let result = self.create_webgl_context(version, size, attributes); @@ -1104,7 +1105,7 @@ impl WebGLImpl { alpha_treatment, y_axis_treatment, pixel_format, - Cow::Borrowed(data), + Cow::Borrowed(&*data), ); ctx.gl() @@ -1144,7 +1145,7 @@ impl WebGLImpl { alpha_treatment, y_axis_treatment, pixel_format, - Cow::Borrowed(data), + Cow::Borrowed(&*data), ); ctx.gl() diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index 3ef88844e50..6b34965ae61 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -9,7 +9,9 @@ use offscreen_gl_context::{GLContextAttributes, GLLimits}; use pixels::PixelFormat; use serde_bytes::ByteBuf; use std::borrow::Cow; +use std::fmt; use std::num::NonZeroU32; +use std::ops::Deref; use webrender_api::{DocumentId, ImageKey, PipelineId}; /// Helper function that creates a WebGL channel (WebGLSender, WebGLReceiver) to be used in WebGLCommands. @@ -173,6 +175,33 @@ impl WebGLMsgSender { } } +#[derive(Deserialize, Serialize)] +pub struct TruncatedDebug(T); + +impl From for TruncatedDebug { + fn from(v: T) -> TruncatedDebug { + TruncatedDebug(v) + } +} + +impl fmt::Debug for TruncatedDebug { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut s = format!("{:?}", self.0); + if s.len() > 20 { + s.truncate(20); + s.push_str("..."); + } + write!(f, "{}", s) + } +} + +impl Deref for TruncatedDebug { + type Target = T; + fn deref(&self) -> &T { + &self.0 + } +} + /// WebGL Commands for a specific WebGLContext #[derive(Debug, Deserialize, Serialize)] pub enum WebGLCommand { @@ -284,7 +313,7 @@ pub enum WebGLCommand { alpha_treatment: Option, y_axis_treatment: YAxisTreatment, pixel_format: Option, - data: IpcSharedMemory, + data: TruncatedDebug, }, TexSubImage2D { target: u32, @@ -300,7 +329,7 @@ pub enum WebGLCommand { alpha_treatment: Option, y_axis_treatment: YAxisTreatment, pixel_format: Option, - data: IpcSharedMemory, + data: TruncatedDebug, }, DrawingBufferWidth(WebGLSender), DrawingBufferHeight(WebGLSender), diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 6175f2ad2b9..413d4d5a8cd 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -708,7 +708,7 @@ impl WebGLRenderingContext { alpha_treatment, y_axis_treatment, pixel_format: pixels.pixel_format, - data: pixels.data, + data: pixels.data.into(), }); if let Some(fb) = self.bound_framebuffer.get() { @@ -783,7 +783,7 @@ impl WebGLRenderingContext { alpha_treatment, y_axis_treatment, pixel_format: pixels.pixel_format, - data: pixels.data, + data: pixels.data.into(), }); }