Skip to content

Commit 51776f0

Browse files
committed
fix again
1 parent f1d00db commit 51776f0

4 files changed

Lines changed: 28 additions & 24 deletions

File tree

crates/gdcef/src/cef_texture/browser_lifecycle.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ impl CefTexture {
6262
let logical_size = self.base().get_size();
6363
let dpi = self.get_pixel_scale_factor();
6464
let max_fps = self.get_max_fps();
65-
self.sync_runtime_config();
6665
let params = backend::BackendCreateParams {
6766
logical_size,
6867
dpi,

crates/gdcef/src/cef_texture/mod.rs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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]

crates/gdcef/src/cef_texture/rendering.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ impl CefTexture {
3535

3636
pub(super) fn update_texture(&mut self) {
3737
let should_bind_initial = self.base().get_texture().is_none();
38-
// Capture an initial texture handle before taking a mutable runtime borrow.
39-
// Keeping this as a separate immutable-read phase makes borrow intent explicit.
4038
let initial_texture = if should_bind_initial {
4139
self.with_app(|app| {
4240
app.state

crates/gdcef/src/cef_texture2d/mod.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,6 @@ impl CefTexture2D {
311311
self.background_color = color;
312312
}
313313

314-
/// Updates local URL property without triggering navigation.
315-
pub(crate) fn set_url_state_property(&mut self, url: GString) {
316-
self.url = url;
317-
}
318-
319-
/// Updates local popup policy property without applying to a live browser.
320-
pub(crate) fn set_popup_policy_state(&mut self, policy: i32) {
321-
self.popup_policy = policy;
322-
}
323-
324314
#[func]
325315
fn _on_frame_pre_draw(&mut self) {
326316
self.tick();

0 commit comments

Comments
 (0)