Bug 1393031 - Expose webrender transactions at the ipc boundary. r=jrmuizel, r=kanru

This commit is contained in:
Nicolas Silva 2017-09-04 13:59:26 +02:00
Родитель b4671ccb28
Коммит 09e43ac029
15 изменённых файлов: 223 добавлений и 165 удалений

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

@ -47,6 +47,7 @@ parent:
async InitReadLocks(ReadLockInit[] locks);
sync Create(IntSize aSize);
async UpdateResources(ByteBuffer aUpdates);
async AddImage(ImageKey aImageKey, IntSize aSize, uint32_t aStride,
SurfaceFormat aFormat, ByteBuffer aBytes);
async AddBlobImage(ImageKey aImageKey, IntSize aSize, uint32_t aStride,
@ -60,15 +61,18 @@ parent:
async AddFontInstance(FontInstanceKey aInstanceKey, FontKey aFontKey, float aGlyphSize,
MaybeFontInstanceOptions aOptions, MaybeFontInstancePlatformOptions aPlatformOptions);
async DeleteFontInstance(FontInstanceKey aInstanceKey);
async DPBegin(IntSize aSize);
async DPEnd(IntSize aSize, WebRenderParentCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, uint64_t transactionId,
LayoutSize aContentSize, ByteBuffer aDL, BuiltDisplayListDescriptor aDLDesc,
WebRenderScrollData aScrollData, IdNamespace aIdNamespace, TimeStamp txnStartTime, TimeStamp fwdTime);
sync DPSyncEnd(IntSize aSize, WebRenderParentCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, uint64_t transactionId,
LayoutSize aContentSize, ByteBuffer aDL, BuiltDisplayListDescriptor aDLDesc,
WebRenderScrollData aScrollData, IdNamespace aIdNamespace, TimeStamp txnStartTime, TimeStamp fwdTime);
async SetDisplayList(IntSize aSize, WebRenderParentCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, uint64_t transactionId,
LayoutSize aContentSize, ByteBuffer aDL, BuiltDisplayListDescriptor aDLDesc,
WebRenderScrollData aScrollData,
ByteBuffer aResourceUpdates,
IdNamespace aIdNamespace, TimeStamp txnStartTime, TimeStamp fwdTime);
sync SetDisplayListSync(IntSize aSize, WebRenderParentCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, uint64_t transactionId,
LayoutSize aContentSize, ByteBuffer aDL, BuiltDisplayListDescriptor aDLDesc,
WebRenderScrollData aScrollData,
ByteBuffer aResourceUpdates,
IdNamespace aIdNamespace, TimeStamp txnStartTime, TimeStamp fwdTime);
async ParentCommands(WebRenderParentCommand[] commands);
sync DPGetSnapshot(PTexture texture);
sync GetSnapshot(PTexture texture);
async AddPipelineIdForCompositable(PipelineId aImageId, CompositableHandle aHandle, bool aAsync);
async RemovePipelineIdForCompositable(PipelineId aPipelineId);
async AddExternalImageIdForCompositable(ExternalImageId aImageId, CompositableHandle aHandle);

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

@ -71,12 +71,11 @@ WebRenderBridgeChild::AddWebRenderParentCommands(const nsTArray<WebRenderParentC
}
bool
WebRenderBridgeChild::DPBegin(const gfx::IntSize& aSize)
WebRenderBridgeChild::BeginTransaction(const gfx::IntSize& aSize)
{
MOZ_ASSERT(!mDestroyed);
UpdateFwdTransactionId();
this->SendDPBegin(aSize);
mIsInTransaction = true;
mReadLockSequenceNumber = 0;
mReadLocks.AppendElement();
@ -99,12 +98,12 @@ WebRenderBridgeChild::ClearReadLocks()
}
void
WebRenderBridgeChild::DPEnd(wr::DisplayListBuilder &aBuilder,
const gfx::IntSize& aSize,
bool aIsSync,
uint64_t aTransactionId,
const WebRenderScrollData& aScrollData,
const mozilla::TimeStamp& aTxnStartTime)
WebRenderBridgeChild::EndTransaction(wr::DisplayListBuilder &aBuilder,
const gfx::IntSize& aSize,
bool aIsSync,
uint64_t aTransactionId,
const WebRenderScrollData& aScrollData,
const mozilla::TimeStamp& aTxnStartTime)
{
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(mIsInTransaction);
@ -119,12 +118,20 @@ WebRenderBridgeChild::DPEnd(wr::DisplayListBuilder &aBuilder,
fwdTime = TimeStamp::Now();
#endif
// TODO(nical)
wr::ResourceUpdateQueue updates;
wr::ByteBuffer serializedUpdates(Move(updates.Serialize()));
if (aIsSync) {
this->SendDPSyncEnd(aSize, mParentCommands, mDestroyedActors, GetFwdTransactionId(), aTransactionId,
contentSize, dlData, dl.dl_desc, aScrollData, mIdNamespace, aTxnStartTime, fwdTime);
this->SendSetDisplayListSync(aSize, mParentCommands, mDestroyedActors,
GetFwdTransactionId(), aTransactionId,
contentSize, dlData, dl.dl_desc, aScrollData,
serializedUpdates, mIdNamespace, aTxnStartTime, fwdTime);
} else {
this->SendDPEnd(aSize, mParentCommands, mDestroyedActors, GetFwdTransactionId(), aTransactionId,
contentSize, dlData, dl.dl_desc, aScrollData, mIdNamespace, aTxnStartTime, fwdTime);
this->SendSetDisplayList(aSize, mParentCommands, mDestroyedActors,
GetFwdTransactionId(), aTransactionId,
contentSize, dlData, dl.dl_desc, aScrollData,
serializedUpdates, mIdNamespace, aTxnStartTime, fwdTime);
}
mParentCommands.Clear();

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

@ -64,8 +64,8 @@ public:
void AddWebRenderParentCommand(const WebRenderParentCommand& aCmd);
void AddWebRenderParentCommands(const nsTArray<WebRenderParentCommand>& aCommands);
bool DPBegin(const gfx::IntSize& aSize);
void DPEnd(wr::DisplayListBuilder &aBuilder, const gfx::IntSize& aSize,
bool BeginTransaction(const gfx::IntSize& aSize);
void EndTransaction(wr::DisplayListBuilder &aBuilder, const gfx::IntSize& aSize,
bool aIsSync, uint64_t aTransactionId,
const WebRenderScrollData& aScrollData,
const mozilla::TimeStamp& aTxnStartTime);

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

@ -222,6 +222,13 @@ WebRenderBridgeParent::Destroy()
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvUpdateResources(const wr::ByteBuffer& aUpdates)
{
wr::ResourceUpdateQueue updates = wr::ResourceUpdateQueue::Deserialize(aUpdates.AsSlice());
mApi->UpdateResources(updates);
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvAddImage(const wr::ImageKey& aImageKey,
const gfx::IntSize& aSize,
const uint32_t& aStride,
@ -408,60 +415,6 @@ WebRenderBridgeParent::RecvDeleteCompositorAnimations(InfallibleTArray<uint64_t>
return IPC_OK();
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvDPBegin(const gfx::IntSize& aSize)
{
if (mDestroyed) {
return IPC_OK();
}
return IPC_OK();
}
void
WebRenderBridgeParent::HandleDPEnd(const gfx::IntSize& aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime)
{
AutoProfilerTracing tracing("Paint", "DPTransaction");
UpdateFwdTransactionId(aFwdTransactionId);
AutoClearReadLocks clearLocks(mReadLocks);
if (mDestroyed) {
for (const auto& op : aToDestroy) {
DestroyActor(op);
}
return;
}
// This ensures that destroy operations are always processed. It is not safe
// to early-return from RecvDPEnd without doing so.
AutoWebRenderBridgeParentAsyncMessageSender autoAsyncMessageSender(this, &aToDestroy);
uint32_t wrEpoch = GetNextWrEpoch();
ProcessWebRenderCommands(aSize, aCommands, wr::NewEpoch(wrEpoch),
aContentSize, dl, dlDesc, aIdNamespace);
HoldPendingTransactionId(wrEpoch, aTransactionId, aTxnStartTime, aFwdTime);
mScrollData = aScrollData;
UpdateAPZ();
if (mIdNamespace != aIdNamespace) {
// Pretend we composited since someone is wating for this event,
// though DisplayList was not pushed to webrender.
TimeStamp now = TimeStamp::Now();
mCompositorBridge->DidComposite(wr::AsUint64(mPipelineId), now, now);
}
}
CompositorBridgeParent*
WebRenderBridgeParent::GetRootCompositorBridgeParent() const
{
@ -536,47 +489,73 @@ WebRenderBridgeParent::GetScrollData() const
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvDPEnd(const gfx::IntSize& aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime)
WebRenderBridgeParent::RecvSetDisplayList(const gfx::IntSize& aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::ByteBuffer& aResourceUpdates,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime)
{
if (mDestroyed) {
for (const auto& op : aToDestroy) {
DestroyActor(op);
}
return IPC_OK();
}
HandleDPEnd(aSize, Move(aCommands), Move(aToDestroy), aFwdTransactionId, aTransactionId,
aContentSize, dl, dlDesc, aScrollData, aIdNamespace, aTxnStartTime, aFwdTime);
AutoProfilerTracing tracing("Paint", "SetDisplayList");
UpdateFwdTransactionId(aFwdTransactionId);
AutoClearReadLocks clearLocks(mReadLocks);
// This ensures that destroy operations are always processed. It is not safe
// to early-return from RecvDPEnd without doing so.
AutoWebRenderBridgeParentAsyncMessageSender autoAsyncMessageSender(this, &aToDestroy);
wr::ResourceUpdateQueue resources = wr::ResourceUpdateQueue::Deserialize(aResourceUpdates.AsSlice());
uint32_t wrEpoch = GetNextWrEpoch();
ProcessWebRenderCommands(aSize, aCommands, wr::NewEpoch(wrEpoch),
aContentSize, dl, dlDesc, resources, aIdNamespace);
HoldPendingTransactionId(wrEpoch, aTransactionId, aTxnStartTime, aFwdTime);
mScrollData = aScrollData;
UpdateAPZ();
if (mIdNamespace != aIdNamespace) {
// Pretend we composited since someone is wating for this event,
// though DisplayList was not pushed to webrender.
TimeStamp now = TimeStamp::Now();
mCompositorBridge->DidComposite(wr::AsUint64(mPipelineId), now, now);
}
return IPC_OK();
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvDPSyncEnd(const gfx::IntSize &aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime)
WebRenderBridgeParent::RecvSetDisplayListSync(const gfx::IntSize &aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::ByteBuffer& aResourceUpdates,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime)
{
if (mDestroyed) {
return IPC_OK();
}
HandleDPEnd(aSize, Move(aCommands), Move(aToDestroy), aFwdTransactionId, aTransactionId,
aContentSize, dl, dlDesc, aScrollData, aIdNamespace, aTxnStartTime, aFwdTime);
return IPC_OK();
return RecvSetDisplayList(aSize, Move(aCommands), Move(aToDestroy), aFwdTransactionId, aTransactionId,
aContentSize, dl, dlDesc, aScrollData, aResourceUpdates,
aIdNamespace, aTxnStartTime, aFwdTime);
}
mozilla::ipc::IPCResult
@ -688,6 +667,7 @@ WebRenderBridgeParent::ProcessWebRenderCommands(const gfx::IntSize &aSize,
InfallibleTArray<WebRenderParentCommand>& aCommands, const wr::Epoch& aEpoch,
const wr::LayoutSize& aContentSize, const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
wr::ResourceUpdateQueue& aResourceUpdates,
const wr::IdNamespace& aIdNamespace)
{
mAsyncImageManager->SetCompositionTime(TimeStamp::Now());
@ -706,7 +686,8 @@ WebRenderBridgeParent::ProcessWebRenderCommands(const gfx::IntSize &aSize,
gfx::Color color = mWidget ? gfx::Color(0.3f, 0.f, 0.f, 1.f) : gfx::Color(0.f, 0.f, 0.f, 0.f);
mApi->SetDisplayList(color, aEpoch, LayerSize(aSize.width, aSize.height),
mPipelineId, aContentSize,
dlDesc, dl.mData, dl.mLength);
dlDesc, dl.mData, dl.mLength,
&aResourceUpdates);
ScheduleComposition();
DeleteOldImages();
@ -717,7 +698,7 @@ WebRenderBridgeParent::ProcessWebRenderCommands(const gfx::IntSize &aSize,
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvDPGetSnapshot(PTextureParent* aTexture)
WebRenderBridgeParent::RecvGetSnapshot(PTextureParent* aTexture)
{
if (mDestroyed) {
return IPC_OK();

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

@ -72,6 +72,7 @@ public:
mozilla::ipc::IPCResult RecvCreate(const gfx::IntSize& aSize) override;
mozilla::ipc::IPCResult RecvShutdown() override;
mozilla::ipc::IPCResult RecvShutdownSync() override;
mozilla::ipc::IPCResult RecvUpdateResources(const wr::ByteBuffer& aUpdates) override;
mozilla::ipc::IPCResult RecvAddImage(const wr::ImageKey& aImageKey,
const gfx::IntSize& aSize,
const uint32_t& aStride,
@ -98,33 +99,34 @@ public:
const MaybeFontInstanceOptions& aOptions,
const MaybeFontInstancePlatformOptions& aPlatformOptions) override;
mozilla::ipc::IPCResult RecvDeleteFontInstance(const wr::FontInstanceKey& aInstanceKey) override;
mozilla::ipc::IPCResult RecvDPBegin(const gfx::IntSize& aSize) override;
mozilla::ipc::IPCResult RecvDPEnd(const gfx::IntSize& aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime) override;
mozilla::ipc::IPCResult RecvDPSyncEnd(const gfx::IntSize& aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime) override;
mozilla::ipc::IPCResult RecvSetDisplayList(const gfx::IntSize& aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::ByteBuffer& aResourceUpdates,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime) override;
mozilla::ipc::IPCResult RecvSetDisplayListSync(const gfx::IntSize& aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::ByteBuffer& aResourceUpdates,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime) override;
mozilla::ipc::IPCResult RecvParentCommands(nsTArray<WebRenderParentCommand>&& commands) override;
mozilla::ipc::IPCResult RecvDPGetSnapshot(PTextureParent* aTexture) override;
mozilla::ipc::IPCResult RecvGetSnapshot(PTextureParent* aTexture) override;
mozilla::ipc::IPCResult RecvAddPipelineIdForCompositable(const wr::PipelineId& aPipelineIds,
const CompositableHandle& aHandle,
@ -216,22 +218,11 @@ private:
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
wr::ResourceUpdateQueue& aResourceUpdates,
const wr::IdNamespace& aIdNamespace);
void ClearResources();
uint64_t GetChildLayerObserverEpoch() const { return mChildLayerObserverEpoch; }
bool ShouldParentObserveEpoch();
void HandleDPEnd(const gfx::IntSize& aSize,
InfallibleTArray<WebRenderParentCommand>&& aCommands,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const wr::IdNamespace& aIdNamespace,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime);
mozilla::ipc::IPCResult HandleShutdown();
void AdvanceAnimations();

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

@ -699,7 +699,7 @@ WebRenderLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback
mAnimationReadyTime = TimeStamp::Now();
LayoutDeviceIntSize size = mWidget->GetClientSize();
if (!WrBridge()->DPBegin(size.ToUnknownSize())) {
if (!WrBridge()->BeginTransaction(size.ToUnknownSize())) {
return false;
}
DiscardCompositorAnimations();
@ -815,7 +815,8 @@ WebRenderLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback
{
AutoProfilerTracing
tracing("Paint", sync ? "ForwardDPTransactionSync":"ForwardDPTransaction");
WrBridge()->DPEnd(builder, size.ToUnknownSize(), sync, mLatestTransactionId, mScrollData, transactionStart);
WrBridge()->EndTransaction(builder, size.ToUnknownSize(), sync,
mLatestTransactionId, mScrollData, transactionStart);
}
MakeSnapshotIfRequired(size);
@ -870,7 +871,7 @@ WebRenderLayerManager::MakeSnapshotIfRequired(LayoutDeviceIntSize aSize)
}
IntRect bounds = ToOutsideIntRect(mTarget->GetClipExtents());
if (!WrBridge()->SendDPGetSnapshot(texture->GetIPDLActor())) {
if (!WrBridge()->SendGetSnapshot(texture->GetIPDLActor())) {
return;
}

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

@ -6,6 +6,7 @@ license = "MPL-2.0"
[dependencies]
webrender_api = {path = "../webrender_api", version = "0.50.0"}
bincode = "0.8"
rayon = "0.8"
thread_profiler = "0.1.1"
euclid = "0.15"

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

@ -235,18 +235,26 @@ WebRenderAPI::SetDisplayList(gfx::Color aBgColor,
const LayoutSize& content_size,
wr::BuiltDisplayListDescriptor dl_descriptor,
uint8_t *dl_data,
size_t dl_size)
size_t dl_size,
ResourceUpdateQueue* aResources)
{
wr_api_set_display_list(mDocHandle,
ToColorF(aBgColor),
aEpoch,
aViewportSize.width, aViewportSize.height,
pipeline_id,
content_size,
dl_descriptor,
dl_data,
dl_size,
mResources.Raw());
ResourceUpdateQueue* resources = aResources ? aResources : &mResources;
if (aResources) {
// TODO(nical) properly separate ResourceUpdateQueue from the api object.
// In the mean time, it makes sense to flush mResources it has updates
// and we pass another resource update queue.
UpdateResources(mResources);
}
wr_api_set_display_list(mDocHandle,
ToColorF(aBgColor),
aEpoch,
aViewportSize.width, aViewportSize.height,
pipeline_id,
content_size,
dl_descriptor,
dl_data,
dl_size,
resources->Raw());
}
void
@ -456,6 +464,24 @@ ResourceUpdateQueue::~ResourceUpdateQueue()
}
}
ByteBuffer
ResourceUpdateQueue::Serialize()
{
VecU8 data;
wr_resource_updates_serialize(mUpdates, &data);
ByteBuffer result(Move(data));
return result;
}
//static
ResourceUpdateQueue
ResourceUpdateQueue::Deserialize(Range<uint8_t> aData)
{
auto slice = wr::RangeToByteSlice(aData);
ResourceUpdateQueue result(wr_resource_updates_deserialize(slice));
return result;
}
void
ResourceUpdateQueue::AddImage(ImageKey key, const ImageDescriptor& aDescriptor,
Range<uint8_t> aBytes)

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

@ -59,6 +59,11 @@ public:
ResourceUpdateQueue& operator=(ResourceUpdateQueue&&);
ResourceUpdateQueue& operator=(const ResourceUpdateQueue&) = delete;
/// Serializes into a buffer of bytes and clears the queue.
ByteBuffer Serialize();
static ResourceUpdateQueue Deserialize(Range<uint8_t> aData);
void AddImage(wr::ImageKey aKey,
const ImageDescriptor& aDescriptor,
Range<uint8_t> aBytes);
@ -109,6 +114,9 @@ public:
wr::ResourceUpdates* Raw() { return mUpdates; }
protected:
ResourceUpdateQueue(wr::ResourceUpdates* aUpdates)
: mUpdates(aUpdates) {}
wr::ResourceUpdates* mUpdates;
};
@ -143,7 +151,8 @@ public:
const wr::LayoutSize& content_size,
wr::BuiltDisplayListDescriptor dl_descriptor,
uint8_t *dl_data,
size_t dl_size);
size_t dl_size,
ResourceUpdateQueue* aResources = nullptr);
void ClearDisplayList(Epoch aEpoch, wr::WrPipelineId pipeline_id);

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

@ -587,6 +587,16 @@ struct ByteBuffer
}
}
ByteBuffer(ByteBuffer&& aFrom)
: mLength(aFrom.mLength)
, mData(aFrom.mData)
, mOwned(aFrom.mOwned)
{
aFrom.mLength = 0;
aFrom.mData = nullptr;
aFrom.mOwned = false;
}
ByteBuffer()
: mLength(0)
, mData(nullptr)

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

@ -15,6 +15,7 @@ use moz2d_renderer::Moz2dImageRenderer;
use app_units::Au;
use rayon;
use euclid::SideOffsets2D;
use bincode;
extern crate webrender_api;
@ -964,6 +965,22 @@ pub extern "C" fn wr_resource_updates_delete(updates: *mut ResourceUpdates) {
}
}
#[no_mangle]
pub extern "C" fn wr_resource_updates_serialize(resources: &mut ResourceUpdates, into: &mut VecU8) {
let mut data = Vec::new();
bincode::serialize_into(&mut data, &resources.updates, bincode::Infinite).unwrap();
resources.updates.clear();
*into = data;
}
#[no_mangle]
pub extern "C" fn wr_resource_updates_deserialize(data: ByteSlice) -> *mut ResourceUpdates {
let resources: Box<ResourceUpdates> = Box::new(
bincode::deserialize_from(&mut data.as_slice(), bincode::Infinite).expect("Invalid wr::ResourceUpdate serialization?")
);
Box::into_raw(resources)
}
#[no_mangle]
pub unsafe extern "C" fn wr_api_get_namespace(dh: &mut DocumentHandle) -> WrIdNamespace {
dh.api.get_namespace_id()

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

@ -11,6 +11,7 @@ extern crate app_units;
extern crate gleam;
extern crate rayon;
extern crate thread_profiler;
extern crate bincode;
#[allow(non_snake_case)]
pub mod bindings;

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

@ -1224,10 +1224,19 @@ void wr_resource_updates_delete_image(ResourceUpdates *aResources,
WrImageKey aKey)
WR_FUNC;
WR_INLINE
ResourceUpdates *wr_resource_updates_deserialize(ByteSlice aData)
WR_FUNC;
WR_INLINE
ResourceUpdates *wr_resource_updates_new()
WR_FUNC;
WR_INLINE
void wr_resource_updates_serialize(ResourceUpdates *aResources,
VecU8 *aInto)
WR_FUNC;
WR_INLINE
void wr_resource_updates_update_blob_image(ResourceUpdates *aResources,
WrImageKey aImageKey,

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

@ -1027,9 +1027,9 @@ description =
description =
[PWebRenderBridge::Create]
description =
[PWebRenderBridge::DPSyncEnd]
[PWebRenderBridge::SetDisplayListSync]
description =
[PWebRenderBridge::DPGetSnapshot]
[PWebRenderBridge::GetSnapshot]
description =
[PWebRenderBridge::SetTestSampleTime]
description = test only

1
toolkit/library/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -1500,6 +1500,7 @@ name = "webrender_bindings"
version = "0.1.0"
dependencies = [
"app_units 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",