@@ -3,22 +3,21 @@ use crate::Inspector;
33use crate :: {
44 Action , AnyDrag , AnyElement , AnyImageCache , AnyTooltip , AnyView , App , AppContext , Arena , Asset ,
55 AsyncWindowContext , AvailableSpace , Background , BorderStyle , Bounds , BoxShadow , Capslock ,
6- Context , Corners , CursorHideMode , CursorStyle , Decorations , DevicePixels ,
7- DispatchActionListener , DispatchNodeId , DispatchTree , DisplayId , Edges , Effect , Entity ,
8- EntityId , EventEmitter , FileDropEvent , FontId , Global , GlobalElementId , GlyphId , GpuSpecs ,
9- Hsla , InputHandler , IsZero , KeyBinding , KeyContext , KeyDownEvent , KeyEvent , Keystroke ,
10- KeystrokeEvent , LayoutId , LineLayoutIndex , Modifiers , ModifiersChangedEvent , MonochromeSprite ,
11- MouseButton , MouseEvent , MouseMoveEvent , MouseUpEvent , Path , Pixels , PlatformAtlas ,
12- PlatformDisplay , PlatformInput , PlatformInputHandler , PlatformWindow , Point , PolychromeSprite ,
13- Priority , PromptButton , PromptLevel , Quad , Render , RenderGlyphParams , RenderImage ,
14- RenderImageParams , RenderSvgParams , Replay , ResizeEdge , SMOOTH_SVG_SCALE_FACTOR ,
15- SUBPIXEL_VARIANTS_X , SUBPIXEL_VARIANTS_Y , ScaledPixels , Scene , Shadow , SharedString , Size ,
16- StrikethroughStyle , Style , SubpixelSprite , SubscriberSet , Subscription , SystemWindowTab ,
17- SystemWindowTabController , TabStopMap , TaffyLayoutEngine , Task , TextRenderingMode , TextStyle ,
18- TextStyleRefinement , ThermalState , TransformationMatrix , Underline , UnderlineStyle ,
19- WindowAppearance , WindowBackgroundAppearance , WindowBounds , WindowControls , WindowDecorations ,
20- WindowOptions , WindowParams , WindowTextSystem , point, prelude:: * , px, rems, size,
21- transparent_black,
6+ Context , Corners , CursorStyle , CustomRenderPassPrimitive , Decorations , DevicePixels , DispatchActionListener ,
7+ DispatchNodeId , DispatchTree , DisplayId , Edges , Effect , Entity , EntityId , EventEmitter ,
8+ FileDropEvent , FontId , Global , GlobalElementId , GlyphId , GpuSpecs , Hsla , InputHandler , IsZero ,
9+ KeyBinding , KeyContext , KeyDownEvent , KeyEvent , Keystroke , KeystrokeEvent , LayoutId ,
10+ LineLayoutIndex , Modifiers , ModifiersChangedEvent , MonochromeSprite , MouseButton , MouseEvent ,
11+ MouseMoveEvent , MouseUpEvent , Path , Pixels , PlatformAtlas , PlatformDisplay , PlatformInput ,
12+ PlatformInputHandler , PlatformWindow , Point , PolychromeSprite , Priority , PromptButton ,
13+ PromptLevel , Quad , Render , RenderGlyphParams , RenderImage , RenderImageParams , RenderSvgParams ,
14+ Replay , ResizeEdge , SMOOTH_SVG_SCALE_FACTOR , SUBPIXEL_VARIANTS_X , SUBPIXEL_VARIANTS_Y ,
15+ ScaledPixels , Scene , Shadow , SharedString , Size , StrikethroughStyle , Style , SubpixelSprite ,
16+ SubscriberSet , Subscription , SystemWindowTab , SystemWindowTabController , TabStopMap ,
17+ TaffyLayoutEngine , Task , TextRenderingMode , TextStyle , TextStyleRefinement , ThermalState ,
18+ TransformationMatrix , Underline , UnderlineStyle , WindowAppearance , WindowBackgroundAppearance ,
19+ WindowBounds , WindowControls , WindowDecorations , WindowOptions , WindowParams , WindowTextSystem ,
20+ point, prelude:: * , px, rems, size, transparent_black,
2221} ;
2322use anyhow:: { Context as _, Result , anyhow} ;
2423use collections:: { FxHashMap , FxHashSet } ;
@@ -3858,6 +3857,30 @@ impl Window {
38583857 } ) ;
38593858 }
38603859
3860+ /// Schedule a custom render pass to be executed during the wgpu rendering phase.
3861+ ///
3862+ /// The callback receives a type-erased context (`&mut dyn Any`) which the wgpu renderer
3863+ /// populates with GPU resources. On Linux/wgpu, this is a `CustomRenderPassContext`
3864+ /// containing `&wgpu::Device`, `&wgpu::Queue`, `&wgpu::TextureView`, and `wgpu::TextureFormat`.
3865+ ///
3866+ /// This method should only be called as part of the paint phase of element drawing.
3867+ pub fn paint_custom_render_pass (
3868+ & mut self ,
3869+ bounds : Bounds < Pixels > ,
3870+ callback : Arc < dyn Fn ( & mut dyn crate :: AnyRenderContext ) + Send + Sync > ,
3871+ ) {
3872+ self . invalidator . debug_assert_paint ( ) ;
3873+
3874+ let bounds = self . snap_bounds ( bounds) ;
3875+ let content_mask = self . snapped_content_mask ( ) ;
3876+ self . next_frame . scene . insert_primitive ( CustomRenderPassPrimitive {
3877+ order : 0 ,
3878+ bounds,
3879+ content_mask,
3880+ callback,
3881+ } ) ;
3882+ }
3883+
38613884 /// Removes an image from the sprite atlas.
38623885 pub fn drop_image ( & mut self , data : Arc < RenderImage > ) -> Result < ( ) > {
38633886 for frame_index in 0 ..data. frame_count ( ) {
0 commit comments