Skip to content

Commit a884e67

Browse files
author
bors-servo
authored
Auto merge of #1801 - glennw:text-shadow-rename, r=nical
Rename text-shadow APIs to shadow instead. In the near future, the text-shadow APIs will be used to implement other types of shadows (e.g. box-shadows). This patch just renames all functions and structures, which will make it easier to review the follow up patches that modify box shadows to work via the current text-shadow API. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1801) <!-- Reviewable:end -->
2 parents 9ba91c3 + 75216e5 commit a884e67

27 files changed

+131
-131
lines changed

webrender/src/frame.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,15 +800,15 @@ impl Frame {
800800
SpecificDisplayItem::PopStackingContext => {
801801
unreachable!("Should have returned in parent method.")
802802
}
803-
SpecificDisplayItem::PushTextShadow(shadow) => {
803+
SpecificDisplayItem::PushShadow(shadow) => {
804804
let mut prim_info = prim_info.clone();
805805
prim_info.rect = LayerRect::zero();
806806
context
807807
.builder
808-
.push_text_shadow(shadow, clip_and_scroll, &prim_info);
808+
.push_shadow(shadow, clip_and_scroll, &prim_info);
809809
}
810-
SpecificDisplayItem::PopTextShadow => {
811-
context.builder.pop_text_shadow();
810+
SpecificDisplayItem::PopShadow => {
811+
context.builder.pop_shadow();
812812
}
813813
}
814814
None

webrender/src/frame_builder.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use api::{GlyphInstance, GlyphOptions, GradientStop, HitTestFlags, HitTestItem,
1010
use api::{ImageKey, ImageRendering, ItemRange, ItemTag, LayerPoint, LayerPrimitiveInfo, LayerRect};
1111
use api::{LayerSize, LayerToScrollTransform, LayerVector2D, LayoutVector2D, LineOrientation};
1212
use api::{LineStyle, LocalClip, POINT_RELATIVE_TO_PIPELINE_VIEWPORT, PipelineId, RepeatMode};
13-
use api::{ScrollSensitivity, SubpixelDirection, TextShadow, TileOffset, TransformStyle};
13+
use api::{ScrollSensitivity, SubpixelDirection, Shadow, TileOffset, TransformStyle};
1414
use api::{WorldPixel, WorldPoint, YuvColorSpace, YuvData, device_length};
1515
use app_units::Au;
1616
use border::ImageBorderSegment;
@@ -26,7 +26,7 @@ use prim_store::{BoxShadowPrimitiveCpu, TexelRect, YuvImagePrimitiveCpu};
2626
use prim_store::{GradientPrimitiveCpu, ImagePrimitiveCpu, LinePrimitive, PrimitiveKind};
2727
use prim_store::{PrimitiveContainer, PrimitiveIndex};
2828
use prim_store::{PrimitiveStore, RadialGradientPrimitiveCpu};
29-
use prim_store::{RectanglePrimitive, TextRunPrimitiveCpu, TextShadowPrimitiveCpu};
29+
use prim_store::{RectanglePrimitive, TextRunPrimitiveCpu, ShadowPrimitiveCpu};
3030
use profiler::{FrameProfileCounters, GpuCacheProfileCounters, TextureCacheProfileCounters};
3131
use render_task::{AlphaRenderItem, ClipWorkItem, RenderTask};
3232
use render_task::{RenderTaskId, RenderTaskLocation, RenderTaskTree};
@@ -100,7 +100,7 @@ pub struct FrameBuilder {
100100
clip_scroll_group_indices: FastHashMap<ClipAndScrollInfo, usize>,
101101
packed_layers: Vec<PackedLayer>,
102102

103-
// A stack of the current text-shadow primitives.
103+
// A stack of the current shadow primitives.
104104
shadow_prim_stack: Vec<PrimitiveIndex>,
105105

106106
scrollbar_prims: Vec<ScrollbarPrimitive>,
@@ -578,33 +578,33 @@ impl FrameBuilder {
578578
self.reference_frame_stack.pop();
579579
}
580580

581-
pub fn push_text_shadow(
581+
pub fn push_shadow(
582582
&mut self,
583-
shadow: TextShadow,
583+
shadow: Shadow,
584584
clip_and_scroll: ClipAndScrollInfo,
585585
info: &LayerPrimitiveInfo,
586586
) {
587-
let prim = TextShadowPrimitiveCpu {
587+
let prim = ShadowPrimitiveCpu {
588588
shadow,
589589
primitives: Vec::new(),
590590
render_task_id: None,
591591
};
592592

593-
// Create an empty text-shadow primitive. Insert it into
593+
// Create an empty shadow primitive. Insert it into
594594
// the draw lists immediately so that it will be drawn
595595
// before any visual text elements that are added as
596-
// part of this text-shadow context.
596+
// part of this shadow context.
597597
let prim_index = self.add_primitive(
598598
clip_and_scroll,
599599
info,
600600
Vec::new(),
601-
PrimitiveContainer::TextShadow(prim),
601+
PrimitiveContainer::Shadow(prim),
602602
);
603603

604604
self.shadow_prim_stack.push(prim_index);
605605
}
606606

607-
pub fn pop_text_shadow(&mut self) {
607+
pub fn pop_shadow(&mut self) {
608608
let prim_index = self.shadow_prim_stack
609609
.pop()
610610
.expect("invalid shadow push/pop count");
@@ -614,7 +614,7 @@ impl FrameBuilder {
614614
// safe to offset the local rect by the offset of the shadow, which
615615
// is then used when blitting the shadow to the final location.
616616
let metadata = &mut self.prim_store.cpu_metadata[prim_index.0];
617-
let prim = &self.prim_store.cpu_text_shadows[metadata.cpu_prim_index.0];
617+
let prim = &self.prim_store.cpu_shadows[metadata.cpu_prim_index.0];
618618

619619
metadata.local_rect = metadata.local_rect.translate(&prim.shadow.offset);
620620
}
@@ -683,15 +683,15 @@ impl FrameBuilder {
683683
orientation: orientation,
684684
};
685685

686-
let mut fast_text_shadow_prims = Vec::new();
686+
let mut fast_shadow_prims = Vec::new();
687687
for shadow_prim_index in &self.shadow_prim_stack {
688688
let shadow_metadata = &self.prim_store.cpu_metadata[shadow_prim_index.0];
689-
let shadow_prim = &self.prim_store.cpu_text_shadows[shadow_metadata.cpu_prim_index.0];
689+
let shadow_prim = &self.prim_store.cpu_shadows[shadow_metadata.cpu_prim_index.0];
690690
if shadow_prim.shadow.blur_radius == 0.0 {
691-
fast_text_shadow_prims.push(shadow_prim.shadow);
691+
fast_shadow_prims.push(shadow_prim.shadow);
692692
}
693693
}
694-
for shadow in fast_text_shadow_prims {
694+
for shadow in fast_shadow_prims {
695695
let mut line = line.clone();
696696
line.color = shadow.color;
697697
let mut info = info.clone();
@@ -720,9 +720,9 @@ impl FrameBuilder {
720720

721721
for shadow_prim_index in &self.shadow_prim_stack {
722722
let shadow_metadata = &mut self.prim_store.cpu_metadata[shadow_prim_index.0];
723-
debug_assert_eq!(shadow_metadata.prim_kind, PrimitiveKind::TextShadow);
723+
debug_assert_eq!(shadow_metadata.prim_kind, PrimitiveKind::Shadow);
724724
let shadow_prim =
725-
&mut self.prim_store.cpu_text_shadows[shadow_metadata.cpu_prim_index.0];
725+
&mut self.prim_store.cpu_shadows[shadow_metadata.cpu_prim_index.0];
726726

727727
// Only run real blurs here (fast path zero blurs are handled above).
728728
if shadow_prim.shadow.blur_radius > 0.0 {
@@ -1208,10 +1208,10 @@ impl FrameBuilder {
12081208
// *before* the visual text primitive in order to get the correct paint
12091209
// order. Store them in a Vec first to work around borrowck issues.
12101210
// TODO(gw): Refactor to avoid having to store them in a Vec first.
1211-
let mut fast_text_shadow_prims = Vec::new();
1211+
let mut fast_shadow_prims = Vec::new();
12121212
for shadow_prim_index in &self.shadow_prim_stack {
12131213
let shadow_metadata = &self.prim_store.cpu_metadata[shadow_prim_index.0];
1214-
let shadow_prim = &self.prim_store.cpu_text_shadows[shadow_metadata.cpu_prim_index.0];
1214+
let shadow_prim = &self.prim_store.cpu_shadows[shadow_metadata.cpu_prim_index.0];
12151215
if shadow_prim.shadow.blur_radius == 0.0 {
12161216
let mut text_prim = prim.clone();
12171217
if font.render_mode != FontRenderMode::Bitmap {
@@ -1225,10 +1225,10 @@ impl FrameBuilder {
12251225
}
12261226
text_prim.color = shadow_prim.shadow.color;
12271227
text_prim.offset += shadow_prim.shadow.offset;
1228-
fast_text_shadow_prims.push(text_prim);
1228+
fast_shadow_prims.push(text_prim);
12291229
}
12301230
}
1231-
for text_prim in fast_text_shadow_prims {
1231+
for text_prim in fast_shadow_prims {
12321232
let rect = info.rect;
12331233
let mut info = info.clone();
12341234
info.rect = rect.translate(&text_prim.offset);
@@ -1258,15 +1258,15 @@ impl FrameBuilder {
12581258
// Now add this primitive index to all the currently active text shadow
12591259
// primitives. Although we're adding the indices *after* the visual
12601260
// primitive here, they will still draw before the visual text, since
1261-
// the text-shadow primitive itself has been added to the draw cmd
1262-
// list *before* the visual element, during push_text_shadow. We need
1261+
// the shadow primitive itself has been added to the draw cmd
1262+
// list *before* the visual element, during push_shadow. We need
12631263
// the primitive index of the visual element here before we can add
12641264
// the indices as sub-primitives to the shadow primitives.
12651265
for shadow_prim_index in &self.shadow_prim_stack {
12661266
let shadow_metadata = &mut self.prim_store.cpu_metadata[shadow_prim_index.0];
1267-
debug_assert_eq!(shadow_metadata.prim_kind, PrimitiveKind::TextShadow);
1267+
debug_assert_eq!(shadow_metadata.prim_kind, PrimitiveKind::Shadow);
12681268
let shadow_prim =
1269-
&mut self.prim_store.cpu_text_shadows[shadow_metadata.cpu_prim_index.0];
1269+
&mut self.prim_store.cpu_shadows[shadow_metadata.cpu_prim_index.0];
12701270

12711271
// Only run real blurs here (fast path zero blurs are handled above).
12721272
if shadow_prim.shadow.blur_radius > 0.0 {

webrender/src/prim_store.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use api::{BorderRadius, BuiltDisplayList, ColorF, ComplexClipRegion, DeviceIntRect, DeviceIntSize};
66
use api::{DevicePoint, ExtendMode, FontInstance, FontRenderMode, GlyphInstance, GlyphKey};
77
use api::{GradientStop, ImageKey, ImageRendering, ItemRange, ItemTag, LayerPoint, LayerRect};
8-
use api::{LayerSize, LayerVector2D, LineOrientation, LineStyle, TextShadow};
8+
use api::{LayerSize, LayerVector2D, LineOrientation, LineStyle, Shadow};
99
use api::{TileOffset, YuvColorSpace, YuvFormat, device_length};
1010
use app_units::Au;
1111
use border::BorderCornerInstance;
@@ -110,7 +110,7 @@ pub enum PrimitiveKind {
110110
AngleGradient,
111111
RadialGradient,
112112
BoxShadow,
113-
TextShadow,
113+
Shadow,
114114
Line,
115115
}
116116

@@ -515,8 +515,8 @@ impl RadialGradientPrimitiveCpu {
515515
}
516516

517517
#[derive(Debug)]
518-
pub struct TextShadowPrimitiveCpu {
519-
pub shadow: TextShadow,
518+
pub struct ShadowPrimitiveCpu {
519+
pub shadow: Shadow,
520520
pub primitives: Vec<PrimitiveIndex>,
521521
pub render_task_id: Option<RenderTaskId>,
522522
}
@@ -807,15 +807,15 @@ pub enum PrimitiveContainer {
807807
AngleGradient(GradientPrimitiveCpu),
808808
RadialGradient(RadialGradientPrimitiveCpu),
809809
BoxShadow(BoxShadowPrimitiveCpu),
810-
TextShadow(TextShadowPrimitiveCpu),
810+
Shadow(ShadowPrimitiveCpu),
811811
Line(LinePrimitive),
812812
}
813813

814814
pub struct PrimitiveStore {
815815
/// CPU side information only.
816816
pub cpu_rectangles: Vec<RectanglePrimitive>,
817817
pub cpu_text_runs: Vec<TextRunPrimitiveCpu>,
818-
pub cpu_text_shadows: Vec<TextShadowPrimitiveCpu>,
818+
pub cpu_shadows: Vec<ShadowPrimitiveCpu>,
819819
pub cpu_images: Vec<ImagePrimitiveCpu>,
820820
pub cpu_yuv_images: Vec<YuvImagePrimitiveCpu>,
821821
pub cpu_gradients: Vec<GradientPrimitiveCpu>,
@@ -832,7 +832,7 @@ impl PrimitiveStore {
832832
cpu_metadata: Vec::new(),
833833
cpu_rectangles: Vec::new(),
834834
cpu_text_runs: Vec::new(),
835-
cpu_text_shadows: Vec::new(),
835+
cpu_shadows: Vec::new(),
836836
cpu_images: Vec::new(),
837837
cpu_yuv_images: Vec::new(),
838838
cpu_gradients: Vec::new(),
@@ -848,7 +848,7 @@ impl PrimitiveStore {
848848
cpu_metadata: recycle_vec(self.cpu_metadata),
849849
cpu_rectangles: recycle_vec(self.cpu_rectangles),
850850
cpu_text_runs: recycle_vec(self.cpu_text_runs),
851-
cpu_text_shadows: recycle_vec(self.cpu_text_shadows),
851+
cpu_shadows: recycle_vec(self.cpu_shadows),
852852
cpu_images: recycle_vec(self.cpu_images),
853853
cpu_yuv_images: recycle_vec(self.cpu_yuv_images),
854854
cpu_gradients: recycle_vec(self.cpu_gradients),
@@ -920,15 +920,15 @@ impl PrimitiveStore {
920920
self.cpu_text_runs.push(text_cpu);
921921
metadata
922922
}
923-
PrimitiveContainer::TextShadow(text_shadow) => {
923+
PrimitiveContainer::Shadow(shadow) => {
924924
let metadata = PrimitiveMetadata {
925925
opacity: PrimitiveOpacity::translucent(),
926-
prim_kind: PrimitiveKind::TextShadow,
927-
cpu_prim_index: SpecificPrimitiveIndex(self.cpu_text_shadows.len()),
926+
prim_kind: PrimitiveKind::Shadow,
927+
cpu_prim_index: SpecificPrimitiveIndex(self.cpu_shadows.len()),
928928
..base_metadata
929929
};
930930

931-
self.cpu_text_shadows.push(text_shadow);
931+
self.cpu_shadows.push(shadow);
932932
metadata
933933
}
934934
PrimitiveContainer::Image(image_cpu) => {
@@ -1035,9 +1035,9 @@ impl PrimitiveStore {
10351035
let box_shadow = &self.cpu_box_shadows[metadata.cpu_prim_index.0];
10361036
box_shadow.render_task_id
10371037
}
1038-
PrimitiveKind::TextShadow => {
1039-
let text_shadow = &self.cpu_text_shadows[metadata.cpu_prim_index.0];
1040-
text_shadow.render_task_id
1038+
PrimitiveKind::Shadow => {
1039+
let shadow = &self.cpu_shadows[metadata.cpu_prim_index.0];
1040+
shadow.render_task_id
10411041
}
10421042
PrimitiveKind::Rectangle |
10431043
PrimitiveKind::TextRun |
@@ -1114,10 +1114,10 @@ impl PrimitiveStore {
11141114
// ignore the new task if we are in a dependency context
11151115
box_shadow.render_task_id = render_tasks.map(|rt| rt.add(render_task));
11161116
}
1117-
PrimitiveKind::TextShadow => {
1118-
let shadow = &mut self.cpu_text_shadows[metadata.cpu_prim_index.0];
1117+
PrimitiveKind::Shadow => {
1118+
let shadow = &mut self.cpu_shadows[metadata.cpu_prim_index.0];
11191119

1120-
// This is a text-shadow element. Create a render task that will
1120+
// This is a shadow element. Create a render task that will
11211121
// render the text run to a target, and then apply a gaussian
11221122
// blur to that text run in order to build the actual primitive
11231123
// which will be blitted to the framebuffer.
@@ -1234,8 +1234,8 @@ impl PrimitiveStore {
12341234
let text = &self.cpu_text_runs[metadata.cpu_prim_index.0];
12351235
text.write_gpu_blocks(&mut request);
12361236
}
1237-
PrimitiveKind::TextShadow => {
1238-
let prim = &self.cpu_text_shadows[metadata.cpu_prim_index.0];
1237+
PrimitiveKind::Shadow => {
1238+
let prim = &self.cpu_shadows[metadata.cpu_prim_index.0];
12391239
request.push(prim.shadow.color);
12401240
request.push([
12411241
prim.shadow.offset.x,
@@ -1374,8 +1374,8 @@ impl PrimitiveStore {
13741374
};
13751375

13761376
let dependencies = match metadata.prim_kind {
1377-
PrimitiveKind::TextShadow =>
1378-
self.cpu_text_shadows[metadata.cpu_prim_index.0].primitives.clone(),
1377+
PrimitiveKind::Shadow =>
1378+
self.cpu_shadows[metadata.cpu_prim_index.0].primitives.clone(),
13791379
_ => Vec::new(),
13801380
};
13811381
(geometry, dependencies)

webrender/src/render_backend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ impl ToDebugString for SpecificDisplayItem {
716716
SpecificDisplayItem::PopNestedDisplayList => String::from("pop_nested_display_list"),
717717
SpecificDisplayItem::SetGradientStops => String::from("set_gradient_stops"),
718718
SpecificDisplayItem::PopStackingContext => String::from("pop_stacking_context"),
719-
SpecificDisplayItem::PushTextShadow(..) => String::from("push_text_shadow"),
720-
SpecificDisplayItem::PopTextShadow => String::from("pop_text_shadow"),
719+
SpecificDisplayItem::PushShadow(..) => String::from("push_shadow"),
720+
SpecificDisplayItem::PopShadow => String::from("pop_shadow"),
721721
}
722722
}
723723
}

webrender/src/renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2659,7 +2659,7 @@ impl Renderer {
26592659

26602660
// Draw any textrun caches for this target. For now, this
26612661
// is only used to cache text runs that are to be blurred
2662-
// for text-shadow support. In the future it may be worth
2662+
// for shadow support. In the future it may be worth
26632663
// considering using this for (some) other text runs, since
26642664
// it removes the overhead of submitting many small glyphs
26652665
// to multiple tiles in the normal text run case.

webrender/src/tiling.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl AlphaBatchHelpers for PrimitiveStore {
6464
PrimitiveKind::AlignedGradient |
6565
PrimitiveKind::AngleGradient |
6666
PrimitiveKind::RadialGradient |
67-
PrimitiveKind::TextShadow => if needs_blending {
67+
PrimitiveKind::Shadow => if needs_blending {
6868
BlendMode::PremultipliedAlpha
6969
} else {
7070
BlendMode::None
@@ -541,10 +541,10 @@ impl AlphaRenderItem {
541541
},
542542
);
543543
}
544-
PrimitiveKind::TextShadow => {
545-
let text_shadow =
546-
&ctx.prim_store.cpu_text_shadows[prim_metadata.cpu_prim_index.0];
547-
let cache_task_id = text_shadow.render_task_id.expect("no render task!");
544+
PrimitiveKind::Shadow => {
545+
let shadow =
546+
&ctx.prim_store.cpu_shadows[prim_metadata.cpu_prim_index.0];
547+
let cache_task_id = shadow.render_task_id.expect("no render task!");
548548
let cache_task_address = render_tasks.get_task_address(cache_task_id);
549549
let textures = BatchTextures::render_target_cache();
550550
let kind = BatchKind::Transformable(
@@ -1140,8 +1140,8 @@ impl RenderTarget for ColorRenderTarget {
11401140
let prim_address = prim_metadata.gpu_location.as_int(gpu_cache);
11411141

11421142
match prim_metadata.prim_kind {
1143-
PrimitiveKind::TextShadow => {
1144-
let prim = &ctx.prim_store.cpu_text_shadows[prim_metadata.cpu_prim_index.0];
1143+
PrimitiveKind::Shadow => {
1144+
let prim = &ctx.prim_store.cpu_shadows[prim_metadata.cpu_prim_index.0];
11451145

11461146
let task_index = render_tasks.get_task_address(task_id);
11471147

@@ -1160,8 +1160,8 @@ impl RenderTarget for ColorRenderTarget {
11601160
match sub_metadata.prim_kind {
11611161
PrimitiveKind::TextRun => {
11621162
// Add instances that reference the text run GPU location. Also supply
1163-
// the parent text-shadow prim address as a user data field, allowing
1164-
// the shader to fetch the text-shadow parameters.
1163+
// the parent shadow prim address as a user data field, allowing
1164+
// the shader to fetch the shadow parameters.
11651165
let text = &ctx.prim_store.cpu_text_runs
11661166
[sub_metadata.cpu_prim_index.0];
11671167
let text_run_cache_prims = &mut self.text_run_cache_prims;

webrender_api/src/display_item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ pub enum SpecificDisplayItem {
104104
SetGradientStops,
105105
PushNestedDisplayList,
106106
PopNestedDisplayList,
107-
PushTextShadow(TextShadow),
108-
PopTextShadow,
107+
PushShadow(Shadow),
108+
PopShadow,
109109
}
110110

111111
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
@@ -308,7 +308,7 @@ pub struct BoxShadowDisplayItem {
308308

309309
#[repr(C)]
310310
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
311-
pub struct TextShadow {
311+
pub struct Shadow {
312312
pub offset: LayoutVector2D,
313313
pub color: ColorF,
314314
pub blur_radius: f32,

0 commit comments

Comments
 (0)