Struct Transaction

Source
pub struct Transaction {
    pub resource_updates: Vec<ResourceUpdate>,
    pub invalidate_rendered_frame: bool,
    /* private fields */
}
Expand description

A Transaction is a group of commands to apply atomically to a document.

This mechanism ensures that:

  • no other message can be interleaved between two commands that need to be applied together.
  • no redundant work is performed if two commands in the same transaction cause the scene or the frame to be rebuilt.

Fields§

§resource_updates: Vec<ResourceUpdate>

Persistent resource updates to apply as part of this transaction.

§invalidate_rendered_frame: bool

Set to true in order to force re-rendering even if WebRender can’t internally detect that something has changed.

Implementations§

Source§

impl Transaction

Source

pub fn new() -> Self

Constructor.

Source

pub fn skip_scene_builder(&mut self)

Marks this transaction to allow it to skip going through the scene builder thread.

This is useful to avoid jank in transaction associated with animated property updates, panning and zooming.

Note that transactions that skip the scene builder thread can race ahead of transactions that don’t skip it.

Source

pub fn use_scene_builder_thread(&mut self)

Marks this transaction to enforce going through the scene builder thread.

Source

pub fn is_empty(&self) -> bool

Returns true if the transaction has no effect.

Source

pub fn update_epoch(&mut self, pipeline_id: PipelineId, epoch: Epoch)

Update a pipeline’s epoch.

Source

pub fn set_root_pipeline(&mut self, pipeline_id: PipelineId)

Sets the root pipeline.

§Examples
let pipeline_id = PipelineId(0, 0);
let mut txn = Transaction::new();
txn.set_root_pipeline(pipeline_id);
Source

pub fn remove_pipeline(&mut self, pipeline_id: PipelineId)

Removes data associated with a pipeline from the internal data structures. If the specified pipeline_id is for the root pipeline, the root pipeline is reset back to None.

Source

pub fn set_display_list( &mut self, epoch: Epoch, background: Option<ColorF>, viewport_size: LayoutSize, (pipeline_id, content_size, display_list): (PipelineId, LayoutSize, BuiltDisplayList), preserve_frame_state: bool, )

Supplies a new frame to WebRender.

Non-blocking, it notifies a worker process which processes the display list.

Note: Scrolling doesn’t require an own Frame.

Arguments:

  • epoch: The unique Frame ID, monotonically increasing.
  • background: The background color of this pipeline.
  • viewport_size: The size of the viewport for this frame.
  • pipeline_id: The ID of the pipeline that is supplying this display list.
  • content_size: The total screen space size of this display list’s display items.
  • display_list: The root Display list used in this frame.
  • preserve_frame_state: If a previous frame exists which matches this pipeline id, this setting determines if frame state (such as scrolling position) should be preserved for this new display list.
Source

pub fn update_resources(&mut self, resources: Vec<ResourceUpdate>)

Add a set of persistent resource updates to apply as part of this transaction.

Source

pub fn notify(&mut self, event: NotificationRequest)

Trigger a notification at a certain stage of the rendering pipeline.

Not that notification requests are skipped during serialization, so is is best to use them for synchronization purposes and not for things that could affect the WebRender’s state.

Source

pub fn set_document_view( &mut self, device_rect: DeviceIntRect, device_pixel_ratio: f32, )

Setup the output region in the framebuffer for a given document.

Source

pub fn enable_frame_output(&mut self, pipeline_id: PipelineId, enable: bool)

Enable copying of the output of this pipeline id to an external texture for callers to consume.

Source

pub fn scroll(&mut self, scroll_location: ScrollLocation, cursor: WorldPoint)

Scrolls the scrolling layer under the cursor

WebRender looks for the layer closest to the user which has ScrollPolicy::Scrollable set.

Source

pub fn scroll_node_with_id( &mut self, origin: LayoutPoint, id: ExternalScrollId, clamp: ScrollClamping, )

Source

pub fn set_quality_settings(&mut self, settings: QualitySettings)

Set the current quality / performance settings for this document.

Source

pub fn set_page_zoom(&mut self, page_zoom: ZoomFactor)

