Bug 1240819 - cleanup dead branches in gfxXlibNativeRender.cpp. r=jrmuizel

This commit is contained in:
Nicolas Silva 2016-01-26 15:35:11 +01:00
parent 1a161fcba6
commit ddc36c8ef3

View File

@ -492,6 +492,10 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
} }
DrawTarget* drawTarget = ctx->GetDrawTarget(); DrawTarget* drawTarget = ctx->GetDrawTarget();
if (!drawTarget) {
gfxCriticalError() << "gfxContext without a DrawTarget";
return;
}
// Clipping to the region affected by drawing allows us to consider only // Clipping to the region affected by drawing allows us to consider only
// the portions of the clip region that will be affected by drawing. // the portions of the clip region that will be affected by drawing.
@ -533,16 +537,18 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
gfxPoint deviceTranslation = gfxPoint(dtTransform._31, dtTransform._32); gfxPoint deviceTranslation = gfxPoint(dtTransform._31, dtTransform._32);
cairo_t* cairo = static_cast<cairo_t*> cairo_t* cairo = static_cast<cairo_t*>
(drawTarget->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT)); (drawTarget->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
if (!cairo) if (!cairo) {
return; return;
}
cairo_surface_t* cairoTarget = cairo_get_group_target(cairo); cairo_surface_t* cairoTarget = cairo_get_group_target(cairo);
cairo_surface_t* tempXlibSurface = cairo_surface_t* tempXlibSurface =
CreateTempXlibSurface(cairoTarget, drawTarget, size, CreateTempXlibSurface(cairoTarget, drawTarget, size,
canDrawOverBackground, flags, screen, visual, canDrawOverBackground, flags, screen, visual,
&method); &method);
if (!tempXlibSurface) if (!tempXlibSurface) {
return; return;
}
bool drawIsOpaque = (flags & DRAW_IS_OPAQUE) != 0; bool drawIsOpaque = (flags & DRAW_IS_OPAQUE) != 0;
if (!drawIsOpaque) { if (!drawIsOpaque) {
@ -574,26 +580,20 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
cairo_surface_get_content(tempXlibSurface) == CAIRO_CONTENT_COLOR ? cairo_surface_get_content(tempXlibSurface) == CAIRO_CONTENT_COLOR ?
SurfaceFormat::B8G8R8A8 : SurfaceFormat::B8G8R8X8; SurfaceFormat::B8G8R8A8 : SurfaceFormat::B8G8R8X8;
if (method != eAlphaExtraction) { if (method != eAlphaExtraction) {
if (drawTarget) { RefPtr<SourceSurface> sourceSurface =
RefPtr<SourceSurface> sourceSurface = Factory::CreateSourceSurfaceForCairoSurface(tempXlibSurface, size, moz2DFormat);
Factory::CreateSourceSurfaceForCairoSurface(tempXlibSurface, size, moz2DFormat); if (sourceSurface) {
if (sourceSurface) { drawTarget->DrawSurface(sourceSurface,
drawTarget->DrawSurface(sourceSurface, Rect(offset.x, offset.y, size.width, size.height),
Rect(offset.x, offset.y, size.width, size.height), Rect(0, 0, size.width, size.height));
Rect(0, 0, size.width, size.height));
}
} else {
RefPtr<gfxASurface> tmpSurf = gfxASurface::Wrap(tempXlibSurface);
ctx->SetSource(tmpSurf, offset);
ctx->Paint();
} }
cairo_surface_destroy(tempXlibSurface); cairo_surface_destroy(tempXlibSurface);
return; return;
} }
RefPtr<gfxImageSurface> blackImage = RefPtr<gfxImageSurface> blackImage =
CopyXlibSurfaceToImage(tempXlibSurface, size, SurfaceFormat::A8R8G8B8_UINT32); CopyXlibSurfaceToImage(tempXlibSurface, size, SurfaceFormat::A8R8G8B8_UINT32);
cairo_t* tmpCtx = cairo_create(tempXlibSurface); cairo_t* tmpCtx = cairo_create(tempXlibSurface);
cairo_set_source_rgba(tmpCtx, 1.0, 1.0, 1.0, 1.0); cairo_set_source_rgba(tmpCtx, 1.0, 1.0, 1.0, 1.0);
cairo_set_operator(tmpCtx, CAIRO_OPERATOR_SOURCE); cairo_set_operator(tmpCtx, CAIRO_OPERATOR_SOURCE);
@ -602,7 +602,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
DrawOntoTempSurface(tempXlibSurface, -drawingRect.TopLeft()); DrawOntoTempSurface(tempXlibSurface, -drawingRect.TopLeft());
RefPtr<gfxImageSurface> whiteImage = RefPtr<gfxImageSurface> whiteImage =
CopyXlibSurfaceToImage(tempXlibSurface, size, SurfaceFormat::X8R8G8B8_UINT32); CopyXlibSurfaceToImage(tempXlibSurface, size, SurfaceFormat::X8R8G8B8_UINT32);
if (blackImage->CairoStatus() == CAIRO_STATUS_SUCCESS && if (blackImage->CairoStatus() == CAIRO_STATUS_SUCCESS &&
whiteImage->CairoStatus() == CAIRO_STATUS_SUCCESS) { whiteImage->CairoStatus() == CAIRO_STATUS_SUCCESS) {
if (!gfxAlphaRecovery::RecoverAlpha(blackImage, whiteImage)) { if (!gfxAlphaRecovery::RecoverAlpha(blackImage, whiteImage)) {
@ -611,18 +611,13 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, IntSize size,
} }
gfxASurface* paintSurface = blackImage; gfxASurface* paintSurface = blackImage;
if (drawTarget) { RefPtr<SourceSurface> sourceSurface =
RefPtr<SourceSurface> sourceSurface = Factory::CreateSourceSurfaceForCairoSurface(paintSurface->CairoSurface(),
Factory::CreateSourceSurfaceForCairoSurface(paintSurface->CairoSurface(), size, moz2DFormat);
size, moz2DFormat); if (sourceSurface) {
if (sourceSurface) { drawTarget->DrawSurface(sourceSurface,
drawTarget->DrawSurface(sourceSurface, Rect(offset.x, offset.y, size.width, size.height),
Rect(offset.x, offset.y, size.width, size.height), Rect(0, 0, size.width, size.height));
Rect(0, 0, size.width, size.height));
}
} else {
ctx->SetSource(paintSurface, offset);
ctx->Paint();
} }
} }
cairo_surface_destroy(tempXlibSurface); cairo_surface_destroy(tempXlibSurface);