Skip to content

Commit

Permalink
#1496: copy pixels at a time with an alpha threshold
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@15576 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 12, 2017
1 parent 5b17dc2 commit 18dd536
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions src/xpra/client/gl/gl_window_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# later version. See the file COPYING for details.

import os
import struct
import time, math

from xpra.os_util import monotonic_time
Expand Down Expand Up @@ -97,7 +98,7 @@ def get_fcolor(encoding):
GL_BLEND, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, \
GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_BASE_LEVEL, \
GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST, \
glLineStipple, GL_LINE_STIPPLE, \
glLineStipple, GL_LINE_STIPPLE, GL_POINTS, \
glTexEnvi, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE, GL_TEXTURE_2D, \
glHint, \
glBlendFunc, \
Expand Down Expand Up @@ -733,11 +734,24 @@ def draw_pointer(self):
#timeout - stop showing it:
self.pointer_overlay = None
return
if self.cursor_data and TEXTURE_CURSOR:
#paint the texture containing the cursor:
cw = self.cursor_data[3]
ch = self.cursor_data[4]

if not self.cursor_data:
#paint a fake one:
alpha = max(0, (5.0-elapsed)/5.0)
lw = 2
glLineWidth(lw)
glBegin(GL_LINES)
glColor4f(0, 0, 0, alpha)
glVertex2i(x-size, y-lw//2)
glVertex2i(x+size, y-lw//2)
glVertex2i(x, y-size)
glVertex2i(x, y+size)
glEnd()

cw = self.cursor_data[3]
ch = self.cursor_data[4]
if TEXTURE_CURSOR:
#paint the texture containing the cursor:
#glActiveTexture(GL_TEXTURE1)
target = GL_TEXTURE_2D
glEnable(target)
Expand All @@ -764,17 +778,19 @@ def draw_pointer(self):
glDisable(target)
#glActiveTexture(GL_TEXTURE0)
else:
#paint a fake one:
alpha = max(0, (5.0-elapsed)/5.0)
lw = 2
glLineWidth(lw)
glBegin(GL_LINES)
glColor4f(0, 0, 0, alpha)
glVertex2i(x-size, y-lw//2)
glVertex2i(x+size, y-lw//2)
glVertex2i(x, y-size)
glVertex2i(x, y+size)
glEnd()
#FUGLY: paint each pixel separately..
pixels = self.cursor_data[8]
p = struct.unpack("B"*(cw*ch*4), pixels)
glLineWidth(1)
#TODO: use VBO arrays to make this faster
for cx in range(cw):
for cy in range(ch):
i = cx*4+cy*cw*4
if p[i+3]>=64:
glBegin(GL_POINTS)
glColor4f(p[i]/256.0, p[i+1]/256.0, p[i+2]/256.0, p[i+3]/256.0)
glVertex2i(x+cx, y+cy)
glEnd()

def upload_cursor_texture(self, target, cursor_data):
width = cursor_data[3]
Expand Down

0 comments on commit 18dd536

Please sign in to comment.