Skip to content

Commit

Permalink
Auto merge of #2556 - glennw:remove-text-shadow3, r=Gankro
Browse files Browse the repository at this point in the history
Unify text-shadows with the blur filter.

This removes any special code for text shadows. A text shadow is
now simply a Picture with text runs and/or line decorations that
has a blur filter applied to it.

This is possible due to the recent work related to removing the line
decoration and cached text run primitives.

This greatly simplifies the shadow code, and a lot of the functionality
of the text shadows (e.g. fast path shadows) just fall out of the
existing Picture functionality for blur filters.

Next step is to expand the primitive types that can run through the
shadow paths, which will then allow us to unify the drop-shadow
filter to be a simple shadow + blur filter.

NOTE: The PictureKind enum now has only a single kind (Image). I could
      have removed that in this PR, and added the fields to Picture
      directly. However, that will result in a lot of indentation
      changes. So I'll do that as a follow up PR to make this one
      easier to review.

<!-- 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/2556)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo authored Mar 27, 2018
2 parents 53750b8 + 2afe3d0 commit 9893ea1
Show file tree
Hide file tree
Showing 15 changed files with 267 additions and 408 deletions.
29 changes: 0 additions & 29 deletions webrender/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,35 +649,6 @@ impl AlphaBatchBuilder {
let textures = BatchTextures::render_target_cache();

match picture.kind {
PictureKind::TextShadow { .. } => {
let kind = BatchKind::Brush(
BrushBatchKind::Image(ImageBufferKind::Texture2DArray)
);
let key = BatchKey::new(kind, non_segmented_blend_mode, textures);
let batch = self.batch_list.get_suitable_batch(key, &task_relative_bounding_rect);

let uv_rect_address = render_tasks[cache_task_id]
.get_texture_handle()
.as_int(gpu_cache);

let instance = BrushInstance {
picture_address: task_address,
prim_address: prim_cache_address,
clip_chain_rect_index,
scroll_id,
clip_task_address,
z,
segment_index: 0,
edge_flags: EdgeAaSegmentMask::empty(),
brush_flags: BrushFlags::empty(),
user_data: [
uv_rect_address,
BrushImageSourceKind::Color as i32,
RasterizationSpace::Screen as i32,
],
};
batch.push(PrimitiveInstance::from(instance));
}
PictureKind::Image {
composite_mode,
secondary_render_task_id,
Expand Down
16 changes: 16 additions & 0 deletions webrender/src/clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,22 @@ impl ClipSource {
minimal_shadow_rect,
})
}

// Return a modified clip source that is the same as self
// but offset in local-space by a specified amount.
pub fn offset(&self, offset: &LayoutVector2D) -> ClipSource {
match *self {
ClipSource::LineDecoration(ref info) => {
ClipSource::LineDecoration(LineDecorationClipSource {
rect: info.rect.translate(offset),
..*info
})
}
_ => {
panic!("bug: other clip sources not expected here yet");
}
}
}
}

#[derive(Debug)]
Expand Down
Loading

0 comments on commit 9893ea1

Please sign in to comment.