From 78ef16bfaeb23e35e0e0adf1ddf8e756a444815d Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 2 Sep 2014 15:58:36 +1000 Subject: [PATCH] Fix task failure when loading wikipedia. There is still an issue with alpha display, so there is likely a problem elsewhere, but this at least allows the page to load for now (ref #2554). --- src/components/gfx/render_context.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/gfx/render_context.rs b/src/components/gfx/render_context.rs index 31c68e7c34d..68449cdff19 100644 --- a/src/components/gfx/render_context.rs +++ b/src/components/gfx/render_context.rs @@ -5,7 +5,7 @@ use font_context::FontContext; use style::computed_values::border_style; -use azure::azure_hl::{B8G8R8A8, Color, ColorPattern, DrawOptions, DrawSurfaceOptions, DrawTarget}; +use azure::azure_hl::{B8G8R8A8, A8, Color, ColorPattern, DrawOptions, DrawSurfaceOptions, DrawTarget}; use azure::azure_hl::{Linear, SourceOp, StrokeOptions}; use azure::AZ_CAP_BUTT; use azure::AzFloat; @@ -100,9 +100,11 @@ impl<'a> RenderContext<'a> { pub fn draw_image(&self, bounds: Rect, image: Arc>) { let size = Size2D(image.width as i32, image.height as i32); - let (pixel_width, pixels) = match image.pixels { - RGBA8(ref pixels) => (4, pixels.as_slice()), - RGB8(_) | K8(_) | KA8(_) => fail!("color type not supported"), + let (pixel_width, pixels, source_format) = match image.pixels { + RGBA8(ref pixels) => (4, pixels.as_slice(), B8G8R8A8), + K8(ref pixels) => (1, pixels.as_slice(), A8), + RGB8(_) => fail!("RGB8 color type not supported"), + KA8(_) => fail!("KA8 color type not supported"), }; let stride = image.width * pixel_width; @@ -111,7 +113,7 @@ impl<'a> RenderContext<'a> { let azure_surface = draw_target_ref.create_source_surface_from_data(pixels, size, stride as i32, - B8G8R8A8); + source_format); let source_rect = Rect(Point2D(0u as AzFloat, 0u as AzFloat), Size2D(image.width as AzFloat, image.height as AzFloat)); let dest_rect = bounds.to_azure_rect();