Bug 1435291 - Part 2. Make background SVGs use WebRender instead of fallback. r=jrmuizel

This commit is contained in:
Andrew Osmond
2018-03-14 14:19:13 -04:00
parent ef00f2864c
commit 53293bdc25
8 changed files with 36 additions and 34 deletions

View File

@@ -154,12 +154,6 @@ WebRenderLayerManager::GetCompositorBridgeChild()
return WrBridge()->GetCompositorBridgeChild(); return WrBridge()->GetCompositorBridgeChild();
} }
int32_t
WebRenderLayerManager::GetMaxTextureSize() const
{
return WrBridge()->GetMaxTextureSize();
}
bool bool
WebRenderLayerManager::BeginTransactionWithTarget(gfxContext* aTarget) WebRenderLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
{ {

View File

@@ -63,7 +63,8 @@ public:
WebRenderLayerManager* AsWebRenderLayerManager() override { return this; } WebRenderLayerManager* AsWebRenderLayerManager() override { return this; }
virtual CompositorBridgeChild* GetCompositorBridgeChild() override; virtual CompositorBridgeChild* GetCompositorBridgeChild() override;
virtual int32_t GetMaxTextureSize() const override; // WebRender can handle images larger than the max texture size via tiling.
virtual int32_t GetMaxTextureSize() const override { return INT32_MAX; }
virtual bool BeginTransactionWithTarget(gfxContext* aTarget) override; virtual bool BeginTransactionWithTarget(gfxContext* aTarget) override;
virtual bool BeginTransaction() override; virtual bool BeginTransaction() override;

View File

@@ -15,7 +15,6 @@
#include "mozilla/MemoryReporting.h" #include "mozilla/MemoryReporting.h"
#include "mozilla/dom/SVGSVGElement.h" #include "mozilla/dom/SVGSVGElement.h"
#include "mozilla/gfx/2D.h" #include "mozilla/gfx/2D.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/Tuple.h" #include "mozilla/Tuple.h"
#include "nsIDOMEvent.h" #include "nsIDOMEvent.h"
@@ -860,13 +859,20 @@ VectorImage::GetImageContainerSize(LayerManager* aManager,
NS_IMETHODIMP_(bool) NS_IMETHODIMP_(bool)
VectorImage::IsImageContainerAvailable(LayerManager* aManager, uint32_t aFlags) VectorImage::IsImageContainerAvailable(LayerManager* aManager, uint32_t aFlags)
{ {
return false; if (mError || !mIsFullyLoaded || mHaveAnimations ||
aManager->GetBackendType() != LayersBackend::LAYERS_WR) {
return false;
}
return true;
} }
//****************************************************************************** //******************************************************************************
NS_IMETHODIMP_(already_AddRefed<ImageContainer>) NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
VectorImage::GetImageContainer(LayerManager* aManager, uint32_t aFlags) VectorImage::GetImageContainer(LayerManager* aManager, uint32_t aFlags)
{ {
MOZ_ASSERT(aManager->GetBackendType() != LayersBackend::LAYERS_WR,
"WebRender should always use GetImageContainerAvailableAtSize!");
return nullptr; return nullptr;
} }
@@ -876,14 +882,9 @@ VectorImage::IsImageContainerAvailableAtSize(LayerManager* aManager,
const IntSize& aSize, const IntSize& aSize,
uint32_t aFlags) uint32_t aFlags)
{ {
if (mError || !mIsFullyLoaded || aSize.IsEmpty() || // Since we only support image containers with WebRender, and it can handle
mHaveAnimations || !gfxVars::GetUseWebRenderOrDefault()) { // textures larger than the hw max texture size, we don't need to check aSize.
return false; return !aSize.IsEmpty() && IsImageContainerAvailable(aManager, aFlags);
}
int32_t maxTextureSize = aManager->GetMaxTextureSize();
return aSize.width <= maxTextureSize &&
aSize.height <= maxTextureSize;
} }
//****************************************************************************** //******************************************************************************

View File

@@ -18,6 +18,7 @@
#include "GeckoProfiler.h" #include "GeckoProfiler.h"
#include "MainThreadUtils.h" #include "MainThreadUtils.h"
#include "mozilla/CheckedInt.h" #include "mozilla/CheckedInt.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/gfx/Tools.h" #include "mozilla/gfx/Tools.h"
#include "mozilla/gfx/SourceSurfaceRawData.h" #include "mozilla/gfx/SourceSurfaceRawData.h"
#include "mozilla/layers/SourceSurfaceSharedData.h" #include "mozilla/layers/SourceSurfaceSharedData.h"

View File

@@ -26,12 +26,12 @@
# RUN TESTS NOT AFFECTED BY DOWNSCALE-DURING-DECODE: # RUN TESTS NOT AFFECTED BY DOWNSCALE-DURING-DECODE:
# ================================================== # ==================================================
fuzzy-if(skiaContent,14,416) fails-if(webrender) == downscale-svg-1a.html downscale-svg-1-ref.html?80 fuzzy-if(skiaContent,14,416) fuzzy-if(webrender,102-102,396-396) == downscale-svg-1a.html downscale-svg-1-ref.html?80
fuzzy(80,468) == downscale-svg-1b.html downscale-svg-1-ref.html?72 fuzzy(80,468) fuzzy-if(webrender,65-65,579-579) == downscale-svg-1b.html downscale-svg-1-ref.html?72
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),1,62) fuzzy-if(skiaContent,8,292) == downscale-svg-1c.html downscale-svg-1-ref.html?64 fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),1,62) fuzzy-if(skiaContent,8,292) fuzzy-if(webrender,14-14,316-316) == downscale-svg-1c.html downscale-svg-1-ref.html?64
fuzzy(17,208) == downscale-svg-1d.html downscale-svg-1-ref.html?53 fuzzy(17,208) fuzzy-if(webrender,83-83,325-325) == downscale-svg-1d.html downscale-svg-1-ref.html?53
fuzzy(80,216) fuzzy-if(skiaContent,110,181) == downscale-svg-1e.html downscale-svg-1-ref.html?40 fuzzy(80,216) fuzzy-if(skiaContent,110,181) fuzzy-if(webrender,84-84,216-216) == downscale-svg-1e.html downscale-svg-1-ref.html?40
fuzzy(51,90) fuzzy-if(skiaContent,142,77) == downscale-svg-1f.html downscale-svg-1-ref.html?24 fuzzy(51,90) fuzzy-if(skiaContent,142,77) fuzzy-if(webrender,62-62,98-98) == downscale-svg-1f.html downscale-svg-1-ref.html?24
# RUN TESTS WITH DOWNSCALE-DURING-DECODE DISABLED: # RUN TESTS WITH DOWNSCALE-DURING-DECODE DISABLED:
# ================================================ # ================================================

