From 10de3b2d5a9f00694b8886327d1a4b34f4488caa Mon Sep 17 00:00:00 2001 From: Andreea Pavel Date: Tue, 27 Mar 2018 15:01:23 +0300 Subject: [PATCH] Backed out changeset 38fd94fbfdaf (bug 1443912) for QR crastest failures at /xpcom/string/crashtests/1113005.html a=backout --- layout/painting/nsCSSRenderingGradients.cpp | 97 --------------------- layout/painting/nsCSSRenderingGradients.h | 17 ---- 2 files changed, 114 deletions(-) diff --git a/layout/painting/nsCSSRenderingGradients.cpp b/layout/painting/nsCSSRenderingGradients.cpp index 8c6535525de5..1381dc70d024 100644 --- a/layout/painting/nsCSSRenderingGradients.cpp +++ b/layout/painting/nsCSSRenderingGradients.cpp @@ -939,17 +939,6 @@ nsCSSGradientRenderer::Paint(gfxContext& aContext, nscoord xEnd = forceRepeatToCoverTiles ? xStart + aDest.width : dirty.XMost(); nscoord yEnd = forceRepeatToCoverTiles ? yStart + aDest.height : dirty.YMost(); - if (TryPaintTilesWithExtendMode(aContext, - gradientPattern, - xStart, - yStart, - dirtyAreaToFill, - aDest, - aRepeatSize, - forceRepeatToCoverTiles)) { - return; - } - // x and y are the top-left corner of the tile to draw for (nscoord y = yStart; y < yEnd; y += aRepeatSize.height) { for (nscoord x = xStart; x < xEnd; x += aRepeatSize.width) { @@ -1008,92 +997,6 @@ nsCSSGradientRenderer::Paint(gfxContext& aContext, } } -bool -nsCSSGradientRenderer::TryPaintTilesWithExtendMode(gfxContext& aContext, - gfxPattern* aGradientPattern, - nscoord aXStart, - nscoord aYStart, - const gfxRect& aDirtyAreaToFill, - const nsRect& aDest, - const nsSize& aRepeatSize, - bool aForceRepeatToCoverTiles) -{ - // If we have forced a non-repeating gradient to repeat to cover tiles, - // then it will be faster to just paint it once using that optimization - if (aForceRepeatToCoverTiles) { - return false; - } - - nscoord appUnitsPerDevPixel = mPresContext->AppUnitsPerDevPixel(); - - // We can only use this fast path if we don't have to worry about pixel - // snapping, and there is no spacing between tiles. We could handle spacing - // by increasing the size of tileSurface and leaving it transparent, but I'm - // not sure it's worth it - bool canUseExtendModeForTiling = - (aXStart % appUnitsPerDevPixel == 0) && - (aYStart % appUnitsPerDevPixel == 0) && - (aDest.width % appUnitsPerDevPixel == 0) && - (aDest.height % appUnitsPerDevPixel == 0) && - (aRepeatSize.width == aDest.width) && - (aRepeatSize.height == aDest.height); - - if (!canUseExtendModeForTiling) { - return false; - } - - IntSize tileSize { - NSAppUnitsToIntPixels(aDest.width, appUnitsPerDevPixel), - NSAppUnitsToIntPixels(aDest.height, appUnitsPerDevPixel), - }; - - // We only want to do this when there are enough tiles to justify the - // overhead of painting to an offscreen surface. The heuristic here - // is when we will be painting at least 16 tiles or more, this is kind - // of arbitrary - bool shouldUseExtendModeForTiling = - aDirtyAreaToFill.Area() > (tileSize.width * tileSize.height) * 16.0; - - if (!shouldUseExtendModeForTiling) { - return false; - } - - // Draw the gradient pattern into a surface for our single tile - RefPtr tileSurface; - { - RefPtr tileTarget = aContext. - GetDrawTarget()-> - CreateSimilarDrawTarget(tileSize, gfx::SurfaceFormat::B8G8R8A8); - if (!tileTarget || !tileTarget->IsValid()) { - return false; - } - - RefPtr tileContext = gfxContext::CreateOrNull(tileTarget); - - tileContext->SetPattern(aGradientPattern); - tileContext->Paint(); - - tileContext = nullptr; - tileSurface = tileTarget->Snapshot(); - tileTarget = nullptr; - } - - // Draw the gradient using tileSurface as a repeating pattern masked by - // the dirtyRect - Matrix tileTransform = Matrix::Translation( - NSAppUnitsToFloatPixels(aXStart, appUnitsPerDevPixel), - NSAppUnitsToFloatPixels(aYStart, appUnitsPerDevPixel)); - - aContext.NewPath(); - aContext.Rectangle(aDirtyAreaToFill); - aContext.Fill(SurfacePattern( - tileSurface, - ExtendMode::REPEAT, - tileTransform)); - - return true; -} - void nsCSSGradientRenderer::BuildWebRenderParameters(float aOpacity, wr::ExtendMode& aMode, diff --git a/layout/painting/nsCSSRenderingGradients.h b/layout/painting/nsCSSRenderingGradients.h index 39ba02234da7..dd9891457d0f 100644 --- a/layout/painting/nsCSSRenderingGradients.h +++ b/layout/painting/nsCSSRenderingGradients.h @@ -92,23 +92,6 @@ public: private: nsCSSGradientRenderer() {} - /** - * Attempts to paint the tiles for a gradient by painting it once to an - * offscreen surface and then painting that offscreen surface with - * ExtendMode::Repeat to cover all tiles. - * - * Returns false if the optimization wasn't able to be used, in which case - * a fallback should be used. - */ - bool TryPaintTilesWithExtendMode(gfxContext& aContext, - gfxPattern* aGradientPattern, - nscoord aXStart, - nscoord aYStart, - const gfxRect& aDirtyAreaToFill, - const nsRect& aDest, - const nsSize& aRepeatSize, - bool aForceRepeatToCoverTiles); - nsPresContext* mPresContext; nsStyleGradient* mGradient; nsTArray mStops;