xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #717: remove-opengl-zerocopy-upload.patch

File remove-opengl-zerocopy-upload.patch, 2.5 KB (added by Antoine Martin, 7 years ago)

completely removes all the memoryview code from the opengl backend

  • xpra/client/gl/gl_window_backing.py

     
    100100from ctypes import c_char_p
    101101
    102102
    103 #support for memory views requires Python 2.7 and PyOpenGL 3.1
    104 memoryview_type = None
    105 if sys.version_info[:2]>=(2,7) and OpenGL_version.__version__.split('.')[:2]>=['3','1']:
    106     memoryview_type = memoryview
    107 
    108 
    109103# Texture number assignment
    110104#  1 = Y plane
    111105#  2 = U plane
     
    465459            log("%s._do_paint_rgb(..) drawable is not set!", self)
    466460            return False
    467461
    468         #deal with buffers uploads by wrapping them if we can, or copy to a string:
    469         if type(img_data)==buffer:
    470             if memoryview_type is not None:
    471                 img_data = memoryview_type(img_data)
    472             else:
    473                 img_data = str(img_data)
    474 
    475462        try:
    476463            self.set_rgb_paint_state()
    477464
     
    534521        return True
    535522
    536523    def do_video_paint(self, img, x, y, enc_width, enc_height, width, height, options, callbacks):
    537         clone = True
    538         #we can only use zero copy upload if the image is "thread_safe"
    539         #(dec_avcodec2 is not safe...)
    540         #and if the data is a memoryview (or if we can wrap it in one)
    541         if memoryview_type is not None and img.is_thread_safe():
    542             pixels = img.get_pixels()
    543             assert len(pixels)==3, "invalid number of planes: %s" % len(pixels)
    544             plane_types = list(set([type(plane) for plane in img.get_pixels()]))
    545             if len(plane_types)==1:
    546                 plane_type = plane_types[0]
    547                 if plane_type==memoryview_type:
    548                     clone = False
    549                 elif plane_type in (str, buffer):
    550                     #wrap with a memoryview that pyopengl can use:
    551                     views = []
    552                     for i in range(3):
    553                         views.append(memoryview_type(pixels[i]))
    554                     img.set_pixels(views)
    555                     clone = False
    556         if clone:
    557             #copy so the data will be usable (usually a str)
    558             img.clone_pixel_data()
     524        #copy so the data will be usable (usually a str)
     525        img.clone_pixel_data()
    559526        gobject.idle_add(self.gl_paint_planar, img, x, y, enc_width, enc_height, width, height, callbacks)
    560527
    561528    def gl_paint_planar(self, img, x, y, enc_width, enc_height, width, height, callbacks):