Skip to content

Commit

Permalink
we can shortcut the damaged ratio if the whole window got damaged at …
Browse files Browse the repository at this point in the history
…least once

git-svn-id: https://xpra.org/svn/Xpra/trunk@13640 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 9, 2016
1 parent b66e57f commit 0a422f4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/xpra/server/window/video_subregion.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ def few_damage_events(event_types, event_count):
wc.setdefault(w, dict()).setdefault(x, set()).add(r)
if h>=MIN_H:
hc.setdefault(h, dict()).setdefault(y, set()).add(r)
#we can shortcut the damaged ratio if the whole window got damaged at least once:
all_damaged = dec.get(rectangle(0, 0, ww, wh), 0) > 0

def inoutcount(region, ignore_size=0):
#count how many pixels are in or out if this region
Expand All @@ -308,6 +310,8 @@ def inoutcount(region, ignore_size=0):
return incount, outcount

def damaged_ratio(rect):
if all_damaged:
return 1
rects = [rect]
for _,x,y,w,h in lde:
r = rectangle(x,y,w,h)
Expand All @@ -321,7 +325,7 @@ def damaged_ratio(rect):
not_damaged_pixels = sum((r.width*r.height) for r in rects)
rect_pixels = rect.width*rect.height
#sslog("damaged_ratio: not damaged pixels(%s)=%i, rect pixels(%s)=%i", rects, not_damaged_pixels, rect, rect_pixels)
return max(0, min(1.0, 1.0-float(not_damaged_pixels)/rect_pixels))
return max(0, min(1, 1.0-float(not_damaged_pixels)/rect_pixels))

scores = {None : 0}
def score_region(info, region, ignore_size=0, d_ratio=0):
Expand Down

0 comments on commit 0a422f4

Please sign in to comment.