diff --git a/src/servo/gfx/display_list.rs b/src/servo/gfx/display_list.rs index c8c0dd485f6..dd8920b110e 100644 --- a/src/servo/gfx/display_list.rs +++ b/src/servo/gfx/display_list.rs @@ -1,12 +1,12 @@ use azure::azure_hl::DrawTarget; -use gfx::render_task::{draw_solid_color, draw_image, draw_text}; +use gfx::render_task::{draw_solid_color, draw_image, draw_glyphs}; use gfx::geometry::*; use geom::rect::Rect; use image::base::Image; -use servo_text::text_run::TextRun; use std::arc::{ARC, clone}; use dvec::DVec; +use text::glyph::Glyph; struct DisplayItem { draw: ~fn((&DisplayItem), (&DrawTarget)), @@ -16,11 +16,20 @@ struct DisplayItem { enum DisplayItemData { SolidColorData(u8, u8, u8), - TextData(TextRun), + GlyphData(GlyphRun), ImageData(ARC<~image::base::Image>), PaddingData(u8, u8, u8, u8) // This is a hack to make fonts work (?) } +/** +A run of glyphs in a single font. This is distinguished from any similar +structure used by layout in that this must be sendable, whereas the text +shaping data structures may end up unsendable. +*/ +struct GlyphRun { + glyphs: ~[Glyph] +} + fn draw_SolidColor(self: &DisplayItem, ctx: &DrawTarget) { match self.data { SolidColorData(r,g,b) => draw_solid_color(ctx, &self.bounds, r, g, b), @@ -28,9 +37,9 @@ fn draw_SolidColor(self: &DisplayItem, ctx: &DrawTarget) { } } -fn draw_Text(self: &DisplayItem, ctx: &DrawTarget) { +fn draw_Glyphs(self: &DisplayItem, ctx: &DrawTarget) { match self.data { - TextData(run) => draw_text(ctx, self.bounds, &run), + GlyphData(run) => draw_glyphs(ctx, self.bounds, &run), _ => fail } } @@ -51,11 +60,11 @@ fn SolidColor(bounds: Rect, r: u8, g: u8, b: u8) -> DisplayItem { } } -fn Text(bounds: Rect, run: TextRun) -> DisplayItem { +fn Glyphs(bounds: Rect, run: GlyphRun) -> DisplayItem { DisplayItem { - draw: |self, ctx| draw_Text(self, ctx), + draw: |self, ctx| draw_Glyphs(self, ctx), bounds: bounds, - data: TextData(run) + data: GlyphData(run) } } diff --git a/src/servo/gfx/render_task.rs b/src/servo/gfx/render_task.rs index c0415015507..ec1e2b8746e 100644 --- a/src/servo/gfx/render_task.rs +++ b/src/servo/gfx/render_task.rs @@ -7,7 +7,7 @@ use azure::*; use azure::bindgen::*; use libc::size_t; use text::font::Font; -use text::text_run::TextRun; +use display_list::GlyphRun; use geom::size::Size2D; use geom::rect::Rect; use geom::point::Point2D; @@ -118,7 +118,7 @@ pub fn draw_image(draw_target: &DrawTarget, bounds: Rect, image: ARC<~Image> draw_options); } -pub fn draw_text(draw_target: &DrawTarget, bounds: Rect, text_run: &TextRun) { +pub fn draw_glyphs(draw_target: &DrawTarget, bounds: Rect, text_run: &GlyphRun) { use ptr::{addr_of, null}; use vec::raw::to_ptr; use libc::types::common::c99::{uint16_t, uint32_t}; diff --git a/src/servo/layout/display_list_builder.rs b/src/servo/layout/display_list_builder.rs index 354070667a4..25eeaf18e5e 100644 --- a/src/servo/layout/display_list_builder.rs +++ b/src/servo/layout/display_list_builder.rs @@ -11,7 +11,7 @@ use geom::rect::Rect; use geom::size::Size2D; use gfx::geometry::{au, au_to_px, box, px_to_au}; use util::tree; - +use servo_text::text_run::TextRun; use dvec::DVec; use vec::push; @@ -87,8 +87,15 @@ fn box_to_display_items(list: dl::DisplayList, box: @Box, origin: Point2D) { let run = copy subbox.run; assert run.is_some(); list.push(~dl::SolidColor(bounds, 255u8, 255u8, 255u8)); - list.push(~dl::Text(bounds, run.get())); + let glyph_run = text_run_to_dl_glyph_run(run.get_ref()); + list.push(~dl::Glyphs(bounds, glyph_run)); return; + + fn text_run_to_dl_glyph_run(text_run: &TextRun) -> dl::GlyphRun { + dl::GlyphRun { + glyphs: copy text_run.glyphs + } + } } _ => { // Fall through @@ -156,7 +163,7 @@ fn should_convert_text_boxes_to_text_items() { do list.borrow |l| { match l[1].data { - dl::TextData(_) => { } + dl::GlyphData(_) => { } _ => { fail } } }