mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Bug 795763 - Support extend mode for gradient patterns in DrawTargetCairo. r=joe
This commit is contained in:
parent
4c511b46d7
commit
f118b7b673
@ -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<GradientStop>& stops =
|
||||
static_cast<GradientStopsCairo*>(pattern.mStops.get())->GetStops();
|
||||
GradientStopsCairo* cairoStops = static_cast<GradientStopsCairo*>(pattern.mStops.get());
|
||||
cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(cairoStops->GetExtendMode()));
|
||||
|
||||
const std::vector<GradientStop>& 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<GradientStop>& stops =
|
||||
static_cast<GradientStopsCairo*>(pattern.mStops.get())->GetStops();
|
||||
MOZ_ASSERT(pattern.mStops->GetBackendType() == BACKEND_CAIRO);
|
||||
GradientStopsCairo* cairoStops = static_cast<GradientStopsCairo*>(pattern.mStops.get());
|
||||
cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(cairoStops->GetExtendMode()));
|
||||
|
||||
const std::vector<GradientStop>& 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<GradientStops>
|
||||
DrawTargetCairo::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, ExtendMode aExtendMode) const
|
||||
DrawTargetCairo::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops,
|
||||
ExtendMode aExtendMode) const
|
||||
{
|
||||
RefPtr<GradientStopsCairo> stops = new GradientStopsCairo(aStops, aNumStops);
|
||||
RefPtr<GradientStopsCairo> stops = new GradientStopsCairo(aStops, aNumStops,
|
||||
aExtendMode);
|
||||
return stops;
|
||||
}
|
||||
|
||||
|
@ -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<GradientStop> mStops;
|
||||
ExtendMode mExtendMode;
|
||||
};
|
||||
|
||||
class DrawTargetCairo : public DrawTarget
|
||||
|
Loading…
x
Reference in New Issue
Block a user