Struct webrender::render_api::Transaction
source · pub struct Transaction {
scene_ops: Vec<SceneMsg>,
frame_ops: Vec<FrameMsg>,
notifications: Vec<NotificationRequest>,
pub resource_updates: Vec<ResourceUpdate>,
use_scene_builder_thread: bool,
generate_frame: GenerateFrame,
creation_time: u64,
pub invalidate_rendered_frame: bool,
low_priority: bool,
pub render_reasons: RenderReasons,
}
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§
§scene_ops: Vec<SceneMsg>
Operations affecting the scene (applied before scene building).
frame_ops: Vec<FrameMsg>
Operations affecting the generation of frames (applied after scene building).
notifications: Vec<NotificationRequest>
§resource_updates: Vec<ResourceUpdate>
Persistent resource updates to apply as part of this transaction.
use_scene_builder_thread: bool
True if the transaction needs the scene building thread’s attention. False for things that can skip the scene builder, like APZ changes and async images.
Before this Transaction
is converted to a TransactionMsg
, we look
over its contents and set this if we’re doing anything the scene builder
needs to know about, so this is only a default.
generate_frame: GenerateFrame
Whether to generate a frame, and if so, an id that allows tracking this transaction through the various frame stages. Specified by the caller of generate_frame().
creation_time: u64
Time when this transaction was constructed.
invalidate_rendered_frame: bool
Set to true in order to force re-rendering even if WebRender can’t internally detect that something has changed.
low_priority: bool
§render_reasons: RenderReasons
Implementations§
source§impl Transaction
impl Transaction
sourcepub fn skip_scene_builder(&mut self)
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.
sourcepub fn use_scene_builder_thread(&mut self)
pub fn use_scene_builder_thread(&mut self)
Marks this transaction to enforce going through the scene builder thread.
sourcepub fn update_epoch(&mut self, pipeline_id: PipelineId, epoch: Epoch)
pub fn update_epoch(&mut self, pipeline_id: PipelineId, epoch: Epoch)
Update a pipeline’s epoch.
sourcepub fn set_root_pipeline(&mut self, pipeline_id: PipelineId)
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);
sourcepub fn remove_pipeline(&mut self, pipeline_id: PipelineId)
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
.
sourcepub fn set_display_list(
&mut self,
epoch: Epoch,
(pipeline_id, display_list): (PipelineId, BuiltDisplayList),
)
pub fn set_display_list( &mut self, epoch: Epoch, (pipeline_id, display_list): (PipelineId, BuiltDisplayList), )
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.pipeline_id
: The ID of the pipeline that is supplying this display list.display_list
: The root Display list used in this frame.
sourcepub fn update_resources(&mut self, resources: Vec<ResourceUpdate>)
pub fn update_resources(&mut self, resources: Vec<ResourceUpdate>)
Add a set of persistent resource updates to apply as part of this transaction.
sourcepub fn notify(&mut self, event: NotificationRequest)
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.
sourcepub fn set_document_view(&mut self, device_rect: DeviceIntRect)
pub fn set_document_view(&mut self, device_rect: DeviceIntRect)
Setup the output region in the framebuffer for a given document.
sourcepub fn set_scroll_offsets(
&mut self,
id: ExternalScrollId,
sampled_scroll_offsets: Vec<SampledScrollOffset>,
)
pub fn set_scroll_offsets( &mut self, id: ExternalScrollId, sampled_scroll_offsets: Vec<SampledScrollOffset>, )
Set multiple scroll offsets with generations to the node identified by the given external scroll id, the scroll offsets are relative to the pre-scrolled offset for the scrolling layer.
sourcepub fn set_quality_settings(&mut self, settings: QualitySettings)
pub fn set_quality_settings(&mut self, settings: QualitySettings)
Set the current quality / performance settings for this document.
sourcepub fn set_is_transform_async_zooming(
&mut self,
is_zooming: bool,
animation_id: PropertyBindingId,
)
pub fn set_is_transform_async_zooming( &mut self, is_zooming: bool, animation_id: PropertyBindingId, )
sourcepub fn set_minimap_data(
&mut self,
id: ExternalScrollId,
minimap_data: MinimapData,
)
pub fn set_minimap_data( &mut self, id: ExternalScrollId, minimap_data: MinimapData, )
Specify data for APZ minimap debug overlay to be composited
sourcepub fn generate_frame(&mut self, id: u64, reasons: RenderReasons)
pub fn generate_frame(&mut self, id: u64, reasons: RenderReasons)
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.
sourcepub fn invalidate_rendered_frame(&mut self, reasons: RenderReasons)
pub fn invalidate_rendered_frame(&mut self, reasons: RenderReasons)
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).
sourcepub fn reset_dynamic_properties(&mut self)
pub fn reset_dynamic_properties(&mut self)
Reset the list of animated property bindings that should be used to resolve bindings in the current display list.
sourcepub fn append_dynamic_properties(&mut self, properties: DynamicProperties)
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.
sourcepub fn append_dynamic_transform_properties(
&mut self,
transforms: Vec<PropertyValue<LayoutTransform>>,
)
pub fn append_dynamic_transform_properties( &mut self, transforms: Vec<PropertyValue<LayoutTransform>>, )
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.
sourcepub fn get_frame_ops(self) -> Vec<FrameMsg>
pub fn get_frame_ops(self) -> Vec<FrameMsg>
Consumes this object and just returns the frame ops.
fn finalize(self, document_id: DocumentId) -> Box<TransactionMsg>
sourcepub fn add_image(
&mut self,
key: ImageKey,
descriptor: ImageDescriptor,
data: ImageData,
tiling: Option<TileSize>,
)
pub fn add_image( &mut self, key: ImageKey, descriptor: ImageDescriptor, data: ImageData, tiling: Option<TileSize>, )
See ResourceUpdate::AddImage
.
sourcepub fn update_image(
&mut self,
key: ImageKey,
descriptor: ImageDescriptor,
data: ImageData,
dirty_rect: &ImageDirtyRect,
)
pub fn update_image( &mut self, key: ImageKey, descriptor: ImageDescriptor, data: ImageData, dirty_rect: &ImageDirtyRect, )
See ResourceUpdate::UpdateImage
.
sourcepub fn delete_image(&mut self, key: ImageKey)
pub fn delete_image(&mut self, key: ImageKey)
See ResourceUpdate::DeleteImage
.
sourcepub fn add_blob_image(
&mut self,
key: BlobImageKey,
descriptor: ImageDescriptor,
data: Arc<BlobImageData>,
visible_rect: DeviceIntRect,
tile_size: Option<TileSize>,
)
pub fn add_blob_image( &mut self, key: BlobImageKey, descriptor: ImageDescriptor, data: Arc<BlobImageData>, visible_rect: DeviceIntRect, tile_size: Option<TileSize>, )
See ResourceUpdate::AddBlobImage
.
sourcepub fn update_blob_image(
&mut self,
key: BlobImageKey,
descriptor: ImageDescriptor,
data: Arc<BlobImageData>,
visible_rect: DeviceIntRect,
dirty_rect: &BlobDirtyRect,
)
pub fn update_blob_image( &mut self, key: BlobImageKey, descriptor: ImageDescriptor, data: Arc<BlobImageData>, visible_rect: DeviceIntRect, dirty_rect: &BlobDirtyRect, )
See ResourceUpdate::UpdateBlobImage
.
sourcepub fn delete_blob_image(&mut self, key: BlobImageKey)
pub fn delete_blob_image(&mut self, key: BlobImageKey)
See ResourceUpdate::DeleteBlobImage
.
sourcepub fn set_blob_image_visible_area(
&mut self,
key: BlobImageKey,
area: DeviceIntRect,
)
pub fn set_blob_image_visible_area( &mut self, key: BlobImageKey, area: DeviceIntRect, )
See ResourceUpdate::SetBlobImageVisibleArea
.
sourcepub fn add_raw_font(&mut self, key: FontKey, bytes: Vec<u8>, index: u32)
pub fn add_raw_font(&mut self, key: FontKey, bytes: Vec<u8>, index: u32)
See ResourceUpdate::AddFont
.
sourcepub fn add_native_font(&mut self, key: FontKey, native_handle: NativeFontHandle)
pub fn add_native_font(&mut self, key: FontKey, native_handle: NativeFontHandle)
See ResourceUpdate::AddFont
.
sourcepub fn delete_font(&mut self, key: FontKey)
pub fn delete_font(&mut self, key: FontKey)
See ResourceUpdate::DeleteFont
.
sourcepub fn add_font_instance(
&mut self,
key: FontInstanceKey,
font_key: FontKey,
glyph_size: f32,
options: Option<FontInstanceOptions>,
platform_options: Option<FontInstancePlatformOptions>,
variations: Vec<FontVariation>,
)
pub fn add_font_instance( &mut self, key: FontInstanceKey, font_key: FontKey, glyph_size: f32, options: Option<FontInstanceOptions>, platform_options: Option<FontInstancePlatformOptions>, variations: Vec<FontVariation>, )
See ResourceUpdate::AddFontInstance
.
sourcepub fn delete_font_instance(&mut self, key: FontInstanceKey)
pub fn delete_font_instance(&mut self, key: FontInstanceKey)
See ResourceUpdate::DeleteFontInstance
.
sourcepub fn set_low_priority(&mut self, low_priority: bool)
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.
sourcepub fn is_low_priority(&self) -> bool
pub fn is_low_priority(&self) -> bool
Returns whether this transaction is marked as low priority.
Auto Trait Implementations§
impl Freeze for Transaction
impl !RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl !UnwindSafe for Transaction
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more