コード例 #1
0
ファイル: video_subregion.py プロジェクト: DiGuoZhiMeng/Xpra
 def add_video_refresh(self, region):
     #called by add_refresh_region if the video region got painted on
     #Note: this does not run in the UI thread!
     rect = self.rectangle
     if not rect:
         return
     #something in the video region is still refreshing,
     #so we re-schedule the subregion refresh:
     self.cancel_refresh_timer()
     #add the new region to what we already have:
     add_rectangle(self.refresh_regions, region)
     #do refresh any regions which are now outside the current video region:
     #(this can happen when the region moves or changes size)
     nonvideo = []
     for r in self.refresh_regions:
         if not rect.contains_rect(r):
             nonvideo += r.substract_rect(rect)
     delay = max(150, self.auto_refresh_delay)
     refreshlog("add_video_refresh(%s) rectangle=%s, delay=%ims", region, rect, delay)
     self.nonvideo_regions += nonvideo
     if self.nonvideo_regions:
         if not self.nonvideo_refresh_timer:
             #refresh via timeout_add so this will run in the UI thread:
             self.nonvideo_refresh_timer = self.timeout_add(delay, self.nonvideo_refresh)
         #only keep the regions still in the video region:
         inrect = (rect.intersection_rect(r) for r in self.refresh_regions)
         self.refresh_regions = [r for r in inrect if r is not None]
     #re-schedule the video region refresh (if we have regions to fresh):
     if self.refresh_regions:
         self.refresh_timer = self.timeout_add(delay, self.refresh)
コード例 #2
0
ファイル: test_region.py プロジェクト: gitmirrors2/xpra
def test_gvim_damage_performance(rectangles):
    start = time.time()
    for _ in range(N):
        rects = []
        for x, y, width, height in rectangles:
            r = rectangle(x, y, width, height)
            rects.append(r)
    end = time.time()
    print("created %s rectangles %s times in %.3fms" %
          (len(rectangles), N, (end - start) * 1000.0 / N))
    #now try add rectangle:
    start = time.time()
    for _ in range(N):
        rects = []
        for x, y, width, height in rectangles:
            r = rectangle(x, y, width, height)
            add_rectangle(rects, r)
    end = time.time()
    print("add_rectangle %s rectangles %s times in %.3fms" %
          (len(rectangles), N, (end - start) * 1000.0 / N))
    #now try remove rectangle:
    start = time.time()
    for _ in range(N):
        rects = []
        for x, y, width, height in rectangles:
            r = rectangle(x + width // 4, y + height // 3, width // 2,
                          height // 2)
            remove_rectangle(rects, r)
    end = time.time()
    print("remove_rectangle %s rectangles %s times in %.3fms" %
          (len(rectangles), N, (end - start) * 1000.0 / N))

    start = time.time()
    n = N * 1000
    for _ in range(n):
        for r in rects:
            contains_rect(rects, r)
    end = time.time()
    print("contains_rect %s rectangles %s times in %.3fms" %
          (len(rectangles), n, (end - start) * 1000.0 / N))