From 6673742a204f298db1ca983da0184224d9f21649 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Tue, 24 Dec 2024 15:30:47 +1300 Subject: Fixed issue with checking runtime tags for Surfaces --- src/fltk-devices-surface.adb | 33 +++++++++++---------------------- src/fltk-devices-surface.ads | 12 +++++------- 2 files changed, 16 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/fltk-devices-surface.adb b/src/fltk-devices-surface.adb index 9a93768..8ae558d 100644 --- a/src/fltk-devices-surface.adb +++ b/src/fltk-devices-surface.adb @@ -66,22 +66,15 @@ package body FLTK.Devices.Surface is -- Constructors -- -------------------- - procedure Initialize - (This : in out Surface_Device) is - begin - Wrapper (This.My_Driver).Needs_Dealloc := False; - end Initialize; - - package body Forge is function Create - (Graphics : in FLTK.Devices.Graphics.Graphics_Driver) + (Graphics : in out FLTK.Devices.Graphics.Graphics_Driver) return Surface_Device is begin return This : Surface_Device do This.Void_Ptr := new_fl_surface (Wrapper (Graphics).Void_Ptr); - Wrapper (This.My_Driver).Void_Ptr := Wrapper (Graphics).Void_Ptr; + This.My_Driver := Graphics'Unchecked_Access; end return; end Create; @@ -95,14 +88,13 @@ package body FLTK.Devices.Surface is ------------------------- Original_Surface : aliased Surface_Device; - Current_Surface : aliased Surface_Device; + Current_Surface : access Surface_Device'Class := Original_Surface'Access; procedure Set_Current_Bookkeep - (Surface : in Surface_Device'Class) is + (Surface : in out Surface_Device'Class) is begin - Current_Surface.Void_Ptr := Surface.Void_Ptr; - Wrapper (Current_Surface.My_Driver).Void_Ptr := Wrapper (Surface.My_Driver).Void_Ptr; + Current_Surface := Surface'Unchecked_Access; end Set_Current_Bookkeep; @@ -115,7 +107,7 @@ package body FLTK.Devices.Surface is function Get_Current return Surface_Device_Reference is begin - return Ref : Surface_Device_Reference (Data => Current_Surface'Access); + return Ref : Surface_Device_Reference (Data => Current_Surface); end Get_Current; @@ -140,7 +132,8 @@ package body FLTK.Devices.Surface is (This : in Surface_Device) return Boolean is begin - return Wrapper (This.My_Driver).Void_Ptr /= Null_Pointer; + return This.My_Driver /= null and then + Wrapper (This.My_Driver.all).Void_Ptr /= Null_Pointer; end Has_Driver; @@ -148,17 +141,16 @@ package body FLTK.Devices.Surface is (This : in out Surface_Device) return FLTK.Devices.Graphics.Graphics_Driver_Reference is begin - return Ref : FLTK.Devices.Graphics.Graphics_Driver_Reference - (Data => This.My_Driver'Unchecked_Access); + return Ref : FLTK.Devices.Graphics.Graphics_Driver_Reference (Data => This.My_Driver); end Get_Driver; procedure Set_Driver (This : in out Surface_Device; - Driver : in FLTK.Devices.Graphics.Graphics_Driver'Class) is + Driver : in out FLTK.Devices.Graphics.Graphics_Driver'Class) is begin fl_surface_set_driver (This.Void_Ptr, Wrapper (Driver).Void_Ptr); - Wrapper (This.My_Driver).Void_Ptr := Wrapper (Driver).Void_Ptr; + This.My_Driver := Driver'Unchecked_Access; end Set_Driver; @@ -168,9 +160,6 @@ begin Original_Surface.Void_Ptr := fl_surface_get_surface; Original_Surface.Needs_Dealloc := False; - Current_Surface.Void_Ptr := Original_Surface.Void_Ptr; - Current_Surface.Needs_Dealloc := False; - end FLTK.Devices.Surface; diff --git a/src/fltk-devices-surface.ads b/src/fltk-devices-surface.ads index cbad055..68d0df7 100644 --- a/src/fltk-devices-surface.ads +++ b/src/fltk-devices-surface.ads @@ -26,7 +26,7 @@ package FLTK.Devices.Surface is package Forge is function Create - (Graphics : in FLTK.Devices.Graphics.Graphics_Driver) + (Graphics : in out FLTK.Devices.Graphics.Graphics_Driver) return Surface_Device; end Forge; @@ -56,25 +56,23 @@ package FLTK.Devices.Surface is procedure Set_Driver (This : in out Surface_Device; - Driver : in FLTK.Devices.Graphics.Graphics_Driver'Class); + Driver : in out FLTK.Devices.Graphics.Graphics_Driver'Class); private type Surface_Device is new Device with record - My_Driver : aliased FLTK.Devices.Graphics.Graphics_Driver; + My_Driver : access FLTK.Devices.Graphics.Graphics_Driver'Class; end record; - overriding procedure Initialize - (This : in out Surface_Device); - overriding procedure Finalize (This : in out Surface_Device); procedure Set_Current_Bookkeep - (Surface : in Surface_Device'Class); + (Surface : in out Surface_Device'Class) + with Inline; pragma Inline (Get_Current); -- cgit