Bug 1379680. Move the displaylist ByteBuf into a Vec instead of copying. r=kats

This eliminates a copy of the displaylist on the compositor thread.
This commit is contained in:
Jeff Muizelaar
2017-11-30 15:12:14 -05:00
parent 0faec56bdb
commit 32a2e8870b
9 changed files with 44 additions and 16 deletions

View File

@@ -353,7 +353,7 @@ AsyncImagePipelineManager::ApplyAsyncImages()
builder.Finalize(builderContentSize, dl);
mApi->SetDisplayList(gfx::Color(0.f, 0.f, 0.f, 0.f), epoch, LayerSize(pipeline->mScBounds.Width(), pipeline->mScBounds.Height()),
pipelineId, builderContentSize,
dl.dl_desc, dl.dl.inner.data, dl.dl.inner.length,
dl.dl_desc, dl.dl,
resourceUpdates);
}
}

View File

@@ -114,6 +114,7 @@ gecko_profiler_unregister_thread()
}
namespace mozilla {
namespace layers {
using namespace mozilla::gfx;
@@ -598,6 +599,9 @@ WebRenderBridgeParent::RecvSetDisplayList(const gfx::IntSize& aSize,
return IPC_FAIL(this, "Failed to deserialize resource updates");
}
wr::Vec_u8 dlData(Move(dl));
// If id namespaces do not match, it means the command is obsolete, probably
// because the tab just moved to a new window.
// In that case do not send the commands to webrender.
@@ -609,7 +613,7 @@ WebRenderBridgeParent::RecvSetDisplayList(const gfx::IntSize& aSize,
gfx::Color clearColor(0.f, 0.f, 0.f, 0.f);
mApi->SetDisplayList(clearColor, wr::NewEpoch(wrEpoch), LayerSize(aSize.width, aSize.height),
mPipelineId, aContentSize,
dlDesc, dl.mData, dl.mLen,
dlDesc, dlData,
resources);
ScheduleGenerateFrame();

View File

@@ -265,8 +265,7 @@ WebRenderAPI::SetDisplayList(gfx::Color aBgColor,
wr::WrPipelineId pipeline_id,
const LayoutSize& content_size,
wr::BuiltDisplayListDescriptor dl_descriptor,
uint8_t *dl_data,
size_t dl_size,
wr::Vec_u8& dl_data,
ResourceUpdateQueue& aResources)
{
wr_api_set_display_list(mDocHandle,
@@ -276,8 +275,7 @@ WebRenderAPI::SetDisplayList(gfx::Color aBgColor,
pipeline_id,
content_size,
dl_descriptor,
dl_data,
dl_size,
&dl_data.inner,
aResources.Raw());
}

View File

@@ -161,8 +161,7 @@ public:
wr::WrPipelineId pipeline_id,
const wr::LayoutSize& content_size,
wr::BuiltDisplayListDescriptor dl_descriptor,
uint8_t *dl_data,
size_t dl_size,
wr::Vec_u8& dl_data,
ResourceUpdateQueue& aResources);
void ClearDisplayList(Epoch aEpoch, wr::WrPipelineId pipeline_id);

View File

@@ -0,0 +1,24 @@
/* -*- 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/. */
#include "WebRenderTypes.h"
#include "mozilla/ipc/ByteBuf.h"
namespace mozilla {
namespace wr {
Vec_u8::Vec_u8(mozilla::ipc::ByteBuf&& aSrc) {
inner.data = aSrc.mData;
inner.length = aSrc.mLen;
inner.capacity = aSrc.mCapacity;
aSrc.mData = nullptr;
aSrc.mLen = 0;
aSrc.mCapacity = 0;
}
} // namespace wr
} // namespace mozilla

View File

@@ -21,6 +21,11 @@
#include "nsStyleConsts.h"
namespace mozilla {
namespace ipc {
class ByteBuf;
} // namespace ipc
namespace wr {
typedef wr::WrWindowId WindowId;
@@ -576,6 +581,8 @@ struct Vec_u8 {
src.SetEmpty();
}
explicit Vec_u8(mozilla::ipc::ByteBuf&& aSrc);
Vec_u8&
operator=(Vec_u8&& src) {
inner = src.inner;

View File

@@ -29,6 +29,7 @@ UNIFIED_SOURCES += [
'RenderTextureHostOGL.cpp',
'RenderThread.cpp',
'WebRenderAPI.cpp',
'WebRenderTypes.cpp',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':

View File

@@ -958,8 +958,7 @@ pub unsafe extern "C" fn wr_api_set_display_list(
pipeline_id: WrPipelineId,
content_size: LayoutSize,
dl_descriptor: BuiltDisplayListDescriptor,
dl_data: *mut u8,
dl_size: usize,
dl_data: &mut WrVecU8,
resources: &mut ResourceUpdates,
) {
let resource_updates = mem::replace(resources, ResourceUpdates::new());
@@ -971,10 +970,7 @@ pub unsafe extern "C" fn wr_api_set_display_list(
// but I suppose it is a good default.
let preserve_frame_state = true;
let dl_slice = make_slice(dl_data, dl_size);
let mut dl_vec = Vec::new();
// XXX: see if we can get rid of the copy here
dl_vec.extend_from_slice(dl_slice);
let dl_vec = dl_data.flush_into_vec();
let dl = BuiltDisplayList::from_data(dl_vec, dl_descriptor);
dh.api.set_display_list(

View File

@@ -1068,8 +1068,7 @@ void wr_api_set_display_list(DocumentHandle *aDh,
WrPipelineId aPipelineId,
LayoutSize aContentSize,
BuiltDisplayListDescriptor aDlDescriptor,
uint8_t *aDlData,
size_t aDlSize,
WrVecU8 *aDlData,
ResourceUpdates *aResources)
WR_FUNC;