• R/O
  • HTTP
  • SSH
  • HTTPS

ruby-gtk3: Commit

Ruby GTK3移行後のメインリポジトリ


Commit MetaInfo

Revision3a5bb10018a848d0d867acf2391387b1c4366e2d (tree)
Time2019-01-04 13:10:28
AuthorShyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Log Message

reduce the drawing load(2)

Change Summary

Incremental Difference

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
1+Fri January 4 2019 Shyouzou Sugitani <shy@users.osdn.me>
2+ * 描画処理の負荷低減を「猫どりふ」、「きのこ」、"easyballoon"
3+ まで拡大した.
4+
15 Thu January 3 2019 Shyouzou Sugitani <shy@users.osdn.me>
26 * 5.0.7のバルーンに対する変更から着想を得て
37 描画処理の負荷低減を更に進め、
--- a/lib/ninix/balloon.rb
+++ b/lib/ninix/balloon.rb
@@ -455,7 +455,6 @@ module Balloon
455455 @x_fractions = 0
456456 @y_fractions = 0
457457 @reshape = true
458- @translate = [0, 0]
459458 @darea = @window.darea
460459 @darea.set_events(Gdk::EventMask::EXPOSURE_MASK|
461460 Gdk::EventMask::BUTTON_PRESS_MASK|
@@ -806,10 +805,9 @@ module Balloon
806805 if y < top # XXX
807806 y = top
808807 end
809- @translate = [x, y].zip(@position).map {|new, prev| new - prev}
810808 @position = [x, y]
811809 __move()
812- end
810+ end
813811
814812 def get_position
815813 @position
@@ -1055,13 +1053,8 @@ module Balloon
10551053 update_link_region(widget, cr, @selection) unless @selection.nil?
10561054 redraw_arrow0(widget, cr)
10571055 redraw_arrow1(widget, cr)
1058- if @reshape
1059- @window.set_shape(cr)
1060- else
1061- @window.translate(cr, *@translate)
1062- end
1056+ @window.set_shape(cr, @reshape)
10631057 @reshape = false
1064- @translate = [0, 0]
10651058 return false
10661059 end
10671060
--- a/lib/ninix/dll/bln.rb
+++ b/lib/ninix/dll/bln.rb
@@ -258,6 +258,7 @@ module Bln
258258 destroy()
259259 return
260260 end
261+ @reshape = true
261262 @balloon_surface = balloon_surface
262263 w = balloon_surface.width
263264 h = balloon_surface.height
@@ -763,7 +764,8 @@ module Bln
763764 cr.move_to(@left.to_i, @top.to_i)
764765 cr.show_pango_layout(@layout)
765766 end
766- @window.set_shape(cr)
767+ @window.set_shape(cr, @reshape)
768+ @reshape = false
767769 end
768770
769771 def get_state
--- a/lib/ninix/kinoko.rb
+++ b/lib/ninix/kinoko.rb
@@ -277,6 +277,7 @@ module Kinoko
277277 @seriko.set_responsible(self)
278278 path = File.join(@data['dir'], @data['base'])
279279 begin
280+ @reshape = true
280281 @image_surface = Pix.create_surface_from_file(path)
281282 w = [8, (@image_surface.width * @__scale / 100).to_i].max
282283 h = [8, (@image_surface.height * @__scale / 100).to_i].max
@@ -375,7 +376,8 @@ module Kinoko
375376
376377 def redraw(widget, cr)
377378 @window.set_surface(cr, @image_surface, @__scale)
378- @window.set_shape(cr)
379+ @window.set_shape(cr, @reshape)
380+ @reshape = false
379381 end
380382
381383 def get_image_surface(surface_id)
@@ -399,6 +401,7 @@ module Kinoko
399401 end
400402
401403 def update_frame_buffer()
404+ @reshape = true # FIXME: depends on Seriko
402405 new_surface = create_image_surface(@seriko.get_base_id)
403406 raise "assert" if new_surface.nil?
404407 # draw overlays
--- a/lib/ninix/nekodorif.rb
+++ b/lib/ninix/nekodorif.rb
@@ -335,7 +335,8 @@ module Nekodorif
335335
336336 def redraw(widget, cr)
337337 @window.set_surface(cr, @image_surface, @__scale)
338- @window.set_shape(cr)
338+ @window.set_shape(cr, @reshape)
339+ @reshape = false
339340 end
340341
341342 def delete(widget, event)
@@ -395,6 +396,7 @@ module Nekodorif
395396 return
396397 end
397398 @w, @h = w, h
399+ @reshape = true
398400 @image_surface = new_surface
399401 @darea.queue_draw()
400402 end
@@ -553,7 +555,8 @@ module Nekodorif
553555
554556 def redraw(widget, cr)
555557 @window.set_surface(cr, @image_surface, @__scale)
556- @window.set_shape(cr)
558+ @window.set_shape(cr, @reshape)
559+ @reshape = false
557560 end
558561
559562 def set_movement(timing)
@@ -635,6 +638,7 @@ module Nekodorif
635638 return
636639 end
637640 @w, @h = w, h
641+ @reshape = true
638642 @image_surface = new_surface
639643 @darea.queue_draw()
640644 end
--- a/lib/ninix/pix.rb
+++ b/lib/ninix/pix.rb
@@ -91,6 +91,7 @@ module Pix
9191 set_app_paintable(true)
9292 set_focus_on_map(false)
9393 @__surface_position = [0, 0]
94+ @prev_position = [0, 0]
9495 # create drawing area
9596 @darea = Gtk::DrawingArea.new
9697 @darea.set_size_request(*size) # XXX
@@ -132,31 +133,21 @@ module Pix
132133 cr.restore()
133134 end
134135
135- def set_shape(cr)
136+ def set_shape(cr, reshape)
136137 return if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
137- region = Pix.surface_to_region(cr.target.map_to_image)
138+ if @region.nil? or reshape
139+ @region = Pix.surface_to_region(cr.target.map_to_image)
140+ else
141+ dx, dy = @__surface_position.zip(@prev_position).map {|new, prev| new - prev}
142+ @region.translate!(dx, dy)
143+ end
144+ @prev_position = @__surface_position
138145 if @supports_alpha
139146 input_shape_combine_region(nil)
140- input_shape_combine_region(region)
147+ input_shape_combine_region(@region)
141148 else
142149 shape_combine_region(nil)
143- shape_combine_region(region)
144- end
145- @region = region
146- end
147-
148- def translate(cr, x, y)
149- if @region.nil?
150- set_shape(cr)
151- else
152- @region.translate!(x, y)
153- if @supports_alpha
154- input_shape_combine_region(nil)
155- input_shape_combine_region(@region)
156- else
157- shape_combine_region(nil)
158- shape_combine_region(@region)
159- end
150+ shape_combine_region(@region)
160151 end
161152 end
162153 end
--- a/lib/ninix/surface.rb
+++ b/lib/ninix/surface.rb
@@ -912,7 +912,6 @@ module Surface
912912 @click_count = 0
913913 @__balloon_offset = nil
914914 @reshape = true
915- @translate = [0, 0]
916915 @window.signal_connect('leave_notify_event') do |w, e|
917916 next window_leave_notify(w, e) # XXX
918917 end
@@ -1308,7 +1307,7 @@ module Surface
13081307
13091308 def update_frame_buffer
13101309 return if @parent.handle_request('GET', 'lock_repaint')
1311- @reshape = true
1310+ @reshape = true # FIXME: depends on Seriko
13121311 new_surface = create_image_surface(@seriko.get_base_id)
13131312 fail "assert" if new_surface.nil?
13141313 # update collision areas
@@ -1350,13 +1349,8 @@ module Surface
13501349 unless @parent.handle_request('GET', 'get_preference', 'check_collision').zero?
13511350 draw_region(cr)
13521351 end
1353- if @reshape
1354- @window.set_shape(cr)
1355- else
1356- @window.translate(cr, *@translate)
1357- end
1352+ @window.set_shape(cr, @reshape)
13581353 @reshape = false
1359- @translate = [0, 0]
13601354 end
13611355
13621356 def remove_overlay(actor)
@@ -1472,7 +1466,6 @@ module Surface
14721466
14731467 def set_position(x, y)
14741468 return if @parent.handle_request('GET', 'lock_repaint')
1475- @translate = [x, y].zip(@position).map {|new, prev| new - prev}
14761469 @position = [x, y]
14771470 new_x, new_y = get_position()
14781471 @window.move(new_x, new_y)
@@ -1544,6 +1537,7 @@ module Surface
15441537 def show
15451538 return if @parent.handle_request('GET', 'lock_repaint')
15461539 return if @__shown
1540+ @reshape = true
15471541 @__shown = true
15481542 x, y = get_position()
15491543 @window.move(x, y) # XXX: call before showing the window
Show on old repository browser