зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1523210 - Fix text runs being interned due to scroll offsets. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D17792 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
03dc2eebf4
Коммит
42fff5a810
|
@ -15,7 +15,7 @@ varying vec4 vUvClip;
|
|||
|
||||
#ifdef WR_VERTEX_SHADER
|
||||
|
||||
#define VECS_PER_TEXT_RUN 3
|
||||
#define VECS_PER_TEXT_RUN 2
|
||||
#define GLYPHS_PER_GPU_BLOCK 2U
|
||||
|
||||
struct Glyph {
|
||||
|
@ -53,12 +53,11 @@ GlyphResource fetch_glyph_resource(int address) {
|
|||
struct TextRun {
|
||||
vec4 color;
|
||||
vec4 bg_color;
|
||||
vec2 offset;
|
||||
};
|
||||
|
||||
TextRun fetch_text_run(int address) {
|
||||
vec4 data[3] = fetch_from_gpu_cache_3(address);
|
||||
return TextRun(data[0], data[1], data[2].xy);
|
||||
vec4 data[2] = fetch_from_gpu_cache_2(address);
|
||||
return TextRun(data[0], data[1]);
|
||||
}
|
||||
|
||||
VertexInfo write_text_vertex(RectWithSize local_clip_rect,
|
||||
|
@ -160,14 +159,14 @@ void main(void) {
|
|||
PictureTask task = fetch_picture_task(ph.render_task_index);
|
||||
|
||||
TextRun text = fetch_text_run(ph.specific_prim_address);
|
||||
vec2 text_offset = ph.local_rect.p0 - text.offset;
|
||||
vec2 text_offset = vec2(ph.user_data.xy) / 256.0;
|
||||
|
||||
if (color_mode == COLOR_MODE_FROM_PASS) {
|
||||
color_mode = uMode;
|
||||
}
|
||||
|
||||
Glyph glyph = fetch_glyph(ph.specific_prim_address, glyph_index);
|
||||
glyph.offset += text.offset;
|
||||
glyph.offset += ph.local_rect.p0 - text_offset;
|
||||
|
||||
GlyphResource res = fetch_glyph_resource(resource_address);
|
||||
|
||||
|
|
|
@ -836,7 +836,15 @@ impl AlphaBatchBuilder {
|
|||
}
|
||||
};
|
||||
|
||||
let prim_header_index = prim_headers.push(&prim_header, z_id, [0; 3]);
|
||||
let prim_header_index = prim_headers.push(
|
||||
&prim_header,
|
||||
z_id,
|
||||
[
|
||||
(run.reference_frame_relative_offset.x * 256.0) as i32,
|
||||
(run.reference_frame_relative_offset.y * 256.0) as i32,
|
||||
0,
|
||||
],
|
||||
);
|
||||
let key = BatchKey::new(kind, blend_mode, textures);
|
||||
let base_instance = GlyphInstance::new(
|
||||
prim_header_index,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use api::{BorderRadius, BorderSide, BorderStyle, ColorF, ColorU, DeviceRect, DeviceSize};
|
||||
use api::{LayoutSideOffsets, LayoutSizeAu, LayoutPrimitiveInfo, LayoutToDeviceScale};
|
||||
use api::{DeviceVector2D, DevicePoint, LayoutRect, LayoutSize, DeviceIntSize};
|
||||
use api::{AuHelpers, LayoutPoint, RepeatMode, TexelRect};
|
||||
use api::{AuHelpers, LayoutPoint, RepeatMode, TexelRect, LayoutVector2D};
|
||||
use api::NormalBorder as ApiNormalBorder;
|
||||
use ellipse::Ellipse;
|
||||
use euclid::vec2;
|
||||
|
@ -212,6 +212,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
border: &ApiNormalBorder,
|
||||
widths: LayoutSideOffsets,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
let mut border = *border;
|
||||
ensure_no_corner_overlap(&mut border.radius, info.rect.size);
|
||||
|
@ -224,6 +225,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
border: border.into(),
|
||||
widths: widths.to_au(),
|
||||
},
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
spread_radius: f32,
|
||||
border_radius: BorderRadius,
|
||||
clip_mode: BoxShadowClipMode,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
if color.a == 0.0 {
|
||||
return;
|
||||
|
@ -166,6 +167,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
PrimitiveKeyKind::Rectangle {
|
||||
color: color.into(),
|
||||
},
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
} else {
|
||||
// Normal path for box-shadows with a valid blur radius.
|
||||
|
@ -255,6 +257,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
&prim_info,
|
||||
extra_clips,
|
||||
prim,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -720,6 +720,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info.image_rendering,
|
||||
info.alpha_type,
|
||||
info.color,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
SpecificDisplayItem::YuvImage(ref info) => {
|
||||
|
@ -730,6 +731,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info.color_depth,
|
||||
info.color_space,
|
||||
info.image_rendering,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
SpecificDisplayItem::Text(ref text_info) => {
|
||||
|
@ -749,12 +751,14 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
clip_and_scroll,
|
||||
&prim_info,
|
||||
info.color,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
SpecificDisplayItem::ClearRectangle => {
|
||||
self.add_clear_rectangle(
|
||||
clip_and_scroll,
|
||||
&prim_info,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
SpecificDisplayItem::Line(ref info) => {
|
||||
|
@ -765,6 +769,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info.orientation,
|
||||
info.color,
|
||||
info.style,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
SpecificDisplayItem::Gradient(ref info) => {
|
||||
|
@ -784,6 +789,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
&prim_info,
|
||||
Vec::new(),
|
||||
prim_key_kind,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -806,6 +812,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
&prim_info,
|
||||
Vec::new(),
|
||||
prim_key_kind,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
SpecificDisplayItem::BoxShadow(ref box_shadow_info) => {
|
||||
|
@ -823,6 +830,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
box_shadow_info.spread_radius,
|
||||
box_shadow_info.border_radius,
|
||||
box_shadow_info.clip_mode,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
SpecificDisplayItem::Border(ref info) => {
|
||||
|
@ -832,6 +840,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info,
|
||||
item.gradient_stops(),
|
||||
pipeline_id,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
SpecificDisplayItem::PushStackingContext(ref info) => {
|
||||
|
@ -976,7 +985,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
self.push_shadow(shadow, clip_and_scroll);
|
||||
}
|
||||
SpecificDisplayItem::PopAllShadows => {
|
||||
self.pop_all_shadows();
|
||||
self.pop_all_shadows(reference_frame_relative_offset);
|
||||
}
|
||||
SpecificDisplayItem::PushCacheMarker(_marker) => {
|
||||
}
|
||||
|
@ -1031,6 +1040,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
clip_chain_id: ClipChainId,
|
||||
spatial_node_index: SpatialNodeIndex,
|
||||
prim: P,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstance
|
||||
where
|
||||
P: Internable<InternData=PrimitiveSceneData>,
|
||||
|
@ -1050,8 +1060,11 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
}
|
||||
});
|
||||
|
||||
let instance_kind = prim_key.as_instance_kind(prim_data_handle,
|
||||
&mut self.prim_store);
|
||||
let instance_kind = prim_key.as_instance_kind(
|
||||
prim_data_handle,
|
||||
&mut self.prim_store,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
|
||||
PrimitiveInstance::new(
|
||||
info.rect.origin,
|
||||
|
@ -1106,6 +1119,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info: &LayoutPrimitiveInfo,
|
||||
clip_items: Vec<(LayoutPoint, ClipItemKey)>,
|
||||
prim: P,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
)
|
||||
where
|
||||
P: Internable<InternData = PrimitiveSceneData> + IsVisible,
|
||||
|
@ -1122,7 +1136,8 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info,
|
||||
clip_chain_id,
|
||||
clip_and_scroll,
|
||||
prim
|
||||
prim,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1133,6 +1148,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info: &LayoutPrimitiveInfo,
|
||||
clip_items: Vec<(LayoutPoint, ClipItemKey)>,
|
||||
prim: P,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
)
|
||||
where
|
||||
P: Internable<InternData = PrimitiveSceneData> + IsVisible,
|
||||
|
@ -1143,7 +1159,13 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// If a shadow context is not active, then add the primitive
|
||||
// directly to the parent picture.
|
||||
if self.pending_shadow_items.is_empty() {
|
||||
self.add_nonshadowable_primitive(clip_and_scroll, info, clip_items, prim);
|
||||
self.add_nonshadowable_primitive(
|
||||
clip_and_scroll,
|
||||
info,
|
||||
clip_items,
|
||||
prim,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
} else {
|
||||
debug_assert!(clip_items.is_empty(), "No per-prim clips expected for shadowed primitives");
|
||||
|
||||
|
@ -1163,6 +1185,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
clip_chain_id: ClipChainId,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
prim: P,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
)
|
||||
where
|
||||
P: Internable<InternData = PrimitiveSceneData>,
|
||||
|
@ -1174,6 +1197,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
clip_chain_id,
|
||||
clip_and_scroll.spatial_node_index,
|
||||
prim,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
self.register_chase_primitive_by_rect(
|
||||
&info.rect,
|
||||
|
@ -1747,7 +1771,10 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
}));
|
||||
}
|
||||
|
||||
pub fn pop_all_shadows(&mut self) {
|
||||
pub fn pop_all_shadows(
|
||||
&mut self,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
assert!(!self.pending_shadow_items.is_empty(), "popped shadows, but none were present");
|
||||
|
||||
let pipeline_id = self.sc_stack.last().unwrap().pipeline_id;
|
||||
|
@ -1796,19 +1823,44 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
for item in &items {
|
||||
match item {
|
||||
ShadowItem::Image(ref pending_image) => {
|
||||
self.add_shadow_prim(&pending_shadow, pending_image, &mut prims)
|
||||
self.add_shadow_prim(
|
||||
&pending_shadow,
|
||||
pending_image,
|
||||
&mut prims,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
}
|
||||
ShadowItem::LineDecoration(ref pending_line_dec) => {
|
||||
self.add_shadow_prim(&pending_shadow, pending_line_dec, &mut prims)
|
||||
self.add_shadow_prim(
|
||||
&pending_shadow,
|
||||
pending_line_dec,
|
||||
&mut prims,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
}
|
||||
ShadowItem::NormalBorder(ref pending_border) => {
|
||||
self.add_shadow_prim(&pending_shadow, pending_border, &mut prims)
|
||||
self.add_shadow_prim(
|
||||
&pending_shadow,
|
||||
pending_border,
|
||||
&mut prims,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
}
|
||||
ShadowItem::Primitive(ref pending_primitive) => {
|
||||
self.add_shadow_prim(&pending_shadow, pending_primitive, &mut prims)
|
||||
self.add_shadow_prim(
|
||||
&pending_shadow,
|
||||
pending_primitive,
|
||||
&mut prims,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
}
|
||||
ShadowItem::TextRun(ref pending_text_run) => {
|
||||
self.add_shadow_prim(&pending_shadow, pending_text_run, &mut prims)
|
||||
self.add_shadow_prim(
|
||||
&pending_shadow,
|
||||
pending_text_run,
|
||||
&mut prims,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -1885,19 +1937,34 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
}
|
||||
}
|
||||
ShadowItem::Image(pending_image) => {
|
||||
self.add_shadow_prim_to_draw_list(pending_image)
|
||||
self.add_shadow_prim_to_draw_list(
|
||||
pending_image,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
},
|
||||
ShadowItem::LineDecoration(pending_line_dec) => {
|
||||
self.add_shadow_prim_to_draw_list(pending_line_dec)
|
||||
self.add_shadow_prim_to_draw_list(
|
||||
pending_line_dec,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
},
|
||||
ShadowItem::NormalBorder(pending_border) => {
|
||||
self.add_shadow_prim_to_draw_list(pending_border)
|
||||
self.add_shadow_prim_to_draw_list(
|
||||
pending_border,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
},
|
||||
ShadowItem::Primitive(pending_primitive) => {
|
||||
self.add_shadow_prim_to_draw_list(pending_primitive)
|
||||
self.add_shadow_prim_to_draw_list(
|
||||
pending_primitive,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
},
|
||||
ShadowItem::TextRun(pending_text_run) => {
|
||||
self.add_shadow_prim_to_draw_list(pending_text_run)
|
||||
self.add_shadow_prim_to_draw_list(
|
||||
pending_text_run,
|
||||
reference_frame_relative_offset,
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -1911,6 +1978,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pending_shadow: &PendingShadow,
|
||||
pending_primitive: &PendingPrimitive<P>,
|
||||
prims: &mut Vec<PrimitiveInstance>,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
)
|
||||
where
|
||||
P: Internable<InternData=PrimitiveSceneData> + CreateShadow,
|
||||
|
@ -1930,14 +1998,18 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pending_primitive.prim.create_shadow(
|
||||
&pending_shadow.shadow,
|
||||
),
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
|
||||
// Add the new primitive to the shadow picture.
|
||||
prims.push(shadow_prim_instance);
|
||||
}
|
||||
|
||||
fn add_shadow_prim_to_draw_list<P>(&mut self, pending_primitive: PendingPrimitive<P>)
|
||||
where
|
||||
fn add_shadow_prim_to_draw_list<P>(
|
||||
&mut self,
|
||||
pending_primitive: PendingPrimitive<P>,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) where
|
||||
P: Internable<InternData = PrimitiveSceneData> + IsVisible,
|
||||
P::Source: AsInstanceKind<Handle<P::Marker>> + InternDebug,
|
||||
Interners: InternerMut<P>,
|
||||
|
@ -1950,6 +2022,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pending_primitive.clip_and_scroll.clip_chain_id,
|
||||
pending_primitive.clip_and_scroll,
|
||||
pending_primitive.prim,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1979,6 +2052,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
color: ColorF,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
if color.a == 0.0 {
|
||||
// Don't add transparent rectangles to the draw list, but do consider them for hit
|
||||
|
@ -1994,6 +2068,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
PrimitiveKeyKind::Rectangle {
|
||||
color: color.into(),
|
||||
},
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2001,12 +2076,14 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
self.add_primitive(
|
||||
clip_and_scroll,
|
||||
info,
|
||||
Vec::new(),
|
||||
PrimitiveKeyKind::Clear,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2018,6 +2095,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
orientation: LineOrientation,
|
||||
color: ColorF,
|
||||
style: LineStyle,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
// For line decorations, we can construct the render task cache key
|
||||
// here during scene building, since it doesn't depend on device
|
||||
|
@ -2079,6 +2157,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
cache_key,
|
||||
color: color.into(),
|
||||
},
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2089,6 +2168,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
border_item: &BorderDisplayItem,
|
||||
gradient_stops: ItemRange<GradientStop>,
|
||||
pipeline_id: PipelineId,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
match border_item.details {
|
||||
BorderDetails::NinePatch(ref border) => {
|
||||
|
@ -2119,6 +2199,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info,
|
||||
Vec::new(),
|
||||
prim,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
NinePatchBorderSource::Gradient(gradient) => {
|
||||
|
@ -2142,6 +2223,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info,
|
||||
Vec::new(),
|
||||
prim,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
NinePatchBorderSource::RadialGradient(gradient) => {
|
||||
|
@ -2164,6 +2246,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info,
|
||||
Vec::new(),
|
||||
prim,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -2174,6 +2257,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
border,
|
||||
border_item.widths,
|
||||
clip_and_scroll,
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2362,7 +2446,6 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
TextRun {
|
||||
glyphs: Arc::new(glyphs),
|
||||
font,
|
||||
offset: prim_offset,
|
||||
shadow: false,
|
||||
}
|
||||
};
|
||||
|
@ -2372,6 +2455,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
prim_info,
|
||||
Vec::new(),
|
||||
text_run,
|
||||
offset,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2386,6 +2470,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
image_rendering: ImageRendering,
|
||||
alpha_type: AlphaType,
|
||||
color: ColorF,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
let mut prim_rect = info.rect;
|
||||
simplify_repeated_primitive(&stretch_size, &mut tile_spacing, &mut prim_rect);
|
||||
|
@ -2420,6 +2505,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
image_rendering,
|
||||
alpha_type,
|
||||
},
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2431,6 +2517,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
color_depth: ColorDepth,
|
||||
color_space: YuvColorSpace,
|
||||
image_rendering: ImageRendering,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
let format = yuv_data.get_format();
|
||||
let yuv_key = match yuv_data {
|
||||
|
@ -2450,6 +2537,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
color_space,
|
||||
image_rendering,
|
||||
},
|
||||
reference_frame_relative_offset,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2473,6 +2561,7 @@ pub trait AsInstanceKind<H> {
|
|||
&self,
|
||||
data_handle: H,
|
||||
prim_store: &mut PrimitiveStore,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use api::{
|
||||
AuHelpers, LayoutPrimitiveInfo, LayoutSideOffsets,
|
||||
LayoutSideOffsetsAu, LayoutSize, NormalBorder, PremultipliedColorF,
|
||||
Shadow
|
||||
Shadow, LayoutVector2D,
|
||||
};
|
||||
use border::create_border_segments;
|
||||
use border::NormalBorderAu;
|
||||
|
@ -56,6 +56,7 @@ impl AsInstanceKind<NormalBorderDataHandle> for NormalBorderKey {
|
|||
&self,
|
||||
data_handle: NormalBorderDataHandle,
|
||||
_: &mut PrimitiveStore,
|
||||
_reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
PrimitiveInstanceKind::NormalBorder {
|
||||
data_handle,
|
||||
|
@ -231,6 +232,7 @@ impl AsInstanceKind<ImageBorderDataHandle> for ImageBorderKey {
|
|||
&self,
|
||||
data_handle: ImageBorderDataHandle,
|
||||
_: &mut PrimitiveStore,
|
||||
_reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
PrimitiveInstanceKind::ImageBorder {
|
||||
data_handle
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use api::{
|
||||
ColorF, ColorU,ExtendMode, GradientStop, LayoutPoint, LayoutSize,
|
||||
LayoutPrimitiveInfo, PremultipliedColorF
|
||||
LayoutPrimitiveInfo, PremultipliedColorF, LayoutVector2D,
|
||||
};
|
||||
use display_list_flattener::{AsInstanceKind, IsVisible};
|
||||
use frame_builder::FrameBuildingState;
|
||||
|
@ -84,6 +84,7 @@ impl AsInstanceKind<LinearGradientDataHandle> for LinearGradientKey {
|
|||
&self,
|
||||
data_handle: LinearGradientDataHandle,
|
||||
_prim_store: &mut PrimitiveStore,
|
||||
_reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
PrimitiveInstanceKind::LinearGradient {
|
||||
data_handle,
|
||||
|
@ -332,6 +333,7 @@ impl AsInstanceKind<RadialGradientDataHandle> for RadialGradientKey {
|
|||
&self,
|
||||
data_handle: RadialGradientDataHandle,
|
||||
_prim_store: &mut PrimitiveStore,
|
||||
_reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
PrimitiveInstanceKind::RadialGradient {
|
||||
data_handle,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use api::{
|
||||
AlphaType, ColorDepth, ColorF, ColorU, DeviceIntRect, DeviceIntSideOffsets,
|
||||
DeviceIntSize, ImageRendering, LayoutRect, LayoutSize, LayoutPrimitiveInfo,
|
||||
PremultipliedColorF, Shadow, TileOffset, YuvColorSpace, YuvFormat
|
||||
PremultipliedColorF, Shadow, TileOffset, YuvColorSpace, YuvFormat, LayoutVector2D,
|
||||
};
|
||||
use api::ImageKey as ApiImageKey;
|
||||
use display_list_flattener::{AsInstanceKind, CreateShadow, IsVisible};
|
||||
|
@ -107,6 +107,7 @@ impl AsInstanceKind<ImageDataHandle> for ImageKey {
|
|||
&self,
|
||||
data_handle: ImageDataHandle,
|
||||
prim_store: &mut PrimitiveStore,
|
||||
_reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
// TODO(gw): Refactor this to not need a separate image
|
||||
// instance (see ImageInstance struct).
|
||||
|
@ -416,6 +417,7 @@ impl AsInstanceKind<YuvImageDataHandle> for YuvImageKey {
|
|||
&self,
|
||||
data_handle: YuvImageDataHandle,
|
||||
_prim_store: &mut PrimitiveStore,
|
||||
_reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
PrimitiveInstanceKind::YuvImage {
|
||||
data_handle,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{
|
||||
ColorF, ColorU, LayoutPrimitiveInfo, LayoutSizeAu,
|
||||
ColorF, ColorU, LayoutPrimitiveInfo, LayoutSizeAu, LayoutVector2D,
|
||||
LineOrientation, LineStyle, PremultipliedColorF, Shadow,
|
||||
};
|
||||
use app_units::Au;
|
||||
|
@ -66,6 +66,7 @@ impl AsInstanceKind<LineDecorationDataHandle> for LineDecorationKey {
|
|||
&self,
|
||||
data_handle: LineDecorationDataHandle,
|
||||
_: &mut PrimitiveStore,
|
||||
_reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
PrimitiveInstanceKind::LineDecoration {
|
||||
data_handle,
|
||||
|
|
|
@ -665,6 +665,7 @@ impl AsInstanceKind<PrimitiveDataHandle> for PrimitiveKey {
|
|||
&self,
|
||||
data_handle: PrimitiveDataHandle,
|
||||
_: &mut PrimitiveStore,
|
||||
_reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
match self.kind {
|
||||
PrimitiveKeyKind::Clear => {
|
||||
|
@ -2507,6 +2508,7 @@ impl PrimitiveStore {
|
|||
}
|
||||
PrimitiveInstanceKind::TextRun { data_handle, run_index, .. } => {
|
||||
let prim_data = &mut data_stores.text_run[*data_handle];
|
||||
let run = &mut self.text_runs[*run_index];
|
||||
|
||||
// Update the template this instane references, which may refresh the GPU
|
||||
// cache with any shared template data.
|
||||
|
@ -2514,14 +2516,14 @@ impl PrimitiveStore {
|
|||
|
||||
// The transform only makes sense for screen space rasterization
|
||||
let transform = prim_context.spatial_node.world_content_transform.to_transform();
|
||||
let prim_offset = prim_instance.prim_origin.to_vector() - run.reference_frame_relative_offset;
|
||||
|
||||
// TODO(gw): This match is a bit untidy, but it should disappear completely
|
||||
// once the prepare_prims and batching are unified. When that
|
||||
// happens, we can use the cache handle immediately, and not need
|
||||
// to temporarily store it in the primitive instance.
|
||||
let run = &mut self.text_runs[*run_index];
|
||||
run.prepare_for_render(
|
||||
prim_data.offset,
|
||||
prim_offset,
|
||||
&prim_data.font,
|
||||
&prim_data.glyphs,
|
||||
frame_context.device_pixel_scale,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use api::{
|
||||
ColorU, FilterOp, LayoutSize, LayoutPrimitiveInfo, MixBlendMode,
|
||||
PropertyBinding, PropertyBindingId,
|
||||
PropertyBinding, PropertyBindingId, LayoutVector2D,
|
||||
};
|
||||
use app_units::Au;
|
||||
use display_list_flattener::{AsInstanceKind, IsVisible};
|
||||
|
@ -161,6 +161,7 @@ impl AsInstanceKind<PictureDataHandle> for PictureKey {
|
|||
&self,
|
||||
_: PictureDataHandle,
|
||||
_: &mut PrimitiveStore,
|
||||
_reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
// Should never be hit as this method should not be
|
||||
// called for pictures.
|
||||
|
|
|
@ -12,7 +12,7 @@ use gpu_cache::GpuCache;
|
|||
use intern;
|
||||
use intern_types;
|
||||
use prim_store::{PrimitiveOpacity, PrimitiveSceneData, PrimitiveScratchBuffer};
|
||||
use prim_store::{PrimitiveStore, PrimKeyCommonData, PrimTemplateCommonData, VectorKey};
|
||||
use prim_store::{PrimitiveStore, PrimKeyCommonData, PrimTemplateCommonData};
|
||||
use render_task::{RenderTaskTree};
|
||||
use renderer::{MAX_VERTEX_TEXTURE_WIDTH};
|
||||
use resource_cache::{ResourceCache};
|
||||
|
@ -30,7 +30,6 @@ use util::PrimaryArc;
|
|||
pub struct TextRunKey {
|
||||
pub common: PrimKeyCommonData,
|
||||
pub font: FontInstance,
|
||||
pub offset: VectorKey,
|
||||
pub glyphs: PrimaryArc<Vec<GlyphInstance>>,
|
||||
pub shadow: bool,
|
||||
}
|
||||
|
@ -45,7 +44,6 @@ impl TextRunKey {
|
|||
info,
|
||||
),
|
||||
font: text_run.font,
|
||||
offset: text_run.offset.into(),
|
||||
glyphs: PrimaryArc(text_run.glyphs),
|
||||
shadow: text_run.shadow,
|
||||
}
|
||||
|
@ -61,11 +59,13 @@ impl AsInstanceKind<TextRunDataHandle> for TextRunKey {
|
|||
&self,
|
||||
data_handle: TextRunDataHandle,
|
||||
prim_store: &mut PrimitiveStore,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> PrimitiveInstanceKind {
|
||||
let run_index = prim_store.text_runs.push(TextRunPrimitive {
|
||||
used_font: self.font.clone(),
|
||||
glyph_keys_range: storage::Range::empty(),
|
||||
shadow: self.shadow,
|
||||
reference_frame_relative_offset,
|
||||
});
|
||||
|
||||
PrimitiveInstanceKind::TextRun{ data_handle, run_index }
|
||||
|
@ -78,7 +78,6 @@ impl AsInstanceKind<TextRunDataHandle> for TextRunKey {
|
|||
pub struct TextRunTemplate {
|
||||
pub common: PrimTemplateCommonData,
|
||||
pub font: FontInstance,
|
||||
pub offset: LayoutVector2D,
|
||||
#[ignore_malloc_size_of = "Measured via PrimaryArc"]
|
||||
pub glyphs: Arc<Vec<GlyphInstance>>,
|
||||
}
|
||||
|
@ -102,7 +101,6 @@ impl From<TextRunKey> for TextRunTemplate {
|
|||
TextRunTemplate {
|
||||
common,
|
||||
font: item.font,
|
||||
offset: item.offset.into(),
|
||||
glyphs: item.glyphs.0,
|
||||
}
|
||||
}
|
||||
|
@ -130,12 +128,6 @@ impl TextRunTemplate {
|
|||
// this is the only case where we need to provide plain color to GPU
|
||||
let bg_color = ColorF::from(self.font.bg_color);
|
||||
request.push([bg_color.r, bg_color.g, bg_color.b, 1.0]);
|
||||
request.push([
|
||||
self.offset.x,
|
||||
self.offset.y,
|
||||
0.0,
|
||||
0.0,
|
||||
]);
|
||||
|
||||
let mut gpu_block = [0.0; 4];
|
||||
for (i, src) in self.glyphs.iter().enumerate() {
|
||||
|
@ -166,7 +158,6 @@ pub use intern_types::text_run::Handle as TextRunDataHandle;
|
|||
|
||||
pub struct TextRun {
|
||||
pub font: FontInstance,
|
||||
pub offset: LayoutVector2D,
|
||||
pub glyphs: Arc<Vec<GlyphInstance>>,
|
||||
pub shadow: bool,
|
||||
}
|
||||
|
@ -202,7 +193,6 @@ impl CreateShadow for TextRun {
|
|||
TextRun {
|
||||
font,
|
||||
glyphs: self.glyphs.clone(),
|
||||
offset: self.offset + shadow.offset,
|
||||
shadow: true
|
||||
}
|
||||
}
|
||||
|
@ -218,6 +208,7 @@ impl IsVisible for TextRun {
|
|||
pub struct TextRunPrimitive {
|
||||
pub used_font: FontInstance,
|
||||
pub glyph_keys_range: storage::Range<GlyphKey>,
|
||||
pub reference_frame_relative_offset: LayoutVector2D,
|
||||
pub shadow: bool,
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче