Bug 1344396. Build the display lists directly. r=kats

This is a largely uninteresting patch that just uses the DisplayListBuilder
directly. A wonderful cleanup patch will come after this. One of the more
interesting pieces is the use of PushBuiltDisplayList. This is needed for
handling empty transactions. See https://github.com/servo/webrender/pull/934
for more info.
This commit is contained in:
Jeff Muizelaar 2017-03-03 10:45:29 -05:00
parent 724ef940ac
commit 900393a0dc
30 changed files with 237 additions and 204 deletions

View File

@ -18,7 +18,7 @@ namespace layers {
using namespace mozilla::gfx;
void
WebRenderBorderLayer::RenderLayer()
WebRenderBorderLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
WrScrollFrameStackingContextGenerator scrollFrames(this);
@ -54,23 +54,20 @@ WebRenderBorderLayer::RenderLayer()
Stringify(clip).c_str());
}
WrBridge()->AddWebRenderCommand(
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
Nothing(),
1.0f,
GetAnimations(),
transform,
WrMixBlendMode::Normal,
FrameMetrics::NULL_SCROLL_ID));
WrBridge()->AddWebRenderCommand(
OpDPPushBorder(wr::ToWrRect(rect), wr::ToWrRect(clip),
wr::ToWrBorderSide(mWidths[0], mColors[0], mBorderStyles[0]),
wr::ToWrBorderSide(mWidths[1], mColors[1], mBorderStyles[1]),
wr::ToWrBorderSide(mWidths[2], mColors[2], mBorderStyles[2]),
wr::ToWrBorderSide(mWidths[3], mColors[3], mBorderStyles[3]),
wr::ToWrBorderRadius(mCorners[0], mCorners[1], mCorners[3], mCorners[2])));
WrBridge()->AddWebRenderCommand(OpDPPopStackingContext());
aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
nullptr,
1.0f,
//GetAnimations(),
transform,
WrMixBlendMode::Normal);
aBuilder.PushBorder(wr::ToWrRect(rect), wr::ToWrRect(clip),
wr::ToWrBorderSide(mWidths[0], mColors[0], mBorderStyles[0]),
wr::ToWrBorderSide(mWidths[1], mColors[1], mBorderStyles[1]),
wr::ToWrBorderSide(mWidths[2], mColors[2], mBorderStyles[2]),
wr::ToWrBorderSide(mWidths[3], mColors[3], mBorderStyles[3]),
wr::ToWrBorderRadius(mCorners[0], mCorners[1], mCorners[3], mCorners[2]));
aBuilder.PopStackingContext();
}
} // namespace layers

View File

@ -29,7 +29,7 @@ protected:
public:
Layer* GetLayer() override { return this; }
void RenderLayer() override;
void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
};
} // namespace layers

View File

@ -189,13 +189,11 @@ WebRenderBridgeChild::ProcessWebrenderCommands(const gfx::IntSize &aSize,
}
}
builder.End();
wr::BuiltDisplayList dl;
builder.Finalize(dl.dl_desc, dl.dl, dl.aux_desc, dl.aux);
return dl;
return builder.Finalize();
}
void
WebRenderBridgeChild::DPEnd(const gfx::IntSize& aSize, bool aIsSync, uint64_t aTransactionId)
WebRenderBridgeChild::DPEnd(wr::DisplayListBuilder &aBuilder, const gfx::IntSize& aSize, bool aIsSync, uint64_t aTransactionId)
{
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(mIsInTransaction);
@ -209,7 +207,7 @@ WebRenderBridgeChild::DPEnd(const gfx::IntSize& aSize, bool aIsSync, uint64_t aT
}
}
wr::BuiltDisplayList dl = ProcessWebrenderCommands(aSize, mCommands);
wr::BuiltDisplayList dl = aBuilder.Finalize();
ByteBuffer dlData(Move(dl.dl));
ByteBuffer auxData(Move(dl.aux));

View File

@ -16,6 +16,10 @@ namespace widget {
class CompositorWidget;
}
namespace wr {
class DisplayListBuilder;
}
namespace layers {
class CompositableClient;
@ -36,10 +40,12 @@ public:
void AddWebRenderParentCommands(const nsTArray<WebRenderParentCommand>& aCommands);
bool DPBegin(const gfx::IntSize& aSize);
void DPEnd(const gfx::IntSize& aSize, bool aIsSync, uint64_t aTransactionId);
void DPEnd(wr::DisplayListBuilder &aBuilder, const gfx::IntSize& aSize, bool aIsSync, uint64_t aTransactionId);
CompositorBridgeChild* GetCompositorBridgeChild();
wr::PipelineId GetPipeline() { return mPipelineId; }
// KnowsCompositor
TextureForwarder* GetTextureForwarder() override;
LayersIPCActor* GetLayersIPCActor() override;

View File

@ -46,7 +46,7 @@ WebRenderCanvasLayer::Initialize(const Data& aData)
}
void
WebRenderCanvasLayer::RenderLayer()
WebRenderCanvasLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
UpdateCompositableClient();
@ -98,21 +98,20 @@ WebRenderCanvasLayer::RenderLayer()
Stringify(mixBlendMode).c_str());
}
WrBridge()->AddWebRenderCommand(
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
1.0f,
GetAnimations(),
transform,
mixBlendMode,
FrameMetrics::NULL_SCROLL_ID));
WrImageKey key;
key.mNamespace = WrBridge()->GetNamespace();
key.mHandle = WrBridge()->GetNextResourceId();
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId, key));
WrBridge()->AddWebRenderCommand(OpDPPushImage(wr::ToWrRect(rect), wr::ToWrRect(clip), Nothing(), filter, key));
WrBridge()->AddWebRenderCommand(OpDPPopStackingContext());
aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask.ptrOr(nullptr),
1.0f,
//GetAnimations(),
transform,
mixBlendMode);
aBuilder.PushImage(wr::ToWrRect(rect), wr::ToWrRect(clip), nullptr, filter, key);
aBuilder.PopStackingContext();
}
void

View File

@ -45,7 +45,7 @@ protected:
public:
Layer* GetLayer() override { return this; }
void RenderLayer() override;
void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
protected:
uint64_t mExternalImageId;

View File

@ -17,7 +17,7 @@ namespace layers {
using namespace mozilla::gfx;
void
WebRenderColorLayer::RenderLayer()
WebRenderColorLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
WrScrollFrameStackingContextGenerator scrollFrames(this);
@ -58,18 +58,15 @@ WebRenderColorLayer::RenderLayer()
Stringify(mixBlendMode).c_str());
}
WrBridge()->AddWebRenderCommand(
OpDPPushStackingContext(wr::ToWrRect(relBounds),
aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
mask.ptrOr(nullptr),
1.0f,
GetAnimations(),
//GetAnimations(),
transform,
mixBlendMode,
FrameMetrics::NULL_SCROLL_ID));
WrBridge()->AddWebRenderCommand(
OpDPPushRect(wr::ToWrRect(rect), wr::ToWrRect(clip), wr::ToWrColor(mColor)));
WrBridge()->AddWebRenderCommand(OpDPPopStackingContext());
mixBlendMode);
aBuilder.PushRect(wr::ToWrRect(rect), wr::ToWrRect(clip), wr::ToWrColor(mColor));
aBuilder.PopStackingContext();
}
} // namespace layers

View File

@ -29,7 +29,7 @@ protected:
public:
Layer* GetLayer() override { return this; }
void RenderLayer() override;
void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
};
} // namespace layers

View File

@ -15,7 +15,7 @@ namespace mozilla {
namespace layers {
void
WebRenderContainerLayer::RenderLayer()
WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
WrScrollFrameStackingContextGenerator scrollFrames(this);
@ -43,28 +43,24 @@ WebRenderContainerLayer::RenderLayer()
Stringify(transform).c_str(),
Stringify(mixBlendMode).c_str());
}
WrBridge()->AddWebRenderCommand(
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
GetLocalOpacity(),
GetLayer()->GetAnimations(),
transform,
mixBlendMode,
FrameMetrics::NULL_SCROLL_ID));
aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask.ptrOr(nullptr),
GetLocalOpacity(),
//GetLayer()->GetAnimations(),
transform,
mixBlendMode);
for (LayerPolygon& child : children) {
if (child.layer->IsBackfaceHidden()) {
continue;
}
ToWebRenderLayer(child.layer)->RenderLayer();
ToWebRenderLayer(child.layer)->RenderLayer(aBuilder);
}
WrBridge()->AddWebRenderCommand(
OpDPPopStackingContext());
aBuilder.PopStackingContext();
}
void
WebRenderRefLayer::RenderLayer()
WebRenderRefLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
WrScrollFrameStackingContextGenerator scrollFrames(this);
@ -79,7 +75,7 @@ WebRenderRefLayer::RenderLayer()
Stringify(transform).c_str());
}
WrBridge()->AddWebRenderCommand(OpDPPushIframe(wr::ToWrRect(relBounds), wr::ToWrRect(relBounds), wr::AsPipelineId(mId)));
aBuilder.PushIFrame(wr::ToWrRect(relBounds), wr::ToWrRect(relBounds), wr::AsPipelineId(mId));
}
} // namespace layers

View File

@ -31,7 +31,7 @@ protected:
public:
Layer* GetLayer() override { return this; }
void RenderLayer() override;
void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
{
@ -56,7 +56,7 @@ protected:
public:
Layer* GetLayer() override { return this; }
void RenderLayer() override;
void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
{

View File

@ -16,18 +16,19 @@ namespace mozilla {
namespace layers {
void
WebRenderDisplayItemLayer::RenderLayer()
WebRenderDisplayItemLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
if (mItem) {
wr::DisplayListBuilder builder(WrBridge()->GetPipeline());
// We might have recycled this layer. Throw away the old commands.
mCommands.Clear();
mParentCommands.Clear();
mItem->CreateWebRenderCommands(mCommands, mParentCommands, this);
mItem->CreateWebRenderCommands(builder, mParentCommands, this);
mBuiltDisplayList = builder.Finalize();
}
// else we have an empty transaction and just use the
// old commands.
WrBridge()->AddWebRenderCommands(mCommands);
aBuilder.PushBuiltDisplayList(Move(mBuiltDisplayList));
WrBridge()->AddWebRenderParentCommands(mParentCommands);
}

View File

@ -29,16 +29,15 @@ public:
protected:
virtual ~WebRenderDisplayItemLayer()
{
mCommands.Clear();
MOZ_COUNT_DTOR(WebRenderDisplayItemLayer);
}
public:
Layer* GetLayer() override { return this; }
void RenderLayer() override;
void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
private:
nsTArray<WebRenderCommand> mCommands;
wr::BuiltDisplayList mBuiltDisplayList;
nsTArray<WebRenderParentCommand> mParentCommands;
RefPtr<ImageClient> mImageClient;
RefPtr<ImageContainer> mImageContainer;

View File

@ -80,7 +80,7 @@ WebRenderImageLayer::ClearCachedResources()
}
void
WebRenderImageLayer::RenderLayer()
WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
if (!mContainer) {
return;
@ -165,21 +165,20 @@ WebRenderImageLayer::RenderLayer()
Stringify(mixBlendMode).c_str());
}
WrBridge()->AddWebRenderCommand(
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
1.0f,
GetAnimations(),
transform,
mixBlendMode,
FrameMetrics::NULL_SCROLL_ID));
WrImageKey key;
key.mNamespace = WrBridge()->GetNamespace();
key.mHandle = WrBridge()->GetNextResourceId();
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId, key));
WrBridge()->AddWebRenderCommand(OpDPPushImage(wr::ToWrRect(rect), wr::ToWrRect(clip), Nothing(), filter, key));
WrBridge()->AddWebRenderCommand(OpDPPopStackingContext());
aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask.ptrOr(nullptr),
1.0f,
//GetAnimations(),
transform,
mixBlendMode);
aBuilder.PushImage(wr::ToWrRect(rect), wr::ToWrRect(clip), nullptr, filter, key);
aBuilder.PopStackingContext();
//mContainer->SetImageFactory(originalIF);
}

View File

@ -32,7 +32,7 @@ protected:
public:
Layer* GetLayer() override { return this; }
void RenderLayer() override;
void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
protected:
CompositableType GetImageClientType();

View File

@ -317,12 +317,13 @@ WebRenderLayerManager::EndTransaction(DrawPaintedLayerCallback aCallback,
return;
}
WebRenderLayer::ToWebRenderLayer(mRoot)->RenderLayer();
wr::DisplayListBuilder builder(WrBridge()->GetPipeline());
WebRenderLayer::ToWebRenderLayer(mRoot)->RenderLayer(builder);
bool sync = mTarget != nullptr;
mLatestTransactionId = mTransactionIdAllocator->GetTransactionId();
WrBridge()->DPEnd(size.ToUnknownSize(), sync, mLatestTransactionId);
WrBridge()->DPEnd(builder, size.ToUnknownSize(), sync, mLatestTransactionId);
MakeSnapshotIfRequired(size);

View File

@ -11,6 +11,7 @@
#include "mozilla/layers/TransactionIdAllocator.h"
#include "mozilla/webrender/webrender_ffi.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/webrender/WebRenderAPI.h"
class nsIWidget;
@ -28,7 +29,7 @@ class WebRenderLayer
{
public:
virtual Layer* GetLayer() = 0;
virtual void RenderLayer() = 0;
virtual void RenderLayer(wr::DisplayListBuilder& aBuilder) = 0;
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; }
static inline WebRenderLayer*

View File

@ -114,7 +114,7 @@ WebRenderPaintedLayer::RenderLayerWithReadback(ReadbackProcessor *aReadback)
}
void
WebRenderPaintedLayer::RenderLayer()
WebRenderPaintedLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
// XXX We won't keep using ContentClient for WebRenderPaintedLayer in the future and
// there is a crash problem for ContentClient on MacOS. So replace ContentClient with
@ -224,21 +224,19 @@ WebRenderPaintedLayer::RenderLayer()
Stringify(mixBlendMode).c_str());
}
WrBridge()->AddWebRenderCommand(
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
1.0f,
GetAnimations(),
transform,
mixBlendMode,
FrameMetrics::NULL_SCROLL_ID));
WrImageKey key;
key.mNamespace = WrBridge()->GetNamespace();
key.mHandle = WrBridge()->GetNextResourceId();
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId, key));
WrBridge()->AddWebRenderCommand(OpDPPushImage(wr::ToWrRect(rect), wr::ToWrRect(clip), Nothing(), wr::ImageRendering::Auto, key));
WrBridge()->AddWebRenderCommand(OpDPPopStackingContext());
aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask.ptrOr(nullptr),
1.0f,
//GetAnimations(),
transform,
mixBlendMode);
aBuilder.PushImage(wr::ToWrRect(rect), wr::ToWrRect(clip), nullptr, wr::ImageRendering::Auto, key);
aBuilder.PopStackingContext();
}
} // namespace layers

View File

@ -51,7 +51,7 @@ public:
}
Layer* GetLayer() override { return this; }
void RenderLayer() override;
void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
void PaintThebes(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates);
void RenderLayerWithReadback(ReadbackProcessor *aReadback);
RefPtr<ContentClient> mContentClient;

View File

@ -18,7 +18,7 @@ namespace layers {
using namespace mozilla::gfx;
void
WebRenderTextLayer::RenderLayer()
WebRenderTextLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
if (mBounds.IsEmpty()) {
return;
@ -39,10 +39,8 @@ WebRenderTextLayer::RenderLayer()
Stringify(clip).c_str());
}
nsTArray<WebRenderCommand> commands;
mGlyphHelper.BuildWebRenderCommands(WrBridge(), commands, mGlyphs, mFont,
mGlyphHelper.BuildWebRenderCommands(WrBridge(), aBuilder, mGlyphs, mFont,
GetOffsetToParent(), rect, clip);
WrBridge()->AddWebRenderCommands(commands);
}
} // namespace layers

View File

@ -31,7 +31,7 @@ protected:
public:
Layer* GetLayer() override { return this; }
void RenderLayer() override;
void RenderLayer(wr::DisplayListBuilder& aBuilder) override;
protected:
gfx::WebRenderGlyphHelper mGlyphHelper;
@ -40,4 +40,4 @@ protected:
} // namespace layers
} // namespace mozilla
#endif // GFX_WEBRENDERTEXTLAYER_H
#endif // GFX_WEBRENDERTEXTLAYER_H

View File

