Browse Source

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.
tags/v1.8.90
Pierre Ossman 7 years ago
parent
commit
a88991bdc8
1 changed files with 11 additions and 3 deletions
  1. 11
    3
      vncviewer/Surface_OSX.cxx

+ 11
- 3
vncviewer/Surface_OSX.cxx View File



static CGImageRef create_image(CGColorSpaceRef lut, static CGImageRef create_image(CGColorSpaceRef lut,
const unsigned char* data, const unsigned char* data,
int w, int h)
int w, int h, bool skip_alpha)
{ {
CGDataProviderRef provider; CGDataProviderRef provider;
CGImageAlphaInfo alpha;


CGImageRef image; CGImageRef image;


if (!provider) if (!provider)
throw rdr::Exception("CGDataProviderCreateWithData"); 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, image = CGImageCreate(w, h, 8, 32, w * 4, lut,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little,
alpha | kCGBitmapByteOrder32Little,
provider, NULL, false, kCGRenderingIntentDefault); provider, NULL, false, kCGRenderingIntentDefault);
CGDataProviderRelease(provider); CGDataProviderRelease(provider);
if (!image) if (!image)
CGRect rect; CGRect rect;
CGImageRef image, subimage; 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.x = src_x;
rect.origin.y = src_y; rect.origin.y = src_y;

Loading…
Cancel
Save