diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 01f4e09cff3f..a7f4b4c900df 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -221,8 +221,10 @@ GfxPatternToCairoPattern(const Pattern& aPattern, Float aAlpha) pattern.mEnd.x, pattern.mEnd.y); MOZ_ASSERT(pattern.mStops->GetBackendType() == BACKEND_CAIRO); - const std::vector& stops = - static_cast(pattern.mStops.get())->GetStops(); + GradientStopsCairo* cairoStops = static_cast(pattern.mStops.get()); + cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(cairoStops->GetExtendMode())); + + const std::vector& stops = cairoStops->GetStops(); for (size_t i = 0; i < stops.size(); ++i) { const GradientStop& stop = stops[i]; cairo_pattern_add_color_stop_rgba(pat, stop.offset, stop.color.r, @@ -239,8 +241,11 @@ GfxPatternToCairoPattern(const Pattern& aPattern, Float aAlpha) pat = cairo_pattern_create_radial(pattern.mCenter1.x, pattern.mCenter1.y, pattern.mRadius1, pattern.mCenter2.x, pattern.mCenter2.y, pattern.mRadius2); - const std::vector& stops = - static_cast(pattern.mStops.get())->GetStops(); + MOZ_ASSERT(pattern.mStops->GetBackendType() == BACKEND_CAIRO); + GradientStopsCairo* cairoStops = static_cast(pattern.mStops.get()); + cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(cairoStops->GetExtendMode())); + + const std::vector& stops = cairoStops->GetStops(); for (size_t i = 0; i < stops.size(); ++i) { const GradientStop& stop = stops[i]; cairo_pattern_add_color_stop_rgba(pat, stop.offset, stop.color.r, @@ -727,9 +732,11 @@ DrawTargetCairo::ClearSurfaceForUnboundedSource(const CompositionOp &aOperator) TemporaryRef -DrawTargetCairo::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, ExtendMode aExtendMode) const +DrawTargetCairo::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, + ExtendMode aExtendMode) const { - RefPtr stops = new GradientStopsCairo(aStops, aNumStops); + RefPtr stops = new GradientStopsCairo(aStops, aNumStops, + aExtendMode); return stops; } diff --git a/gfx/2d/DrawTargetCairo.h b/gfx/2d/DrawTargetCairo.h index e007429c062e..8eec8eff8c3a 100644 --- a/gfx/2d/DrawTargetCairo.h +++ b/gfx/2d/DrawTargetCairo.h @@ -20,7 +20,9 @@ class SourceSurfaceCairo; class GradientStopsCairo : public GradientStops { public: - GradientStopsCairo(GradientStop* aStops, uint32_t aNumStops) + GradientStopsCairo(GradientStop* aStops, uint32_t aNumStops, + ExtendMode aExtendMode) + : mExtendMode(aExtendMode) { for (uint32_t i = 0; i < aNumStops; ++i) { mStops.push_back(aStops[i]); @@ -34,10 +36,16 @@ class GradientStopsCairo : public GradientStops return mStops; } + ExtendMode GetExtendMode() const + { + return mExtendMode; + } + virtual BackendType GetBackendType() const { return BACKEND_CAIRO; } private: std::vector mStops; + ExtendMode mExtendMode; }; class DrawTargetCairo : public DrawTarget