@ -27,6 +27,7 @@
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/Vector.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "nsComponentManagerUtils.h"
#include "nsIClipboardHelper.h"
@ -1460,7 +1461,7 @@ WriteFontFileData(const uint8_t* aData, uint32_t aLength, uint32_t aIndex,
void
WebRenderGlyphHelper::BuildWebRenderCommands(WebRenderBridgeChild* aBridge,
nsTArray<WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
const nsTArray<GlyphArray>& aGlyphs,
ScaledFont* aFont,
const Point& aOffset,
@ -1481,30 +1482,26 @@ WebRenderGlyphHelper::BuildWebRenderCommands(WebRenderBridgeChild* aBridge,
aBridge->SendAddRawFont(key, fontBuffer, mIndex);
nsTArray<WrGlyphArray> wr_glyphs;
wr_glyphs.SetLength(aGlyphs.Length());
for (size_t i = 0; i < aGlyphs.Length(); i++) {
GlyphArray glyph_array = aGlyphs[i];
nsTArray<gfx::Glyph>& glyphs = glyph_array.glyphs();
nsTArray<WrGlyphInstance>& wr_glyph_instances = wr_glyphs[i].glyphs;
nsTArray<WrGlyphInstance> wr_glyph_instances;
wr_glyph_instances.SetLength(glyphs.Length());
wr_glyphs[i].color = glyph_array.color().value();
for (size_t j = 0; j < glyphs.Length(); j++) {
wr_glyph_instances[j].index = glyphs[j].mIndex;
wr_glyph_instances[j].x = glyphs[j].mPosition.x - aOffset.x;
wr_glyph_instances[j].y = glyphs[j].mPosition.y - aOffset.y;
}
}
aBuilder.PushText(wr::ToWrRect(aBounds),
wr::ToWrRect(aClip),
glyph_array.color().value(),
key,
Range<const WrGlyphInstance>(wr_glyph_instances.Elements(), wr_glyph_instances.Length()),
mGlyphSize);
aCommands.AppendElement(OpDPPushText(
wr::ToWrRect(aBounds),
wr::ToWrRect(aClip),
wr_glyphs,
mGlyphSize,
key));
}
}
} // namespace gfx

View File