Source

pub fn set_pinch_zoom(&mut self, pinch_zoom: ZoomFactor)

Source

pub fn set_is_transform_async_zooming( &mut self, is_zooming: bool, animation_id: PropertyBindingId, )

Source

pub fn set_pan(&mut self, pan: DeviceIntPoint)

Source

pub fn generate_frame(&mut self)

Generate a new frame. When it’s done and a RenderNotifier has been set in webrender::Renderer, new_frame_ready() gets called. Note that the notifier is called even if the frame generation was a no-op; the arguments passed to new_frame_ready will provide information as to when happened.

Source

pub fn invalidate_rendered_frame(&mut self)

Invalidate rendered frame. It ensure that frame will be rendered during next frame generation. WebRender could skip frame rendering if there is no update. But there are cases that needs to force rendering.

  • Content of image is updated by reusing same ExternalImageId.
  • Platform requests it if pixels become stale (like wakeup from standby).
Source

pub fn update_dynamic_properties(&mut self, properties: DynamicProperties)

Supply a list of animated property bindings that should be used to resolve bindings in the current display list.

Source

pub fn append_dynamic_properties(&mut self, properties: DynamicProperties)

Add to the list of animated property bindings that should be used to resolve bindings in the current display list. This is a convenience method so the caller doesn’t have to figure out all the dynamic properties before setting them on the transaction but can do them incrementally.

Source

pub fn get_frame_ops(self) -> Vec<FrameMsg>

Consumes this object and just returns the frame ops.

Source

pub fn add_image( &mut self, key: ImageKey, descriptor: ImageDescriptor, data: ImageData, tiling: Option<TileSize>, )

See ResourceUpdate::AddImage.

Source

pub fn update_image( &mut self, key: ImageKey, descriptor: ImageDescriptor, data: ImageData, dirty_rect: &ImageDirtyRect, )

See ResourceUpdate::UpdateImage.

Source

pub fn delete_image(&mut self, key: ImageKey)

See ResourceUpdate::DeleteImage.

Source

pub fn add_blob_image( &mut self, key: BlobImageKey, descriptor: ImageDescriptor, data: Arc<BlobImageData>, visible_rect: DeviceIntRect, tiling: Option<TileSize>, )

See ResourceUpdate::AddBlobImage.

Source

pub fn update_blob_image( &mut self, key: BlobImageKey, descriptor: ImageDescriptor, data: Arc<BlobImageData>, visible_rect: DeviceIntRect, dirty_rect: &BlobDirtyRect, )

See ResourceUpdate::UpdateBlobImage.

Source

pub fn delete_blob_image(&mut self, key: BlobImageKey)

See ResourceUpdate::DeleteBlobImage.

Source

pub fn set_blob_image_visible_area( &mut self, key: BlobImageKey, area: DeviceIntRect, )

See ResourceUpdate::SetBlobImageVisibleArea.

Source

pub fn add_raw_font(&mut self, key: FontKey, bytes: Vec<u8>, index: u32)

See ResourceUpdate::AddFont.

Source

pub fn add_native_font(&mut self, key: FontKey, native_handle: NativeFontHandle)

See ResourceUpdate::AddFont.

Source

pub fn delete_font(&mut self, key: FontKey)

See ResourceUpdate::DeleteFont.

Source

pub fn add_font_instance( &mut self, key: FontInstanceKey, font_key: FontKey, glyph_size: Au, options: Option<FontInstanceOptions>, platform_options: Option<FontInstancePlatformOptions>, variations: Vec<FontVariation>, )

See ResourceUpdate::AddFontInstance.

Source

pub fn delete_font_instance(&mut self, key: FontInstanceKey)

See ResourceUpdate::DeleteFontInstance.

Source

pub fn set_low_priority(&mut self, low_priority: bool)

A hint that this transaction can be processed at a lower priority. High- priority transactions can jump ahead of regular-priority transactions, but both high- and regular-priority transactions are processed in order relative to other transactions of the same priority.

Source

pub fn is_low_priority(&self) -> bool

Returns whether this transaction is marked as low priority.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.