mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2026-03-21 19:56:11 +00:00
Improved GuiState to fully recalculate before returning from draw
This commit is contained in:
@@ -69,6 +69,8 @@ require_relative "cyberarm_engine/ui/gui_state"
|
|||||||
|
|
||||||
require_relative "cyberarm_engine/builtin/intro_state"
|
require_relative "cyberarm_engine/builtin/intro_state"
|
||||||
|
|
||||||
at_exit do
|
if RUBY_ENGINE != "mruby" && defined?(StackProf)
|
||||||
StackProf.results("./_prof.txt") if RUBY_ENGINE != "mruby" && defined?(StackProf)
|
at_exit do
|
||||||
|
StackProf.results("./_stackprof.dmp")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
t = Gosu.milliseconds
|
# t = Gosu.milliseconds
|
||||||
# Move children to parent after positioning
|
# Move children to parent after positioning
|
||||||
@children.each do |child|
|
@children.each do |child|
|
||||||
child.x += (@x + @style.border_thickness_left) - style.margin_left
|
child.x += (@x + @style.border_thickness_left) - style.margin_left
|
||||||
@@ -224,7 +224,7 @@ module CyberarmEngine
|
|||||||
|
|
||||||
update_child_element_visibity(child)
|
update_child_element_visibity(child)
|
||||||
end
|
end
|
||||||
puts "TOOK: #{Gosu.milliseconds - t}ms to recalculate #{self.class}:0x#{object_id.to_s(16)}'s #{@children.count} children" if is_root?
|
# puts "TOOK: #{Gosu.milliseconds - t}ms to recalculate #{self.class}:0x#{object_id.to_s(16)}'s #{@children.count} children" if is_root?
|
||||||
|
|
||||||
update_background
|
update_background
|
||||||
|
|
||||||
|
|||||||
@@ -54,27 +54,29 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
|
# t = Gosu.milliseconds
|
||||||
|
# report_recalculate_time = @pending_recalculate_request || @pending_element_recalculate_requests.size.positive?
|
||||||
|
|
||||||
|
StackProf.start(mode: :wall) if RUBY_ENGINE != "mruby" && defined?(StackProf)
|
||||||
Stats.frame.start_timing(:gui_element_recalculate_requests)
|
Stats.frame.start_timing(:gui_element_recalculate_requests)
|
||||||
|
|
||||||
# puts "PENDING REQUESTS: #{@pending_element_recalculate_requests.size}" if @pending_element_recalculate_requests.size.positive?
|
# puts "PENDING REQUESTS: #{@pending_element_recalculate_requests.size}" if @pending_element_recalculate_requests.size.positive?
|
||||||
@pending_recalculate_request = true if @pending_element_recalculate_requests.size.positive?
|
@pending_element_recalculate_requests.shift(&:recalculate)
|
||||||
# @pending_element_recalculate_requests.each(&:recalculate)
|
|
||||||
@pending_element_recalculate_requests.clear
|
|
||||||
|
|
||||||
Stats.frame.end_timing(:gui_element_recalculate_requests)
|
Stats.frame.end_timing(:gui_element_recalculate_requests)
|
||||||
|
|
||||||
if @pending_recalculate_request
|
|
||||||
Stats.frame.start_timing(:gui_recalculate)
|
Stats.frame.start_timing(:gui_recalculate)
|
||||||
|
|
||||||
StackProf.start(mode: :wall) if RUBY_ENGINE != "mruby" && defined?(StackProf)
|
while(@pending_recalculate_request)
|
||||||
@root_container.recalculate
|
|
||||||
StackProf.stop if RUBY_ENGINE != "mruby" && defined?(StackProf)
|
|
||||||
|
|
||||||
@pending_recalculate_request = false
|
@pending_recalculate_request = false
|
||||||
|
|
||||||
Stats.frame.end_timing(:gui_recalculate)
|
@root_container.recalculate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
StackProf.stop if RUBY_ENGINE != "mruby" && defined?(StackProf)
|
||||||
|
Stats.frame.end_timing(:gui_recalculate)
|
||||||
|
# puts "TOOK: #{Gosu.milliseconds - t}ms to recalculate #{self.class}:0x#{object_id.to_s(16)}" if report_recalculate_time && Gosu.milliseconds - t > 0
|
||||||
|
|
||||||
super
|
super
|
||||||
|
|
||||||
if @menu
|
if @menu
|
||||||
|
|||||||
Reference in New Issue
Block a user