Commit 7cda552a authored by Andrew Osmond's avatar Andrew Osmond
Browse files

Bug 1574493 - Part 1. Split out repeating and non-repeating images in the display list. r=jrmuizel

Repeating/background images may have extra parameters such the stretch
size and tile spacing, that non-repeating images do not require. By
splitting these apart, we can make it easier to infer what we should do
if snapping changes the size of an image primitive, in addition to
reducing the display list size for non-repeating images.

Differential Revision: https://phabricator.services.mozilla.com/D45056

--HG--
extra : moz-landing-system : lando
parent 7c06e892
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -1091,14 +1091,15 @@ void DisplayListBuilder::PushImage(
    const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
    bool aIsBackfaceVisible, wr::ImageRendering aFilter, wr::ImageKey aImage,
    bool aPremultipliedAlpha, const wr::ColorF& aColor) {
  wr::LayoutSize size;
  size.width = aBounds.size.width;
  size.height = aBounds.size.height;
  PushImage(aBounds, aClip, aIsBackfaceVisible, size, size, aFilter, aImage,
  wr::LayoutRect clip = MergeClipLeaf(aClip);
  WRDL_LOG("PushImage b=%s cl=%s\n", mWrState, Stringify(aBounds).c_str(),
           Stringify(clip).c_str());
  wr_dp_push_image(mWrState, aBounds, clip, aIsBackfaceVisible,
                   &mCurrentSpaceAndClipChain, aFilter, aImage,
                   aPremultipliedAlpha, aColor);
}

void DisplayListBuilder::PushImage(
void DisplayListBuilder::PushRepeatingImage(
    const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
    bool aIsBackfaceVisible, const wr::LayoutSize& aStretchSize,
    const wr::LayoutSize& aTileSpacing, wr::ImageRendering aFilter,
@@ -1107,9 +1108,9 @@ void DisplayListBuilder::PushImage(
  WRDL_LOG("PushImage b=%s cl=%s s=%s t=%s\n", mWrState,
           Stringify(aBounds).c_str(), Stringify(clip).c_str(),
           Stringify(aStretchSize).c_str(), Stringify(aTileSpacing).c_str());
  wr_dp_push_image(mWrState, aBounds, clip, aIsBackfaceVisible,
                   &mCurrentSpaceAndClipChain, aStretchSize, aTileSpacing,
                   aFilter, aImage, aPremultipliedAlpha, aColor);
  wr_dp_push_repeating_image(
      mWrState, aBounds, clip, aIsBackfaceVisible, &mCurrentSpaceAndClipChain,
      aStretchSize, aTileSpacing, aFilter, aImage, aPremultipliedAlpha, aColor);
}

void DisplayListBuilder::PushYCbCrPlanarImage(
+6 −5
Original line number Diff line number Diff line
@@ -479,7 +479,8 @@ class DisplayListBuilder final {
                 wr::ImageKey aImage, bool aPremultipliedAlpha = true,
                 const wr::ColorF& aColor = wr::ColorF{1.0f, 1.0f, 1.0f, 1.0f});

  void PushImage(const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
  void PushRepeatingImage(
      const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
      bool aIsBackfaceVisible, const wr::LayoutSize& aStretchSize,
      const wr::LayoutSize& aTileSpacing, wr::ImageRendering aFilter,
      wr::ImageKey aImage, bool aPremultipliedAlpha = true,
+42 −4
Original line number Diff line number Diff line
@@ -2566,6 +2566,44 @@ pub extern "C" fn wr_dp_push_clear_rect_with_parent_clip(

#[no_mangle]
pub extern "C" fn wr_dp_push_image(state: &mut WrState,
                                   bounds: LayoutRect,
                                   clip: LayoutRect,
                                   is_backface_visible: bool,
                                   parent: &WrSpaceAndClipChain,
                                   image_rendering: ImageRendering,
                                   key: WrImageKey,
                                   premultiplied_alpha: bool,
                                   color: ColorF) {
    debug_assert!(unsafe { is_in_main_thread() || is_in_compositor_thread() });

    let space_and_clip = parent.to_webrender(state.pipeline_id);

    let prim_info = CommonItemProperties {
        clip_rect: clip,
        clip_id: space_and_clip.clip_id,
        spatial_id: space_and_clip.spatial_id,
        is_backface_visible,
        hit_info: state.current_tag,
    };

    let alpha_type = if premultiplied_alpha {
        AlphaType::PremultipliedAlpha
    } else {
        AlphaType::Alpha
    };

    state.frame_builder
         .dl_builder
         .push_image(&prim_info,
                     bounds,
                     image_rendering,
                     alpha_type,
                     key,
                     color);
}

#[no_mangle]
pub extern "C" fn wr_dp_push_repeating_image(state: &mut WrState,
                                             bounds: LayoutRect,
                                             clip: LayoutRect,
                                             is_backface_visible: bool,
@@ -2596,7 +2634,7 @@ pub extern "C" fn wr_dp_push_image(state: &mut WrState,

    state.frame_builder
         .dl_builder
         .push_image(&prim_info,
         .push_repeating_image(&prim_info,
                               bounds,
                               stretch_size,
                               tile_spacing,
+0 −4
Original line number Diff line number Diff line
@@ -236,8 +236,6 @@ impl Example for App {
        builder.push_image(
            &CommonItemProperties::new(bounds, space_and_clip),
            bounds,
            LayoutSize::new(500.0, 500.0),
            LayoutSize::new(0.0, 0.0),
            api::ImageRendering::Auto,
            api::AlphaType::PremultipliedAlpha,
            blob_img1.as_image(),
@@ -248,8 +246,6 @@ impl Example for App {
        builder.push_image(
            &CommonItemProperties::new(bounds, space_and_clip),
            bounds,
            LayoutSize::new(200.0, 200.0),
            LayoutSize::new(0.0, 0.0),
            api::ImageRendering::Auto,
            api::AlphaType::PremultipliedAlpha,
            blob_img2.as_image(),
+0 −2
Original line number Diff line number Diff line
@@ -170,8 +170,6 @@ impl Example for App {
        builder.push_image(
            &CommonItemProperties::new(bounds, space_and_clip),
            bounds,
            bounds.size,
            LayoutSize::zero(),
            ImageRendering::Auto,
            AlphaType::PremultipliedAlpha,
            self.external_image_key.unwrap(),
Loading