зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1477819 - Expose Transaction::Notify in WebRender's C++ wrapper. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D6515 --HG-- extra : source : 8d58404d71eb944d9dda642c8dc2f53f1d291671 extra : histedit_source : f469b56422dadfe5a5f67faa9e9efddd5839d1ce
This commit is contained in:
Родитель
d1c216b95e
Коммит
924db561d6
|
@ -588,6 +588,11 @@ TransactionBuilder::Clear()
|
|||
wr_resource_updates_clear(mTxn);
|
||||
}
|
||||
|
||||
void
|
||||
TransactionBuilder::Notify(wr::Checkpoint aWhen, UniquePtr<NotificationHandler> aEvent) {
|
||||
wr_transaction_notify(mTxn, aWhen, reinterpret_cast<uintptr_t>(aEvent.release()));
|
||||
}
|
||||
|
||||
void
|
||||
TransactionBuilder::AddImage(ImageKey key, const ImageDescriptor& aDescriptor,
|
||||
wr::Vec<uint8_t>& aBytes)
|
||||
|
@ -1359,3 +1364,15 @@ DisplayListBuilder::FixedPosScrollTargetTracker::GetScrollTargetForASR(const Act
|
|||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
||||
|
||||
extern "C" {
|
||||
|
||||
void wr_transaction_notification_notified(uintptr_t aHandler, mozilla::wr::Checkpoint aWhen) {
|
||||
auto handler = reinterpret_cast<mozilla::wr::NotificationHandler*>(aHandler);
|
||||
handler->Notify(aWhen);
|
||||
// TODO: it would be better to get a callback when the object is destroyed on the
|
||||
// rust side and delete then.
|
||||
delete handler;
|
||||
}
|
||||
|
||||
} // extern C
|
||||
|
|
|
@ -50,6 +50,18 @@ struct Line {
|
|||
wr::LineStyle style;
|
||||
};
|
||||
|
||||
/// A handler that can be bundled into a transaction and notified at specific
|
||||
/// points in the rendering pipeline, such as after scene building or after
|
||||
/// frame building.
|
||||
///
|
||||
/// If for any reason the handler is dropped before reaching the requested
|
||||
/// point, it is notified with the value Checkpoint::TransactionDropped.
|
||||
/// So it is safe to assume that the handler will be notified "at some point".
|
||||
class NotificationHandler {
|
||||
public:
|
||||
virtual void Notify(wr::Checkpoint aCheckpoint) = 0;
|
||||
virtual ~NotificationHandler() = default;
|
||||
};
|
||||
|
||||
class TransactionBuilder {
|
||||
public:
|
||||
|
@ -148,6 +160,8 @@ public:
|
|||
|
||||
void DeleteFontInstance(wr::FontInstanceKey aKey);
|
||||
|
||||
void Notify(wr::Checkpoint aWhen, UniquePtr<NotificationHandler> aHandler);
|
||||
|
||||
void Clear();
|
||||
|
||||
bool UseSceneBuilderThread() const { return mUseSceneBuilderThread; }
|
||||
|
|
|
@ -504,6 +504,8 @@ extern "C" {
|
|||
fn wr_notifier_external_event(window_id: WrWindowId,
|
||||
raw_event: usize);
|
||||
fn wr_schedule_render(window_id: WrWindowId);
|
||||
|
||||
fn wr_transaction_notification_notified(handler: usize, when: Checkpoint);
|
||||
}
|
||||
|
||||
impl RenderNotifier for CppNotifier {
|
||||
|
@ -1097,6 +1099,21 @@ pub extern "C" fn wr_transaction_is_empty(txn: &Transaction) -> bool {
|
|||
txn.is_empty()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_transaction_notify(txn: &mut Transaction, when: Checkpoint, event: usize) {
|
||||
struct GeckoNotification(usize);
|
||||
impl NotificationHandler for GeckoNotification {
|
||||
fn notify(&self, when: Checkpoint) {
|
||||
unsafe {
|
||||
wr_transaction_notification_notified(self.0, when);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let handler = Arc::new(GeckoNotification(event));
|
||||
txn.notify(NotificationRequest::new(when, handler));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_transaction_update_epoch(
|
||||
txn: &mut Transaction,
|
||||
|
|
|
@ -43,6 +43,16 @@ enum class BoxShadowClipMode : uint32_t {
|
|||
Sentinel /* this must be last for serialization purposes. */
|
||||
};
|
||||
|
||||
enum class Checkpoint : uint32_t {
|
||||
SceneBuilt,
|
||||
FrameBuilt,
|
||||
// NotificationRequests get notified with this if they get dropped without having been
|
||||
// notified. This provides the guarantee that if a request is created it will get notified.
|
||||
TransactionDropped,
|
||||
|
||||
Sentinel /* this must be last for serialization purposes. */
|
||||
};
|
||||
|
||||
enum class ClipMode {
|
||||
Clip,
|
||||
ClipOut,
|
||||
|
@ -1752,6 +1762,15 @@ WR_INLINE
|
|||
Transaction *wr_transaction_new(bool aDoAsync)
|
||||
WR_FUNC;
|
||||
|
||||
extern void wr_transaction_notification_notified(uintptr_t aHandler,
|
||||
Checkpoint aWhen);
|
||||
|
||||
WR_INLINE
|
||||
void wr_transaction_notify(Transaction *aTxn,
|
||||
Checkpoint aWhen,
|
||||
uintptr_t aEvent)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_transaction_remove_pipeline(Transaction *aTxn,
|
||||
WrPipelineId aPipelineId)
|
||||
|
|
Загрузка…
Ссылка в новой задаче