View File

@@ -7181,22 +7181,24 @@ nsLayoutUtils::ComputeImageContainerDrawingParameters(imgIContainer*
SamplingFilter samplingFilter = SamplingFilter samplingFilter =
nsLayoutUtils::GetSamplingFilterForFrame(aForFrame); nsLayoutUtils::GetSamplingFilterForFrame(aForFrame);
// Compute our SVG context parameters, if any. // Compute our SVG context parameters, if any. Don't replace the viewport
// size if it was already set, prefer what the caller gave.
SVGImageContext::MaybeStoreContextPaint(aSVGContext, aForFrame, aImage); SVGImageContext::MaybeStoreContextPaint(aSVGContext, aForFrame, aImage);
if ((scaleFactors.width != 1.0 || scaleFactors.height != 1.0) && if ((scaleFactors.width != 1.0 || scaleFactors.height != 1.0) &&
aImage->GetType() == imgIContainer::TYPE_VECTOR) { aImage->GetType() == imgIContainer::TYPE_VECTOR &&
if (!aSVGContext) { (!aSVGContext || !aSVGContext->GetViewportSize())) {
aSVGContext.emplace();
}
gfxSize gfxDestSize(aDestRect.Width(), aDestRect.Height()); gfxSize gfxDestSize(aDestRect.Width(), aDestRect.Height());
IntSize viewportSize = IntSize viewportSize =
aImage->OptimalImageSizeForDest(gfxDestSize, aImage->OptimalImageSizeForDest(gfxDestSize,
imgIContainer::FRAME_CURRENT, imgIContainer::FRAME_CURRENT,
samplingFilter, aFlags); samplingFilter, aFlags);
aSVGContext->SetViewportSize(Some(CSSIntSize(viewportSize.width, CSSIntSize cssViewportSize(viewportSize.width, viewportSize.height);
viewportSize.height))); if (!aSVGContext) {
aSVGContext.emplace(Some(cssViewportSize));
} else {
aSVGContext->SetViewportSize(Some(cssViewportSize));
}
} }
// Attempt to snap pixels, the same as ComputeSnappedImageDrawingParameters. // Attempt to snap pixels, the same as ComputeSnappedImageDrawingParameters.

View File

@@ -600,10 +600,13 @@ nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
containerFlags |= imgIContainer::FLAG_SYNC_DECODE; containerFlags |= imgIContainer::FLAG_SYNC_DECODE;
} }
CSSIntSize imageSize(nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
nsPresContext::AppUnitsToIntCSSPixels(mSize.height));
Maybe<SVGImageContext> svgContext(Some(SVGImageContext(Some(imageSize))));
const int32_t appUnitsPerDevPixel = mForFrame->PresContext()->AppUnitsPerDevPixel(); const int32_t appUnitsPerDevPixel = mForFrame->PresContext()->AppUnitsPerDevPixel();
LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits( LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits(
aDest, appUnitsPerDevPixel); aDest, appUnitsPerDevPixel);
Maybe<SVGImageContext> svgContext;
gfx::IntSize decodeSize = gfx::IntSize decodeSize =
nsLayoutUtils::ComputeImageContainerDrawingParameters(mImageContainer, mForFrame, destRect, nsLayoutUtils::ComputeImageContainerDrawingParameters(mImageContainer, mForFrame, destRect,
aSc, containerFlags, svgContext); aSc, containerFlags, svgContext);

