aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2017-04-28 11:40:02 +0200
committerPierre Ossman <ossman@cendio.se>2017-04-28 12:29:37 +0200
commita88991bdc8154bda8a805755dd82cb71c93b35df (patch)
treef5880c7bb325830e6c9e0af288620aface0f232e
parent1669a2d5a15aa39313cb74eff4f62dfe14d136cd (diff)
downloadtigervnc-a88991bdc8154bda8a805755dd82cb71c93b35df.tar.gz
tigervnc-a88991bdc8154bda8a805755dd82cb71c93b35df.zip
Filter out alpha channel for normal draw() operation
macOS actually uses the alpha channel on windows, so we can get visual artifacts if we feed it bogus alpha data. This filtering unfortunately causes some CPU usage, but it's necessary until we can make sure the framebuffer always contains proper 0xff for alpha.
-rw-r--r--vncviewer/Surface_OSX.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/vncviewer/Surface_OSX.cxx b/vncviewer/Surface_OSX.cxx
index 3313ae3b..fe2d722b 100644
--- a/vncviewer/Surface_OSX.cxx
+++ b/vncviewer/Surface_OSX.cxx
@@ -33,9 +33,10 @@ static CGColorSpaceRef srgb = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
static CGImageRef create_image(CGColorSpaceRef lut,
const unsigned char* data,
- int w, int h)
+ int w, int h, bool skip_alpha)
{
CGDataProviderRef provider;
+ CGImageAlphaInfo alpha;
CGImageRef image;
@@ -44,8 +45,15 @@ static CGImageRef create_image(CGColorSpaceRef lut,
if (!provider)
throw rdr::Exception("CGDataProviderCreateWithData");
+ // FIXME: This causes a performance hit, but is necessary to avoid
+ // artifacts in the edges of the window
+ if (skip_alpha)
+ alpha = kCGImageAlphaNoneSkipFirst;
+ else
+ alpha = kCGImageAlphaPremultipliedFirst;
+
image = CGImageCreate(w, h, 8, 32, w * 4, lut,
- kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little,
+ alpha | kCGBitmapByteOrder32Little,
provider, NULL, false, kCGRenderingIntentDefault);
CGDataProviderRelease(provider);
if (!image)
@@ -63,7 +71,7 @@ static void render(CGContextRef gc, CGColorSpaceRef lut,
CGRect rect;
CGImageRef image, subimage;
- image = create_image(lut, data, src_w, src_h);
+ image = create_image(lut, data, src_w, src_h, mode == kCGBlendModeCopy);
rect.origin.x = src_x;
rect.origin.y = src_y;