Backed out 8 changesets (bug 1540737) for causing graphics crashes in Bug 1711718. a=backout

Backed out changeset 37628894ffd5 (bug 1540737)
Backed out changeset 4b5f53d5127b (bug 1540737)
Backed out changeset a73e041f1f1d (bug 1540737)
Backed out changeset 81f1a9d1a5e1 (bug 1540737)
Backed out changeset b3d0cc460b24 (bug 1540737)
Backed out changeset f929de495b87 (bug 1540737)
Backed out changeset 2f5b8369d061 (bug 1540737)
Backed out changeset b4c93d182ef4 (bug 1540737)
This commit is contained in:
Csoregi Natalia 2021-05-18 19:06:20 +03:00
Родитель 4274173c80
Коммит 1f3f5df2ce
37 изменённых файлов: 372 добавлений и 746 удалений

Просмотреть файл

@ -1540,16 +1540,6 @@ void DrawTargetCairo::PushLayer(bool aOpaque, Float aOpacity,
SourceSurface* aMask,
const Matrix& aMaskTransform,
const IntRect& aBounds, bool aCopyBackground) {
PushLayerWithBlend(aOpaque, aOpacity, aMask, aMaskTransform, aBounds,
aCopyBackground, CompositionOp::OP_OVER);
}
void DrawTargetCairo::PushLayerWithBlend(bool aOpaque, Float aOpacity,
SourceSurface* aMask,
const Matrix& aMaskTransform,
const IntRect& aBounds,
bool aCopyBackground,
CompositionOp aCompositionOp) {
cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
if (mFormat == SurfaceFormat::A8) {
@ -1571,7 +1561,7 @@ void DrawTargetCairo::PushLayerWithBlend(bool aOpaque, Float aOpacity,
cairo_push_group_with_content(mContext, content);
}
PushedLayer layer(aOpacity, aCompositionOp, mPermitSubpixelAA);
PushedLayer layer(aOpacity, mPermitSubpixelAA);
if (aMask) {
cairo_surface_t* surf = GetCairoSurfaceForSourceSurface(aMask);
@ -1605,7 +1595,6 @@ void DrawTargetCairo::PopLayer() {
mPushedLayers.pop_back();
if (!layer.mMaskPattern) {
cairo_set_operator(mContext, GfxOpToCairoOp(layer.mCompositionOp));
cairo_paint_with_alpha(mContext, layer.mOpacity);
} else {
if (layer.mOpacity != Float(1.0)) {
@ -1616,7 +1605,6 @@ void DrawTargetCairo::PopLayer() {
cairo_pop_group_to_source(mContext);
}
cairo_set_operator(mContext, GfxOpToCairoOp(layer.mCompositionOp));
cairo_mask(mContext, layer.mMaskPattern);
}
@ -1624,8 +1612,6 @@ void DrawTargetCairo::PopLayer() {
GfxMatrixToCairoMatrix(mTransform, mat);
cairo_set_matrix(mContext, &mat);
cairo_set_operator(mContext, CAIRO_OPERATOR_OVER);
cairo_pattern_destroy(layer.mMaskPattern);
SetPermitSubpixelAA(layer.mWasPermittingSubpixelAA);
}

Просмотреть файл

@ -131,11 +131,6 @@ class DrawTargetCairo final : public DrawTarget {
const Matrix& aMaskTransform,
const IntRect& aBounds = IntRect(),
bool aCopyBackground = false) override;
virtual void PushLayerWithBlend(
bool aOpaque, Float aOpacity, SourceSurface* aMask,
const Matrix& aMaskTransform, const IntRect& aBounds = IntRect(),
bool aCopyBackground = false,
CompositionOp = CompositionOp::OP_OVER) override;
virtual void PopLayer() override;
virtual already_AddRefed<PathBuilder> CreatePathBuilder(
@ -225,14 +220,11 @@ class DrawTargetCairo final : public DrawTarget {
cairo_font_options_t* mFontOptions;
struct PushedLayer {
PushedLayer(Float aOpacity, CompositionOp aCompositionOp,
bool aWasPermittingSubpixelAA)
PushedLayer(Float aOpacity, bool aWasPermittingSubpixelAA)
: mOpacity(aOpacity),
mCompositionOp(aCompositionOp),
mMaskPattern(nullptr),
mWasPermittingSubpixelAA(aWasPermittingSubpixelAA) {}
Float mOpacity;
CompositionOp mCompositionOp;
cairo_pattern_t* mMaskPattern;
bool mWasPermittingSubpixelAA;
};

Просмотреть файл

@ -10,13 +10,12 @@
namespace mozilla {
namespace layers {
template <typename T>
void BSPTree<T>::BuildDrawOrder(BSPTreeNode<T>* aNode,
nsTArray<BSPPolygon<T>>& aLayers) const {
void BSPTree::BuildDrawOrder(BSPTreeNode* aNode,
nsTArray<LayerPolygon>& aLayers) const {
const gfx::Point4D& normal = aNode->First().GetNormal();
BSPTreeNode<T>* front = aNode->front;
BSPTreeNode<T>* back = aNode->back;
BSPTreeNode* front = aNode->front;
BSPTreeNode* back = aNode->back;
// Since the goal is to return the draw order from back to front, we reverse
// the traversal order if the current polygon is facing towards the camera.
@ -30,7 +29,7 @@ void BSPTree<T>::BuildDrawOrder(BSPTreeNode<T>* aNode,
BuildDrawOrder(front, aLayers);
}
for (BSPPolygon<T>& layer : aNode->layers) {
for (LayerPolygon& layer : aNode->layers) {
MOZ_ASSERT(layer.geometry);
if (layer.geometry->GetPoints().Length() >= 3) {
@ -43,8 +42,7 @@ void BSPTree<T>::BuildDrawOrder(BSPTreeNode<T>* aNode,
}
}
template <typename T>
void BSPTree<T>::BuildTree(BSPTreeNode<T>* aRoot, PolygonList<T>& aLayers) {
void BSPTree::BuildTree(BSPTreeNode* aRoot, std::list<LayerPolygon>& aLayers) {
MOZ_ASSERT(!aLayers.empty());
aRoot->layers.push_back(std::move(aLayers.front()));
@ -60,8 +58,8 @@ void BSPTree<T>::BuildTree(BSPTreeNode<T>* aRoot, PolygonList<T>& aLayers) {
const gfx::Point4D& planeNormal = plane.GetNormal();
const gfx::Point4D& planePoint = plane.GetPoints()[0];
PolygonList<T> backLayers, frontLayers;
for (BSPPolygon<T>& layerPolygon : aLayers) {
std::list<LayerPolygon> backLayers, frontLayers;
for (LayerPolygon& layerPolygon : aLayers) {
const nsTArray<gfx::Point4D>& geometry = layerPolygon.geometry->GetPoints();
// Calculate the plane-point distances for the polygon classification.
@ -90,14 +88,14 @@ void BSPTree<T>::BuildTree(BSPTreeNode<T>* aRoot, PolygonList<T>& aLayers) {
frontPoints);
const gfx::Point4D& normal = layerPolygon.geometry->GetNormal();
T* data = layerPolygon.data;
Layer* layer = layerPolygon.layer;
if (backPoints.Length() >= 3) {
backLayers.emplace_back(data, std::move(backPoints), normal);
backLayers.emplace_back(layer, std::move(backPoints), normal);
}
if (frontPoints.Length() >= 3) {
frontLayers.emplace_back(data, std::move(frontPoints), normal);
frontLayers.emplace_back(layer, std::move(frontPoints), normal);
}
}
}
@ -113,17 +111,5 @@ void BSPTree<T>::BuildTree(BSPTreeNode<T>* aRoot, PolygonList<T>& aLayers) {
}
}
template void BSPTree<Layer>::BuildTree(BSPTreeNode<Layer>* aRoot,
PolygonList<Layer>& aLayers);
template void BSPTree<Layer>::BuildDrawOrder(
BSPTreeNode<Layer>* aNode, nsTArray<BSPPolygon<Layer>>& aLayers) const;
template void BSPTree<nsDisplayTransform>::BuildTree(
BSPTreeNode<nsDisplayTransform>* aRoot,
PolygonList<nsDisplayTransform>& aLayers);
template void BSPTree<nsDisplayTransform>::BuildDrawOrder(
BSPTreeNode<nsDisplayTransform>* aNode,
nsTArray<BSPPolygon<nsDisplayTransform>>& aLayers) const;
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -15,8 +15,6 @@
#include "mozilla/gfx/Polygon.h"
#include "nsTArray.h"
class nsDisplayTransform;
namespace mozilla {
namespace layers {
@ -25,20 +23,19 @@ class Layer;
/**
* Represents a layer that might have a non-rectangular geometry.
*/
template <typename T>
struct BSPPolygon {
explicit BSPPolygon(T* aData) : data(aData) {}
struct LayerPolygon {
explicit LayerPolygon(Layer* aLayer) : layer(aLayer) {}
BSPPolygon<T>(T* aData, gfx::Polygon&& aGeometry)
: data(aData), geometry(Some(std::move(aGeometry))) {}
LayerPolygon(Layer* aLayer, gfx::Polygon&& aGeometry)
: layer(aLayer), geometry(Some(std::move(aGeometry))) {}
BSPPolygon(T* aData, nsTArray<gfx::Point4D>&& aPoints,
const gfx::Point4D& aNormal)
: data(aData) {
LayerPolygon(Layer* aLayer, nsTArray<gfx::Point4D>&& aPoints,
const gfx::Point4D& aNormal)
: layer(aLayer) {
geometry.emplace(std::move(aPoints), aNormal);
}
T* data;
Layer* layer;
Maybe<gfx::Polygon> geometry;
};
@ -53,19 +50,15 @@ typedef mozilla::ArenaAllocator<4096, 8> BSPTreeArena;
/**
* Aliases the container type used to store layers within BSPTreeNodes.
*/
template <typename T>
using PolygonList = std::list<BSPPolygon<T>>;
using LayerPolygon = BSPPolygon<Layer>;
typedef std::list<LayerPolygon> LayerList;
/**
* Represents a node in a BSP tree. The node contains at least one layer with
* associated geometry that is used as a splitting plane, and at most two child
* nodes that represent the splitting planes that further subdivide the space.
*/
template <typename T>
struct BSPTreeNode {
explicit BSPTreeNode(nsTArray<PolygonList<T>*>& aListPointers)
explicit BSPTreeNode(nsTArray<LayerList*>& aListPointers)
: front(nullptr), back(nullptr) {
// Store the layer list pointer to free memory when BSPTree is destroyed.
aListPointers.AppendElement(&layers);
@ -83,7 +76,7 @@ struct BSPTreeNode {
BSPTreeNode* front;
BSPTreeNode* back;
PolygonList<T> layers;
LayerList layers;
};
/**
@ -95,13 +88,12 @@ struct BSPTreeNode {
* https://en.wikipedia.org/wiki/Binary_space_partitioning
* ftp://ftp.sgi.com/other/bspfaq/faq/bspfaq.html
*/
template <typename T>
class BSPTree final {
public:
/**
* The constructor modifies layers in the given list.
*/
explicit BSPTree(std::list<BSPPolygon<T>>& aLayers) {
explicit BSPTree(std::list<LayerPolygon>& aLayers) {
MOZ_ASSERT(!aLayers.empty());
mRoot = new (mPool) BSPTreeNode(mListPointers);
@ -109,33 +101,33 @@ class BSPTree final {
}
~BSPTree() {
for (PolygonList<T>* listPtr : mListPointers) {
listPtr->~list();
for (LayerList* listPtr : mListPointers) {
listPtr->~LayerList();
}
}
/**
* Builds and returns the back-to-front draw order for the created BSP tree.
*/
nsTArray<BSPPolygon<T>> GetDrawOrder() const {
nsTArray<BSPPolygon<T>> layers;
nsTArray<LayerPolygon> GetDrawOrder() const {
nsTArray<LayerPolygon> layers;
BuildDrawOrder(mRoot, layers);
return layers;
}
private:
BSPTreeArena mPool;
BSPTreeNode<T>* mRoot;
nsTArray<PolygonList<T>*> mListPointers;
BSPTreeNode* mRoot;
nsTArray<LayerList*> mListPointers;
/**
* BuildDrawOrder and BuildTree are called recursively. The depth of the
* recursion depends on the amount of polygons and their intersections.
*/
void BuildDrawOrder(BSPTreeNode<T>* aNode,
nsTArray<BSPPolygon<T>>& aLayers) const;
void BuildDrawOrder(BSPTreeNode* aNode,
nsTArray<LayerPolygon>& aLayers) const;
void BuildTree(BSPTreeNode<T>* aRoot, PolygonList<T>& aLayers);
void BuildTree(BSPTreeNode* aRoot, std::list<LayerPolygon>& aLayers);
};
} // namespace layers

Просмотреть файл

@ -80,6 +80,7 @@ class FrameUniformityData;
class PersistentBufferProvider;
class GlyphArray;
class WebRenderLayerManager;
struct LayerPolygon;
struct AnimData;
namespace layerscope {

Просмотреть файл

@ -939,14 +939,14 @@ static nsTArray<LayerPolygon> SortLayersWithBSPTree(nsTArray<Layer*>& aArray) {
}
// Build a BSP tree from the list of polygons.
BSPTree<Layer> tree(inputLayers);
BSPTree tree(inputLayers);
nsTArray<LayerPolygon> orderedLayers(tree.GetDrawOrder());
// Transform the polygons back to layer space.
for (LayerPolygon& layerPolygon : orderedLayers) {
gfx::Matrix4x4 inverse =
layerPolygon.data->GetEffectiveTransform().Inverse();
layerPolygon.layer->GetEffectiveTransform().Inverse();
MOZ_ASSERT(layerPolygon.geometry);
layerPolygon.geometry->TransformToLayerSpace(inverse);
@ -961,11 +961,11 @@ static nsTArray<LayerPolygon> StripLayerGeometry(
std::set<Layer*> uniqueLayers;
for (const LayerPolygon& layerPolygon : aLayers) {
auto result = uniqueLayers.insert(layerPolygon.data);
auto result = uniqueLayers.insert(layerPolygon.layer);
if (result.second) {
// Layer was added to the set.
layers.AppendElement(LayerPolygon(layerPolygon.data));
layers.AppendElement(LayerPolygon(layerPolygon.layer));
}
}
@ -1441,7 +1441,7 @@ void Layer::Dump(std::stringstream& aStream, const char* aPrefix,
}
for (LayerPolygon& child : children) {
child.data->Dump(aStream, pfx.get(), aDumpHtml, aSorted, child.geometry);
child.layer->Dump(aStream, pfx.get(), aDumpHtml, aSorted, child.geometry);
}
if (aDumpHtml) {

Просмотреть файл

@ -35,7 +35,6 @@
#include "mozilla/layers/LayerAttributes.h" // for SimpleLayerAttributes, ScrollbarData (ptr only)
#include "mozilla/layers/LayerManager.h" // for LayerManager, LayerManager::PaintedLayerCreationHint
#include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid, ScrollableLayerGuid::ViewID
#include "mozilla/layers/BSPTree.h"
#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING
#include "nsPoint.h" // for nsIntPoint
#include "nsRect.h" // for nsIntRect
@ -78,6 +77,7 @@ class ShadowableLayer;
class SpecificLayerAttributes;
class Compositor;
class TransformData;
struct LayerPolygon;
struct PropertyAnimationGroup;
namespace layerscope {

Просмотреть файл

@ -717,7 +717,7 @@ void BasicLayerManager::PaintSelfOrChildren(PaintLayerContext& aPaintContext,
ContainerLayer::SortMode::WITHOUT_GEOMETRY);
for (uint32_t i = 0; i < children.Length(); i++) {
Layer* layer = children.ElementAt(i).data;
Layer* layer = children.ElementAt(i).layer;
if (layer->IsBackfaceHidden()) {
continue;
}

Просмотреть файл

@ -226,7 +226,7 @@ void ContainerPrepare(ContainerT* aContainer, LayerManagerComposite* aManager,
for (LayerPolygon& layer : polygons) {
LayerComposite* layerToRender =
static_cast<LayerComposite*>(layer.data->ImplData());
static_cast<LayerComposite*>(layer.layer->ImplData());
RenderTargetIntRect clipRect =
layerToRender->GetLayer()->CalculateScissorRect(aClipRect);

Просмотреть файл

@ -26,11 +26,11 @@
# RUN TESTS NOT AFFECTED BY DOWNSCALE-DURING-DECODE:
# ==================================================
fuzzy-if(skiaContent,0-14,0-416) == downscale-svg-1a.html downscale-svg-1-ref.html?80
fuzzy-if(skiaContent,0-14,0-416) fuzzy-if(webrender&&!geckoview,1-1,2-2) == downscale-svg-1a.html downscale-svg-1-ref.html?80
fuzzy(0-80,0-468) fuzzy-if(webrender,65-65,468-480) == downscale-svg-1b.html downscale-svg-1-ref.html?72
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-1,0-62) fuzzy-if(skiaContent,0-8,0-292) == downscale-svg-1c.html downscale-svg-1-ref.html?64
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-1,0-62) fuzzy-if(skiaContent,0-8,0-292) fuzzy-if(webrender&&!geckoview,1-1,2-2) == downscale-svg-1c.html downscale-svg-1-ref.html?64
fuzzy(0-17,0-208) fuzzy-if(webrender,7-7,208-208) == downscale-svg-1d.html downscale-svg-1-ref.html?53
fuzzy(0-80,0-216) fuzzy-if(skiaContent,0-110,0-181) fuzzy-if(webrender,54-55,178-178) == downscale-svg-1e.html downscale-svg-1-ref.html?40
fuzzy(0-80,0-216) fuzzy-if(skiaContent,0-110,0-181) fuzzy-if(webrender,54-54,178-178) == downscale-svg-1e.html downscale-svg-1-ref.html?40
fuzzy(0-51,0-90) fuzzy-if(skiaContent,0-142,0-77) fuzzy-if(webrender,64-64,31-31) == downscale-svg-1f.html downscale-svg-1-ref.html?24
# RUN TESTS WITH DOWNSCALE-DURING-DECODE DISABLED:

Просмотреть файл

@ -3080,7 +3080,7 @@ static void DumpAfterPaintDisplayList(UniquePtr<std::stringstream>& aStream,
std::stringstream lsStream;
nsIFrame::PrintDisplayList(aBuilder, *aList, lsStream);
if (aManager && aManager->GetRoot()) {
if (aManager->GetRoot()) {
aManager->GetRoot()->SetDisplayListLog(lsStream.str().c_str());
}
}
@ -3510,7 +3510,7 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext,
gfxUtils::sDumpPaintFile = savedDumpFile;
#endif
if (StaticPrefs::layers_dump_client_layers() && layerManager) {
if (StaticPrefs::layers_dump_client_layers()) {
std::stringstream ss;
FrameLayerBuilder::DumpRetainedLayerTree(layerManager, ss, false);
print_stderr(ss);

Просмотреть файл

@ -75,6 +75,7 @@ skip-if = os == 'linux' && !debug # Bug 1208197
[test_bug551434.html]
[test_bug708062.html]
[test_bug812817.xhtml]
[test_bug847890_paintFlashing.html]
[test_bug1018265.xhtml]
[test_bug1041200.xhtml]
skip-if = os == 'win' && bits == 64 # Bug 1272321

Просмотреть файл

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Tests for paint flashing</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function startTest() {
waitForAllPaintsFlushed(function () {
var before = snapshotWindow(window, false);
SpecialPowers.getDOMWindowUtils(window).paintFlashing = true;
document.body.innerHTML = "bar";
waitForAllPaintsFlushed(function () {
document.body.innerHTML = "foo";
waitForAllPaintsFlushed(function () {
var after = snapshotWindow(window, false);
ok(compareSnapshots(before, after, false)[0], "windows are different");
SpecialPowers.getDOMWindowUtils(window).paintFlashing = false;
SimpleTest.finish();
});
});
});
}
</script>
</head>
<body onload="startTest()">foo</body>
</html>

Просмотреть файл

@ -48,10 +48,6 @@ class nsDisplayOptionEventGrabber : public nsDisplayWrapList {
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override {
return false;
}
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override {
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
}
NS_DISPLAY_DECL_NAME("OptionEventGrabber", TYPE_OPTION_EVENT_GRABBER)
};
@ -78,7 +74,7 @@ void nsDisplayOptionEventGrabber::HitTest(nsDisplayListBuilder* aBuilder,
}
}
class nsOptionEventGrabberWrapper : public nsDisplayItemWrapper {
class nsOptionEventGrabberWrapper : public nsDisplayWrapper {
public:
nsOptionEventGrabberWrapper() = default;
virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder,

Просмотреть файл

@ -229,13 +229,11 @@ nsDisplayWrapList* ViewportFrame::BuildDisplayListForTopLayer(
if (topLayerList.IsEmpty()) {
return nullptr;
}
nsPoint offset = aBuilder->GetCurrentFrame()->GetOffsetTo(this);
nsDisplayListBuilder::AutoBuildingDisplayList buildingDisplayList(
aBuilder, this, aBuilder->GetVisibleRect() + offset,
aBuilder->GetDirtyRect() + offset);
nsDisplayListBuilder::AutoBuildingDisplayList buildingDisplayList(aBuilder,
this);
// Wrap the whole top layer in a single item with maximum z-index,
// and append it at the very end, so that it stays at the topmost.
nsDisplayWrapList* wrapList = MakeDisplayItemWithIndex<nsDisplayWrapper>(
nsDisplayWrapList* wrapList = MakeDisplayItemWithIndex<nsDisplayWrapList>(
aBuilder, this, 2, &topLayerList, aBuilder->CurrentActiveScrolledRoot(),
false);
if (!wrapList) {

Просмотреть файл

@ -3262,7 +3262,7 @@ static void AppendToTop(nsDisplayListBuilder* aBuilder,
} else {
// Build the wrap list with an index of 1, since the scrollbar frame itself
// might have already built an nsDisplayWrapList.
newItem = MakeDisplayItemWithIndex<nsDisplayWrapper>(
newItem = MakeDisplayItemWithIndex<nsDisplayWrapList>(
aBuilder, aSourceFrame, 1, aSource, asr, false);
}
if (!newItem) {

Просмотреть файл

@ -16,7 +16,6 @@
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "mozilla/layers/WebRenderCanvasRenderer.h"
#include "mozilla/layers/RenderRootStateManager.h"
#include "BasicLayers.h"
#include "mozilla/webgpu/CanvasContext.h"
#include "nsDisplayList.h"
#include "nsLayoutUtils.h"
@ -304,27 +303,6 @@ class nsDisplayCanvas final : public nsPaintedDisplayItem {
HTMLCanvasElement* canvas = HTMLCanvasElement::FromNode(f->GetContent());
return canvas->MaybeModified();
}
virtual void Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) override {
// This currently uses BasicLayerManager to re-use the code for extracting
// the current CanvasRenderer/Image and generating DrawTarget rendering
// commands for it.
// Ideally we'll factor out that code and use it directly soon.
RefPtr<BasicLayerManager> layerManager =
new BasicLayerManager(BasicLayerManager::BLM_OFFSCREEN);
layerManager->BeginTransactionWithTarget(aCtx);
RefPtr<Layer> layer =
BuildLayer(aBuilder, layerManager, ContainerLayerParameters());
if (!layer) {
layerManager->AbortTransaction();
return;
}
layerManager->SetRoot(layer);
layerManager->EndEmptyTransaction();
}
};
nsIFrame* NS_NewHTMLCanvasFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
@ -518,9 +496,7 @@ already_AddRefed<Layer> nsHTMLCanvasFrame::BuildLayer(
return nullptr;
Layer* oldLayer =
aManager->GetLayerBuilder()
? aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem)
: nullptr;
aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem);
RefPtr<Layer> layer = element->GetCanvasLayer(aBuilder, oldLayer, aManager);
if (!layer) return nullptr;

Просмотреть файл

@ -235,7 +235,7 @@ static void BuildPreviousPageOverflow(nsDisplayListBuilder* aBuilder,
// Convert the overflowRect to the coordinate system of aPageFrame, and
// set it as the visible rect for display list building.
const nsRect visibleRect =
overflowRect.GetPhysicalRect(wm, prevPageCF->GetSize()) +
overflowRect.GetPhysicalRect(wm, aPageFrame->GetSize()) +
prevPageCF->GetOffsetTo(aPageFrame);
nsDisplayListBuilder::AutoBuildingDisplayList buildingForChild(
aBuilder, aPageFrame, visibleRect, visibleRect);

Просмотреть файл

@ -16,7 +16,6 @@
#include "mozilla/dom/HTMLVideoElement.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/layers/RenderRootStateManager.h"
#include "BasicLayers.h"
#include "nsDisplayList.h"
#include "nsGenericHTMLElement.h"
#include "nsPresContext.h"
@ -211,9 +210,7 @@ already_AddRefed<Layer> nsVideoFrame::BuildLayer(
container->SetScaleHint(scaleHint);
RefPtr<ImageLayer> layer = static_cast<ImageLayer*>(
aManager->GetLayerBuilder()
? aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem)
: nullptr);
aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
if (!layer) {
layer = aManager->CreateImageLayer();
if (!layer) return nullptr;
@ -500,26 +497,6 @@ class nsDisplayVideo : public nsPaintedDisplayItem {
HTMLVideoElement* video = HTMLVideoElement::FromNode(f->GetContent());
return video->VideoWidth() > 0;
}
virtual void Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) override {
// This currently uses BasicLayerManager to re-use the code for extracting
// the current Image and generating DrawTarget rendering commands for it.
// Ideally we'll factor out that code and use it directly soon.
RefPtr<BasicLayerManager> layerManager =
new BasicLayerManager(BasicLayerManager::BLM_OFFSCREEN);
layerManager->BeginTransactionWithTarget(aCtx);
RefPtr<Layer> layer =
BuildLayer(aBuilder, layerManager, ContainerLayerParameters());
if (!layer) {
layerManager->AbortTransaction();
return;
}
layerManager->SetRoot(layer);
layerManager->EndEmptyTransaction();
}
};
void nsVideoFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,

Просмотреть файл

@ -326,10 +326,6 @@ class nsDisplaymtdBorder final : public nsDisplayBorder {
nsDisplayListBuilder* aDisplayListBuilder) override {
return false;
}
virtual bool IsInvisibleInRect(const nsRect& aRect) const override {
return false;
}
};
#ifdef DEBUG

Просмотреть файл

@ -2431,37 +2431,6 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder,
return layerBuilder;
}
void nsDisplayList::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
int32_t aAppUnitsPerDevPixel) {
FlattenedDisplayListIterator iter(aBuilder, this);
while (iter.HasNext()) {
nsPaintedDisplayItem* item = iter.GetNextItem()->AsPaintedDisplayItem();
if (!item) {
continue;
}
nsRegion visible(item->GetClippedBounds(aBuilder));
visible.And(visible, item->GetBuildingRect());
item->SetPaintRect(visible.GetBounds());
if (!item->ComputeVisibility(aBuilder, &visible)) {
continue;
}
DisplayItemClip currentClip = item->GetClip();
if (currentClip.HasClip()) {
aCtx->Save();
currentClip.ApplyTo(aCtx, aAppUnitsPerDevPixel);
}
aCtx->NewPath();
item->Paint(aBuilder, aCtx);
if (currentClip.HasClip()) {
aCtx->Restore();
}
}
}
/**
* We paint by executing a layer manager transaction, constructing a
* single layer representing the display list, and then making it the
@ -2485,28 +2454,19 @@ already_AddRefed<LayerManager> nsDisplayList::PaintRoot(
widgetTransaction = true;
}
}
nsIFrame* frame = aBuilder->RootReferenceFrame();
nsPresContext* presContext = frame->PresContext();
PresShell* presShell = presContext->PresShell();
Document* document = presShell->GetDocument();
if (!layerManager) {
if (!aCtx) {
NS_WARNING("Nowhere to paint into");
return nullptr;
}
bool prevIsCompositingCheap = aBuilder->SetIsCompositingCheap(false);
Paint(aBuilder, aCtx, presContext->AppUnitsPerDevPixel());
if (document && document->IsBeingUsedAsImage()) {
frame->ClearInvalidationStateBits();
}
aBuilder->SetIsCompositingCheap(prevIsCompositingCheap);
return nullptr;
layerManager = new BasicLayerManager(BasicLayerManager::BLM_OFFSCREEN);
}
nsIFrame* frame = aBuilder->RootReferenceFrame();
nsPresContext* presContext = frame->PresContext();
PresShell* presShell = presContext->PresShell();
Document* document = presShell->GetDocument();
if (layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
if (doBeginTransaction) {
if (aCtx) {
@ -3681,10 +3641,7 @@ AppendedBackgroundType nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
if ((drawBackgroundColor && color != NS_RGBA(0, 0, 0, 0)) ||
aBuilder->IsForEventDelivery()) {
if (aAutoBuildingDisplayList && !*aAutoBuildingDisplayList) {
nsPoint offset = aBuilder->GetCurrentFrame()->GetOffsetTo(aFrame);
aAutoBuildingDisplayList->emplace(aBuilder, aFrame,
aBuilder->GetVisibleRect() + offset,
aBuilder->GetDirtyRect() + offset);
aAutoBuildingDisplayList->emplace(aBuilder, aFrame);
}
Maybe<DisplayListClipState::AutoSaveRestore> clipState;
nsRect bgColorRect = bgRect;
@ -3764,10 +3721,7 @@ AppendedBackgroundType nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
}
if (aAutoBuildingDisplayList && !*aAutoBuildingDisplayList) {
nsPoint offset = aBuilder->GetCurrentFrame()->GetOffsetTo(aFrame);
aAutoBuildingDisplayList->emplace(aBuilder, aFrame,
aBuilder->GetVisibleRect() + offset,
aBuilder->GetDirtyRect() + offset);
aAutoBuildingDisplayList->emplace(aBuilder, aFrame);
}
if (bg->mImage.mLayers[i].mBlendMode != StyleBlend::Normal) {
@ -4984,12 +4938,6 @@ nsDisplayCaret::nsDisplayCaret(nsDisplayListBuilder* aBuilder,
mCaret(aBuilder->GetCaret()),
mBounds(aBuilder->GetCaretRect() + ToReferenceFrame()) {
MOZ_COUNT_CTOR(nsDisplayCaret);
// The presence of a caret doesn't change the overflow rect
// of the owning frame, so the normal building rect might not
// include the caret at all. We use MarkFrameForDisplay to ensure
// we build this item, and here we override the building rect
// to cover the pixels we're going to draw.
SetBuildingRect(mBounds);
}
#ifdef NS_BUILD_REFCNT_LOGGING
@ -5581,8 +5529,7 @@ void nsDisplayWrapList::MergeDisplayListFromItem(
// Create a new nsDisplayWrapList using a copy-constructor. This is done
// to preserve the information about bounds.
nsDisplayWrapList* wrapper =
new (aBuilder) nsDisplayWrapper(aBuilder, *wrappedItem);
wrapper->SetType(nsDisplayWrapper::ItemType());
MakeClone<nsDisplayWrapList>(aBuilder, wrappedItem);
MOZ_ASSERT(wrapper);
// Set the display list pointer of the new wrapper item to the display list
@ -5623,8 +5570,9 @@ Maybe<nscolor> nsDisplayWrapList::IsUniform(
return Nothing();
}
void nsDisplayWrapper::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
NS_ERROR("nsDisplayWrapper should have been flattened away for painting");
void nsDisplayWrapList::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
NS_ERROR("nsDisplayWrapList should have been flattened away for painting");
}
/**
@ -5701,7 +5649,7 @@ bool nsDisplayWrapList::CreateWebRenderCommands(
static nsresult WrapDisplayList(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsDisplayList* aList,
nsDisplayItemWrapper* aWrapper) {
nsDisplayWrapper* aWrapper) {
if (!aList->GetTop()) {
return NS_OK;
}
@ -5716,7 +5664,7 @@ static nsresult WrapDisplayList(nsDisplayListBuilder* aBuilder,
static nsresult WrapEachDisplayItem(nsDisplayListBuilder* aBuilder,
nsDisplayList* aList,
nsDisplayItemWrapper* aWrapper) {
nsDisplayWrapper* aWrapper) {
nsDisplayList newList;
nsDisplayItem* item;
while ((item = aList->RemoveBottom())) {
@ -5731,10 +5679,10 @@ static nsresult WrapEachDisplayItem(nsDisplayListBuilder* aBuilder,
return NS_OK;
}
nsresult nsDisplayItemWrapper::WrapLists(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
const nsDisplayListSet& aIn,
const nsDisplayListSet& aOut) {
nsresult nsDisplayWrapper::WrapLists(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
const nsDisplayListSet& aIn,
const nsDisplayListSet& aOut) {
nsresult rv = WrapListsInPlace(aBuilder, aFrame, aIn);
NS_ENSURE_SUCCESS(rv, rv);
@ -5750,9 +5698,9 @@ nsresult nsDisplayItemWrapper::WrapLists(nsDisplayListBuilder* aBuilder,
return NS_OK;
}
nsresult nsDisplayItemWrapper::WrapListsInPlace(
nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
const nsDisplayListSet& aLists) {
nsresult nsDisplayWrapper::WrapListsInPlace(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
const nsDisplayListSet& aLists) {
nsresult rv;
if (WrapBorderBackground()) {
// Our border-backgrounds are in-flow
@ -5832,20 +5780,6 @@ already_AddRefed<Layer> nsDisplayOpacity::BuildLayer(
return container.forget();
}
void nsDisplayOpacity::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
if (GetOpacity() == 0.0f) {
return;
}
// TODO: Compute a bounds rect to pass to PushLayer for a smaller
// allocation.
aCtx->GetDrawTarget()->PushLayer(false, GetOpacity(), nullptr,
mozilla::gfx::Matrix());
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
aCtx->GetDrawTarget()->PopLayer();
}
/**
* This doesn't take into account layer scaling --- the layer may be
* rendered at a higher (or lower) resolution, affecting the retained layer
@ -6048,8 +5982,10 @@ bool nsDisplayOpacity::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) {
return true;
}
// Return true if we successfully applied opacity to child items.
return ApplyToChildren(aBuilder);
// Return true if we successfully applied opacity to child items, or if
// WebRender is not in use. In the latter case, the opacity gets flattened and
// applied during layer building.
return ApplyToChildren(aBuilder) || usingLayers;
}
nsDisplayItem::LayerState nsDisplayOpacity::GetLayerState(
@ -6206,16 +6142,6 @@ already_AddRefed<Layer> nsDisplayBlendMode::BuildLayer(
return container.forget();
}
void nsDisplayBlendMode::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
aCtx->GetDrawTarget()->PushLayerWithBlend(false, 1.0, nullptr,
mozilla::gfx::Matrix(), IntRect(),
false, BlendMode());
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
aCtx->GetDrawTarget()->PopLayer();
}
mozilla::gfx::CompositionOp nsDisplayBlendMode::BlendMode() {
return nsCSSRendering::GetGFXBlendMode(mBlendMode);
}
@ -6311,14 +6237,6 @@ LayerState nsDisplayBlendContainer::GetLayerState(
GetActiveScrolledRoot());
}
void nsDisplayBlendContainer::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
aCtx->GetDrawTarget()->PushLayer(false, 1.0, nullptr, mozilla::gfx::Matrix());
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
aCtx->GetDrawTarget()->PopLayer();
}
bool nsDisplayBlendContainer::CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
@ -7538,7 +7456,14 @@ void nsDisplayTransform::Init(nsDisplayListBuilder* aBuilder,
}
bool nsDisplayTransform::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) {
return false;
if (gfxVars::UseWebRender() ||
!StaticPrefs::layout_display_list_flatten_transform()) {
return false;
}
MOZ_ASSERT(!mShouldFlatten);
mShouldFlatten = GetTransform().Is2D();
return mShouldFlatten;
}
/* Returns the delta specified by the transform-origin property.
@ -8255,163 +8180,6 @@ already_AddRefed<Layer> nsDisplayTransform::BuildLayer(
return container.forget();
}
void nsDisplayTransform::Collect3DTransformLeaves(
nsTArray<nsDisplayTransform*>& aLeaves) {
if (!IsParticipating3DContext() || IsLeafOf3DContext()) {
aLeaves.AppendElement(this);
return;
}
for (nsDisplayItem* item : mChildren) {
if (item->GetType() == DisplayItemType::TYPE_PERSPECTIVE) {
auto* perspective = static_cast<nsDisplayPerspective*>(item);
if (!perspective->GetChildren()->GetTop()) {
continue;
}
item = perspective->GetChildren()->GetTop();
}
MOZ_RELEASE_ASSERT(item->GetType() == DisplayItemType::TYPE_TRANSFORM);
static_cast<nsDisplayTransform*>(item)->Collect3DTransformLeaves(aLeaves);
}
}
static RefPtr<gfx::Path> BuildPathFromPolygon(const RefPtr<DrawTarget>& aDT,
const gfx::Polygon& aPolygon) {
MOZ_ASSERT(!aPolygon.IsEmpty());
RefPtr<PathBuilder> pathBuilder = aDT->CreatePathBuilder();
const nsTArray<Point4D>& points = aPolygon.GetPoints();
pathBuilder->MoveTo(points[0].As2DPoint());
for (size_t i = 1; i < points.Length(); ++i) {
pathBuilder->LineTo(points[i].As2DPoint());
}
pathBuilder->Close();
return pathBuilder->Finish();
}
void nsDisplayTransform::CollectSorted3DTransformLeaves(
nsDisplayListBuilder* aBuilder, nsTArray<TransformPolygon>& aLeaves) {
std::list<TransformPolygon> inputLayers;
nsTArray<nsDisplayTransform*> leaves;
Collect3DTransformLeaves(leaves);
for (nsDisplayTransform* item : leaves) {
auto bounds = LayoutDeviceRect::FromAppUnits(
item->mChildBounds, item->mFrame->PresContext()->AppUnitsPerDevPixel());
Matrix4x4 transform = item->GetAccumulatedPreserved3DTransform(aBuilder);
if (!IsFrameVisible(item->mFrame, transform)) {
continue;
}
gfx::Polygon polygon =
gfx::Polygon::FromRect(gfx::Rect(bounds.ToUnknownRect()));
polygon.TransformToScreenSpace(transform);
if (polygon.GetPoints().Length() >= 3) {
inputLayers.push_back(TransformPolygon(item, std::move(polygon)));
}
}
if (inputLayers.empty()) {
return;
}
BSPTree<nsDisplayTransform> tree(inputLayers);
nsTArray<TransformPolygon> orderedLayers(tree.GetDrawOrder());
for (TransformPolygon& polygon : orderedLayers) {
Matrix4x4 inverse =
polygon.data->GetAccumulatedPreserved3DTransform(aBuilder).Inverse();
MOZ_ASSERT(polygon.geometry);
polygon.geometry->TransformToLayerSpace(inverse);
}
aLeaves = std::move(orderedLayers);
}
void nsDisplayTransform::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
Paint(aBuilder, aCtx, Nothing());
}
void nsDisplayTransform::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
const Maybe<gfx::Polygon>& aPolygon) {
if (IsParticipating3DContext() && !IsLeafOf3DContext()) {
MOZ_ASSERT(!aPolygon);
nsTArray<TransformPolygon> leaves;
CollectSorted3DTransformLeaves(aBuilder, leaves);
for (TransformPolygon& item : leaves) {
item.data->Paint(aBuilder, aCtx, item.geometry);
}
return;
}
gfxContextMatrixAutoSaveRestore saveMatrix(aCtx);
Matrix4x4 trans = GetAccumulatedPreserved3DTransform(aBuilder);
if (!IsFrameVisible(mFrame, trans)) {
return;
}
Matrix trans2d;
if (trans.CanDraw2D(&trans2d)) {
aCtx->Multiply(ThebesMatrix(trans2d));
if (aPolygon) {
RefPtr<gfx::Path> path =
BuildPathFromPolygon(aCtx->GetDrawTarget(), *aPolygon);
aCtx->GetDrawTarget()->PushClip(path);
}
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
if (aPolygon) {
aCtx->GetDrawTarget()->PopClip();
}
return;
}
// TODO: Implement 3d transform handling, including plane splitting and
// sorting. See BasicCompositor.
auto pixelBounds = LayoutDeviceRect::FromAppUnitsToOutside(
mChildBounds, mFrame->PresContext()->AppUnitsPerDevPixel());
RefPtr<DrawTarget> untransformedDT =
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
IntSize(pixelBounds.Width(), pixelBounds.Height()),
SurfaceFormat::B8G8R8A8, true);
if (!untransformedDT || !untransformedDT->IsValid()) {
return;
}
untransformedDT->SetTransform(
Matrix::Translation(-Point(pixelBounds.X(), pixelBounds.Y())));
RefPtr<gfxContext> groupTarget =
gfxContext::CreatePreservingTransformOrNull(untransformedDT);
if (aPolygon) {
RefPtr<gfx::Path> path =
BuildPathFromPolygon(aCtx->GetDrawTarget(), *aPolygon);
aCtx->GetDrawTarget()->PushClip(path);
}
GetChildren()->Paint(aBuilder, groupTarget,
mFrame->PresContext()->AppUnitsPerDevPixel());
if (aPolygon) {
aCtx->GetDrawTarget()->PopClip();
}
RefPtr<SourceSurface> untransformedSurf = untransformedDT->Snapshot();
trans.PreTranslate(pixelBounds.X(), pixelBounds.Y(), 0);
aCtx->GetDrawTarget()->Draw3DTransformedSurface(untransformedSurf, trans);
}
bool nsDisplayTransform::MayBeAnimated(nsDisplayListBuilder* aBuilder,
bool aEnforceMinimumSize) const {
// If EffectCompositor::HasAnimationsForCompositor() is true then we can
@ -8954,14 +8722,6 @@ already_AddRefed<Layer> nsDisplayPerspective::BuildLayer(
return container.forget();
}
void nsDisplayPerspective::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
// Just directly recurse into children, since we'll include the persepctive
// value in any nsDisplayTransform children.
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
}
LayerState nsDisplayPerspective::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) {
@ -9721,17 +9481,6 @@ void nsDisplayMasksAndClipPaths::PaintWithContentsPaintCallback(
nsDisplayMasksAndClipPathsGeometry::UpdateDrawResult(this, imgParams.result);
}
void nsDisplayMasksAndClipPaths::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
if (!IsValidMask()) {
return;
}
PaintWithContentsPaintCallback(aBuilder, aCtx, [&] {
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
});
}
static Maybe<wr::WrClipId> CreateSimpleClipRegion(
const nsDisplayMasksAndClipPaths& aDisplayItem,
wr::DisplayListBuilder& aBuilder) {
@ -10001,14 +9750,6 @@ already_AddRefed<Layer> nsDisplayBackdropRootContainer::BuildLayer(
return container.forget();
}
void nsDisplayBackdropRootContainer::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
aCtx->GetDrawTarget()->PushLayer(false, 1.0, nullptr, mozilla::gfx::Matrix());
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
aCtx->GetDrawTarget()->PopLayer();
}
LayerState nsDisplayBackdropRootContainer::GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) {
@ -10085,13 +9826,6 @@ bool nsDisplayBackdropFilters::CreateWebRenderCommands(
return true;
}
void nsDisplayBackdropFilters::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
// TODO: Implement backdrop filters
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
}
/* static */
nsDisplayFilters::nsDisplayFilters(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsDisplayList* aList)
@ -10138,13 +9872,6 @@ LayerState nsDisplayFilters::GetLayerState(
return LayerState::LAYER_SVG_EFFECTS;
}
void nsDisplayFilters::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
PaintWithContentsPaintCallback(aBuilder, aCtx, [&](gfxContext* aContext) {
GetChildren()->Paint(aBuilder, aContext,
mFrame->PresContext()->AppUnitsPerDevPixel());
});
}
bool nsDisplayFilters::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion) {
nsPoint offset = ToReferenceFrame();
@ -10179,37 +9906,12 @@ void nsDisplayFilters::ComputeInvalidationRegion(
void nsDisplayFilters::PaintAsLayer(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx, LayerManager* aManager) {
PaintWithContentsPaintCallback(aBuilder, aCtx, [&](gfxContext* aContext) {
BasicLayerManager* basic = aManager->AsBasicLayerManager();
RefPtr<gfxContext> oldCtx = basic->GetTarget();
basic->SetTarget(aContext);
aManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer, aBuilder);
basic->SetTarget(oldCtx);
});
}
void nsDisplayFilters::PaintWithContentsPaintCallback(
nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
const std::function<void(gfxContext* aContext)>& aPaintChildren) {
imgDrawingParams imgParams(aBuilder->GetImageDecodeFlags());
nsRect borderArea = nsRect(ToReferenceFrame(), mFrame->GetSize());
SVGIntegrationUtils::PaintFramesParams params(*aCtx, mFrame, GetPaintRect(),
borderArea, aBuilder, nullptr,
borderArea, aBuilder, aManager,
mHandleOpacity, imgParams);
gfxPoint userSpaceToFrameSpaceOffset =
SVGIntegrationUtils::GetOffsetToUserSpaceInDevPx(mFrame, params);
SVGIntegrationUtils::PaintFilter(
params,
[&](gfxContext& aContext, nsIFrame* aTarget, const gfxMatrix& aTransform,
const nsIntRect* aDirtyRect, image::imgDrawingParams& aImgParams) {
gfxContextMatrixAutoSaveRestore autoSR(&aContext);
aContext.SetMatrixDouble(aContext.CurrentMatrixDouble().PreTranslate(
-userSpaceToFrameSpaceOffset));
aPaintChildren(&aContext);
});
SVGIntegrationUtils::PaintFilter(params);
nsDisplayFiltersGeometry::UpdateDrawResult(this, imgParams.result);
}

Просмотреть файл

@ -46,7 +46,6 @@
#include "mozilla/gfx/UserData.h"
#include "mozilla/layers/LayerAttributes.h"
#include "mozilla/layers/ScrollableLayerGuid.h"
#include "mozilla/layers/BSPTree.h"
#include "nsCSSRenderingBorders.h"
#include "nsPresArena.h"
#include "nsAutoLayoutPhase.h"
@ -1105,6 +1104,11 @@ class nsDisplayListBuilder {
*/
class AutoBuildingDisplayList {
public:
AutoBuildingDisplayList(nsDisplayListBuilder* aBuilder, nsIFrame* aForChild)
: AutoBuildingDisplayList(
aBuilder, aForChild, aBuilder->GetVisibleRect(),
aBuilder->GetDirtyRect(), aForChild->IsTransformed()) {}
AutoBuildingDisplayList(nsDisplayListBuilder* aBuilder, nsIFrame* aForChild,
const nsRect& aVisibleRect,
const nsRect& aDirtyRect)
@ -2238,7 +2242,7 @@ class nsDisplayItemBase : public nsDisplayItemLink {
/**
* Create a clone of this item.
*/
virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const {
virtual nsDisplayItem* Clone(nsDisplayListBuilder* aBuilder) const {
return nullptr;
}
@ -3257,7 +3261,10 @@ class nsPaintedDisplayItem : public nsDisplayItem {
/**
* Paint this item to some rendering context.
*/
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) = 0;
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
// TODO(miko): Make this a pure virtual function to force implementation.
MOZ_ASSERT_UNREACHABLE("Paint() is not implemented!");
}
/**
* External storage used by |DisplayItemCache| to avoid hashmap lookups.
@ -3657,10 +3664,6 @@ class nsDisplayList {
LayerManager* aLayerManager,
uint32_t aFlags,
bool aIsWidgetTransaction);
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
int32_t aAppUnitsPerDevPixel);
/**
* Get the bounds. Takes the union of the bounds of all children.
* The result is not cached.
@ -5294,6 +5297,8 @@ class nsDisplayWrapList : public nsPaintedDisplayItem {
~nsDisplayWrapList() override;
NS_DISPLAY_DECL_NAME("WrapList", TYPE_WRAP_LIST)
const nsDisplayWrapList* AsDisplayWrapList() const final { return this; }
nsDisplayWrapList* AsDisplayWrapList() final { return this; }
@ -5346,6 +5351,7 @@ class nsDisplayWrapList : public nsPaintedDisplayItem {
bool* aSnap) const override;
mozilla::Maybe<nscolor> IsUniform(
nsDisplayListBuilder* aBuilder) const override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion) override;
@ -5469,30 +5475,10 @@ class nsDisplayWrapList : public nsPaintedDisplayItem {
int32_t mOverrideZIndex;
bool mHasZIndexOverride;
bool mClearingClipChain = false;
};
class nsDisplayWrapper : public nsDisplayWrapList {
public:
NS_DISPLAY_DECL_NAME("WrapList", TYPE_WRAP_LIST)
nsDisplayWrapper(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList,
const ActiveScrolledRoot* aActiveScrolledRoot,
bool aClearClipChain = false)
: nsDisplayWrapList(aBuilder, aFrame, aList, aActiveScrolledRoot,
aClearClipChain) {}
nsDisplayWrapper(const nsDisplayWrapper& aOther) = delete;
nsDisplayWrapper(nsDisplayListBuilder* aBuilder,
const nsDisplayWrapList& aOther)
: nsDisplayWrapList(aBuilder, aOther) {}
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
private:
NS_DISPLAY_ALLOW_CLONING()
friend class nsDisplayListBuilder;
friend class nsDisplayWrapList;
};
/**
@ -5502,7 +5488,7 @@ class nsDisplayWrapper : public nsDisplayWrapList {
* and Floats(). This is done to support special wrapping processing for frames
* that may not be in-flow descendants of the current frame.
*/
class nsDisplayItemWrapper {
class nsDisplayWrapper {
public:
// This is never instantiated directly (it has pure virtual methods), so no
// need to count constructors and destructors.
@ -5519,7 +5505,7 @@ class nsDisplayItemWrapper {
const nsDisplayListSet& aLists);
protected:
nsDisplayItemWrapper() = default;
nsDisplayWrapper() = default;
};
/**
@ -5573,7 +5559,6 @@ class nsDisplayOpacity : public nsDisplayWrapList {
LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion) override;
@ -5703,7 +5688,6 @@ class nsDisplayBlendMode : public nsDisplayWrapList {
const StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion) override;
@ -5792,7 +5776,6 @@ class nsDisplayBlendContainer : public nsDisplayWrapList {
LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
@ -5956,10 +5939,6 @@ class nsDisplayOwnLayer : public nsDisplayWrapList {
LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override {
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
}
bool CanMerge(const nsDisplayItem* aItem) const override {
// Don't allow merging, each sublist must have its own layer
@ -6082,10 +6061,6 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
const ContainerLayerParameters& aParameters) override {
return mozilla::LayerState::LAYER_ACTIVE;
}
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override {
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
}
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
@ -6162,10 +6137,6 @@ class nsDisplayFixedPosition : public nsDisplayOwnLayer {
const ContainerLayerParameters& aParameters) override {
return mozilla::LayerState::LAYER_ACTIVE_FORCE;
}
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override {
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
}
bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder) const override {
return mIsFixedBackground;
@ -6265,9 +6236,6 @@ class nsDisplayScrollInfoLayer : public nsDisplayWrapList {
LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override {
return;
}
bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override {
return false;
@ -6492,7 +6460,6 @@ class nsDisplayMasksAndClipPaths : public nsDisplayEffectsBase {
LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion) override;
@ -6569,7 +6536,6 @@ class nsDisplayBackdropRootContainer : public nsDisplayWrapList {
LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
@ -6602,7 +6568,6 @@ class nsDisplayBackdropFilters : public nsDisplayWrapList {
const StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
static bool CanCreateWebRenderCommands(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame);
@ -6660,7 +6625,6 @@ class nsDisplayFilters : public nsDisplayEffectsBase {
LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const override {
*aSnap = false;
@ -6685,10 +6649,6 @@ class nsDisplayFilters : public nsDisplayEffectsBase {
void PaintAsLayer(nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
LayerManager* aManager);
void PaintWithContentsPaintCallback(
nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
const std::function<void(gfxContext* aContext)>& aPaintChildren);
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
@ -6799,9 +6759,6 @@ class nsDisplayTransform : public nsPaintedDisplayItem {
already_AddRefed<Layer> BuildLayer(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
const mozilla::Maybe<mozilla::gfx::Polygon>& aPolygon);
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
@ -7073,11 +7030,6 @@ class nsDisplayTransform : public nsPaintedDisplayItem {
TransformReferenceBox& aRefBox, const nsPoint& aOrigin,
float aAppUnitsPerPixel, uint32_t aFlags);
void Collect3DTransformLeaves(nsTArray<nsDisplayTransform*>& aLeaves);
using TransformPolygon = mozilla::layers::BSPPolygon<nsDisplayTransform>;
void CollectSorted3DTransformLeaves(nsDisplayListBuilder* aBuilder,
nsTArray<TransformPolygon>& aLeaves);
mutable mozilla::Maybe<Matrix4x4Flagged> mTransform;
mutable mozilla::Maybe<Matrix4x4Flagged> mInverseTransform;
// Accumulated transform of ancestors on the preserves-3d chain.
@ -7160,7 +7112,6 @@ class nsDisplayPerspective : public nsPaintedDisplayItem {
already_AddRefed<Layer> BuildLayer(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
RetainedDisplayList* GetSameCoordinateSystemChildren() const override {
return &mList;
@ -7330,10 +7281,6 @@ class nsDisplaySVGWrapper : public nsDisplayWrapList {
LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override {
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
}
bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override;
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
@ -7363,10 +7310,6 @@ class nsDisplayForeignObject : public nsDisplayWrapList {
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override {
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
}
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,

Просмотреть файл

@ -89,5 +89,5 @@ fuzzy(0-125,0-5903) == border-image-element.html border-image-element-ref.html
== svg-as-border-image-1c.html svg-as-border-image-1-ref.html
== svg-as-border-image-2.html svg-as-border-image-2-ref.html
== svg-as-border-image-3.html svg-as-border-image-3-ref.html
fuzzy-if(useDrawSnapshot,16-16,80-80) == svg-as-border-image-4a.html svg-as-border-image-4-ref.html
fails-if(useDrawSnapshot) == svg-as-border-image-4a.html svg-as-border-image-4-ref.html
== svg-as-border-image-4b.html svg-as-border-image-4-ref.html

Просмотреть файл

@ -43,14 +43,14 @@ fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-1,0-1) fuzzy-if(skiaConten
# Tests for clipping the contents of replaced elements and overflow!=visible
!= clipping-4-ref.html clipping-4-notref.html
fuzzy-if(true,0-1,0-20) fuzzy-if(d2d,0-72,0-196) fuzzy-if(cocoaWidget,0-1,0-180) fuzzy-if(Android,0-140,0-237) fuzzy-if(webrender,0-8,0-20) fuzzy-if(useDrawSnapshot,1-1,172-172) == clipping-4-canvas.html clipping-4-ref.html # bug 732535
fuzzy-if(true,0-1,0-20) fuzzy-if(d2d,0-72,0-196) fuzzy-if(cocoaWidget,0-1,0-180) fuzzy-if(Android,0-140,0-237) fuzzy-if(webrender,0-8,0-20) == clipping-4-canvas.html clipping-4-ref.html # bug 732535
fuzzy-if(Android,0-5,0-54) fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-37,0-157) fuzzy-if(skiaContent,0-1,0-172) == clipping-4-image.html clipping-4-ref.html
fuzzy-if(skiaContent,0-1,0-77) == clipping-4-overflow-hidden.html clipping-4-ref.html
== clipping-5-canvas.html clipping-5-refc.html
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-1,0-5) == clipping-5-image.html clipping-5-refi.html
fuzzy-if(skiaContent,0-1,0-77) == clipping-5-overflow-hidden.html clipping-5-ref.html
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-1,0-4) fuzzy-if(Android,0-5,0-21) fuzzy-if(skiaContent,0-1,0-97) == clipping-5-refi.html clipping-5-ref.html
fuzzy-if(true,0-1,0-7) fuzzy-if(d2d,0-55,0-95) fuzzy-if(cocoaWidget,0-1,0-99) fuzzy-if(Android,0-99,0-115) fuzzy-if(skiaContent,0-1,0-77) fuzzy-if(useDrawSnapshot,1-1,97-97) == clipping-5-refc.html clipping-5-ref.html # bug 732535
fuzzy-if(true,0-1,0-7) fuzzy-if(d2d,0-55,0-95) fuzzy-if(cocoaWidget,0-1,0-99) fuzzy-if(Android,0-99,0-115) fuzzy-if(skiaContent,0-1,0-77) == clipping-5-refc.html clipping-5-ref.html # bug 732535
fuzzy-if(Android,0-8,0-469) fuzzy-if(skiaContent,0-21,0-76) fuzzy-if(winWidget,0-144,0-335) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == clipping-6.html clipping-6-ref.html # PaintedLayer and MaskLayer with transforms that aren't identical, bug 1392106
fuzzy-if(true,0-2,0-29) fuzzy-if(d2d,0-46,0-71) fuzzy-if(Android,0-255,0-586) fuzzy-if(skiaContent,0-28,0-97) == clipping-7.html clipping-7-ref.html # ColorLayer and MaskLayer with transforms that aren't identical. Reference image rendered without using layers (which causes fuzzy failures).
fuzzy-if(/^Windows\x20NT\x206\.2/.test(http.oscpu),0-1,0-5) == clipping-and-zindex-1.html clipping-and-zindex-1-ref.html
@ -58,7 +58,7 @@ fuzzy-if(cocoaWidget,0-1,0-4) fuzzy-if(d2d,0-59,0-342) fuzzy-if(d3d11&&advancedL
== intersecting-clipping-1-image.html intersecting-clipping-1-refi.html
== intersecting-clipping-1-overflow-hidden.html intersecting-clipping-1-ref.html
fuzzy-if(Android,0-5,0-105) fuzzy-if(d2d,0-1,0-20) fuzzy-if(skiaContent,0-1,0-300) == intersecting-clipping-1-refi.html intersecting-clipping-1-ref.html
fuzzy-if(true,0-1,0-33) fuzzy-if(d2d,0-59,0-350) fuzzy-if(cocoaWidget,0-1,0-332) fuzzy-if(Android,0-124,0-440) fuzzy-if(skiaContent,0-1,0-135) fuzzy-if(d3d11&&advancedLayers,0-81,0-353) skip-if(winWidget) fuzzy-if(useDrawSnapshot,1-1,299-299) == intersecting-clipping-1-refc.html intersecting-clipping-1-ref.html # bug 732535 # Disable on Windows bug 1451808
fuzzy-if(true,0-1,0-33) fuzzy-if(d2d,0-59,0-350) fuzzy-if(cocoaWidget,0-1,0-332) fuzzy-if(Android,0-124,0-440) fuzzy-if(skiaContent,0-1,0-135) fuzzy-if(d3d11&&advancedLayers,0-81,0-353) skip-if(winWidget) == intersecting-clipping-1-refc.html intersecting-clipping-1-ref.html # bug 732535 # Disable on Windows bug 1451808
== clipping-preserve-3d.html clipping-preserve-3d-ref.html
@ -80,7 +80,7 @@ fails-if(Android) == scrollbar-clamping-2.html scrollbar-clamping-2-ref.html
fuzzy-if(true,0-1,0-1) == corner-joins-1.xhtml corner-joins-1-ref.xhtml
fuzzy(0-255,0-20) random-if(winWidget) fuzzy-if(skiaContent,0-255,0-610) == corner-joins-2.xhtml corner-joins-2-ref.xhtml
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu)||/^Windows\x20NT\x206\.2/.test(http.oscpu),0-1,0-20) fuzzy-if(d2d,0-98,0-157) fuzzy-if(Android,0-166,0-400) fuzzy-if(skiaContent,0-59,0-146) fuzzy-if(useDrawSnapshot,42-42,147-147) == scroll-1.html scroll-1-ref.html # see bug 732535 #Bug 959166
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu)||/^Windows\x20NT\x206\.2/.test(http.oscpu),0-1,0-20) fuzzy-if(d2d,0-98,0-157) fuzzy-if(Android,0-166,0-400) fuzzy-if(skiaContent,0-59,0-146) == scroll-1.html scroll-1-ref.html # see bug 732535 #Bug 959166
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-35,0-194) == transforms-1.html transforms-1-ref.html # bug 1507152

Просмотреть файл

@ -1675,7 +1675,7 @@ fuzzy-if(skiaContent,0-1,0-3) needs-focus == 712130-2.html 712130-2-ref.html
== 714519-1-q.html 714519-1-ref.html
== 714519-2-as.html 714519-2-ref.html
== 714519-2-q.html 714519-2-ref.html
fuzzy-if(true,0-1,0-21) fuzzy-if(d2d,0-77,0-173) fuzzy-if(cocoaWidget,0-1,0-170) fuzzy-if(useDrawSnapshot,1-1,163-163) == 718521.html 718521-ref.html # bug 773482
fuzzy-if(true,0-1,0-21) fuzzy-if(d2d,0-77,0-173) fuzzy-if(cocoaWidget,0-1,0-170) == 718521.html 718521-ref.html # bug 773482
== 720987.html 720987-ref.html
== 722888-1.html 722888-1-ref.html
fuzzy(0-2,0-40000) == 722923-1.html 722923-1-ref.html
@ -1766,7 +1766,7 @@ test-pref(font.minimum-size.x-western,32) fuzzy-if(Android,0-45,0-324) == 935056
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 936670-1.svg 936670-1-ref.svg # Bug 1392106
== 941940-1.html 941940-1-ref.html
fails == 942017.html 942017-ref.html # bug 942017
fuzzy-if(Android,0-1,0-1) fuzzy-if(skiaContent,0-2,0-160000) fuzzy-if(d2d&&!webrender,1-1,215-215) == 942672-1.html 942672-1-ref.html
fuzzy-if(Android,0-1,0-1) fuzzy-if(skiaContent,0-1,0-160000) == 942672-1.html 942672-1-ref.html
== 953334-win32-clipping.html 953334-win32-clipping-ref.html
fuzzy-if(skiaContent,0-1,0-5) == 956513-1.svg 956513-1-ref.svg
== 944291-1.html 944291-1-ref.html
@ -1825,9 +1825,9 @@ fails-if(webrender) == 1059498-3.html 1059498-1-ref.html # WebRender: see bug 14
pref(layout.css.caption-side-non-standard.enabled,true) == 1062963-floatmanager-reflow.html 1062963-floatmanager-reflow-ref.html
== 1066554-1.html 1066554-1-ref.html
== 1069716-1.html 1069716-1-ref.html
skip-if(geckoview&&!webrender) == 1078262-1.html about:blank # bug 1656792
skip-if(geckoview&&!webrender) fails-if(useDrawSnapshot) == 1078262-1.html about:blank # bug 1656792
test-pref(layout.testing.overlay-scrollbars.always-visible,false) == 1081072-1.html 1081072-1-ref.html
fuzzy-if(webrender,63-64,142-845) fuzzy-if(useDrawSnapshot,33-33,218-218) == 1081185-1.html 1081185-1-ref.html
fuzzy-if(webrender,63-64,142-845) == 1081185-1.html 1081185-1-ref.html
== 1097437-1.html 1097437-1-ref.html
== 1103258-1.html 1103258-1-ref.html # assertion crash test with layers culling test
== 1105137-1.html 1105137-1-ref.html
@ -1908,7 +1908,7 @@ fuzzy-if(webrender,0-128,0-22) == 1151145-1.html 1151145-1-ref.html # bug 164652
fuzzy-if(webrender,0-128,0-22) == 1155828-1.html 1155828-1-ref.html # bug 1646527 for WR fuzz
fuzzy-if(skiaContent,0-7,0-84) == 1156129-1.html 1156129-1-ref.html
pref(dom.use_xbl_scopes_for_remote_xul,true) HTTP(..) == 1157127-1.html 1157127-1-ref.html
fuzzy-if(Android,0-6,0-6) fuzzy-if(appleSilicon,1-1,4-4) fuzzy-if(useDrawSnapshot,1-1,16-16) == 1169331-1.html 1169331-1-ref.html
fuzzy-if(Android,0-6,0-6) fuzzy-if(appleSilicon,1-1,4-4) == 1169331-1.html 1169331-1-ref.html
fuzzy(0-3,0-110) random-if(winWidget||Android||gtkWidget) fails-if(!nativeThemePref) == 1174332-1.html 1174332-1-ref.html # bug 1312658, expected to fail w/ non-native theme because of bug 1699937
== 1179078-1.html 1179078-1-ref.html
== 1179288-1.html 1179288-1-ref.html
@ -2047,7 +2047,7 @@ fails-if(useDrawSnapshot) == 1456111-1.html about:blank
# the pref is enabled by default; we just need to be able to pref it off here.
# For now, we use the "backdrop-filter" CSS property (and its pref).
test-pref(layout.css.backdrop-filter.enabled,false) == 1466008.html 1466008-ref.html
fuzzy(0-2,0-625) == 1466638-1.html 1466638-1-ref.html
fuzzy(0-1,0-625) == 1466638-1.html 1466638-1-ref.html
== bug1472465-1.html bug1472465-1-ref.html
== 1475971-1.html 1475971-1-ref.html
== chrome://reftest/content/bugs/1483649-1.xhtml chrome://reftest/content/bugs/1483649-1-ref.xhtml

Просмотреть файл

@ -25,9 +25,9 @@ fuzzy-if(asyncPan,0-2,0-140) fuzzy-if(skiaContent,0-24,0-106) fuzzy-if(webrender
fails-if(usesRepeatResampling&&!(webrender&&winWidget)) == element-paint-subimage-sampling-restriction.html about:blank
== element-paint-clippath.html element-paint-clippath-ref.html
fuzzy-if(!useDrawSnapshot,1-1,128-128) fuzzy-if(d2d,47-47,652-652) fuzzy-if(webrender,36-39,704-738) == element-paint-sharpness-01a.html element-paint-sharpness-01b.html
fuzzy-if(webrender,36-39,704-738) == element-paint-sharpness-01a.html element-paint-sharpness-01b.html
fuzzy-if(skiaContent,0-1,0-326) fails-if(useDrawSnapshot) == element-paint-sharpness-01b.html element-paint-sharpness-01c.html
fuzzy-if(!useDrawSnapshot,1-1,128-128) fuzzy-if(d2d,47-47,652-652) fuzzy-if(webrender,36-39,704-738) == element-paint-sharpness-01c.html element-paint-sharpness-01d.html
fuzzy-if(webrender,36-39,704-738) == element-paint-sharpness-01c.html element-paint-sharpness-01d.html
== element-paint-sharpness-02a.html element-paint-sharpness-02b.html
fails-if(useDrawSnapshot) == element-paint-sharpness-02b.html element-paint-sharpness-02c.html
== element-paint-paintserversize-rounding-01.html element-paint-paintserversize-rounding-01-ref.html

Просмотреть файл

@ -106,4 +106,4 @@ skip-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu)) != fractional-transform-2.ht
pref(image.downscale-during-decode.enabled,true) == jetstream-scroll.html jetstream-scroll-ref.html
fuzzy-if(webrender,0-1,0-1) == svg-paint-rect-changes.html svg-paint-rect-changes-ref.html
fuzzy-if(skiaContent&&!webrender&&!useDrawSnapshot,1-1,64-64) fuzzy-if(skiaContent&&!webrender&&Android,10-10,108-108) == border-radius-1.html border-radius-1-ref.html
fuzzy-if(skiaContent&&!webrender,1-1,64-64) fuzzy-if(skiaContent&&!webrender&&Android,10-10,108-108) == border-radius-1.html border-radius-1-ref.html

Просмотреть файл

@ -24,7 +24,7 @@ skip-if(!asyncPan) != pull-background-displayport-5.html about:blank
skip-if(!asyncPan) != pull-background-displayport-6.html about:blank # fails with non-overlay scrollbars and event regions due to bug 1148515
fuzzy(0-2,0-30150) == opacity-blending.html opacity-blending-ref.html
fuzzy(0-16,0-5) == mask-layer-transform.html mask-layer-transform-ref.html
fuzzy(0-16,0-5) fails-if(useDrawSnapshot) == mask-layer-transform.html mask-layer-transform-ref.html
fuzzy-if(gtkWidget,0-1,0-17) fuzzy-if(Android,0-3,0-4) == forced-bg-color-outside-visible-region.html forced-bg-color-outside-visible-region-ref.html
!= layerize-over-fixed-bg-1.html about:blank
skip-if(!asyncPan) != fixed-pos-scrolled-clip-layerize.html about:blank

Просмотреть файл

@ -67,7 +67,7 @@ skip-if(gtkWidget) random-if(d2d) == chrome://reftest/content/native-theme/resiz
skip-if(!winWidget) == scroll-thumb-minimum-size-notheme.html scroll-thumb-minimum-size-notheme-ref.html
# skip-if(!winWidget) == scroll-thumb-minimum-size-theme.html scroll-thumb-minimum-size-theme-ref.html # Bug 512206
fuzzy-if(useDrawSnapshot,1-1,3-3) == border-radius.html border-radius-ref.html
== border-radius.html border-radius-ref.html
== checkbox-dynamic-1.html checkbox-dynamic-1-ref.html

Просмотреть файл

@ -38,7 +38,7 @@ fuzzy-if(webrender,0-1,0-6) == rotate3d-2a.html rotatey-1-ref.html
!= backface-visibility-1a.html about:blank
== backface-visibility-1b.html about:blank
== backface-visibility-1c.html about:blank
fuzzy-if(winWidget&&!layersGPUAccelerated,0-1,0-251) fuzzy-if(useDrawSnapshot,64-64,1438-1438) == backface-visibility-2.html backface-visibility-2-ref.html
fuzzy-if(winWidget&&!layersGPUAccelerated,0-1,0-251) == backface-visibility-2.html backface-visibility-2-ref.html
== backface-visibility-3.html backface-visibility-3-ref.html
== perspective-clipping-1.html perspective-clipping-1-ref.html
== perspective-clipping-2.html perspective-clipping-2-ref.html
@ -85,7 +85,7 @@ fuzzy(0-1,0-10000) == opacity-preserve3d-4.html opacity-preserve3d-4-ref.html
fuzzy-if(webrender&&Android,0-8,0-1) == mask-layer-1.html mask-layer-ref.html
fuzzy-if(webrender&&Android,0-8,0-1) == mask-layer-2.html mask-layer-ref.html
fuzzy-if(webrender,0-16,0-132) == mask-layer-3.html mask-layer-ref.html
== split-intersect1.html split-intersect1-ref.html
fails-if(useDrawSnapshot) == split-intersect1.html split-intersect1-ref.html
fuzzy(0-255,0-150) fails-if(useDrawSnapshot) == split-intersect2.html split-intersect2-ref.html
fuzzy(0-255,0-100) fails-if(useDrawSnapshot) == split-non-ortho1.html split-non-ortho1-ref.html
fuzzy-if(winWidget,0-150,0-120) == component-alpha-1.html component-alpha-1-ref.html
@ -99,4 +99,4 @@ fuzzy-if(webrender,0-1,0-5) == perspective-overflow-1.html perspective-overflow-
== perspective-overflow-2.html perspective-overflow-2-ref.html
== 1544995-1.html 1544995-1-ref.html
== preserve3d-will-change-large-frame.html preserve3d-will-change-ref.html
fuzzy-if(webrender,0-6,0-3117) fuzzy-if(useDrawSnapshot,4-4,13-13) == 1637067-1.html 1637067-1-ref.html
fuzzy-if(webrender,0-6,0-3117) == 1637067-1.html 1637067-1-ref.html

Просмотреть файл

@ -29,6 +29,7 @@
#include "mozilla/SVGFilterInstance.h"
#include "mozilla/SVGUtils.h"
#include "CSSFilterInstance.h"
#include "SVGFilterPaintCallback.h"
#include "SVGIntegrationUtils.h"
using namespace mozilla::dom;
@ -59,10 +60,12 @@ static UniquePtr<UserSpaceMetrics> UserSpaceMetricsForFrame(nsIFrame* aFrame) {
return MakeUnique<NonSVGFrameUserSpaceMetrics>(aFrame);
}
void FilterInstance::PaintFilteredFrame(
nsIFrame* aFilteredFrame, gfxContext* aCtx,
const SVGFilterPaintCallback& aPaintCallback, const nsRegion* aDirtyArea,
imgDrawingParams& aImgParams, float aOpacity) {
void FilterInstance::PaintFilteredFrame(nsIFrame* aFilteredFrame,
gfxContext* aCtx,
SVGFilterPaintCallback* aPaintCallback,
const nsRegion* aDirtyArea,
imgDrawingParams& aImgParams,
float aOpacity) {
auto filterChain = aFilteredFrame->StyleEffects()->mFilters.AsSpan();
UniquePtr<UserSpaceMetrics> metrics =
UserSpaceMetricsForFrame(aFilteredFrame);
@ -434,7 +437,7 @@ nsRect FilterInstance::GetPostFilterBounds(nsIFrame* aFilteredFrame,
FilterInstance::FilterInstance(
nsIFrame* aTargetFrame, nsIContent* aTargetContent,
const UserSpaceMetrics& aMetrics, Span<const StyleFilter> aFilterChain,
bool aFilterInputIsTainted, const SVGFilterPaintCallback& aPaintCallback,
bool aFilterInputIsTainted, SVGFilterPaintCallback* aPaintCallback,
const gfxMatrix& aPaintTransform, const nsRegion* aPostFilterDirtyRegion,
const nsRegion* aPreFilterDirtyRegion,
const nsRect* aPreFilterInkOverflowRectOverride,
@ -730,7 +733,7 @@ void FilterInstance::BuildSourceImage(DrawTarget* aDest,
imageFlags &= ~imgIContainer::FLAG_HIGH_QUALITY_SCALING;
}
imgDrawingParams imgParams(imageFlags);
mPaintCallback(*ctx, mTargetFrame, mPaintTransform, &dirty, imgParams);
mPaintCallback->Paint(*ctx, mTargetFrame, mPaintTransform, &dirty, imgParams);
aImgParams.result = imgParams.result;
mSourceGraphic.mSourceSurface = offscreenDT->Snapshot();

Просмотреть файл

@ -20,7 +20,6 @@
#include "mozilla/gfx/2D.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/ServoStyleConsts.h"
#include "mozilla/SVGIntegrationUtils.h"
class gfxContext;
class nsIContent;
@ -28,6 +27,7 @@ class nsIFrame;
struct WrFiltersHolder;
namespace mozilla {
class SVGFilterPaintCallback;
namespace dom {
class UserSpaceMetrics;
@ -61,7 +61,6 @@ class FilterInstance {
using FilterDescription = gfx::FilterDescription;
using UserSpaceMetrics = dom::UserSpaceMetrics;
using imgDrawingParams = image::imgDrawingParams;
using SVGFilterPaintCallback = SVGIntegrationUtils::SVGFilterPaintCallback;
public:
/**
@ -90,7 +89,7 @@ class FilterInstance {
* border box).
*/
static void PaintFilteredFrame(nsIFrame* aFilteredFrame, gfxContext* aCtx,
const SVGFilterPaintCallback& aPaintCallback,
SVGFilterPaintCallback* aPaintCallback,
const nsRegion* aDirtyArea,
imgDrawingParams& aImgParams,
float aOpacity = 1.0f);
@ -159,16 +158,16 @@ class FilterInstance {
* @param aOverrideBBox [optional] Use a different SVG bbox for the target
* element. Must be non-null if aTargetFrame is null.
*/
FilterInstance(
nsIFrame* aTargetFrame, nsIContent* aTargetContent,
const UserSpaceMetrics& aMetrics, Span<const StyleFilter> aFilterChain,
bool aFilterInputIsTainted,
const SVGIntegrationUtils::SVGFilterPaintCallback& aPaintCallback,
const gfxMatrix& aPaintTransform,
const nsRegion* aPostFilterDirtyRegion = nullptr,
const nsRegion* aPreFilterDirtyRegion = nullptr,
const nsRect* aPreFilterInkOverflowRectOverride = nullptr,
const gfxRect* aOverrideBBox = nullptr);
FilterInstance(nsIFrame* aTargetFrame, nsIContent* aTargetContent,
const UserSpaceMetrics& aMetrics,
Span<const StyleFilter> aFilterChain,
bool aFilterInputIsTainted,
SVGFilterPaintCallback* aPaintCallback,
const gfxMatrix& aPaintTransform,
const nsRegion* aPostFilterDirtyRegion = nullptr,
const nsRegion* aPreFilterDirtyRegion = nullptr,
const nsRect* aPreFilterInkOverflowRectOverride = nullptr,
const gfxRect* aOverrideBBox = nullptr);
/**
* Returns true if the filter instance was created successfully.
@ -337,7 +336,7 @@ class FilterInstance {
*/
const UserSpaceMetrics& mMetrics;
const SVGFilterPaintCallback& mPaintCallback;
SVGFilterPaintCallback* mPaintCallback;
/**
* The SVG bbox of the element that is being filtered, in user space.

Просмотреть файл

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef LAYOUT_SVG_SVGFILTERPAINTCALLBACK_H_
#define LAYOUT_SVG_SVGFILTERPAINTCALLBACK_H_
#include "gfxMatrix.h"
#include "nsRect.h"
class nsIFrame;
class gfxContext;
namespace mozilla {
namespace image {
struct imgDrawingParams;
}
class SVGFilterPaintCallback {
public:
using imgDrawingParams = image::imgDrawingParams;
/**
* Paint the frame contents.
* SVG frames will have had matrix propagation set to false already.
* Non-SVG frames have to do their own thing.
* The caller will do a Save()/Restore() as necessary so feel free
* to mess with context state.
* The context will be configured to use the "user space" coordinate
* system.
* @param aDirtyRect the dirty rect *in user space pixels*
* @param aTransformRoot the outermost frame whose transform should be taken
* into account when painting an SVG glyph
*/
virtual void Paint(gfxContext& aContext, nsIFrame* aTarget,
const gfxMatrix& aTransform, const nsIntRect* aDirtyRect,
imgDrawingParams& aImgParams) = 0;
};
} // namespace mozilla
#endif // LAYOUT_SVG_SVGFILTERPAINTCALLBACK_H_

Просмотреть файл

@ -16,6 +16,7 @@
#include "nsDisplayList.h"
#include "nsLayoutUtils.h"
#include "gfxContext.h"
#include "SVGFilterPaintCallback.h"
#include "SVGPaintServerFrame.h"
#include "FrameLayerBuilder.h"
#include "BasicLayers.h"
@ -201,89 +202,6 @@ nsPoint SVGIntegrationUtils::GetOffsetToBoundingBox(nsIFrame* aFrame) {
return -nsLayoutUtils::GetAllInFlowRectsUnion(aFrame, aFrame).TopLeft();
}
struct EffectOffsets {
// The offset between the reference frame and the bounding box of the
// target frame in app unit.
nsPoint offsetToBoundingBox;
// The offset between the reference frame and the bounding box of the
// target frame in app unit.
nsPoint offsetToUserSpace;
// The offset between the reference frame and the bounding box of the
// target frame in device unit.
gfxPoint offsetToUserSpaceInDevPx;
};
static EffectOffsets ComputeEffectOffset(
nsIFrame* aFrame, const SVGIntegrationUtils::PaintFramesParams& aParams) {
EffectOffsets result;
result.offsetToBoundingBox =
aParams.builder->ToReferenceFrame(aFrame) -
SVGIntegrationUtils::GetOffsetToBoundingBox(aFrame);
if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) {
/* Snap the offset if the reference frame is not a SVG frame,
* since other frames will be snapped to pixel when rendering. */
result.offsetToBoundingBox =
nsPoint(aFrame->PresContext()->RoundAppUnitsToNearestDevPixels(
result.offsetToBoundingBox.x),
aFrame->PresContext()->RoundAppUnitsToNearestDevPixels(
result.offsetToBoundingBox.y));
}
// After applying only "aOffsetToBoundingBox", aParams.ctx would have its
// origin at the top left corner of frame's bounding box (over all
// continuations).
// However, SVG painting needs the origin to be located at the origin of the
// SVG frame's "user space", i.e. the space in which, for example, the
// frame's BBox lives.
// SVG geometry frames and foreignObject frames apply their own offsets, so
// their position is relative to their user space. So for these frame types,
// if we want aParams.ctx to be in user space, we first need to subtract the
// frame's position so that SVG painting can later add it again and the
// frame is painted in the right place.
gfxPoint toUserSpaceGfx =
SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(aFrame);
nsPoint toUserSpace =
nsPoint(nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.x)),
nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.y)));
result.offsetToUserSpace = result.offsetToBoundingBox - toUserSpace;
#ifdef DEBUG
bool hasSVGLayout = aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT);
NS_ASSERTION(
hasSVGLayout || result.offsetToBoundingBox == result.offsetToUserSpace,
"For non-SVG frames there shouldn't be any additional offset");
#endif
result.offsetToUserSpaceInDevPx = nsLayoutUtils::PointToGfxPoint(
result.offsetToUserSpace, aFrame->PresContext()->AppUnitsPerDevPixel());
return result;
}
/**
* Setup transform matrix of a gfx context by a specific frame. Move the
* origin of aParams.ctx to the user space of aFrame.
*/
static EffectOffsets MoveContextOriginToUserSpace(
nsIFrame* aFrame, const SVGIntegrationUtils::PaintFramesParams& aParams) {
EffectOffsets offset = ComputeEffectOffset(aFrame, aParams);
aParams.ctx.SetMatrixDouble(aParams.ctx.CurrentMatrixDouble().PreTranslate(
offset.offsetToUserSpaceInDevPx));
return offset;
}
gfxPoint SVGIntegrationUtils::GetOffsetToUserSpaceInDevPx(
nsIFrame* aFrame, const PaintFramesParams& aParams) {
nsIFrame* firstFrame =
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
EffectOffsets offset = ComputeEffectOffset(firstFrame, aParams);
return offset.offsetToUserSpaceInDevPx;
}
/* static */
nsSize SVGIntegrationUtils::GetContinuationUnionSize(nsIFrame* aNonSVGFrame) {
NS_ASSERTION(!aNonSVGFrame->IsFrameOfType(nsIFrame::eSVG),
@ -485,6 +403,37 @@ bool SVGIntegrationUtils::HitTestFrameForEffects(nsIFrame* aFrame,
return SVGUtils::HitTestClip(firstFrame, userSpacePt);
}
class RegularFramePaintCallback : public SVGFilterPaintCallback {
public:
RegularFramePaintCallback(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const gfxPoint& aUserSpaceToFrameSpaceOffset)
: mBuilder(aBuilder),
mLayerManager(aManager),
mUserSpaceToFrameSpaceOffset(aUserSpaceToFrameSpaceOffset) {}
virtual void Paint(gfxContext& aContext, nsIFrame* aTarget,
const gfxMatrix& aTransform, const nsIntRect* aDirtyRect,
imgDrawingParams& aImgParams) override {
BasicLayerManager* basic = mLayerManager->AsBasicLayerManager();
RefPtr<gfxContext> oldCtx = basic->GetTarget();
basic->SetTarget(&aContext);
gfxContextMatrixAutoSaveRestore autoSR(&aContext);
aContext.SetMatrixDouble(aContext.CurrentMatrixDouble().PreTranslate(
-mUserSpaceToFrameSpaceOffset));
mLayerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer,
mBuilder);
basic->SetTarget(oldCtx);
}
private:
nsDisplayListBuilder* mBuilder;
LayerManager* mLayerManager;
gfxPoint mUserSpaceToFrameSpaceOffset;
};
using PaintFramesParams = SVGIntegrationUtils::PaintFramesParams;
/**
@ -686,6 +635,81 @@ static bool ValidateSVGFrame(nsIFrame* aFrame) {
return true;
}
struct EffectOffsets {
// The offset between the reference frame and the bounding box of the
// target frame in app unit.
nsPoint offsetToBoundingBox;
// The offset between the reference frame and the bounding box of the
// target frame in app unit.
nsPoint offsetToUserSpace;
// The offset between the reference frame and the bounding box of the
// target frame in device unit.
gfxPoint offsetToUserSpaceInDevPx;
};
static EffectOffsets ComputeEffectOffset(nsIFrame* aFrame,
const PaintFramesParams& aParams) {
EffectOffsets result;
result.offsetToBoundingBox =
aParams.builder->ToReferenceFrame(aFrame) -
SVGIntegrationUtils::GetOffsetToBoundingBox(aFrame);
if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) {
/* Snap the offset if the reference frame is not a SVG frame,
* since other frames will be snapped to pixel when rendering. */
result.offsetToBoundingBox =
nsPoint(aFrame->PresContext()->RoundAppUnitsToNearestDevPixels(
result.offsetToBoundingBox.x),
aFrame->PresContext()->RoundAppUnitsToNearestDevPixels(
result.offsetToBoundingBox.y));
}
// After applying only "aOffsetToBoundingBox", aParams.ctx would have its
// origin at the top left corner of frame's bounding box (over all
// continuations).
// However, SVG painting needs the origin to be located at the origin of the
// SVG frame's "user space", i.e. the space in which, for example, the
// frame's BBox lives.
// SVG geometry frames and foreignObject frames apply their own offsets, so
// their position is relative to their user space. So for these frame types,
// if we want aParams.ctx to be in user space, we first need to subtract the
// frame's position so that SVG painting can later add it again and the
// frame is painted in the right place.
gfxPoint toUserSpaceGfx =
SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(aFrame);
nsPoint toUserSpace =
nsPoint(nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.x)),
nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.y)));
result.offsetToUserSpace = result.offsetToBoundingBox - toUserSpace;
#ifdef DEBUG
bool hasSVGLayout = aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT);
NS_ASSERTION(
hasSVGLayout || result.offsetToBoundingBox == result.offsetToUserSpace,
"For non-SVG frames there shouldn't be any additional offset");
#endif
result.offsetToUserSpaceInDevPx = nsLayoutUtils::PointToGfxPoint(
result.offsetToUserSpace, aFrame->PresContext()->AppUnitsPerDevPixel());
return result;
}
/**
* Setup transform matrix of a gfx context by a specific frame. Move the
* origin of aParams.ctx to the user space of aFrame.
*/
static EffectOffsets MoveContextOriginToUserSpace(
nsIFrame* aFrame, const PaintFramesParams& aParams) {
EffectOffsets offset = ComputeEffectOffset(aFrame, aParams);
aParams.ctx.SetMatrixDouble(aParams.ctx.CurrentMatrixDouble().PreTranslate(
offset.offsetToUserSpaceInDevPx));
return offset;
}
bool SVGIntegrationUtils::IsMaskResourceReady(nsIFrame* aFrame) {
nsIFrame* firstFrame =
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
@ -1043,8 +1067,7 @@ void SVGIntegrationUtils::PaintMaskAndClipPath(
PaintMaskAndClipPathInternal(aParams, aPaintChild);
}
void SVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams,
const SVGFilterPaintCallback& aCallback) {
void SVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams) {
MOZ_ASSERT(!aParams.builder->IsForGenerateGlyphMask(),
"Filter effect is discarded while generating glyph mask.");
MOZ_ASSERT(aParams.frame->StyleEffects()->HasFilters(),
@ -1083,9 +1106,11 @@ void SVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams,
EffectOffsets offsets = MoveContextOriginToUserSpace(firstFrame, aParams);
/* Paint the child and apply filters */
RegularFramePaintCallback callback(aParams.builder, aParams.layerManager,
offsets.offsetToUserSpaceInDevPx);
nsRegion dirtyRegion = aParams.dirtyRect - offsets.offsetToBoundingBox;
FilterInstance::PaintFilteredFrame(frame, &context, aCallback, &dirtyRegion,
FilterInstance::PaintFilteredFrame(frame, &context, &callback, &dirtyRegion,
aParams.imgParams, opacity);
}

Просмотреть файл

@ -203,27 +203,10 @@ class SVGIntegrationUtils final {
*/
static bool IsMaskResourceReady(nsIFrame* aFrame);
/**
* Paint the frame contents.
* SVG frames will have had matrix propagation set to false already.
* Non-SVG frames have to do their own thing.
* The caller will do a Save()/Restore() as necessary so feel free
* to mess with context state.
* The context will be configured to use the "user space" coordinate
* system.
* @param aDirtyRect the dirty rect *in user space pixels*
* @param aTransformRoot the outermost frame whose transform should be taken
* into account when painting an SVG glyph
*/
using SVGFilterPaintCallback = std::function<void(
gfxContext& aContext, nsIFrame* aTarget, const gfxMatrix& aTransform,
const nsIntRect* aDirtyRect, image::imgDrawingParams& aImgParams)>;
/**
* Paint non-SVG frame with filter and opacity effect.
*/
static void PaintFilter(const PaintFramesParams& aParams,
const SVGFilterPaintCallback& aCallback);
static void PaintFilter(const PaintFramesParams& aParams);
/**
* Build WebRender filters for a frame with CSS filters applied to it.
@ -285,13 +268,6 @@ class SVGIntegrationUtils final {
* For SVG frames, this returns a zero offset.
*/
static nsPoint GetOffsetToBoundingBox(nsIFrame* aFrame);
/**
* The offset between the reference frame and the bounding box of the
* target frame in device units.
*/
static gfxPoint GetOffsetToUserSpaceInDevPx(nsIFrame* aFrame,
const PaintFramesParams& aParams);
};
} // namespace mozilla

Просмотреть файл

@ -28,6 +28,7 @@
#include "nsStyleStruct.h"
#include "nsStyleTransformMatrix.h"
#include "SVGAnimatedLength.h"
#include "SVGFilterPaintCallback.h"
#include "SVGPaintServerFrame.h"
#include "nsTextFrame.h"
#include "mozilla/CSSClipPathInstance.h"
@ -381,6 +382,37 @@ void SVGUtils::NotifyChildrenOfSVGChange(nsIFrame* aFrame, uint32_t aFlags) {
// ************************************************************
class SVGPaintCallback : public SVGFilterPaintCallback {
public:
virtual void Paint(gfxContext& aContext, nsIFrame* aTarget,
const gfxMatrix& aTransform, const nsIntRect* aDirtyRect,
imgDrawingParams& aImgParams) override {
ISVGDisplayableFrame* svgFrame = do_QueryFrame(aTarget);
NS_ASSERTION(svgFrame, "Expected SVG frame here");
nsIntRect* dirtyRect = nullptr;
nsIntRect tmpDirtyRect;
// aDirtyRect is in user-space pixels, we need to convert to
// outer-SVG-frame-relative device pixels.
if (aDirtyRect) {
gfxMatrix userToDeviceSpace = aTransform;
if (userToDeviceSpace.IsSingular()) {
return;
}
gfxRect dirtyBounds = userToDeviceSpace.TransformBounds(gfxRect(
aDirtyRect->x, aDirtyRect->y, aDirtyRect->width, aDirtyRect->height));
dirtyBounds.RoundOut();
if (gfxUtils::GfxRectToIntRect(dirtyBounds, &tmpDirtyRect)) {
dirtyRect = &tmpDirtyRect;
}
}
svgFrame->PaintSVG(aContext, SVGUtils::GetCSSPxToDevPxMatrix(aTarget),
aImgParams, dirtyRect);
}
};
float SVGUtils::ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity) {
float opacity = aFrame->StyleEffects()->mOpacity;
@ -758,36 +790,9 @@ void SVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext,
target->SetMatrixDouble(reverseScaleMatrix * aTransform *
target->CurrentMatrixDouble());
auto callback = [](gfxContext& aContext, nsIFrame* aTarget,
const gfxMatrix& aTransform, const nsIntRect* aDirtyRect,
imgDrawingParams& aImgParams) {
ISVGDisplayableFrame* svgFrame = do_QueryFrame(aTarget);
NS_ASSERTION(svgFrame, "Expected SVG frame here");
nsIntRect* dirtyRect = nullptr;
nsIntRect tmpDirtyRect;
// aDirtyRect is in user-space pixels, we need to convert to
// outer-SVG-frame-relative device pixels.
if (aDirtyRect) {
gfxMatrix userToDeviceSpace = aTransform;
if (userToDeviceSpace.IsSingular()) {
return;
}
gfxRect dirtyBounds = userToDeviceSpace.TransformBounds(
gfxRect(aDirtyRect->x, aDirtyRect->y, aDirtyRect->width,
aDirtyRect->height));
dirtyBounds.RoundOut();
if (gfxUtils::GfxRectToIntRect(dirtyBounds, &tmpDirtyRect)) {
dirtyRect = &tmpDirtyRect;
}
}
svgFrame->PaintSVG(aContext, SVGUtils::GetCSSPxToDevPxMatrix(aTarget),
aImgParams, dirtyRect);
};
FilterInstance::PaintFilteredFrame(aFrame, target, callback, dirtyRegion,
aImgParams);
SVGPaintCallback paintCallback;
FilterInstance::PaintFilteredFrame(aFrame, target, &paintCallback,
dirtyRegion, aImgParams);
} else {
svgFrame->PaintSVG(*target, aTransform, aImgParams, aDirtyRect);
}

Просмотреть файл

@ -1043,10 +1043,6 @@ class nsDisplayXULEventRedirector final : public nsDisplayWrapList {
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override {
return false;
}
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override {
GetChildren()->Paint(aBuilder, aCtx,
mFrame->PresContext()->AppUnitsPerDevPixel());
}
NS_DISPLAY_DECL_NAME("XULEventRedirector", TYPE_XUL_EVENT_REDIRECTOR)
private:
nsIFrame* mTargetFrame;
@ -1087,7 +1083,7 @@ void nsDisplayXULEventRedirector::HitTest(nsDisplayListBuilder* aBuilder,
}
}
class nsXULEventRedirectorWrapper final : public nsDisplayItemWrapper {
class nsXULEventRedirectorWrapper final : public nsDisplayWrapper {
public:
explicit nsXULEventRedirectorWrapper(nsIFrame* aTargetFrame)
: mTargetFrame(aTargetFrame) {}