diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 1d5df63a7d41..4be6dbce5294 100755 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -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 shell = presContext->PresShell(); diff --git a/gfx/layers/basic/TextureClientX11.cpp b/gfx/layers/basic/TextureClientX11.cpp index 371631e3fba9..aba9e39be4c7 100644 --- a/gfx/layers/basic/TextureClientX11.cpp +++ b/gfx/layers/basic/TextureClientX11.cpp @@ -82,24 +82,14 @@ TextureClientX11::UpdateSurface(gfxASurface* aSurface) { MOZ_ASSERT(IsValid()); - if (gfxPlatform::GetPlatform()->SupportsAzureContent()) { - RefPtr dt = GetAsDrawTarget(); - if (!dt) { - return false; - } - - RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface); - dt->CopySurface(source, IntRect(IntPoint(), GetSize()), IntPoint()); - } else { - if (!mSurface) { - return false; - } - - nsRefPtr ctx = new gfxContext(mSurface.get()); - ctx->SetOperator(gfxContext::OPERATOR_SOURCE); - ctx->DrawSurface(aSurface, mSurface->GetSize()); + RefPtr dt = GetAsDrawTarget(); + if (!dt) { + return false; } + RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface); + dt->CopySurface(source, IntRect(IntPoint(), GetSize()), IntPoint()); + return true; } diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 9ce9d52d2e74..cda7008e4f3a 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -103,7 +103,6 @@ ContentClientBasic::CreateBuffer(ContentType aType, RefPtr* 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 onBlackDT = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(onBlack, onBlack->GetSize().ToIntSize()); RefPtr onWhiteDT = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(onWhite, onWhite->GetSize().ToIntSize()); mLoanedDrawTarget = Factory::CreateDualDrawTarget(onBlackDT, onWhiteDT); @@ -1294,7 +1292,6 @@ ContentClientIncremental::BorrowDrawTargetForPainting(ThebesLayer* aLayer, } } else { nsRefPtr surf = GetUpdateSurface(BUFFER_BLACK, aPaintState.mRegionToDraw); - MOZ_ASSERT(gfxPlatform::GetPlatform()->SupportsAzureContent()); mLoanedDrawTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(surf, surf->GetSize().ToIntSize()); } if (!mLoanedDrawTarget) { diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 408eff772185..41936b8892ac 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -678,25 +678,13 @@ BufferTextureClient::UpdateSurface(gfxASurface* aSurface) return false; } - if (gfxPlatform::GetPlatform()->SupportsAzureContent()) { - RefPtr dt = GetAsDrawTarget(); - RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface); + RefPtr dt = GetAsDrawTarget(); + RefPtr 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 surf = serializer.GetAsThebesSurface(); - if (!surf) { - return false; - } - - nsRefPtr 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 diff --git a/gfx/layers/d3d10/ThebesLayerD3D10.cpp b/gfx/layers/d3d10/ThebesLayerD3D10.cpp index 4d018e6c14e7..47781cecfdf5 100644 --- a/gfx/layers/d3d10/ThebesLayerD3D10.cpp +++ b/gfx/layers/d3d10/ThebesLayerD3D10.cpp @@ -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 { diff --git a/gfx/layers/opengl/GrallocTextureClient.cpp b/gfx/layers/opengl/GrallocTextureClient.cpp index 2d10c5c9588d..c91b9785365e 100644 --- a/gfx/layers/opengl/GrallocTextureClient.cpp +++ b/gfx/layers/opengl/GrallocTextureClient.cpp @@ -169,18 +169,10 @@ GrallocTextureClientOGL::UpdateSurface(gfxASurface* aSurface) return false; } - if (gfxPlatform::GetPlatform()->SupportsAzureContent()) { - RefPtr dt = GetAsDrawTarget(); - RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface); + RefPtr dt = GetAsDrawTarget(); + RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface); - dt->CopySurface(source, IntRect(IntPoint(), GetSize()), IntPoint()); - } else { - nsRefPtr surf = GetAsSurface(); - nsRefPtr 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; } diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index 52b87a4aeac8..33a5181eade6 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -362,17 +362,10 @@ gfxASurface::CopyToARGB32ImageSurface() nsRefPtr imgSurface = new gfxImageSurface(size, gfxImageFormat::ARGB32); - if (gfxPlatform::GetPlatform()->SupportsAzureContent()) { - RefPtr dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height)); - RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, this); + RefPtr dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height)); + RefPtr 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(); } diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index c522e585a367..ec64e2ca4479 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -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(); diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 8d846cf79c7a..8922b36ff466 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -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 diff --git a/image/src/ClippedImage.cpp b/image/src/ClippedImage.cpp index 6780cf438ba7..e7f63c8525a5 100644 --- a/image/src/ClippedImage.cpp +++ b/image/src/ClippedImage.cpp @@ -235,19 +235,10 @@ ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize, mozilla::RefPtr target; nsRefPtr 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 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 drawTileCallback = diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index ef8562e3e5df..f8e8599c742e 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -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 imageBuffer(new (std::nothrow) uint8_t[bufferSize]); - RefPtr 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 imageBuffer(new (std::nothrow) uint8_t[bufferSize]); + RefPtr 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 img = - new gfxImageSurface(aBoundsRect.Size(), gfxImageFormat::A8); - if (img && !img->CairoStatus()) { - img->SetDeviceOffset(-aBoundsRect.TopLeft()); - - nsRefPtr 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