mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Upgrade to the latest version of WebRender
This commit is contained in:
parent
4b6e79337e
commit
e58e8ab42e
88 changed files with 554 additions and 521 deletions
|
@ -38,14 +38,14 @@ style_traits = {path = "../style_traits"}
|
|||
time = "0.1.12"
|
||||
unicode-bidi = {version = "0.3", features = ["with_serde"]}
|
||||
unicode-script = {version = "0.1", features = ["harfbuzz"]}
|
||||
webrender_traits = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
xi-unicode = "0.1.0"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
byteorder = "1.0"
|
||||
core-foundation = "0.3"
|
||||
core-graphics = "0.8"
|
||||
core-text = "5.0"
|
||||
core-text = "6.0"
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
|
||||
freetype = "0.2"
|
||||
|
|
|
@ -33,7 +33,8 @@ use style::values::computed::Filter;
|
|||
use style_traits::cursor::Cursor;
|
||||
use text::TextRun;
|
||||
use text::glyph::ByteIndex;
|
||||
use webrender_traits::{self, ClipId, ColorF, GradientStop, MixBlendMode, ScrollPolicy, TransformStyle, WebGLContextId};
|
||||
use webrender_api::{self, ClipId, ColorF, GradientStop, LocalClip, MixBlendMode, ScrollPolicy};
|
||||
use webrender_api::{TransformStyle, WebGLContextId};
|
||||
|
||||
pub use style::dom::OpaqueNode;
|
||||
|
||||
|
@ -556,6 +557,12 @@ impl fmt::Debug for StackingContext {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub enum ScrollRootType {
|
||||
ScrollFrame,
|
||||
Clip,
|
||||
}
|
||||
|
||||
/// Defines a stacking context.
|
||||
#[derive(Clone, Debug, HeapSizeOf, Deserialize, Serialize)]
|
||||
pub struct ScrollRoot {
|
||||
|
@ -571,6 +578,9 @@ pub struct ScrollRoot {
|
|||
|
||||
/// The rect of the contents that can be scrolled inside of the scroll root.
|
||||
pub content_rect: Rect<Au>,
|
||||
|
||||
/// The type of this ScrollRoot.
|
||||
pub root_type: ScrollRootType
|
||||
}
|
||||
|
||||
impl ScrollRoot {
|
||||
|
@ -610,8 +620,8 @@ pub struct BaseDisplayItem {
|
|||
/// Metadata attached to this display item.
|
||||
pub metadata: DisplayItemMetadata,
|
||||
|
||||
/// The region to clip to.
|
||||
pub clip: ClippingRegion,
|
||||
/// The local clip for this item.
|
||||
pub local_clip: LocalClip,
|
||||
|
||||
/// The section of the display list that this item belongs to.
|
||||
pub section: DisplayListSection,
|
||||
|
@ -627,22 +637,15 @@ impl BaseDisplayItem {
|
|||
#[inline(always)]
|
||||
pub fn new(bounds: &Rect<Au>,
|
||||
metadata: DisplayItemMetadata,
|
||||
clip: &ClippingRegion,
|
||||
local_clip: LocalClip,
|
||||
section: DisplayListSection,
|
||||
stacking_context_id: StackingContextId,
|
||||
scroll_root_id: ClipId)
|
||||
-> BaseDisplayItem {
|
||||
// Detect useless clipping regions here and optimize them to `ClippingRegion::max()`.
|
||||
// The painting backend may want to optimize out clipping regions and this makes it easier
|
||||
// for it to do so.
|
||||
BaseDisplayItem {
|
||||
bounds: *bounds,
|
||||
metadata: metadata,
|
||||
clip: if clip.does_not_clip_rect(&bounds) {
|
||||
ClippingRegion::max()
|
||||
} else {
|
||||
(*clip).clone()
|
||||
},
|
||||
local_clip: local_clip,
|
||||
section: section,
|
||||
stacking_context_id: stacking_context_id,
|
||||
scroll_root_id: scroll_root_id,
|
||||
|
@ -657,7 +660,7 @@ impl BaseDisplayItem {
|
|||
node: OpaqueNode(0),
|
||||
pointing: None,
|
||||
},
|
||||
clip: ClippingRegion::max(),
|
||||
local_clip: LocalClip::from(max_rect().to_rectf()),
|
||||
section: DisplayListSection::Content,
|
||||
stacking_context_id: StackingContextId::root(),
|
||||
scroll_root_id: pipeline_id.root_scroll_node(),
|
||||
|
@ -1023,10 +1026,10 @@ pub struct ImageBorder {
|
|||
pub fill: bool,
|
||||
|
||||
/// How to repeat or stretch horizontal edges (border-image-repeat).
|
||||
pub repeat_horizontal: webrender_traits::RepeatMode,
|
||||
pub repeat_horizontal: webrender_api::RepeatMode,
|
||||
|
||||
/// How to repeat or stretch vertical edges (border-image-repeat).
|
||||
pub repeat_vertical: webrender_traits::RepeatMode,
|
||||
pub repeat_vertical: webrender_api::RepeatMode,
|
||||
}
|
||||
|
||||
/// A border that is made of linear gradient
|
||||
|
@ -1273,7 +1276,7 @@ impl DisplayItem {
|
|||
let point = Point2D::new(point.x - Au::from_f32_px(scroll_offset.x),
|
||||
point.y - Au::from_f32_px(scroll_offset.y));
|
||||
|
||||
if !base_item.clip.might_intersect_point(&point) {
|
||||
if !base_item.local_clip.clip_rect().contains(&point.to_pointf()) {
|
||||
// Clipped out.
|
||||
return None;
|
||||
}
|
||||
|
@ -1356,7 +1359,7 @@ impl fmt::Debug for DisplayItem {
|
|||
DisplayItem::DefineClip(_) => "".to_owned(),
|
||||
},
|
||||
self.bounds(),
|
||||
self.base().clip
|
||||
self.base().local_clip
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1366,7 +1369,7 @@ pub struct WebRenderImageInfo {
|
|||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub format: PixelFormat,
|
||||
pub key: Option<webrender_traits::ImageKey>,
|
||||
pub key: Option<webrender_api::ImageKey>,
|
||||
}
|
||||
|
||||
impl WebRenderImageInfo {
|
||||
|
@ -1399,3 +1402,29 @@ impl SimpleMatrixDetection for Transform3D<f32> {
|
|||
self.m44 == _1
|
||||
}
|
||||
}
|
||||
|
||||
trait ToPointF {
|
||||
fn to_pointf(&self) -> webrender_api::LayoutPoint;
|
||||
}
|
||||
|
||||
impl ToPointF for Point2D<Au> {
|
||||
fn to_pointf(&self) -> webrender_api::LayoutPoint {
|
||||
webrender_api::LayoutPoint::new(self.x.to_f32_px(), self.y.to_f32_px())
|
||||
}
|
||||
}
|
||||
|
||||
trait ToRectF {
|
||||
fn to_rectf(&self) -> webrender_api::LayoutRect;
|
||||
}
|
||||
|
||||
impl ToRectF for Rect<Au> {
|
||||
fn to_rectf(&self) -> webrender_api::LayoutRect {
|
||||
let x = self.origin.x.to_f32_px();
|
||||
let y = self.origin.y.to_f32_px();
|
||||
let w = self.size.width.to_f32_px();
|
||||
let h = self.size.height.to_f32_px();
|
||||
let point = webrender_api::LayoutPoint::new(x, y);
|
||||
let size = webrender_api::LayoutSize::new(w, h);
|
||||
webrender_api::LayoutRect::new(point, size)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ use text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore};
|
|||
use text::shaping::ShaperMethods;
|
||||
use time;
|
||||
use unicode_script::Script;
|
||||
use webrender_traits;
|
||||
use webrender_api;
|
||||
|
||||
macro_rules! ot_tag {
|
||||
($t1:expr, $t2:expr, $t3:expr, $t4:expr) => (
|
||||
|
@ -112,7 +112,7 @@ pub struct Font {
|
|||
shaper: Option<Shaper>,
|
||||
shape_cache: RefCell<HashMap<ShapeCacheEntry, Arc<GlyphStore>>>,
|
||||
glyph_advance_cache: RefCell<HashMap<u32, FractionalPixel>>,
|
||||
pub font_key: webrender_traits::FontKey,
|
||||
pub font_key: webrender_api::FontKey,
|
||||
}
|
||||
|
||||
impl Font {
|
||||
|
@ -121,7 +121,7 @@ impl Font {
|
|||
descriptor: FontTemplateDescriptor,
|
||||
requested_pt_size: Au,
|
||||
actual_pt_size: Au,
|
||||
font_key: webrender_traits::FontKey) -> Font {
|
||||
font_key: webrender_api::FontKey) -> Font {
|
||||
let metrics = handle.metrics();
|
||||
Font {
|
||||
handle: handle,
|
||||
|
|
|
@ -26,7 +26,7 @@ use std::thread;
|
|||
use std::u32;
|
||||
use style::font_face::{EffectiveSources, Source};
|
||||
use style::properties::longhands::font_family::computed_value::{FontFamily, FamilyName};
|
||||
use webrender_traits;
|
||||
use webrender_api;
|
||||
|
||||
/// A list of font templates that make up a given font family.
|
||||
struct FontTemplates {
|
||||
|
@ -36,7 +36,7 @@ struct FontTemplates {
|
|||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct FontTemplateInfo {
|
||||
pub font_template: Arc<FontTemplateData>,
|
||||
pub font_key: Option<webrender_traits::FontKey>,
|
||||
pub font_key: Option<webrender_api::FontKey>,
|
||||
}
|
||||
|
||||
impl FontTemplates {
|
||||
|
@ -127,8 +127,8 @@ struct FontCache {
|
|||
web_families: HashMap<LowercaseString, FontTemplates>,
|
||||
font_context: FontContextHandle,
|
||||
core_resource_thread: CoreResourceThread,
|
||||
webrender_api: Option<webrender_traits::RenderApi>,
|
||||
webrender_fonts: HashMap<Atom, webrender_traits::FontKey>,
|
||||
webrender_api: Option<webrender_api::RenderApi>,
|
||||
webrender_fonts: HashMap<Atom, webrender_api::FontKey>,
|
||||
}
|
||||
|
||||
fn populate_generic_fonts() -> HashMap<FontFamily, LowercaseString> {
|
||||
|
@ -400,7 +400,7 @@ pub struct FontCacheThread {
|
|||
|
||||
impl FontCacheThread {
|
||||
pub fn new(core_resource_thread: CoreResourceThread,
|
||||
webrender_api: Option<webrender_traits::RenderApi>) -> FontCacheThread {
|
||||
webrender_api: Option<webrender_api::RenderApi>) -> FontCacheThread {
|
||||
let (chan, port) = ipc::channel().unwrap();
|
||||
|
||||
let channel_to_self = chan.clone();
|
||||
|
|
|
@ -22,7 +22,7 @@ use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
|||
use style::computed_values::{font_style, font_variant_caps};
|
||||
use style::properties::style_structs;
|
||||
use style::stylearc::Arc as StyleArc;
|
||||
use webrender_traits;
|
||||
use webrender_api;
|
||||
|
||||
static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h)
|
||||
|
||||
|
@ -79,7 +79,7 @@ impl FontContext {
|
|||
descriptor: FontTemplateDescriptor,
|
||||
pt_size: Au,
|
||||
variant: font_variant_caps::T,
|
||||
font_key: webrender_traits::FontKey) -> Result<Font, ()> {
|
||||
font_key: webrender_api::FontKey) -> Result<Font, ()> {
|
||||
// TODO: (Bug #3463): Currently we only support fake small-caps
|
||||
// painting. We should also support true small-caps (where the
|
||||
// font supports it) in the future.
|
||||
|
|
|
@ -66,7 +66,7 @@ extern crate style_traits;
|
|||
extern crate time;
|
||||
extern crate unicode_bidi;
|
||||
extern crate unicode_script;
|
||||
extern crate webrender_traits;
|
||||
extern crate webrender_api;
|
||||
extern crate xi_unicode;
|
||||
#[cfg(target_os = "android")]
|
||||
extern crate xml5ever;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use servo_atoms::Atom;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Error};
|
||||
use webrender_traits::NativeFontHandle;
|
||||
use webrender_api::NativeFontHandle;
|
||||
|
||||
/// Platform specific font representation for Linux.
|
||||
/// The identifier is an absolute path, and the bytes
|
||||
|
|
|
@ -18,7 +18,7 @@ use std::fs::File;
|
|||
use std::io::{Read, Error as IoError};
|
||||
use std::ops::Deref;
|
||||
use std::sync::Mutex;
|
||||
use webrender_traits::NativeFontHandle;
|
||||
use webrender_api::NativeFontHandle;
|
||||
|
||||
/// Platform specific font representation for mac.
|
||||
/// The identifier is a PostScript font name. The
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use platform::windows::font_list::{descriptor_from_atom, font_from_atom};
|
||||
use servo_atoms::Atom;
|
||||
use std::io;
|
||||
use webrender_traits::NativeFontHandle;
|
||||
use webrender_api::NativeFontHandle;
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct FontTemplateData {
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::sync::Arc;
|
|||
use style::str::char_is_whitespace;
|
||||
use text::glyph::{ByteIndex, GlyphStore};
|
||||
use unicode_bidi as bidi;
|
||||
use webrender_traits;
|
||||
use webrender_api;
|
||||
use xi_unicode::LineBreakIterator;
|
||||
|
||||
thread_local! {
|
||||
|
@ -30,7 +30,7 @@ pub struct TextRun {
|
|||
pub font_template: Arc<FontTemplateData>,
|
||||
pub actual_pt_size: Au,
|
||||
pub font_metrics: FontMetrics,
|
||||
pub font_key: webrender_traits::FontKey,
|
||||
pub font_key: webrender_api::FontKey,
|
||||
/// The glyph runs that make up this text run.
|
||||
pub glyphs: Arc<Vec<GlyphRun>>,
|
||||
pub bidi_level: bidi::Level,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue