Bug 1814398 - SVGImageElement should not derive from SVGGeometryElement r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D168674
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "mozilla/ProfilerLabels.h"
|
||||
#include "mozilla/StaticPrefs_gfx.h"
|
||||
#include "mozilla/SVGGeometryFrame.h"
|
||||
#include "mozilla/SVGImageFrame.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
@@ -1125,6 +1126,26 @@ static ItemActivity HasActiveChildren(
|
||||
return activity;
|
||||
}
|
||||
|
||||
static ItemActivity AssessBounds(
|
||||
const mozilla::layers::StackingContextHelper& aSc, const nsRect& aBounds) {
|
||||
// Arbitrary threshold up for adjustments. What we want to avoid here
|
||||
// is alternating between active and non active items and create a lot
|
||||
// of overlapping blobs, so we only make images active if they are
|
||||
// costly enough that it's worth the risk of having more layers. As we
|
||||
// move more blob items into wr display items it will become less of a
|
||||
// concern.
|
||||
constexpr float largeish = 512;
|
||||
|
||||
float width = aBounds.width * aSc.GetInheritedScale().xScale;
|
||||
float height = aBounds.height * aSc.GetInheritedScale().yScale;
|
||||
|
||||
if (width > largeish || height > largeish) {
|
||||
return ItemActivity::Should;
|
||||
}
|
||||
|
||||
return ItemActivity::Could;
|
||||
}
|
||||
|
||||
// This function decides whether we want to treat this item as "active", which
|
||||
// means that it's a container item which we will turn into a WebRender
|
||||
// StackingContext, or whether we treat it as "inactive" and include it inside
|
||||
@@ -1175,29 +1196,28 @@ static ItemActivity IsItemProbablyActive(
|
||||
}
|
||||
case DisplayItemType::TYPE_SVG_GEOMETRY: {
|
||||
auto* svgItem = static_cast<DisplaySVGGeometry*>(aItem);
|
||||
if (StaticPrefs::gfx_webrender_svg_shapes() && aUniformlyScaled &&
|
||||
svgItem->ShouldBeActive(aBuilder, aResources, aSc, aManager,
|
||||
aDisplayListBuilder)) {
|
||||
if (aHasActivePrecedingSibling) {
|
||||
return ItemActivity::Should;
|
||||
}
|
||||
bool snap = false;
|
||||
return AssessBounds(aSc, aItem->GetBounds(aDisplayListBuilder, &snap));
|
||||
}
|
||||
|
||||
return ItemActivity::No;
|
||||
}
|
||||
case DisplayItemType::TYPE_SVG_IMAGE: {
|
||||
auto* svgItem = static_cast<DisplaySVGImage*>(aItem);
|
||||
if (StaticPrefs::gfx_webrender_svg_images() && aUniformlyScaled &&
|
||||
svgItem->ShouldBeActive(aBuilder, aResources, aSc, aManager,
|
||||
aDisplayListBuilder)) {
|
||||
bool snap = false;
|
||||
auto bounds = aItem->GetBounds(aDisplayListBuilder, &snap);
|
||||
|
||||
// Arbitrary threshold up for adjustments. What we want to avoid here
|
||||
// is alternating between active and non active items and create a lot
|
||||
// of overlapping blobs, so we only make images active if they are
|
||||
// costly enough that it's worth the risk of having more layers. As we
|
||||
// move more blob items into wr dislplay items it will become less of a
|
||||
// concern.
|
||||
const int32_t largeish = 512;
|
||||
|
||||
float width = bounds.width * aSc.GetInheritedScale().xScale;
|
||||
float height = bounds.height * aSc.GetInheritedScale().yScale;
|
||||
|
||||
if (aHasActivePrecedingSibling || width > largeish ||
|
||||
height > largeish) {
|
||||
if (aHasActivePrecedingSibling) {
|
||||
return ItemActivity::Should;
|
||||
}
|
||||
|
||||
return ItemActivity::Could;
|
||||
bool snap = false;
|
||||
return AssessBounds(aSc, aItem->GetBounds(aDisplayListBuilder, &snap));
|
||||
}
|
||||
|
||||
return ItemActivity::No;
|
||||
|
||||
Reference in New Issue
Block a user