@ -35,6 +35,9 @@ class WebRenderCommand;
namespace image {
class ImageRegion;
} // namespace image
namespace wr {
class DisplayListBuilder;
} // namespace wr
} // namespace mozilla
class gfxUtils {
@ -328,7 +331,7 @@ public:
}
void BuildWebRenderCommands(layers::WebRenderBridgeChild* aChild,
nsTArray<layers::WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
const nsTArray<layers::GlyphArray>& aGlyphs,
ScaledFont* aFont,
const Point& aOffset,

View File

@ -384,17 +384,16 @@ DisplayListBuilder::End()
wr_dp_end(mWrState);
}
void
DisplayListBuilder::Finalize(WrBuiltDisplayListDescriptor& dl_descriptor,
wr::VecU8& dl_data,
WrAuxiliaryListsDescriptor& aux_descriptor,
wr::VecU8& aux_data)
BuiltDisplayList
DisplayListBuilder::Finalize()
{
wr_api_finalize_builder(mWrState,
dl_descriptor,
dl_data.inner,
aux_descriptor,
aux_data.inner);
BuiltDisplayList dl;
wr_api_finalize_builder(mWrState,
dl.dl_desc,
dl.dl.inner,
dl.aux_desc,
dl.aux.inner);
return dl;
}
void
@ -415,6 +414,16 @@ DisplayListBuilder::PopStackingContext()
wr_dp_pop_stacking_context(mWrState);
}
void
DisplayListBuilder::PushBuiltDisplayList(BuiltDisplayList dl)
{
wr_dp_push_built_display_list(mWrState,
dl.dl_desc,
dl.dl.Extract(),
dl.aux_desc,
dl.aux.Extract());
}
void
DisplayListBuilder::PushScrollLayer(const WrRect& aBounds,
const WrRect& aOverflow,

View File

@ -11,6 +11,7 @@
#include "mozilla/Range.h"
#include "mozilla/webrender/webrender_ffi.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "GLTypes.h"
#include "Units.h"
namespace mozilla {
@ -127,10 +128,7 @@ public:
void Begin(const LayerIntSize& aSize);
void End();
void Finalize(WrBuiltDisplayListDescriptor& dl_descriptor,
wr::VecU8& dl_data,
WrAuxiliaryListsDescriptor& aux_descriptor,
wr::VecU8& aux_data);
wr::BuiltDisplayList Finalize();
void PushStackingContext(const WrRect& aBounds, // TODO: We should work with strongly typed rects
const WrRect& aOverflow,
@ -141,6 +139,8 @@ public:
void PopStackingContext();
void PushBuiltDisplayList(wr::BuiltDisplayList dl);
void PushScrollLayer(const WrRect& aBounds, // TODO: We should work with strongly typed rects
const WrRect& aOverflow,
const WrImageMask* aMask); // TODO: needs a wrapper.

View File

@ -258,6 +258,22 @@ struct VecU8 {
src.inner.capacity = 0;
}
VecU8&
operator=(VecU8&& src) {
inner = src.inner;
src.inner.data = nullptr;
src.inner.capacity = 0;
return *this;
}
WrVecU8
Extract() {
WrVecU8 ret = inner;
inner.data = nullptr;
inner.capacity = 0;
return ret;
}
~VecU8() {
if (inner.data) {
wr_vec_u8_free(inner);

View File

@ -221,6 +221,22 @@ pub unsafe extern fn wr_api_finalize_builder(state: &mut WrState,
*aux_descriptor = aux.descriptor().clone();
}
#[no_mangle]
pub unsafe extern fn wr_dp_push_built_display_list(state: &mut WrState,
dl_descriptor: BuiltDisplayListDescriptor,
dl_data: WrVecU8,
aux_descriptor: AuxiliaryListsDescriptor,
aux_data: WrVecU8)
{
let dl_vec = dl_data.to_vec();
let aux_vec = aux_data.to_vec();
let dl = BuiltDisplayList::from_data(dl_vec, dl_descriptor);
let aux = AuxiliaryLists::from_data(aux_vec, aux_descriptor);
state.frame_builder.dl_builder.push_built_display_list(dl, aux);
}
#[no_mangle]
pub unsafe extern fn wr_api_set_root_display_list(api: &mut RenderApi,
epoch: Epoch,

View File

@ -603,6 +603,14 @@ wr_api_finalize_builder(WrState* wrState,
WrVecU8& aux_data)
WR_FUNC;
WR_INLINE void
wr_dp_push_built_display_list(WrState* wrState,
WrBuiltDisplayListDescriptor dl_descriptor,
WrVecU8 dl_data,
WrAuxiliaryListsDescriptor aux_descriptor,
WrVecU8 aux_data)
WR_FUNC;
WR_INLINE void
wr_vec_u8_free(WrVecU8 dl_data)
WR_FUNC;

View File

@ -228,7 +228,7 @@ public:
void
CreateWebRenderCommands(nsDisplayItem* aItem,
nsTArray<layers::WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
nsTArray<layers::WebRenderParentCommand>& aParentCommands,
layers::WebRenderDisplayItemLayer* aLayer);
@ -275,18 +275,18 @@ public:
private:
void
CreateWebRenderCommandsForImage(nsDisplayItem* aItem,
nsTArray<layers::WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
nsTArray<layers::WebRenderParentCommand>& aParentCommands,
layers::WebRenderDisplayItemLayer* aLayer);
void
CreateWebRenderCommandsForPath(nsDisplayItem* aItem,
nsTArray<layers::WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
layers::WebRenderDisplayItemLayer* aLayer);
void
CreateWebRenderCommandsForText(nsDisplayItem* aItem,
nsTArray<layers::WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
layers::WebRenderDisplayItemLayer* aLayer);
private:
@ -317,17 +317,17 @@ private:
void
BulletRenderer::CreateWebRenderCommands(nsDisplayItem* aItem,
nsTArray<layers::WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
nsTArray<layers::WebRenderParentCommand>& aParentCommands,
layers::WebRenderDisplayItemLayer* aLayer)
{
if (IsImageType()) {
CreateWebRenderCommandsForImage(aItem, aCommands, aParentCommands, aLayer);
CreateWebRenderCommandsForImage(aItem, aBuilder, aParentCommands, aLayer);
} else if (IsPathType()) {
CreateWebRenderCommandsForPath(aItem, aCommands, aLayer);
CreateWebRenderCommandsForPath(aItem, aBuilder, aLayer);
} else {
MOZ_ASSERT(IsTextType());
CreateWebRenderCommandsForText(aItem, aCommands, aLayer);
CreateWebRenderCommandsForText(aItem, aBuilder, aLayer);
}
}
@ -435,7 +435,7 @@ BulletRenderer::IsImageContainerAvailable(layers::LayerManager* aManager, uint32
void
BulletRenderer::CreateWebRenderCommandsForImage(nsDisplayItem* aItem,
nsTArray<layers::WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
nsTArray<layers::WebRenderParentCommand>& aParentCommands,
layers::WebRenderDisplayItemLayer* aLayer)
{
@ -471,19 +471,16 @@ BulletRenderer::CreateWebRenderCommandsForImage(nsDisplayItem* aItem,
aParentCommands.AppendElement(layers::OpAddExternalImage(
externalImageId,
key));
aCommands.AppendElement(layers::OpDPPushImage(
wr::ToWrRect(dest),
wr::ToWrRect(dest),
Nothing(),
WrImageRendering::Auto,
key));
aBuilder.PushImage(wr::ToWrRect(dest),
wr::ToWrRect(dest),
nullptr,
WrImageRendering::Auto,
key);
}
void
BulletRenderer::CreateWebRenderCommandsForPath(nsDisplayItem* aItem,
nsTArray<layers::WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
layers::WebRenderDisplayItemLayer* aLayer)
{
MOZ_ASSERT(IsPathType());
@ -493,7 +490,7 @@ BulletRenderer::CreateWebRenderCommandsForPath(nsDisplayItem* aItem,
void
BulletRenderer::CreateWebRenderCommandsForText(nsDisplayItem* aItem,
nsTArray<layers::WebRenderCommand>& aCommands,
wr::DisplayListBuilder& aBuilder,
layers::WebRenderDisplayItemLayer* aLayer)
{
MOZ_ASSERT(IsTextType());
@ -508,7 +505,7 @@ BulletRenderer::CreateWebRenderCommandsForText(nsDisplayItem* aItem,
NSRectToRect(aItem->GetBounds(builder, &dummy), appUnitsPerDevPixel);
Rect destRectTransformed = aLayer->RelativeToParent(destRect);
mGlyphHelper.BuildWebRenderCommands(layer->WrBridge(), aCommands, mGlyphs, mFont, aLayer->GetOffsetToParent(),
mGlyphHelper.BuildWebRenderCommands(layer->WrBridge(), aBuilder, mGlyphs, mFont, aLayer->GetOffsetToParent(),
destRectTransformed, destRectTransformed);
}
@ -541,7 +538,7 @@ public:
LayerManager* aManager,
const ContainerLayerParameters& aParameters) override;
virtual void CreateWebRenderCommands(nsTArray<layers::WebRenderCommand>& aCommands,
virtual void CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<layers::WebRenderParentCommand>& aParentCommands,
layers::WebRenderDisplayItemLayer* aLayer) override;
@ -655,14 +652,14 @@ nsDisplayBullet::BuildLayer(nsDisplayListBuilder* aBuilder,
}
void
nsDisplayBullet::CreateWebRenderCommands(nsTArray<layers::WebRenderCommand>& aCommands,
nsDisplayBullet::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
nsTArray<layers::WebRenderParentCommand>& aParentCommands,
layers::WebRenderDisplayItemLayer* aLayer)
{
if (!mBulletRenderer)
return;
mBulletRenderer->CreateWebRenderCommands(this, aCommands, aParentCommands, aLayer);
mBulletRenderer->CreateWebRenderCommands(this, aBuilder, aParentCommands, aLayer);
}
void nsDisplayBullet::Paint(nsDisplayListBuilder* aBuilder,

View File

@ -4147,7 +4147,7 @@ nsDisplayOutline::BuildLayer(nsDisplayListBuilder* aBuilder,
}
void
nsDisplayOutline::CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
nsDisplayOutline::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands,
WebRenderDisplayItemLayer* aLayer)
{
@ -4164,10 +4164,10 @@ nsDisplayOutline::CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
LayerSize(br->mBorderRadii[1].width, br->mBorderRadii[1].height),
LayerSize(br->mBorderRadii[3].width, br->mBorderRadii[3].height),
LayerSize(br->mBorderRadii[2].width, br->mBorderRadii[2].height));
aCommands.AppendElement(OpDPPushBorder(wr::ToWrRect(outlineTransformedRect),
wr::ToWrRect(outlineTransformedRect),
side[0], side[1], side[2], side[3],
borderRadius));
aBuilder.PushBorder(wr::ToWrRect(outlineTransformedRect),
wr::ToWrRect(outlineTransformedRect),
side[0], side[1], side[2], side[3],
borderRadius);
}
bool
@ -4427,7 +4427,7 @@ nsDisplayCaret::Paint(nsDisplayListBuilder* aBuilder,
}
void
nsDisplayCaret::CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
nsDisplayCaret::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands,
WebRenderDisplayItemLayer* aLayer) {
using namespace mozilla::layers;
@ -4457,16 +4457,14 @@ nsDisplayCaret::CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
IntRect hook = RoundedToInt(hookTransformedRect);
// Note, WR will pixel snap anything that is layout aligned.
aCommands.AppendElement(OpDPPushRect(
wr::ToWrRect(caret),
wr::ToWrRect(caret),
wr::ToWrColor(color)));
aBuilder.PushRect(wr::ToWrRect(caret),
wr::ToWrRect(caret),
wr::ToWrColor(color));
if (!devHookRect.IsEmpty()) {
aCommands.AppendElement(OpDPPushRect(
wr::ToWrRect(hook),
wr::ToWrRect(hook),
wr::ToWrColor(color)));
aBuilder.PushRect(wr::ToWrRect(hook),
wr::ToWrRect(hook),
wr::ToWrColor(color));
}
}
@ -4836,7 +4834,7 @@ nsDisplayBoxShadowOuter::BuildLayer(nsDisplayListBuilder* aBuilder,
}
void
nsDisplayBoxShadowOuter::CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
nsDisplayBoxShadowOuter::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands,
WebRenderDisplayItemLayer* aLayer)
{
@ -4902,17 +4900,15 @@ nsDisplayBoxShadowOuter::CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCo
: 0.0;
float spreadRadius = float(shadow->mSpread) / float(appUnitsPerDevPixel);
aCommands.AppendElement(OpDPPushBoxShadow(
wr::ToWrRect(deviceBoxRect),
wr::ToWrRect(deviceClipRect),
wr::ToWrRect(deviceBoxRect),
wr::ToWrPoint(shadowOffset),
wr::ToWrColor(shadowColor),
blurRadius,
spreadRadius,
borderRadius,
WrBoxShadowClipMode::Outset
));
aBuilder.PushBoxShadow(wr::ToWrRect(deviceBoxRect),
wr::ToWrRect(deviceClipRect),
wr::ToWrRect(deviceBoxRect),
wr::ToWrPoint(shadowOffset),
wr::ToWrColor(shadowColor),
blurRadius,
spreadRadius,
borderRadius,
WrBoxShadowClipMode::Outset);
}
}
}
@ -4990,7 +4986,7 @@ nsDisplayBoxShadowInner::BuildLayer(nsDisplayListBuilder* aBuilder,
}
void
nsDisplayBoxShadowInner::CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
nsDisplayBoxShadowInner::CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands,
WebRenderDisplayItemLayer* aLayer)
{
@ -5037,17 +5033,15 @@ nsDisplayBoxShadowInner::CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCo
// NOTE: Any spread radius > 0 will render nothing. WR Bug.
float spreadRadius = float(shadowItem->mSpread) / float(appUnitsPerDevPixel);
aCommands.AppendElement(OpDPPushBoxShadow(
wr::ToWrRect(deviceBoxRect),
wr::ToWrRect(deviceClipRect),
wr::ToWrRect(deviceBoxRect),
wr::ToWrPoint(shadowOffset),
wr::ToWrColor(shadowColor),
blurRadius,
spreadRadius,
borderRadius,
WrBoxShadowClipMode::Inset
));
aBuilder.PushBoxShadow(wr::ToWrRect(deviceBoxRect),
wr::ToWrRect(deviceClipRect),
wr::ToWrRect(deviceBoxRect),
wr::ToWrPoint(shadowOffset),
wr::ToWrColor(shadowColor),
blurRadius,
spreadRadius,
borderRadius,
WrBoxShadowClipMode::Inset);
}
}
}

View File

@ -62,6 +62,9 @@ class WebRenderCommand;
class WebRenderParentCommand;
class WebRenderDisplayItemLayer;
} // namespace layers
namespace wr {
class DisplayListBuilder;
} // namespace wr
} // namespace mozilla
// A set of blend modes, that never includes OP_OVER (since it's
@ -1927,7 +1930,7 @@ public:
* The layer this item is in is passed in as rects must be relative
* to their parent.
*/
virtual void CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
virtual void CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands,
WebRenderDisplayItemLayer* aLayer) {}
/**
@ -2824,9 +2827,9 @@ public:
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
virtual void CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
virtual void CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands,
WebRenderDisplayItemLayer* aLayer) override;
WebRenderDisplayItemLayer* aLayer) override;
protected:
RefPtr<nsCaret> mCaret;
@ -3387,7 +3390,7 @@ public:
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
virtual void CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
virtual void CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands,
WebRenderDisplayItemLayer* aLayer) override;
@ -3443,7 +3446,7 @@ public:
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
virtual void CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
virtual void CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommand,
WebRenderDisplayItemLayer* aLayer) override;
@ -3472,7 +3475,7 @@ public:
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
virtual void CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
virtual void CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
nsTArray<WebRenderParentCommand>& aParentCommands,
mozilla::layers::WebRenderDisplayItemLayer* aLayer) override;
virtual bool IsInvisibleInRect(const nsRect& aRect) override;