Bug 1351480 - Update bindings for gradients. r?jrmuizel
MozReview-Commit-ID: 48bjXH4ZCBi
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -515,27 +515,24 @@ DisplayListBuilder::PushLinearGradient(c
aStartPoint, aEndPoint,
aStops.Elements(), aStops.Length(),
aExtendMode);
}
void
DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
const WrClipRegion& aClip,
- const WrPoint& aStartCenter,
- const WrPoint& aEndCenter,
- float aStartRadius,
- float aEndRadius,
+ const WrPoint& aCenter,
+ const WrSize& aRadius,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode)
{
wr_dp_push_radial_gradient(mWrState,
aBounds, aClip,
- aStartCenter, aEndCenter,
- aStartRadius, aEndRadius,
+ aCenter, aRadius,
aStops.Elements(), aStops.Length(),
aExtendMode);
}
void
DisplayListBuilder::PushImage(const WrRect& aBounds,
const WrClipRegion& aClip,
wr::ImageRendering aFilter,
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -160,20 +160,18 @@ public:
const WrClipRegion& aClip,
const WrPoint& aStartPoint,
const WrPoint& aEndPoint,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode);
void PushRadialGradient(const WrRect& aBounds,
const WrClipRegion& aClip,
- const WrPoint& aStartCenter,
- const WrPoint& aEndCenter,
- float aStartRadius,
- float aEndRadius,
+ const WrPoint& aCenter,
+ const WrSize& aRadius,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode);
void PushImage(const WrRect& aBounds,
const WrClipRegion& aClip,
wr::ImageRendering aFilter,
wr::ImageKey aImage);
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1254,48 +1254,46 @@ pub extern "C" fn wr_dp_push_linear_grad
stops: *const WrGradientStop,
stops_count: usize,
extend_mode: WrGradientExtendMode) {
assert!(unsafe { is_in_main_thread() });
let stops =
WrGradientStop::to_gradient_stops(unsafe { slice::from_raw_parts(stops, stops_count) });
+ let gradient = state.frame_builder.dl_builder.create_gradient(start_point.to_point(),
+ end_point.to_point(),
+ stops,
+ extend_mode.to_gradient_extend_mode());
state.frame_builder.dl_builder.push_gradient(rect.to_rect(),
clip.to_clip_region(),
- start_point.to_point(),
- end_point.to_point(),
- stops,
- extend_mode.to_gradient_extend_mode());
+ gradient);
}
#[no_mangle]
pub extern "C" fn wr_dp_push_radial_gradient(state: &mut WrState,
rect: WrRect,
clip: WrClipRegion,
- start_center: WrPoint,
- end_center: WrPoint,
- start_radius: f32,
- end_radius: f32,
+ center: WrPoint,
+ radius: WrSize,
stops: *const WrGradientStop,
stops_count: usize,
extend_mode: WrGradientExtendMode) {
assert!(unsafe { is_in_main_thread() });
let stops =
WrGradientStop::to_gradient_stops(unsafe { slice::from_raw_parts(stops, stops_count) });
+ let gradient = state.frame_builder.dl_builder.create_radial_gradient(center.to_point(),
+ radius.to_size(),
+ stops,
+ extend_mode.to_gradient_extend_mode());
state.frame_builder.dl_builder.push_radial_gradient(rect.to_rect(),
clip.to_clip_region(),
- start_center.to_point(),
- start_radius,
- end_center.to_point(),
- end_radius,
- stops,
- extend_mode.to_gradient_extend_mode());
+ gradient);
}
#[no_mangle]
pub extern "C" fn wr_dp_push_box_shadow(state: &mut WrState,
rect: WrRect,
clip: WrClipRegion,
box_bounds: WrRect,
offset: WrPoint,
--- a/gfx/webrender_bindings/webrender_ffi.h
+++ b/gfx/webrender_bindings/webrender_ffi.h
@@ -688,18 +688,17 @@ WR_INLINE void
wr_dp_push_linear_gradient(WrState* wrState, WrRect bounds, WrClipRegion clip,
WrPoint startPoint, WrPoint endPoint,
const WrGradientStop* stops, size_t stopsCount,
WrGradientExtendMode extendMode)
WR_FUNC;
WR_INLINE void
wr_dp_push_radial_gradient(WrState* wrState, WrRect bounds, WrClipRegion clip,
- WrPoint startCenter, WrPoint endCenter,
- float startRadius, float endRadius,
+ WrPoint center, WrSize radius,
const WrGradientStop* stops, size_t stopsCount,
WrGradientExtendMode extendMode)
WR_FUNC;
WR_INLINE void
wr_dp_push_box_shadow(WrState* wrState, WrRect rect, WrClipRegion clip,
WrRect box_bounds, WrPoint offset, WrColor color,
float blur_radius, float spread_radius, float border_radius,
--- a/layout/painting/nsCSSRenderingGradients.cpp
+++ b/layout/painting/nsCSSRenderingGradients.cpp
@@ -1021,21 +1021,19 @@ nsCSSGradientRenderer::BuildWebRenderDis
for(uint32_t i = 0; i < mStops.Length(); i++) {
stops[i].color.r = mStops[i].mColor.r;
stops[i].color.g = mStops[i].mColor.g;
stops[i].color.b = mStops[i].mColor.b;
stops[i].color.a = mStops[i].mColor.a * aOpacity;
stops[i].offset = mStops[i].mPosition;
}
- double firstStop = mStops[0].mPosition;
- double lastStop = mStops[mStops.Length() - 1].mPosition;
-
LayoutDevicePoint lineStart = LayoutDevicePoint(mLineStart.x, mLineStart.y);
LayoutDevicePoint lineEnd = LayoutDevicePoint(mLineEnd.x, mLineEnd.y);
+ LayoutDeviceSize gradientRadius = LayoutDeviceSize(mRadiusX, mRadiusY);
// Do a naive tiling of the gradient by making multiple display items
// TODO: this should be done on the WebRender side eventually
nscoord appUnitsPerDevPixel = mPresContext->AppUnitsPerDevPixel();
LayoutDeviceRect firstTileBounds = LayoutDevicePixel::FromAppUnits(mDest, appUnitsPerDevPixel);
LayoutDeviceRect clipBounds = LayoutDevicePixel::FromAppUnits(mFillArea, appUnitsPerDevPixel);
@@ -1065,27 +1063,21 @@ nsCSSGradientRenderer::BuildWebRenderDis
aBuilder.BuildClipRegion(mozilla::wr::ToWrRect(clipBounds)),
mozilla::wr::ToWrPoint(relativeGradientStart),
mozilla::wr::ToWrPoint(relativeGradientEnd),
stops,
extendMode);
} else {
LayoutDevicePoint relativeGradientCenter = lineStart + tileOffset;
- // TODO: ellipse gradients
- double innerRadius = mRadiusX * firstStop;
- double outerRadius = mRadiusX * lastStop;
-
aBuilder.PushRadialGradient(
mozilla::wr::ToWrRect(tileRect),
aBuilder.BuildClipRegion(mozilla::wr::ToWrRect(clipBounds)),
mozilla::wr::ToWrPoint(relativeGradientCenter),
- mozilla::wr::ToWrPoint(relativeGradientCenter),
- innerRadius,
- outerRadius,
+ mozilla::wr::ToWrSize(gradientRadius),
stops,
extendMode);
}
}
}
}
} // namespace mozilla