Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sample/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ fn main() {
font_key,
ColorF::new(1.0, 1.0, 0.0, 1.0),
Au::from_px(32),
Au::from_px(0));
Au::from_px(0),
None);
}

builder.pop_stacking_context();
Expand Down
3 changes: 2 additions & 1 deletion webrender/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ impl Frame {
text_info.size,
text_info.blur_radius,
&text_info.color,
text_info.glyphs);
text_info.glyphs,
text_info.glyph_options);
}
SpecificDisplayItem::Rectangle(ref info) => {
context.builder.add_solid_rectangle(&item.rect,
Expand Down
5 changes: 3 additions & 2 deletions webrender/src/platform/macos/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use core_text::font_descriptor::kCTFontDefaultOrientation;
use core_text;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use webrender_traits::{ColorU, FontKey, FontRenderMode, GlyphDimensions};
use webrender_traits::{ColorU, FontKey, FontRenderMode, GlyphDimensions, GlyphOptions};

pub type NativeFontHandle = CGFont;

Expand Down Expand Up @@ -180,7 +180,8 @@ impl FontContext {
size: Au,
color: ColorU,
character: u32,
render_mode: FontRenderMode) -> Option<RasterizedGlyph> {
render_mode: FontRenderMode,
glyph_options: Option<GlyphOptions>) -> Option<RasterizedGlyph> {
match self.get_ct_font(font_key, size) {
Some(ref ct_font) => {
let glyph = character as CGGlyph;
Expand Down
5 changes: 3 additions & 2 deletions webrender/src/platform/unix/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use app_units::Au;
use webrender_traits::{FontKey, ColorU, FontRenderMode, GlyphDimensions, NativeFontHandle};
use webrender_traits::{FontKey, ColorU, FontRenderMode, GlyphDimensions, NativeFontHandle, GlyphOptions};

use freetype::freetype::{FT_Render_Mode, FT_Pixel_Mode};
use freetype::freetype::{FT_Done_FreeType, FT_Library_SetLcdFilter};
Expand Down Expand Up @@ -135,7 +135,8 @@ impl FontContext {
size: Au,
color: ColorU,
character: u32,
render_mode: FontRenderMode) -> Option<RasterizedGlyph> {
render_mode: FontRenderMode,
glyph_options: Option<GlyphOptions>) -> Option<RasterizedGlyph> {
let mut glyph = None;

if let Some(slot) = self.load_glyph(font_key,
Expand Down
5 changes: 3 additions & 2 deletions webrender/src/platform/windows/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use app_units::Au;
use std::collections::HashMap;
use webrender_traits::{FontKey, ColorU, FontRenderMode, GlyphDimensions};
use webrender_traits::{FontKey, ColorU, FontRenderMode, GlyphDimensions, GlyphOptions};

use dwrote;

Expand Down Expand Up @@ -184,7 +184,8 @@ impl FontContext {
size: Au,
color: ColorU,
glyph: u32,
render_mode: FontRenderMode) -> Option<RasterizedGlyph> {
render_mode: FontRenderMode,
glyph_options: Option<GlyphOptions>) -> Option<RasterizedGlyph> {
let (_, maybe_glyph) =
self.get_glyph_dimensions_and_maybe_rasterize(font_key, size, glyph, Some(render_mode));
maybe_glyph
Expand Down
8 changes: 6 additions & 2 deletions webrender/src/prim_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use webrender_traits::{device_length, DeviceIntRect, DeviceIntSize};
use webrender_traits::{DeviceRect, DevicePoint, DeviceSize};
use webrender_traits::{LayerRect, LayerSize, LayerPoint};
use webrender_traits::LayerToWorldTransform;
use webrender_traits::{GlyphOptions};

pub const CLIP_DATA_GPU_SIZE: usize = 5;
pub const MASK_DATA_GPU_SIZE: usize = 1;
Expand Down Expand Up @@ -290,6 +291,7 @@ pub struct TextRunPrimitiveCpu {
pub color: ColorF,
pub render_mode: FontRenderMode,
pub resource_address: GpuStoreAddress,
pub glyph_options: Option<GlyphOptions>,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -741,7 +743,8 @@ impl PrimitiveStore {
font_size_dp,
text.color,
&text.glyph_indices,
text.render_mode, |index, uv0, uv1| {
text.render_mode,
text.glyph_options, |index, uv0, uv1| {
let dest_rect = &mut dest_rects[index];
dest_rect.uv0 = uv0;
dest_rect.uv1 = uv1;
Expand Down Expand Up @@ -1001,7 +1004,8 @@ impl PrimitiveStore {
font_size_dp,
text.color,
&text.glyph_indices,
text.render_mode);
text.render_mode,
text.glyph_options);
}
PrimitiveKind::Image => {
let image_cpu = &mut self.cpu_images[metadata.cpu_prim_index.0];
Expand Down
27 changes: 18 additions & 9 deletions webrender/src/resource_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use texture_cache::{TextureCache, TextureCacheItemId};
use webrender_traits::{Epoch, FontKey, GlyphKey, ImageKey, ImageFormat, ImageRendering};
use webrender_traits::{FontRenderMode, ImageData, GlyphDimensions, WebGLContextId};
use webrender_traits::{DevicePoint, DeviceIntSize, ImageDescriptor, ColorF};
use webrender_traits::ExternalImageId;
use webrender_traits::{ExternalImageId, GlyphOptions};
use threadpool::ThreadPool;

thread_local!(pub static FONT_CONTEXT: RefCell<FontContext> = RefCell::new(FontContext::new()));
Expand All @@ -36,7 +36,7 @@ enum GlyphCacheMsg {
/// Add a new font.
AddFont(FontKey, FontTemplate),
/// Request glyphs for a text run.
RequestGlyphs(FontKey, Au, ColorF, Vec<u32>, FontRenderMode),
RequestGlyphs(FontKey, Au, ColorF, Vec<u32>, FontRenderMode, Option<GlyphOptions>),
/// Finished requesting glyphs. Reply with new glyphs.
EndFrame,
}
Expand Down Expand Up @@ -66,17 +66,20 @@ pub struct CacheItem {
pub struct RenderedGlyphKey {
pub key: GlyphKey,
pub render_mode: FontRenderMode,
pub glyph_options: Option<GlyphOptions>,
}

impl RenderedGlyphKey {
pub fn new(font_key: FontKey,
size: Au,
color: ColorF,
index: u32,
render_mode: FontRenderMode) -> RenderedGlyphKey {
render_mode: FontRenderMode,
glyph_options: Option<GlyphOptions>) -> RenderedGlyphKey {
RenderedGlyphKey {
key: GlyphKey::new(font_key, size, color, index),
render_mode: render_mode,
glyph_options: glyph_options,
}
}
}
Expand Down Expand Up @@ -328,7 +331,8 @@ impl ResourceCache {
size: Au,
color: ColorF,
glyph_indices: &[u32],
render_mode: FontRenderMode) {
render_mode: FontRenderMode,
glyph_options: Option<GlyphOptions>) {
debug_assert!(self.state == State::AddResources);
let render_mode = self.get_glyph_render_mode(render_mode);
// Immediately request that the glyph cache thread start
Expand All @@ -338,7 +342,8 @@ impl ResourceCache {
size,
color,
glyph_indices.to_vec(),
render_mode);
render_mode,
glyph_options);
self.glyph_cache_tx.send(msg).unwrap();
}

Expand All @@ -356,6 +361,7 @@ impl ResourceCache {
color: ColorF,
glyph_indices: &[u32],
render_mode: FontRenderMode,
glyph_options: Option<GlyphOptions>,
mut f: F) -> SourceTexture where F: FnMut(usize, DevicePoint, DevicePoint) {
debug_assert!(self.state == State::QueryResources);
let cache = self.cached_glyphs.as_ref().unwrap();
Expand All @@ -364,7 +370,8 @@ impl ResourceCache {
size,
color,
0,
render_mode);
render_mode,
glyph_options);
let mut texture_id = None;
for (loop_index, glyph_index) in glyph_indices.iter().enumerate() {
glyph_key.key.index = *glyph_index;
Expand Down Expand Up @@ -668,7 +675,7 @@ fn spawn_glyph_cache_thread() -> (Sender<GlyphCacheMsg>, Receiver<GlyphCacheResu
});
}
}
GlyphCacheMsg::RequestGlyphs(key, size, color, indices, render_mode) => {
GlyphCacheMsg::RequestGlyphs(key, size, color, indices, render_mode, glyph_options) => {
// Request some glyphs for a text run.
// For any glyph that isn't currently in the cache,
// immeediately push a job to the worker thread pool
Expand All @@ -680,7 +687,8 @@ fn spawn_glyph_cache_thread() -> (Sender<GlyphCacheMsg>, Receiver<GlyphCacheResu
size,
color,
glyph_index,
render_mode);
render_mode,
glyph_options);

glyph_cache.mark_as_needed(&glyph_key, current_frame_id);
if !glyph_cache.contains_key(&glyph_key) &&
Expand All @@ -694,7 +702,8 @@ fn spawn_glyph_cache_thread() -> (Sender<GlyphCacheMsg>, Receiver<GlyphCacheResu
glyph_key.key.size,
glyph_key.key.color,
glyph_key.key.index,
render_mode);
render_mode,
glyph_options);
glyph_tx.send((glyph_key, result)).unwrap();
});
});
Expand Down
5 changes: 4 additions & 1 deletion webrender/src/tiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use webrender_traits::{DeviceUintSize, DeviceUintPoint};
use webrender_traits::{LayerRect, LayerPoint, LayerSize};
use webrender_traits::{LayerToScrollTransform, LayerToWorldTransform, WorldToLayerTransform};
use webrender_traits::{WorldPoint4D, ScrollLayerPixel, as_scroll_parent_rect};
use webrender_traits::{GlyphOptions};

// Special sentinel value recognized by the shader. It is considered to be
// a dummy task that doesn't mask out anything.
Expand Down Expand Up @@ -2324,7 +2325,8 @@ impl FrameBuilder {
size: Au,
blur_radius: Au,
color: &ColorF,
glyph_range: ItemRange) {
glyph_range: ItemRange,
glyph_options: Option<GlyphOptions>) {
if color.a == 0.0 {
return
}
Expand Down Expand Up @@ -2370,6 +2372,7 @@ impl FrameBuilder {
color_texture_id: SourceTexture::Invalid,
color: *color,
render_mode: render_mode,
glyph_options: glyph_options,
resource_address: GpuStoreAddress(0),
};

Expand Down
5 changes: 4 additions & 1 deletion webrender_traits/src/display_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use {PushScrollLayerItem, PushStackingContextDisplayItem, RectangleDisplayItem,
use {ScrollPolicy, ServoScrollRootId, SpecificDisplayItem, StackingContext, TextDisplayItem};
use {WebGLContextId, WebGLDisplayItem, YuvImageDisplayItem};
use {LayoutTransform, LayoutPoint, LayoutRect, LayoutSize};
use {GlyphOptions};

impl BuiltDisplayListDescriptor {
pub fn size(&self) -> usize {
Expand Down Expand Up @@ -154,7 +155,8 @@ impl DisplayListBuilder {
font_key: FontKey,
color: ColorF,
size: Au,
blur_radius: Au) {
blur_radius: Au,
glyph_options: Option<GlyphOptions>) {
// Sanity check - anything with glyphs bigger than this
// is probably going to consume too much memory to render
// efficiently anyway. This is specifically to work around
Expand All @@ -168,6 +170,7 @@ impl DisplayListBuilder {
font_key: font_key,
size: size,
blur_radius: blur_radius,
glyph_options: glyph_options,
};

let display_item = DisplayItem {
Expand Down
8 changes: 8 additions & 0 deletions webrender_traits/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,21 @@ pub struct StackingContext {
pub filters: ItemRange,
}

#[derive(Clone, Copy, Debug, Deserialize, Hash, Eq, PartialEq, PartialOrd, Ord, Serialize)]
pub struct GlyphOptions {
// These are currently only used on windows for dwrite fonts.
use_embedded_bitmap: bool,
force_gdi_rendering: bool,
}

#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct TextDisplayItem {
pub glyphs: ItemRange,
pub font_key: FontKey,
pub size: Au,
pub color: ColorF,
pub blur_radius: Au,
pub glyph_options: Option<GlyphOptions>,
}

#[derive(Clone, Deserialize, Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion wrench/src/yaml_frame_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl YamlFrameReader {
};

let clip = self.to_clip_region(&item["clip"], &rect, wrench).unwrap_or(*clip_region);
self.builder().push_text(rect, clip, glyphs, font_key, color, size, blur_radius);
self.builder().push_text(rect, clip, glyphs, font_key, color, size, blur_radius, None);
}

fn handle_iframe(&mut self, wrench: &mut Wrench, clip_region: &ClipRegion, item: &Yaml)
Expand Down