Bug 1241058: Assure several operations properly operate on the current group target. r=jrmuizel
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -608,17 +608,17 @@ DrawTargetCairo::~DrawTargetCairo()
mSurface = nullptr;
}
MOZ_ASSERT(!mLockedBits);
}
bool
DrawTargetCairo::IsValid() const
{
- return mSurface && !cairo_surface_status(mSurface);
+ return mSurface && !cairo_surface_status(mSurface) && !cairo_surface_status(cairo_get_group_target(mContext));
}
DrawTargetType
DrawTargetCairo::GetType() const
{
if (mContext) {
cairo_surface_type_t type = cairo_surface_get_type(mSurface);
if (type == CAIRO_SURFACE_TYPE_TEE) {
@@ -807,17 +807,17 @@ DrawTargetCairo::DrawSurface(SourceSurfa
const DrawSurfaceOptions &aSurfOptions,
const DrawOptions &aOptions)
{
if (mTransformSingular) {
return;
}
if (!IsValid() || !aSurface) {
- gfxCriticalNote << "DrawSurface with bad surface " << cairo_surface_status(mSurface);
+ gfxCriticalNote << "DrawSurface with bad surface " << cairo_surface_status(cairo_get_group_target(mContext));
return;
}
AutoPrepareForDrawing prep(this, mContext);
AutoClearDeviceOffset clear(aSurface);
float sx = aSource.Width() / aDest.Width();
float sy = aSource.Height() / aDest.Height();
@@ -1261,34 +1261,34 @@ DrawTargetCairo::IsCurrentGroupOpaque()
return cairo_surface_get_content(surf) == CAIRO_CONTENT_COLOR;
}
void
DrawTargetCairo::SetPermitSubpixelAA(bool aPermitSubpixelAA)
{
DrawTarget::SetPermitSubpixelAA(aPermitSubpixelAA);
#ifdef MOZ_TREE_CAIRO
- cairo_surface_set_subpixel_antialiasing(mSurface,
+ cairo_surface_set_subpixel_antialiasing(cairo_get_group_target(mContext),
aPermitSubpixelAA ? CAIRO_SUBPIXEL_ANTIALIASING_ENABLED : CAIRO_SUBPIXEL_ANTIALIASING_DISABLED);
#endif
}
void
DrawTargetCairo::FillGlyphs(ScaledFont *aFont,
const GlyphBuffer &aBuffer,
const Pattern &aPattern,
const DrawOptions &aOptions,
const GlyphRenderingOptions*)
{
if (mTransformSingular) {
return;
}
if (!IsValid()) {
- gfxDebug() << "FillGlyphs bad surface " << cairo_surface_status(mSurface);
+ gfxDebug() << "FillGlyphs bad surface " << cairo_surface_status(cairo_get_group_target(mContext));
return;
}
AutoPrepareForDrawing prep(this, mContext);
AutoClearDeviceOffset clear(aPattern);
ScaledFontBase* scaledFont = static_cast<ScaledFontBase*>(aFont);
cairo_set_scaled_font(mContext, scaledFont->GetCairoScaledFont());
@@ -1316,18 +1316,18 @@ DrawTargetCairo::FillGlyphs(ScaledFont *
for (uint32_t i = 0; i < aBuffer.mNumGlyphs; ++i) {
glyphs[i].index = aBuffer.mGlyphs[i].mIndex;
glyphs[i].x = aBuffer.mGlyphs[i].mPosition.x;
glyphs[i].y = aBuffer.mGlyphs[i].mPosition.y;
}
cairo_show_glyphs(mContext, &glyphs[0], aBuffer.mNumGlyphs);
- if (mSurface && cairo_surface_status(mSurface)) {
- gfxDebug() << "Ending FillGlyphs with a bad surface " << cairo_surface_status(mSurface);
+ if (mContext && cairo_surface_status(cairo_get_group_target(mContext))) {
+ gfxDebug() << "Ending FillGlyphs with a bad surface " << cairo_surface_status(cairo_get_group_target(mContext));
}
}
void
DrawTargetCairo::Mask(const Pattern &aSource,
const Pattern &aMask,
const DrawOptions &aOptions /* = DrawOptions() */)
{
@@ -1741,17 +1741,17 @@ DrawTargetCairo::CreateSourceSurfaceFrom
}
return nullptr;
}
already_AddRefed<DrawTarget>
DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
{
- if (cairo_surface_status(mSurface)) {
+ if (cairo_surface_status(cairo_get_group_target(mContext))) {
RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
if (target->Init(aSize, aFormat)) {
return target.forget();
}
}
cairo_surface_t* similar = cairo_surface_create_similar(mSurface,
GfxFormatToCairoContent(aFormat),
@@ -1759,17 +1759,17 @@ DrawTargetCairo::CreateSimilarDrawTarget
if (!cairo_surface_status(similar)) {
RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
if (target->InitAlreadyReferenced(similar, aSize)) {
return target.forget();
}
}
- gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSize))) << "Failed to create similar cairo surface! Size: " << aSize << " Status: " << cairo_surface_status(similar) << cairo_surface_status(mSurface) << " format " << (int)aFormat;
+ gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSize))) << "Failed to create similar cairo surface! Size: " << aSize << " Status: " << cairo_surface_status(similar) << cairo_surface_status(cairo_get_group_target(mContext)) << " format " << (int)aFormat;
return nullptr;
}
bool
DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat)
{
if (cairo_surface_status(aSurface)) {