Bug 1054838, part 1 - Remove dead code supporting cairo_surface_t wrapping gfxPattern. r=Bas

This commit is contained in:
Matt Woodrow 2014-09-14 10:58:55 +01:00
parent fbb262528d
commit 810fbe5243
3 changed files with 3 additions and 117 deletions

View File

@ -940,16 +940,9 @@ gfxContext::Mask(gfxPattern *pattern)
// device offsets in these patterns, but no problems have been observed
// yet because of this. And it would complicate things a little further.
offset = Point(0.f, 0.f);
} else if (pattern->GetType() == gfxPattern::PATTERN_SURFACE) {
nsRefPtr<gfxASurface> asurf = pattern->GetSurface();
gfxPoint deviceOffset = asurf->GetDeviceOffset();
offset = Point(-deviceOffset.x, -deviceOffset.y);
// this lets GetAzureSurface work
pattern->GetPattern(mDT);
}
if (pattern->IsAzure() || pattern->GetType() == gfxPattern::PATTERN_SURFACE) {
if (pattern->IsAzure()) {
RefPtr<SourceSurface> mask = pattern->GetAzureSurface();
Matrix mat = ToMatrix(pattern->GetInverseMatrix());
Matrix old = mTransform;

View File

@ -16,25 +16,12 @@
using namespace mozilla::gfx;
gfxPattern::gfxPattern(cairo_pattern_t *aPattern)
: mGfxPattern(nullptr)
{
mPattern = cairo_pattern_reference(aPattern);
}
gfxPattern::gfxPattern(const gfxRGBA& aColor)
: mGfxPattern(nullptr)
{
mPattern = cairo_pattern_create_rgba(aColor.r, aColor.g, aColor.b, aColor.a);
}
// from another surface
gfxPattern::gfxPattern(gfxASurface *surface)
: mGfxPattern(nullptr)
{
mPattern = cairo_pattern_create_for_surface(surface->CairoSurface());
}
// linear
gfxPattern::gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1)
: mGfxPattern(nullptr)
@ -71,12 +58,6 @@ gfxPattern::~gfxPattern()
}
}
cairo_pattern_t *
gfxPattern::CairoPattern()
{
return mPattern;
}
void
gfxPattern::AddColorStop(gfxFloat offset, const gfxRGBA& c)
{
@ -199,38 +180,6 @@ gfxPattern::GetPattern(DrawTarget *aTarget, Matrix *aPatternTransform)
new (mColorPattern.addr()) ColorPattern(Color(r, g, b, a));
return mColorPattern.addr();
}
case CAIRO_PATTERN_TYPE_SURFACE:
{
GraphicsFilter filter = (GraphicsFilter)cairo_pattern_get_filter(mPattern);
cairo_matrix_t mat;
cairo_pattern_get_matrix(mPattern, &mat);
gfxMatrix matrix(*reinterpret_cast<gfxMatrix*>(&mat));
cairo_surface_t *surf = nullptr;
cairo_pattern_get_surface(mPattern, &surf);
if (!mSourceSurface) {
nsRefPtr<gfxASurface> gfxSurf = gfxASurface::Wrap(surf);
// The underlying surface here will be kept around by the gfxPattern.
// This function is intended to be used right away.
mSourceSurface =
gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(aTarget, gfxSurf);
}
if (mSourceSurface) {
Matrix newMat = ToMatrix(matrix);
AdjustTransformForPattern(newMat, aTarget->GetTransform(), aPatternTransform);
double x, y;
cairo_surface_get_device_offset(surf, &x, &y);
newMat.PreTranslate(-x, -y);
mGfxPattern = new (mSurfacePattern.addr())
SurfacePattern(mSourceSurface, ToExtendMode(extend), newMat, ToFilter(filter));
return mGfxPattern;
}
break;
}
case CAIRO_PATTERN_TYPE_LINEAR:
{
double x1, y1, x2, y2;
@ -324,29 +273,7 @@ gfxPattern::SetExtend(GraphicsExtend extend)
if (mPattern) {
mStops = nullptr;
if (extend == EXTEND_PAD_EDGE) {
if (cairo_pattern_get_type(mPattern) == CAIRO_PATTERN_TYPE_SURFACE) {
cairo_surface_t *surf = nullptr;
cairo_pattern_get_surface (mPattern, &surf);
if (surf) {
switch (cairo_surface_get_type(surf)) {
case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
case CAIRO_SURFACE_TYPE_QUARTZ:
extend = EXTEND_NONE;
break;
case CAIRO_SURFACE_TYPE_WIN32:
case CAIRO_SURFACE_TYPE_XLIB:
default:
extend = EXTEND_PAD;
break;
}
}
}
// if something went wrong, or not a surface pattern, use PAD
if (extend == EXTEND_PAD_EDGE)
extend = EXTEND_PAD;
extend = EXTEND_PAD;
}
cairo_pattern_set_extend(mPattern, (cairo_extend_t)extend);
@ -361,19 +288,7 @@ bool
gfxPattern::IsOpaque()
{
if (mPattern) {
switch (cairo_pattern_get_type(mPattern)) {
case CAIRO_PATTERN_TYPE_SURFACE:
{
cairo_surface_t *surf = nullptr;
cairo_pattern_get_surface(mPattern, &surf);
if (cairo_surface_get_content(surf) == CAIRO_CONTENT_COLOR) {
return true;
}
}
default:
return false;
}
return false;
}
if (mSourceSurface->GetFormat() == SurfaceFormat::B8G8R8X8) {
@ -422,23 +337,6 @@ gfxPattern::GetSolidColor(gfxRGBA& aColor)
&aColor.a) == CAIRO_STATUS_SUCCESS;
}
already_AddRefed<gfxASurface>
gfxPattern::GetSurface()
{
if (mPattern) {
cairo_surface_t *surf = nullptr;
if (cairo_pattern_get_surface (mPattern, &surf) != CAIRO_STATUS_SUCCESS)
return nullptr;
return gfxASurface::Wrap(surf);
} else {
// We should never be trying to get the surface off an Azure gfx Pattern.
NS_ERROR("Attempt to get surface off an Azure gfxPattern!");
return nullptr;
}
}
gfxPattern::GraphicsPatternType
gfxPattern::GetType() const
{

View File

@ -26,9 +26,7 @@ class gfxPattern MOZ_FINAL{
NS_INLINE_DECL_REFCOUNTING(gfxPattern)
public:
explicit gfxPattern(cairo_pattern_t *aPattern);
explicit gfxPattern(const gfxRGBA& aColor);
explicit gfxPattern(gfxASurface *surface); // from another surface
// linear
gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1); // linear
gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0,
@ -36,7 +34,6 @@ public:
gfxPattern(mozilla::gfx::SourceSurface *aSurface,
const mozilla::gfx::Matrix &aTransform); // Azure
cairo_pattern_t *CairoPattern();
void AddColorStop(gfxFloat offset, const gfxRGBA& c);
void SetColorStops(mozilla::gfx::GradientStops* aStops);
@ -96,8 +93,6 @@ public:
/* returns TRUE if it succeeded */
bool GetSolidColor(gfxRGBA& aColor);
already_AddRefed<gfxASurface> GetSurface();
bool IsAzure() { return !mPattern; }
mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetAzureSurface() { return mSourceSurface; }