Bug 1463416 - Update for API changes in WR PR 2718. r=nical

MozReview-Commit-ID: Ct8krYkLfHL

--HG--
extra : rebase_source : ed01919ad38b66d485ae395621167e059f4ec6d8
This commit is contained in:
Kartikaya Gupta 2018-05-26 11:09:21 -04:00
parent 29f53043e5
commit 0e92bc1c16
4 changed files with 52 additions and 95 deletions

View File

@ -137,13 +137,11 @@ TransactionBuilder::TransactionBuilder(bool aUseSceneBuilderThread)
: mUseSceneBuilderThread(gfxPrefs::WebRenderAsyncSceneBuild() && aUseSceneBuilderThread)
{
mTxn = wr_transaction_new(mUseSceneBuilderThread);
mResourceUpdates = wr_resource_updates_new();
}
TransactionBuilder::~TransactionBuilder()
{
wr_transaction_delete(mTxn);
wr_resource_updates_delete(mResourceUpdates);
}
void
@ -350,7 +348,6 @@ WebRenderAPI::~WebRenderAPI()
void
WebRenderAPI::SendTransaction(TransactionBuilder& aTxn)
{
wr_transaction_update_resources(aTxn.Raw(), aTxn.RawUpdates());
wr_api_send_transaction(mDocHandle, aTxn.Raw(), aTxn.UseSceneBuilderThread());
}
@ -548,14 +545,14 @@ WebRenderAPI::Capture()
void
TransactionBuilder::Clear()
{
wr_resource_updates_clear(mResourceUpdates);
wr_resource_updates_clear(mTxn);
}
void
TransactionBuilder::AddImage(ImageKey key, const ImageDescriptor& aDescriptor,
wr::Vec<uint8_t>& aBytes)
{
wr_resource_updates_add_image(mResourceUpdates,
wr_resource_updates_add_image(mTxn,
key,
&aDescriptor,
&aBytes.inner);
@ -565,7 +562,7 @@ void
TransactionBuilder::AddBlobImage(ImageKey key, const ImageDescriptor& aDescriptor,
wr::Vec<uint8_t>& aBytes)
{
wr_resource_updates_add_blob_image(mResourceUpdates,
wr_resource_updates_add_blob_image(mTxn,
key,
&aDescriptor,
&aBytes.inner);
@ -578,7 +575,7 @@ TransactionBuilder::AddExternalImage(ImageKey key,
wr::WrExternalImageBufferType aBufferType,
uint8_t aChannelIndex)
{
wr_resource_updates_add_external_image(mResourceUpdates,
wr_resource_updates_add_external_image(mTxn,
key,
&aDescriptor,
aExtID,
@ -602,7 +599,7 @@ TransactionBuilder::UpdateImageBuffer(ImageKey aKey,
const ImageDescriptor& aDescriptor,
wr::Vec<uint8_t>& aBytes)
{
wr_resource_updates_update_image(mResourceUpdates,
wr_resource_updates_update_image(mTxn,
aKey,
&aDescriptor,
&aBytes.inner);
@ -614,7 +611,7 @@ TransactionBuilder::UpdateBlobImage(ImageKey aKey,
wr::Vec<uint8_t>& aBytes,
const wr::DeviceUintRect& aDirtyRect)
{
wr_resource_updates_update_blob_image(mResourceUpdates,
wr_resource_updates_update_blob_image(mTxn,
aKey,
&aDescriptor,
&aBytes.inner,
@ -628,7 +625,7 @@ TransactionBuilder::UpdateExternalImage(ImageKey aKey,
wr::WrExternalImageBufferType aBufferType,
uint8_t aChannelIndex)
{
wr_resource_updates_update_external_image(mResourceUpdates,
wr_resource_updates_update_external_image(mTxn,
aKey,
&aDescriptor,
aExtID,
@ -639,25 +636,25 @@ TransactionBuilder::UpdateExternalImage(ImageKey aKey,
void
TransactionBuilder::DeleteImage(ImageKey aKey)
{
wr_resource_updates_delete_image(mResourceUpdates, aKey);
wr_resource_updates_delete_image(mTxn, aKey);
}
void
TransactionBuilder::AddRawFont(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes, uint32_t aIndex)
{
wr_resource_updates_add_raw_font(mResourceUpdates, aKey, &aBytes.inner, aIndex);
wr_resource_updates_add_raw_font(mTxn, aKey, &aBytes.inner, aIndex);
}
void
TransactionBuilder::AddFontDescriptor(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes, uint32_t aIndex)
{
wr_resource_updates_add_font_descriptor(mResourceUpdates, aKey, &aBytes.inner, aIndex);
wr_resource_updates_add_font_descriptor(mTxn, aKey, &aBytes.inner, aIndex);
}
void
TransactionBuilder::DeleteFont(wr::FontKey aKey)
{
wr_resource_updates_delete_font(mResourceUpdates, aKey);
wr_resource_updates_delete_font(mTxn, aKey);
}
void
@ -668,7 +665,7 @@ TransactionBuilder::AddFontInstance(wr::FontInstanceKey aKey,
const wr::FontInstancePlatformOptions* aPlatformOptions,
wr::Vec<uint8_t>& aVariations)
{
wr_resource_updates_add_font_instance(mResourceUpdates, aKey, aFontKey, aGlyphSize,
wr_resource_updates_add_font_instance(mTxn, aKey, aFontKey, aGlyphSize,
aOptions, aPlatformOptions,
&aVariations.inner);
}
@ -676,7 +673,7 @@ TransactionBuilder::AddFontInstance(wr::FontInstanceKey aKey,
void
TransactionBuilder::DeleteFontInstance(wr::FontInstanceKey aKey)
{
wr_resource_updates_delete_font_instance(mResourceUpdates, aKey);
wr_resource_updates_delete_font_instance(mTxn, aKey);
}
class FrameStartTime : public RendererEvent

View File

@ -139,11 +139,9 @@ public:
bool UseSceneBuilderThread() const { return mUseSceneBuilderThread; }
Transaction* Raw() { return mTxn; }
wr::ResourceUpdates* RawUpdates() { return mResourceUpdates; }
protected:
bool mUseSceneBuilderThread;
Transaction* mTxn;
wr::ResourceUpdates* mResourceUpdates;
};
class TransactionWrapper

View File

@ -1071,17 +1071,6 @@ pub extern "C" fn wr_transaction_set_display_list(
);
}
#[no_mangle]
pub extern "C" fn wr_transaction_update_resources(
txn: &mut Transaction,
resource_updates: &mut ResourceUpdates
) {
if resource_updates.updates.is_empty() {
return;
}
txn.update_resources(mem::replace(resource_updates, ResourceUpdates::new()));
}
#[no_mangle]
pub extern "C" fn wr_transaction_set_window_parameters(
txn: &mut Transaction,
@ -1183,12 +1172,12 @@ pub extern "C" fn wr_transaction_scroll_layer(
#[no_mangle]
pub extern "C" fn wr_resource_updates_add_image(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
image_key: WrImageKey,
descriptor: &WrImageDescriptor,
bytes: &mut WrVecU8,
) {
resources.add_image(
txn.add_image(
image_key,
descriptor.into(),
ImageData::new(bytes.flush_into_vec()),
@ -1198,12 +1187,12 @@ pub extern "C" fn wr_resource_updates_add_image(
#[no_mangle]
pub extern "C" fn wr_resource_updates_add_blob_image(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
image_key: WrImageKey,
descriptor: &WrImageDescriptor,
bytes: &mut WrVecU8,
) {
resources.add_image(
txn.add_image(
image_key,
descriptor.into(),
ImageData::new_blob_image(bytes.flush_into_vec()),
@ -1213,14 +1202,14 @@ pub extern "C" fn wr_resource_updates_add_blob_image(
#[no_mangle]
pub extern "C" fn wr_resource_updates_add_external_image(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
image_key: WrImageKey,
descriptor: &WrImageDescriptor,
external_image_id: WrExternalImageId,
buffer_type: WrExternalImageBufferType,
channel_index: u8
) {
resources.add_image(
txn.add_image(
image_key,
descriptor.into(),
ImageData::External(
@ -1236,12 +1225,12 @@ pub extern "C" fn wr_resource_updates_add_external_image(
#[no_mangle]
pub extern "C" fn wr_resource_updates_update_image(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
key: WrImageKey,
descriptor: &WrImageDescriptor,
bytes: &mut WrVecU8,
) {
resources.update_image(
txn.update_image(
key,
descriptor.into(),
ImageData::new(bytes.flush_into_vec()),
@ -1251,14 +1240,14 @@ pub extern "C" fn wr_resource_updates_update_image(
#[no_mangle]
pub extern "C" fn wr_resource_updates_update_external_image(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
key: WrImageKey,
descriptor: &WrImageDescriptor,
external_image_id: WrExternalImageId,
image_type: WrExternalImageBufferType,
channel_index: u8
) {
resources.update_image(
txn.update_image(
key,
descriptor.into(),
ImageData::External(
@ -1274,13 +1263,13 @@ pub extern "C" fn wr_resource_updates_update_external_image(
#[no_mangle]
pub extern "C" fn wr_resource_updates_update_blob_image(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
image_key: WrImageKey,
descriptor: &WrImageDescriptor,
bytes: &mut WrVecU8,
dirty_rect: DeviceUintRect,
) {
resources.update_image(
txn.update_image(
image_key,
descriptor.into(),
ImageData::new_blob_image(bytes.flush_into_vec()),
@ -1290,10 +1279,10 @@ pub extern "C" fn wr_resource_updates_update_blob_image(
#[no_mangle]
pub extern "C" fn wr_resource_updates_delete_image(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
key: WrImageKey
) {
resources.delete_image(key);
txn.delete_image(key);
}
#[no_mangle]
@ -1339,12 +1328,12 @@ pub extern "C" fn wr_api_send_external_event(dh: &mut DocumentHandle,
#[no_mangle]
pub extern "C" fn wr_resource_updates_add_raw_font(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
key: WrFontKey,
bytes: &mut WrVecU8,
index: u32
) {
resources.add_raw_font(key, bytes.flush_into_vec(), index);
txn.add_raw_font(key, bytes.flush_into_vec(), index);
}
#[no_mangle]
@ -1414,26 +1403,26 @@ fn read_font_descriptor(
#[no_mangle]
pub extern "C" fn wr_resource_updates_add_font_descriptor(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
key: WrFontKey,
bytes: &mut WrVecU8,
index: u32
) {
let native_font_handle = read_font_descriptor(bytes, index);
resources.add_native_font(key, native_font_handle);
txn.add_native_font(key, native_font_handle);
}
#[no_mangle]
pub extern "C" fn wr_resource_updates_delete_font(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
key: WrFontKey
) {
resources.delete_font(key);
txn.delete_font(key);
}
#[no_mangle]
pub extern "C" fn wr_resource_updates_add_font_instance(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
key: WrFontInstanceKey,
font_key: WrFontKey,
glyph_size: f32,
@ -1441,7 +1430,7 @@ pub extern "C" fn wr_resource_updates_add_font_instance(
platform_options: *const FontInstancePlatformOptions,
variations: &mut WrVecU8,
) {
resources.add_font_instance(
txn.add_font_instance(
key,
font_key,
Au::from_f32_px(glyph_size),
@ -1453,29 +1442,15 @@ pub extern "C" fn wr_resource_updates_add_font_instance(
#[no_mangle]
pub extern "C" fn wr_resource_updates_delete_font_instance(
resources: &mut ResourceUpdates,
txn: &mut Transaction,
key: WrFontInstanceKey
) {
resources.delete_font_instance(key);
txn.delete_font_instance(key);
}
#[no_mangle]
pub extern "C" fn wr_resource_updates_new() -> *mut ResourceUpdates {
let updates = Box::new(ResourceUpdates::new());
Box::into_raw(updates)
}
#[no_mangle]
pub extern "C" fn wr_resource_updates_clear(resources: &mut ResourceUpdates) {
resources.updates.clear();
}
/// cbindgen:postfix=WR_DESTRUCTOR_SAFE_FUNC
#[no_mangle]
pub extern "C" fn wr_resource_updates_delete(updates: *mut ResourceUpdates) {
unsafe {
Box::from_raw(updates);
}
pub extern "C" fn wr_resource_updates_clear(txn: &mut Transaction) {
txn.resource_updates.clear();
}
#[no_mangle]

View File

@ -1479,14 +1479,14 @@ void wr_renderer_update_program_cache(Renderer *aRenderer,
WR_FUNC;
WR_INLINE
void wr_resource_updates_add_blob_image(ResourceUpdates *aResources,
void wr_resource_updates_add_blob_image(Transaction *aTxn,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrVecU8 *aBytes)
WR_FUNC;
WR_INLINE
void wr_resource_updates_add_external_image(ResourceUpdates *aResources,
void wr_resource_updates_add_external_image(Transaction *aTxn,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrExternalImageId aExternalImageId,
@ -1495,14 +1495,14 @@ void wr_resource_updates_add_external_image(ResourceUpdates *aResources,
WR_FUNC;
WR_INLINE
void wr_resource_updates_add_font_descriptor(ResourceUpdates *aResources,
void wr_resource_updates_add_font_descriptor(Transaction *aTxn,
WrFontKey aKey,
WrVecU8 *aBytes,
uint32_t aIndex)
WR_FUNC;
WR_INLINE
void wr_resource_updates_add_font_instance(ResourceUpdates *aResources,
void wr_resource_updates_add_font_instance(Transaction *aTxn,
WrFontInstanceKey aKey,
WrFontKey aFontKey,
float aGlyphSize,
@ -1512,48 +1512,40 @@ void wr_resource_updates_add_font_instance(ResourceUpdates *aResources,
WR_FUNC;
WR_INLINE
void wr_resource_updates_add_image(ResourceUpdates *aResources,
void wr_resource_updates_add_image(Transaction *aTxn,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrVecU8 *aBytes)
WR_FUNC;
WR_INLINE
void wr_resource_updates_add_raw_font(ResourceUpdates *aResources,
void wr_resource_updates_add_raw_font(Transaction *aTxn,
WrFontKey aKey,
WrVecU8 *aBytes,
uint32_t aIndex)
WR_FUNC;
WR_INLINE
void wr_resource_updates_clear(ResourceUpdates *aResources)
void wr_resource_updates_clear(Transaction *aTxn)
WR_FUNC;
WR_INLINE
void wr_resource_updates_delete(ResourceUpdates *aUpdates)
WR_DESTRUCTOR_SAFE_FUNC;
WR_INLINE
void wr_resource_updates_delete_font(ResourceUpdates *aResources,
void wr_resource_updates_delete_font(Transaction *aTxn,
WrFontKey aKey)
WR_FUNC;
WR_INLINE
void wr_resource_updates_delete_font_instance(ResourceUpdates *aResources,
void wr_resource_updates_delete_font_instance(Transaction *aTxn,
WrFontInstanceKey aKey)
WR_FUNC;
WR_INLINE
void wr_resource_updates_delete_image(ResourceUpdates *aResources,
void wr_resource_updates_delete_image(Transaction *aTxn,
WrImageKey aKey)
WR_FUNC;
WR_INLINE
ResourceUpdates *wr_resource_updates_new()
WR_FUNC;
WR_INLINE
void wr_resource_updates_update_blob_image(ResourceUpdates *aResources,
void wr_resource_updates_update_blob_image(Transaction *aTxn,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrVecU8 *aBytes,
@ -1561,7 +1553,7 @@ void wr_resource_updates_update_blob_image(ResourceUpdates *aResources,
WR_FUNC;
WR_INLINE
void wr_resource_updates_update_external_image(ResourceUpdates *aResources,
void wr_resource_updates_update_external_image(Transaction *aTxn,
WrImageKey aKey,
const WrImageDescriptor *aDescriptor,
WrExternalImageId aExternalImageId,
@ -1570,7 +1562,7 @@ void wr_resource_updates_update_external_image(ResourceUpdates *aResources,
WR_FUNC;
WR_INLINE
void wr_resource_updates_update_image(ResourceUpdates *aResources,
void wr_resource_updates_update_image(Transaction *aTxn,
WrImageKey aKey,
const WrImageDescriptor *aDescriptor,
WrVecU8 *aBytes)
@ -1683,11 +1675,6 @@ void wr_transaction_update_epoch(Transaction *aTxn,
WrEpoch aEpoch)
WR_FUNC;
WR_INLINE
void wr_transaction_update_resources(Transaction *aTxn,
ResourceUpdates *aResourceUpdates)
WR_FUNC;
WR_INLINE
void wr_vec_u8_free(WrVecU8 aV)
WR_FUNC;