Beispiel #1
0
def setup_capture(window):
    ww, wh = window.get_geometry()[2:4]
    capture = None
    if USE_NVFBC:
        try:
            if USE_NVFBC_CUDA:
                capture = NvFBC_CUDACapture()
            else:
                capture = NvFBC_SysCapture()
            capture.init_context(ww, wh)
            image = capture.get_image(0, 0, ww, wh)
            assert image
        except Exception as e:
            log("get_image() NvFBC test failed", exc_info=True)
            log("not using %s: %s", capture, e)
            capture = None
    if not capture and XImage.has_XShm() and USE_XSHM:
        capture = XImageCapture(get_xwindow(window))
    if not capture:
        capture = GTKImageCapture(window)
    log("setup_capture(%s)=%s", window, capture)
    return capture
Beispiel #2
0
 def get_image(self, x, y, width, height):
     image = None
     if not self.capture:
         ww, wh = self.get_geometry()[2:4]
         if USE_NVFBC:
             try:
                 if USE_NVFBC_CUDA:
                     self.capture = NvFBC_CUDACapture()
                 else:
                     self.capture = NvFBC_SysCapture()
                 self.capture.init_context(ww, wh)
                 image = self.capture.get_image(x, y, width, height)
             except Exception as e:
                 log("get_image() NvFBC test failed", exc_info=True)
                 log("not using %s: %s", self.capture, e)
                 self.capture = None
         if not self.capture and XImage.has_XShm() and USE_XSHM:
             self.capture = XImageCapture(get_xwindow(self.window))
         if not self.capture:
             self.capture = GTKImageCapture(self)
         log("shadow image capture=%s", self.capture)
     return image or self.capture.get_image(x, y, width, height)