View File

@@ -181,8 +181,8 @@ include empty/reftest.list
== wide--contain--percent-width-percent-height.html ref-wide-lime768x128-aqua768x128.html == wide--contain--percent-width-percent-height.html ref-wide-lime768x128-aqua768x128.html
== wide--contain--percent-width-percent-height-viewbox.html ref-wide-lime16x128-aqua16x128.html == wide--contain--percent-width-percent-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
== wide--cover--nonpercent-width-nonpercent-height.html ref-wide-lime768x256.html fuzzy-if(webrender,127-127,768-768) == wide--cover--nonpercent-width-nonpercent-height.html ref-wide-lime768x256.html
== wide--cover--nonpercent-width-nonpercent-height-viewbox.html ref-wide-lime768x256.html fuzzy-if(webrender,127-127,768-768) == wide--cover--nonpercent-width-nonpercent-height-viewbox.html ref-wide-lime768x256.html
== wide--cover--nonpercent-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html == wide--cover--nonpercent-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html
== wide--cover--nonpercent-width-omitted-height-viewbox.html ref-wide-lime768x256.html == wide--cover--nonpercent-width-omitted-height-viewbox.html ref-wide-lime768x256.html
== wide--cover--nonpercent-width-percent-height.html ref-wide-lime768x128-aqua768x128.html == wide--cover--nonpercent-width-percent-height.html ref-wide-lime768x128-aqua768x128.html