Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle the long text for dl::push_text() #1597

Merged
merged 3 commits into from Aug 24, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -468,6 +468,10 @@ impl<'a> GpuDataRequest<'a> {
self.texture.pending_blocks.extend_from_slice(blocks);
}

pub fn current_used_block_num(&self) -> usize {
self.texture.pending_blocks.len() - self.start_index
}

/// Consume the request and return the number of blocks written
pub fn close(self) -> usize {
self.texture.pending_blocks.len() - self.start_index
@@ -593,6 +593,8 @@ impl TextRunPrimitiveCpu {
self.subpx_dir as u32 as f32,
0.0]);
request.extend_from_slice(&self.glyph_gpu_blocks);

assert!(request.current_used_block_num() <= MAX_VERTEX_TEXTURE_WIDTH);
}
}

@@ -20,6 +20,10 @@ use {StickyFrameInfo, TextDisplayItem, TextShadow, TransformStyle};
use {YuvColorSpace, YuvData, YuvImageDisplayItem};
use std::marker::PhantomData;

// We don't want to push a long text-run. If a text-run is too long, split it into several parts.
// Please check the renderer::MAX_VERTEX_TEXTURE_WIDTH for the detail.
pub const MAX_TEXT_RUN_LENGTH: usize = 2040;

#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ItemRange<T> {
@@ -619,11 +623,13 @@ impl DisplayListBuilder {
glyph_options,
});

self.push_item(item, rect, local_clip);
self.push_iter(glyphs);
for split_glyphs in glyphs.chunks(MAX_TEXT_RUN_LENGTH) {
self.push_item(item, rect, local_clip);
self.push_iter(split_glyphs);

// Remember that we've seen these glyphs
self.cache_glyphs(font_key, color, glyphs.iter().map(|glyph| glyph.index));
// Remember that we've seen these glyphs
self.cache_glyphs(font_key, color, split_glyphs.iter().map(|glyph| glyph.index));
}
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.