xpra icon
Bug tracker and wiki

Ticket #478: gl-noclear.patch

File gl-noclear.patch, 2.8 KB (added by Antoine Martin, 5 years ago)

tries not to clear the textures and fbos when resizing

  • xpra/client/gl/gl_window_backing.py

     
    136136        self.texture_size = 0, 0
    137137        self.gl_setup = False
    138138        self.debug_setup = False
     139        self.resize = False
    139140        self.paint_screen = False
    140141        self._video_use_swscale = False
    141142        self.draw_needs_refresh = False
     
    145146        return "GLPixmapBacking(%s, %s, %s)" % (self.wid, self.size, self.pixel_format)
    146147
    147148    def init(self, w, h):
     149        log.info("init(%s, %s) gl_setup=%s", w, h, self.gl_setup)
    148150        #re-init gl projection with new dimensions
    149151        #(see gl_init)
    150152        if self.size!=(w, h):
     153            self.resize = (self.size!=(0, 0))
    151154            self.gl_setup = False
    152155            self.size = w, h
    153156
     
    224227            self.gl_init_debug()
    225228
    226229        if not self.gl_setup:
    227             self.gl_marker("Initializing GL context for window size %d x %d" % (w, h))
     230            self.gl_marker("Initializing GL context for window size %d x %d (resize=%s)" % (w, h, self.resize))
    228231            # Initialize viewport and matrices for 2D rendering
    229232            glViewport(0, 0, w, h)
    230233            glMatrixMode(GL_PROJECTION)
     
    235238            # glEnableClientState(GL_VERTEX_ARRAY)
    236239            # glEnableClientState(GL_TEXTURE_COORD_ARRAY)
    237240
     241            #if not self.resize:
    238242            # Clear background to transparent black
    239243            glClearColor(0.0, 0.0, 0.0, 0.0)
    240244
     
    248252            # Define empty FBO texture and set rendering to FBO
    249253            glEnable(GL_FRAGMENT_PROGRAM_ARB)
    250254            glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[TEX_FBO])
    251             glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, None)
     255            if not self.resize:
     256                glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, None)
    252257            glBindFramebuffer(GL_FRAMEBUFFER, self.offscreen_fbo)
    253258            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, self.textures[TEX_FBO], 0)
    254             glClear(GL_COLOR_BUFFER_BIT)
     259            if not self.resize:
     260                glClear(GL_COLOR_BUFFER_BIT)
     261            #if not self.resize:
     262            #glClearColor(0.0, 0.0, 0.0, 0.0)
    255263
    256264            # Create and assign fragment programs
    257265            if not self.shaders:
     
    260268            # Bind program 0 for YUV painting by default
    261269            glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, self.shaders[YUV2RGB_SHADER])
    262270            self.gl_setup = True
     271            self.resize = False
    263272        return drawable
    264273
    265274    def close(self):