Skip to content

Commit

Permalink
#391: ensure that picture_encode can deal with pixels wrapped in NSCF…
Browse files Browse the repository at this point in the history
…Data objects

git-svn-id: https://xpra.org/svn/Xpra/trunk@12392 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 16, 2016
1 parent 705ad5f commit ee87e89
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/xpra/platform/darwin/shadow_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
CG.kCGImageAlphaNoneSkipFirst : "SkipFirst",
}

#ensure that picture_encode can deal with pixels as NSCFData:
def patch_picture_encode():
from Foundation import NSCFData #@UnresolvedImport
from CoreFoundation import CFDataGetBytes, CFDataGetLength #@UnresolvedImport
from xpra.os_util import memoryview_to_bytes
def pixels_to_bytes(v):
if isinstance(v, NSCFData):
l = CFDataGetLength(v)
return CFDataGetBytes(v, (0, l), None)
return memoryview_to_bytes(v)
from xpra.server import picture_encode
picture_encode.pixels_to_bytes = pixels_to_bytes
patch_picture_encode()


class OSXRootWindowModel(RootWindowModel):

Expand Down
5 changes: 3 additions & 2 deletions src/xpra/server/picture_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from xpra.net import compression
from xpra.codecs.argb.argb import bgra_to_rgb, bgra_to_rgba, argb_to_rgb, argb_to_rgba #@UnresolvedImport
from xpra.codecs.loader import get_codec
from xpra.os_util import memoryview_to_bytes, _memoryview
#"pixels_to_bytes" gets patched up by the OSX shadow server
from xpra.os_util import memoryview_to_bytes as pixels_to_bytes, _memoryview
try:
from xpra.net.mmap_pipe import mmap_write
except:
Expand Down Expand Up @@ -138,7 +139,7 @@ def rgb_encode(coding, image, rgb_formats, supports_transparency, speed, rgb_zli
if level==0:
#can't pass a raw buffer to bencode / rencode,
#and even if we could, the image containing those pixels may be freed by the time we get to the encoder
cwrapper = compression.Compressed(coding, memoryview_to_bytes(pixels), True)
cwrapper = compression.Compressed(coding, pixels_to_bytes(pixels), True)
if pixel_format.upper().find("A")>=0 or pixel_format.upper().find("X")>=0:
bpp = 32
else:
Expand Down

0 comments on commit ee87e89

Please sign in to comment.