Ruby GTK3移行後のメインリポジトリ
Révision | 3a5bb10018a848d0d867acf2391387b1c4366e2d (tree) |
---|---|
l'heure | 2019-01-04 13:10:28 |
Auteur | Shyouzou Sugitani <shy@user...> |
Commiter | Shyouzou Sugitani |
reduce the drawing load(2)
@@ -1,3 +1,7 @@ | ||
1 | +Fri January 4 2019 Shyouzou Sugitani <shy@users.osdn.me> | |
2 | + * 描画処理の負荷低減を「猫どりふ」、「きのこ」、"easyballoon" | |
3 | + まで拡大した. | |
4 | + | |
1 | 5 | Thu January 3 2019 Shyouzou Sugitani <shy@users.osdn.me> |
2 | 6 | * 5.0.7のバルーンに対する変更から着想を得て |
3 | 7 | 描画処理の負荷低減を更に進め、 |
@@ -455,7 +455,6 @@ module Balloon | ||
455 | 455 | @x_fractions = 0 |
456 | 456 | @y_fractions = 0 |
457 | 457 | @reshape = true |
458 | - @translate = [0, 0] | |
459 | 458 | @darea = @window.darea |
460 | 459 | @darea.set_events(Gdk::EventMask::EXPOSURE_MASK| |
461 | 460 | Gdk::EventMask::BUTTON_PRESS_MASK| |
@@ -806,10 +805,9 @@ module Balloon | ||
806 | 805 | if y < top # XXX |
807 | 806 | y = top |
808 | 807 | end |
809 | - @translate = [x, y].zip(@position).map {|new, prev| new - prev} | |
810 | 808 | @position = [x, y] |
811 | 809 | __move() |
812 | - end | |
810 | + end | |
813 | 811 | |
814 | 812 | def get_position |
815 | 813 | @position |
@@ -1055,13 +1053,8 @@ module Balloon | ||
1055 | 1053 | update_link_region(widget, cr, @selection) unless @selection.nil? |
1056 | 1054 | redraw_arrow0(widget, cr) |
1057 | 1055 | 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) | |
1063 | 1057 | @reshape = false |
1064 | - @translate = [0, 0] | |
1065 | 1058 | return false |
1066 | 1059 | end |
1067 | 1060 |
@@ -258,6 +258,7 @@ module Bln | ||
258 | 258 | destroy() |
259 | 259 | return |
260 | 260 | end |
261 | + @reshape = true | |
261 | 262 | @balloon_surface = balloon_surface |
262 | 263 | w = balloon_surface.width |
263 | 264 | h = balloon_surface.height |
@@ -763,7 +764,8 @@ module Bln | ||
763 | 764 | cr.move_to(@left.to_i, @top.to_i) |
764 | 765 | cr.show_pango_layout(@layout) |
765 | 766 | end |
766 | - @window.set_shape(cr) | |
767 | + @window.set_shape(cr, @reshape) | |
768 | + @reshape = false | |
767 | 769 | end |
768 | 770 | |
769 | 771 | def get_state |
@@ -277,6 +277,7 @@ module Kinoko | ||
277 | 277 | @seriko.set_responsible(self) |
278 | 278 | path = File.join(@data['dir'], @data['base']) |
279 | 279 | begin |
280 | + @reshape = true | |
280 | 281 | @image_surface = Pix.create_surface_from_file(path) |
281 | 282 | w = [8, (@image_surface.width * @__scale / 100).to_i].max |
282 | 283 | h = [8, (@image_surface.height * @__scale / 100).to_i].max |
@@ -375,7 +376,8 @@ module Kinoko | ||
375 | 376 | |
376 | 377 | def redraw(widget, cr) |
377 | 378 | @window.set_surface(cr, @image_surface, @__scale) |
378 | - @window.set_shape(cr) | |
379 | + @window.set_shape(cr, @reshape) | |
380 | + @reshape = false | |
379 | 381 | end |
380 | 382 | |
381 | 383 | def get_image_surface(surface_id) |
@@ -399,6 +401,7 @@ module Kinoko | ||
399 | 401 | end |
400 | 402 | |
401 | 403 | def update_frame_buffer() |
404 | + @reshape = true # FIXME: depends on Seriko | |
402 | 405 | new_surface = create_image_surface(@seriko.get_base_id) |
403 | 406 | raise "assert" if new_surface.nil? |
404 | 407 | # draw overlays |
@@ -335,7 +335,8 @@ module Nekodorif | ||
335 | 335 | |
336 | 336 | def redraw(widget, cr) |
337 | 337 | @window.set_surface(cr, @image_surface, @__scale) |
338 | - @window.set_shape(cr) | |
338 | + @window.set_shape(cr, @reshape) | |
339 | + @reshape = false | |
339 | 340 | end |
340 | 341 | |
341 | 342 | def delete(widget, event) |
@@ -395,6 +396,7 @@ module Nekodorif | ||
395 | 396 | return |
396 | 397 | end |
397 | 398 | @w, @h = w, h |
399 | + @reshape = true | |
398 | 400 | @image_surface = new_surface |
399 | 401 | @darea.queue_draw() |
400 | 402 | end |
@@ -553,7 +555,8 @@ module Nekodorif | ||
553 | 555 | |
554 | 556 | def redraw(widget, cr) |
555 | 557 | @window.set_surface(cr, @image_surface, @__scale) |
556 | - @window.set_shape(cr) | |
558 | + @window.set_shape(cr, @reshape) | |
559 | + @reshape = false | |
557 | 560 | end |
558 | 561 | |
559 | 562 | def set_movement(timing) |
@@ -635,6 +638,7 @@ module Nekodorif | ||
635 | 638 | return |
636 | 639 | end |
637 | 640 | @w, @h = w, h |
641 | + @reshape = true | |
638 | 642 | @image_surface = new_surface |
639 | 643 | @darea.queue_draw() |
640 | 644 | end |
@@ -91,6 +91,7 @@ module Pix | ||
91 | 91 | set_app_paintable(true) |
92 | 92 | set_focus_on_map(false) |
93 | 93 | @__surface_position = [0, 0] |
94 | + @prev_position = [0, 0] | |
94 | 95 | # create drawing area |
95 | 96 | @darea = Gtk::DrawingArea.new |
96 | 97 | @darea.set_size_request(*size) # XXX |
@@ -132,31 +133,21 @@ module Pix | ||
132 | 133 | cr.restore() |
133 | 134 | end |
134 | 135 | |
135 | - def set_shape(cr) | |
136 | + def set_shape(cr, reshape) | |
136 | 137 | 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 | |
138 | 145 | if @supports_alpha |
139 | 146 | input_shape_combine_region(nil) |
140 | - input_shape_combine_region(region) | |
147 | + input_shape_combine_region(@region) | |
141 | 148 | else |
142 | 149 | 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) | |
160 | 151 | end |
161 | 152 | end |
162 | 153 | end |
@@ -912,7 +912,6 @@ module Surface | ||
912 | 912 | @click_count = 0 |
913 | 913 | @__balloon_offset = nil |
914 | 914 | @reshape = true |
915 | - @translate = [0, 0] | |
916 | 915 | @window.signal_connect('leave_notify_event') do |w, e| |
917 | 916 | next window_leave_notify(w, e) # XXX |
918 | 917 | end |
@@ -1308,7 +1307,7 @@ module Surface | ||
1308 | 1307 | |
1309 | 1308 | def update_frame_buffer |
1310 | 1309 | return if @parent.handle_request('GET', 'lock_repaint') |
1311 | - @reshape = true | |
1310 | + @reshape = true # FIXME: depends on Seriko | |
1312 | 1311 | new_surface = create_image_surface(@seriko.get_base_id) |
1313 | 1312 | fail "assert" if new_surface.nil? |
1314 | 1313 | # update collision areas |
@@ -1350,13 +1349,8 @@ module Surface | ||
1350 | 1349 | unless @parent.handle_request('GET', 'get_preference', 'check_collision').zero? |
1351 | 1350 | draw_region(cr) |
1352 | 1351 | end |
1353 | - if @reshape | |
1354 | - @window.set_shape(cr) | |
1355 | - else | |
1356 | - @window.translate(cr, *@translate) | |
1357 | - end | |
1352 | + @window.set_shape(cr, @reshape) | |
1358 | 1353 | @reshape = false |
1359 | - @translate = [0, 0] | |
1360 | 1354 | end |
1361 | 1355 | |
1362 | 1356 | def remove_overlay(actor) |
@@ -1472,7 +1466,6 @@ module Surface | ||
1472 | 1466 | |
1473 | 1467 | def set_position(x, y) |
1474 | 1468 | return if @parent.handle_request('GET', 'lock_repaint') |
1475 | - @translate = [x, y].zip(@position).map {|new, prev| new - prev} | |
1476 | 1469 | @position = [x, y] |
1477 | 1470 | new_x, new_y = get_position() |
1478 | 1471 | @window.move(new_x, new_y) |
@@ -1544,6 +1537,7 @@ module Surface | ||
1544 | 1537 | def show |
1545 | 1538 | return if @parent.handle_request('GET', 'lock_repaint') |
1546 | 1539 | return if @__shown |
1540 | + @reshape = true | |
1547 | 1541 | @__shown = true |
1548 | 1542 | x, y = get_position() |
1549 | 1543 | @window.move(x, y) # XXX: call before showing the window |