mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 985049 - Remove gfxPlatform::SupportsAzureContent() and kill of the resulting dead code. r=mattwoodrow
This commit is contained in:
parent
94aff9a4e6
commit
cddedd8d2b
@ -3577,7 +3577,7 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& window, double x,
|
||||
thebes = new gfxContext(mTarget);
|
||||
thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
|
||||
matrix._22, matrix._31, matrix._32));
|
||||
} else if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
} else {
|
||||
drawDT =
|
||||
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(ceil(sw), ceil(sh)),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
@ -3588,17 +3588,6 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& window, double x,
|
||||
|
||||
thebes = new gfxContext(drawDT);
|
||||
thebes->Scale(matrix._11, matrix._22);
|
||||
} else {
|
||||
drawSurf =
|
||||
gfxPlatform::GetPlatform()->CreateOffscreenSurface(IntSize(ceil(sw), ceil(sh)),
|
||||
gfxContentType::COLOR_ALPHA);
|
||||
if (!drawSurf) {
|
||||
error.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
thebes = new gfxContext(drawSurf);
|
||||
thebes->Scale(matrix._11, matrix._22);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
|
||||
|
@ -82,24 +82,14 @@ TextureClientX11::UpdateSurface(gfxASurface* aSurface)
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
RefPtr<DrawTarget> dt = GetAsDrawTarget();
|
||||
if (!dt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface);
|
||||
dt->CopySurface(source, IntRect(IntPoint(), GetSize()), IntPoint());
|
||||
} else {
|
||||
if (!mSurface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(mSurface.get());
|
||||
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
ctx->DrawSurface(aSurface, mSurface->GetSize());
|
||||
RefPtr<DrawTarget> dt = GetAsDrawTarget();
|
||||
if (!dt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface);
|
||||
dt->CopySurface(source, IntRect(IntPoint(), GetSize()), IntPoint());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,6 @@ ContentClientBasic::CreateBuffer(ContentType aType,
|
||||
RefPtr<gfx::DrawTarget>* aWhiteDT)
|
||||
{
|
||||
MOZ_ASSERT(!(aFlags & BUFFER_COMPONENT_ALPHA));
|
||||
MOZ_ASSERT(gfxPlatform::GetPlatform()->SupportsAzureContent());
|
||||
gfxImageFormat format =
|
||||
gfxPlatform::GetPlatform()->OptimalFormatForContent(aType);
|
||||
|
||||
@ -1285,7 +1284,6 @@ ContentClientIncremental::BorrowDrawTargetForPainting(ThebesLayer* aLayer,
|
||||
"BeginUpdate should always modify the draw region in the same way!");
|
||||
FillSurface(onBlack, aPaintState.mRegionToDraw, nsIntPoint(drawBounds.x, drawBounds.y), gfxRGBA(0.0, 0.0, 0.0, 1.0));
|
||||
FillSurface(onWhite, aPaintState.mRegionToDraw, nsIntPoint(drawBounds.x, drawBounds.y), gfxRGBA(1.0, 1.0, 1.0, 1.0));
|
||||
MOZ_ASSERT(gfxPlatform::GetPlatform()->SupportsAzureContent());
|
||||
RefPtr<DrawTarget> onBlackDT = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(onBlack, onBlack->GetSize().ToIntSize());
|
||||
RefPtr<DrawTarget> onWhiteDT = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(onWhite, onWhite->GetSize().ToIntSize());
|
||||
mLoanedDrawTarget = Factory::CreateDualDrawTarget(onBlackDT, onWhiteDT);
|
||||
@ -1294,7 +1292,6 @@ ContentClientIncremental::BorrowDrawTargetForPainting(ThebesLayer* aLayer,
|
||||
}
|
||||
} else {
|
||||
nsRefPtr<gfxASurface> surf = GetUpdateSurface(BUFFER_BLACK, aPaintState.mRegionToDraw);
|
||||
MOZ_ASSERT(gfxPlatform::GetPlatform()->SupportsAzureContent());
|
||||
mLoanedDrawTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(surf, surf->GetSize().ToIntSize());
|
||||
}
|
||||
if (!mLoanedDrawTarget) {
|
||||
|
@ -678,25 +678,13 @@ BufferTextureClient::UpdateSurface(gfxASurface* aSurface)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
RefPtr<DrawTarget> dt = GetAsDrawTarget();
|
||||
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface);
|
||||
RefPtr<DrawTarget> dt = GetAsDrawTarget();
|
||||
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface);
|
||||
|
||||
dt->CopySurface(source, IntRect(IntPoint(), serializer.GetSize()), IntPoint());
|
||||
// XXX - if the Moz2D backend is D2D, we would be much better off memcpying
|
||||
// the content of the surface directly because with D2D, GetAsDrawTarget is
|
||||
// very expensive.
|
||||
} else {
|
||||
RefPtr<gfxImageSurface> surf = serializer.GetAsThebesSurface();
|
||||
if (!surf) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(surf.get());
|
||||
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
tmpCtx->DrawSurface(aSurface, gfxSize(serializer.GetSize().width,
|
||||
serializer.GetSize().height));
|
||||
}
|
||||
dt->CopySurface(source, IntRect(IntPoint(), serializer.GetSize()), IntPoint());
|
||||
// XXX - if the Moz2D backend is D2D, we would be much better off memcpying
|
||||
// the content of the surface directly because with D2D, GetAsDrawTarget is
|
||||
// very expensive.
|
||||
|
||||
if (TextureRequiresLocking(mFlags) && !ImplementsLocking()) {
|
||||
// We don't have support for proper locking yet, so we'll
|
||||
|
@ -408,14 +408,6 @@ ThebesLayerD3D10::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode)
|
||||
|
||||
if (aMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
|
||||
FillTexturesBlackWhite(aRegion, visibleRect.TopLeft());
|
||||
if (!gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
gfxASurface* surfaces[2] = { mD2DSurface.get(), mD2DSurfaceOnWhite.get() };
|
||||
destinationSurface = new gfxTeeSurface(surfaces, ArrayLength(surfaces));
|
||||
// Using this surface as a source will likely go horribly wrong, since
|
||||
// only the onBlack surface will really be used, so alpha information will
|
||||
// be incorrect.
|
||||
destinationSurface->SetAllowUseAsSource(false);
|
||||
}
|
||||
} else {
|
||||
destinationSurface = mD2DSurface;
|
||||
}
|
||||
@ -465,18 +457,7 @@ ThebesLayerD3D10::CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode
|
||||
NS_WARNING("Failed to create shader resource view for ThebesLayerD3D10.");
|
||||
}
|
||||
|
||||
if (!gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
mD2DSurface = new gfxD2DSurface(mTexture, aMode != SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA ?
|
||||
gfxContentType::COLOR : gfxContentType::COLOR_ALPHA);
|
||||
|
||||
if (!mD2DSurface || mD2DSurface->CairoStatus()) {
|
||||
NS_WARNING("Failed to create surface for ThebesLayerD3D10.");
|
||||
mD2DSurface = nullptr;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
mDrawTarget = nullptr;
|
||||
}
|
||||
mDrawTarget = nullptr;
|
||||
}
|
||||
|
||||
if (aMode == SurfaceMode::SURFACE_COMPONENT_ALPHA && !mTextureOnWhite) {
|
||||
@ -493,20 +474,10 @@ ThebesLayerD3D10::CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode
|
||||
NS_WARNING("Failed to create shader resource view for ThebesLayerD3D10.");
|
||||
}
|
||||
|
||||
if (!gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
mD2DSurfaceOnWhite = new gfxD2DSurface(mTextureOnWhite, gfxContentType::COLOR);
|
||||
|
||||
if (!mD2DSurfaceOnWhite || mD2DSurfaceOnWhite->CairoStatus()) {
|
||||
NS_WARNING("Failed to create surface for ThebesLayerD3D10.");
|
||||
mD2DSurfaceOnWhite = nullptr;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
mDrawTarget = nullptr;
|
||||
}
|
||||
mDrawTarget = nullptr;
|
||||
}
|
||||
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContent() && !mDrawTarget) {
|
||||
if (!mDrawTarget) {
|
||||
if (aMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
|
||||
mDrawTarget = Factory::CreateDualDrawTargetForD3D10Textures(mTexture, mTextureOnWhite, SurfaceFormat::B8G8R8X8);
|
||||
} else {
|
||||
|
@ -169,18 +169,10 @@ GrallocTextureClientOGL::UpdateSurface(gfxASurface* aSurface)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
RefPtr<DrawTarget> dt = GetAsDrawTarget();
|
||||
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface);
|
||||
RefPtr<DrawTarget> dt = GetAsDrawTarget();
|
||||
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface);
|
||||
|
||||
dt->CopySurface(source, IntRect(IntPoint(), GetSize()), IntPoint());
|
||||
} else {
|
||||
nsRefPtr<gfxASurface> surf = GetAsSurface();
|
||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(surf.get());
|
||||
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
tmpCtx->DrawSurface(aSurface, gfxSize(GetSize().width,
|
||||
GetSize().height));
|
||||
}
|
||||
dt->CopySurface(source, IntRect(IntPoint(), GetSize()), IntPoint());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -362,17 +362,10 @@ gfxASurface::CopyToARGB32ImageSurface()
|
||||
nsRefPtr<gfxImageSurface> imgSurface =
|
||||
new gfxImageSurface(size, gfxImageFormat::ARGB32);
|
||||
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height));
|
||||
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, this);
|
||||
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height));
|
||||
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, this);
|
||||
|
||||
dt->CopySurface(source, IntRect(0, 0, size.width, size.height), IntPoint());
|
||||
} else {
|
||||
gfxContext ctx(imgSurface);
|
||||
ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
ctx.SetSource(this);
|
||||
ctx.Paint();
|
||||
}
|
||||
dt->CopySurface(source, IntRect(0, 0, size.width, size.height), IntPoint());
|
||||
|
||||
return imgSurface.forget();
|
||||
}
|
||||
|
@ -392,13 +392,11 @@ gfxPlatform::Init()
|
||||
NS_RUNTIMEABORT("Could not initialize mScreenReferenceSurface");
|
||||
}
|
||||
|
||||
if (gPlatform->SupportsAzureContent()) {
|
||||
gPlatform->mScreenReferenceDrawTarget =
|
||||
gPlatform->CreateOffscreenContentDrawTarget(IntSize(1, 1),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
if (!gPlatform->mScreenReferenceDrawTarget) {
|
||||
NS_RUNTIMEABORT("Could not initialize mScreenReferenceDrawTarget");
|
||||
}
|
||||
gPlatform->mScreenReferenceDrawTarget =
|
||||
gPlatform->CreateOffscreenContentDrawTarget(IntSize(1, 1),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
if (!gPlatform->mScreenReferenceDrawTarget) {
|
||||
NS_RUNTIMEABORT("Could not initialize mScreenReferenceDrawTarget");
|
||||
}
|
||||
|
||||
rv = gfxFontCache::Init();
|
||||
|
@ -256,20 +256,6 @@ public:
|
||||
CreateDrawTargetForData(unsigned char* aData, const mozilla::gfx::IntSize& aSize,
|
||||
int32_t aStride, mozilla::gfx::SurfaceFormat aFormat);
|
||||
|
||||
/**
|
||||
* Returns true if we will render content using Azure using a gfxPlatform
|
||||
* provided DrawTarget.
|
||||
* Prefer using SupportsAzureContentForDrawTarget or
|
||||
* SupportsAzureContentForType.
|
||||
* This function is potentially misleading and dangerous because we might
|
||||
* support a certain Azure backend on the current platform, but when you
|
||||
* ask for a DrawTarget you get one for a different backend which is not
|
||||
* supported for content drawing.
|
||||
*/
|
||||
bool SupportsAzureContent() {
|
||||
return GetContentBackend() != mozilla::gfx::BackendType::NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if we should use Azure to render content with aTarget. For
|
||||
* example, it is possible that we are using Direct2D for rendering and thus
|
||||
|
@ -235,19 +235,10 @@ ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize,
|
||||
mozilla::RefPtr<mozilla::gfx::DrawTarget> target;
|
||||
nsRefPtr<gfxContext> ctx;
|
||||
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
target = gfxPlatform::GetPlatform()->
|
||||
CreateOffscreenContentDrawTarget(gfx::IntSize(mClip.width, mClip.height),
|
||||
gfx::SurfaceFormat::B8G8R8A8);
|
||||
ctx = new gfxContext(target);
|
||||
} else {
|
||||
target = gfxPlatform::GetPlatform()->
|
||||
CreateOffscreenCanvasDrawTarget(gfx::IntSize(mClip.width, mClip.height),
|
||||
gfx::SurfaceFormat::B8G8R8A8);
|
||||
nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->
|
||||
GetThebesSurfaceForDrawTarget(target);
|
||||
ctx = new gfxContext(surface);
|
||||
}
|
||||
target = gfxPlatform::GetPlatform()->
|
||||
CreateOffscreenContentDrawTarget(gfx::IntSize(mClip.width, mClip.height),
|
||||
gfx::SurfaceFormat::B8G8R8A8);
|
||||
ctx = new gfxContext(target);
|
||||
|
||||
// Create our callback.
|
||||
nsRefPtr<gfxDrawingCallback> drawTileCallback =
|
||||
|
@ -2269,38 +2269,22 @@ nsWindow::OnExposeEvent(cairo_t *cr)
|
||||
void
|
||||
nsWindow::UpdateAlpha(gfxPattern* aPattern, nsIntRect aBoundsRect)
|
||||
{
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
|
||||
// We need to create our own buffer to force the stride to match the
|
||||
// expected stride.
|
||||
int32_t stride = GetAlignedStride<4>(BytesPerPixel(SurfaceFormat::A8) *
|
||||
aBoundsRect.width);
|
||||
int32_t bufferSize = stride * aBoundsRect.height;
|
||||
nsAutoArrayPtr<uint8_t> imageBuffer(new (std::nothrow) uint8_t[bufferSize]);
|
||||
RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
|
||||
CreateDrawTargetForData(imageBuffer, ToIntSize(aBoundsRect.Size()),
|
||||
stride, SurfaceFormat::A8);
|
||||
// We need to create our own buffer to force the stride to match the
|
||||
// expected stride.
|
||||
int32_t stride = GetAlignedStride<4>(BytesPerPixel(SurfaceFormat::A8) *
|
||||
aBoundsRect.width);
|
||||
int32_t bufferSize = stride * aBoundsRect.height;
|
||||
nsAutoArrayPtr<uint8_t> imageBuffer(new (std::nothrow) uint8_t[bufferSize]);
|
||||
RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
|
||||
CreateDrawTargetForData(imageBuffer, ToIntSize(aBoundsRect.Size()),
|
||||
stride, SurfaceFormat::A8);
|
||||
|
||||
if (drawTarget) {
|
||||
drawTarget->FillRect(Rect(0, 0, aBoundsRect.width, aBoundsRect.height),
|
||||
*aPattern->GetPattern(drawTarget),
|
||||
DrawOptions(1.0, CompositionOp::OP_SOURCE));
|
||||
}
|
||||
UpdateTranslucentWindowAlphaInternal(aBoundsRect, imageBuffer, stride);
|
||||
} else {
|
||||
nsRefPtr<gfxImageSurface> img =
|
||||
new gfxImageSurface(aBoundsRect.Size(), gfxImageFormat::A8);
|
||||
if (img && !img->CairoStatus()) {
|
||||
img->SetDeviceOffset(-aBoundsRect.TopLeft());
|
||||
|
||||
nsRefPtr<gfxContext> imgCtx = new gfxContext(img);
|
||||
imgCtx->SetPattern(aPattern);
|
||||
imgCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
imgCtx->Paint();
|
||||
|
||||
UpdateTranslucentWindowAlphaInternal(aBoundsRect, img->Data(),
|
||||
img->Stride());
|
||||
}
|
||||
}
|
||||
if (drawTarget) {
|
||||
drawTarget->FillRect(Rect(0, 0, aBoundsRect.width, aBoundsRect.height),
|
||||
*aPattern->GetPattern(drawTarget),
|
||||
DrawOptions(1.0, CompositionOp::OP_SOURCE));
|
||||
}
|
||||
UpdateTranslucentWindowAlphaInternal(aBoundsRect, imageBuffer, stride);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
Loading…
x
Reference in New Issue
Block a user