@@ -31,12 +31,14 @@ pub struct CefTexture {
3131 url : GString ,
3232
3333 #[ export]
34+ #[ var( get = get_enable_accelerated_osr, set = set_enable_accelerated_osr) ]
3435 /// Enable GPU-accelerated Off-Screen Rendering (OSR).
3536 /// If true, uses shared textures (Vulkan/D3D12/Metal) for high performance.
3637 /// If false or unsupported, falls back to software rendering.
3738 enable_accelerated_osr : bool ,
3839
3940 #[ export]
41+ #[ var( get = get_background_color, set = set_background_color) ]
4042 /// The background color of the browser view.
4143 /// Useful for transparent pages.
4244 background_color : Color ,
@@ -160,14 +162,6 @@ impl CefTexture {
160162 f ( helper. runtime_app_mut ( ) )
161163 }
162164
163- fn sync_runtime_config ( & mut self ) {
164- let mut helper = self . texture2d_helper . bind_mut ( ) ;
165- helper. set_url_state_property ( self . url . clone ( ) ) ;
166- helper. set_enable_accelerated_osr_property ( self . enable_accelerated_osr ) ;
167- helper. set_background_color_property ( self . background_color ) ;
168- helper. set_popup_policy_state ( self . popup_policy ) ;
169- }
170-
171165 fn event_position_to_local ( & self , position : Vector2 ) -> Vector2 {
172166 // `input()` delivers positions in viewport space for this node path, while
173167 // CEF expects view-local coordinates relative to the browser texture.
@@ -253,7 +247,6 @@ impl CefTexture {
253247 #[ func]
254248 fn on_ready ( & mut self ) {
255249 use godot:: classes:: control:: FocusMode ;
256- self . sync_runtime_config ( ) ;
257250 if let Err ( e) = cef_init:: cef_retain ( ) {
258251 godot:: global:: godot_error!( "[CefTexture] {}" , e) ;
259252 return ;
@@ -277,7 +270,6 @@ impl CefTexture {
277270
278271 #[ func]
279272 fn on_process ( & mut self ) {
280- self . sync_runtime_config ( ) ;
281273 // Lazy browser creation: if browser doesn't exist yet (e.g., size was 0 in on_ready
282274 // because we're inside a Container), try to create it now that layout may be complete.
283275 if self . with_app ( |app| app. state . is_none ( ) ) {
@@ -382,6 +374,32 @@ impl CefTexture {
382374 self . texture2d_helper . bind_mut ( ) . set_url_property ( url) ;
383375 }
384376
377+ #[ func]
378+ fn get_enable_accelerated_osr ( & self ) -> bool {
379+ self . enable_accelerated_osr
380+ }
381+
382+ #[ func]
383+ fn set_enable_accelerated_osr ( & mut self , enabled : bool ) {
384+ self . enable_accelerated_osr = enabled;
385+ self . texture2d_helper
386+ . bind_mut ( )
387+ . set_enable_accelerated_osr_property ( enabled) ;
388+ }
389+
390+ #[ func]
391+ fn get_background_color ( & self ) -> Color {
392+ self . background_color
393+ }
394+
395+ #[ func]
396+ fn set_background_color ( & mut self , color : Color ) {
397+ self . background_color = color;
398+ self . texture2d_helper
399+ . bind_mut ( )
400+ . set_background_color_property ( color) ;
401+ }
402+
385403 #[ func]
386404 /// Navigates back in the browser history.
387405 pub fn go_back ( & mut self ) {
@@ -752,7 +770,6 @@ impl CefTexture {
752770 fn set_popup_policy ( & mut self , policy : i32 ) {
753771 self . popup_policy = policy;
754772 self . texture2d_helper . bind_mut ( ) . set_popup_policy ( policy) ;
755- self . with_app ( |app| backend:: apply_popup_policy ( app, policy) ) ;
756773 }
757774
758775 #[ func]
0 commit comments