Skip to content

Commit

Permalink
Bug 1404955 - Use ComplexClipRegion instead of WrComplexClipRegion. r…
Browse files Browse the repository at this point in the history
…=kats

cbindgen will let us do this now.
  • Loading branch information
jrmuizel committed Oct 3, 2017
1 parent 0b65e8f commit 5baca5e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 40 deletions.
4 changes: 2 additions & 2 deletions gfx/layers/wr/ScrollingLayersHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ ScrollingLayersHelper::DefineAndPushChain(const DisplayItemClipChain* aChain,
// and save the id
LayoutDeviceRect clip = LayoutDeviceRect::FromAppUnits(
aChain->mClip.GetClipRect(), aAppUnitsPerDevPixel);
nsTArray<wr::WrComplexClipRegion> wrRoundedRects;
aChain->mClip.ToWrComplexClipRegions(aAppUnitsPerDevPixel, aStackingContext, wrRoundedRects);
nsTArray<wr::ComplexClipRegion> wrRoundedRects;
aChain->mClip.ToComplexClipRegions(aAppUnitsPerDevPixel, aStackingContext, wrRoundedRects);
clipId = Some(aBuilder.DefineClip(aStackingContext.ToRelativeLayoutRect(clip), &wrRoundedRects));
if (!aBuilder.HasMaskClip()) {
aCache[aChain] = clipId.value();
Expand Down
2 changes: 1 addition & 1 deletion gfx/webrender_bindings/WebRenderAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ DisplayListBuilder::PopStackingContext()

wr::WrClipId
DisplayListBuilder::DefineClip(const wr::LayoutRect& aClipRect,
const nsTArray<wr::WrComplexClipRegion>* aComplex,
const nsTArray<wr::ComplexClipRegion>* aComplex,
const wr::WrImageMask* aMask)
{
uint64_t clip_id = wr_dp_define_clip(mWrState, aClipRect,
Expand Down
2 changes: 1 addition & 1 deletion gfx/webrender_bindings/WebRenderAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class DisplayListBuilder {
void PopStackingContext();

wr::WrClipId DefineClip(const wr::LayoutRect& aClipRect,
const nsTArray<wr::WrComplexClipRegion>* aComplex = nullptr,
const nsTArray<wr::ComplexClipRegion>* aComplex = nullptr,
const wr::WrImageMask* aMask = nullptr);
void PushClip(const wr::WrClipId& aClipId, bool aMask = false);
void PopClip(bool aMask = false);
Expand Down
16 changes: 8 additions & 8 deletions gfx/webrender_bindings/WebRenderTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ static inline wr::LayoutSize ToLayoutSize(const gfx::SizeTyped<T>& size)
return ls;
}

static inline wr::WrComplexClipRegion ToWrComplexClipRegion(const RoundedRect& rect)
static inline wr::ComplexClipRegion ToComplexClipRegion(const RoundedRect& rect)
{
wr::WrComplexClipRegion ret;
wr::ComplexClipRegion ret;
ret.rect = ToLayoutRect(rect.rect);
ret.radii.top_left = ToLayoutSize(rect.corners.radii[mozilla::eCornerTopLeft]);
ret.radii.top_right = ToLayoutSize(rect.corners.radii[mozilla::eCornerTopRight]);
Expand Down Expand Up @@ -495,20 +495,20 @@ static inline wr::WrOpacityProperty ToWrOpacityProperty(uint64_t id, const float
return prop;
}

static inline wr::WrComplexClipRegion ToWrComplexClipRegion(const wr::LayoutRect& rect,
const mozilla::LayerSize& size)
static inline wr::ComplexClipRegion ToComplexClipRegion(const wr::LayoutRect& rect,
const mozilla::LayerSize& size)
{
wr::WrComplexClipRegion complex_clip;
wr::ComplexClipRegion complex_clip;
complex_clip.rect = rect;
complex_clip.radii = wr::ToUniformBorderRadius(size);
return complex_clip;
}

template<class T>
static inline wr::WrComplexClipRegion ToWrComplexClipRegion(const gfx::RectTyped<T>& rect,
const mozilla::LayerSize& size)
static inline wr::ComplexClipRegion ToComplexClipRegion(const gfx::RectTyped<T>& rect,
const mozilla::LayerSize& size)
{
return ToWrComplexClipRegion(wr::ToLayoutRect(rect), size);
return ToComplexClipRegion(wr::ToLayoutRect(rect), size);
}

// Whenever possible, use wr::ExternalImageId instead of manipulating uint64_t.
Expand Down
20 changes: 2 additions & 18 deletions gfx/webrender_bindings/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,6 @@ impl ExternalImageHandler for WrExternalImageHandler {
}
}

#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct WrComplexClipRegion {
rect: LayoutRect,
radii: BorderRadius,
}

impl<'a> Into<ComplexClipRegion> for &'a WrComplexClipRegion {
fn into(self) -> ComplexClipRegion {
ComplexClipRegion {
rect: self.rect.into(),
radii: self.radii.into(),
}
}
}

#[repr(u32)]
#[derive(Copy, Clone)]
pub enum WrFilterOpType {
Expand Down Expand Up @@ -1187,13 +1171,13 @@ pub extern "C" fn wr_dp_pop_stacking_context(state: &mut WrState) {
#[no_mangle]
pub extern "C" fn wr_dp_define_clip(state: &mut WrState,
clip_rect: LayoutRect,
complex: *const WrComplexClipRegion,
complex: *const ComplexClipRegion,
complex_count: usize,
mask: *const WrImageMask)
-> u64 {
debug_assert!(unsafe { is_in_main_thread() });
let complex_slice = make_slice(complex, complex_count);
let complex_iter = complex_slice.iter().map(|x| x.into());
let complex_iter = complex_slice.iter().cloned();
let mask : Option<ImageMask> = unsafe { mask.as_ref() }.map(|x| x.into());

let clip_id = state.frame_builder.dl_builder.define_clip(None, clip_rect, complex_iter, mask);
Expand Down
8 changes: 5 additions & 3 deletions gfx/webrender_bindings/webrender_ffi_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,13 @@ struct BorderRadius {
}
};

struct WrComplexClipRegion {
struct ComplexClipRegion {
// The boundaries of the rectangle.
LayoutRect rect;
// Border radii of this rectangle.
BorderRadius radii;

bool operator==(const WrComplexClipRegion& aOther) const {
bool operator==(const ComplexClipRegion& aOther) const {
return rect == aOther.rect &&
radii == aOther.radii;
}
Expand Down Expand Up @@ -853,7 +855,7 @@ WR_FUNC;
WR_INLINE
uint64_t wr_dp_define_clip(WrState *aState,
LayoutRect aClipRect,
const WrComplexClipRegion *aComplex,
const ComplexClipRegion *aComplex,
size_t aComplexCount,
const WrImageMask *aMask)
WR_FUNC;
Expand Down
8 changes: 4 additions & 4 deletions layout/painting/DisplayItemClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,12 @@ DisplayItemClip::ToString() const
}

void
DisplayItemClip::ToWrComplexClipRegions(int32_t aAppUnitsPerDevPixel,
const layers::StackingContextHelper& aSc,
nsTArray<wr::WrComplexClipRegion>& aOutArray) const
DisplayItemClip::ToComplexClipRegions(int32_t aAppUnitsPerDevPixel,
const layers::StackingContextHelper& aSc,
nsTArray<wr::ComplexClipRegion>& aOutArray) const
{
for (uint32_t i = 0; i < mRoundedClipRects.Length(); i++) {
wr::WrComplexClipRegion* region = aOutArray.AppendElement();
wr::ComplexClipRegion* region = aOutArray.AppendElement();
region->rect = aSc.ToRelativeLayoutRect(LayoutDeviceRect::FromAppUnits(
mRoundedClipRects[i].mRect, aAppUnitsPerDevPixel));
const nscoord* radii = mRoundedClipRects[i].mRadii;
Expand Down
6 changes: 3 additions & 3 deletions layout/painting/DisplayItemClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace layers {
class StackingContextHelper;
} // namespace layers
namespace wr {
struct WrComplexClipRegion;
struct ComplexClipRegion;
} // namepsace wr
} // namespace mozilla

Expand Down Expand Up @@ -180,9 +180,9 @@ class DisplayItemClip {
uint32_t GetRoundedRectCount() const { return mRoundedClipRects.Length(); }
void AppendRoundedRects(nsTArray<RoundedRect>* aArray, uint32_t aCount) const;

void ToWrComplexClipRegions(int32_t aAppUnitsPerDevPixel,
void ToComplexClipRegions(int32_t aAppUnitsPerDevPixel,
const layers::StackingContextHelper& aSc,
nsTArray<wr::WrComplexClipRegion>& aOutArray) const;
nsTArray<wr::ComplexClipRegion>& aOutArray) const;

static const DisplayItemClip& NoClip();

Expand Down

0 comments on commit 5baca5e

Please sign in to comment.