aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2017-04-27 13:28:49 +0200
committerPierre Ossman <ossman@cendio.se>2017-04-28 11:45:42 +0200
commit2d0dc3abee27c9383ad3ab23e02ecf94fcdd7596 (patch)
tree3e3aea5b08e79f7ea5f2247c45f16dfd9768d78d /vncviewer
parent0630434292b19898e6bd66e46cc4c6a641efdfe5 (diff)
downloadtigervnc-2d0dc3abee27c9383ad3ab23e02ecf94fcdd7596.tar.gz
tigervnc-2d0dc3abee27c9383ad3ab23e02ecf94fcdd7596.zip
Use sub-image instead of clipping
It seems to be more efficient.
Diffstat (limited to 'vncviewer')
-rw-r--r--vncviewer/Surface_OSX.cxx36
1 files changed, 18 insertions, 18 deletions
diff --git a/vncviewer/Surface_OSX.cxx b/vncviewer/Surface_OSX.cxx
index 2dfaa477..668187bc 100644
--- a/vncviewer/Surface_OSX.cxx
+++ b/vncviewer/Surface_OSX.cxx
@@ -30,32 +30,36 @@
static void render(CGContextRef gc, CGImageRef image,
CGBlendMode mode, CGFloat alpha,
- int src_x, int src_y, int src_w, int src_h,
+ int src_x, int src_y,
int x, int y, int w, int h)
{
CGRect rect;
+ CGImageRef subimage;
+
+ rect.origin.x = src_x;
+ rect.origin.y = src_y;
+ rect.size.width = w;
+ rect.size.height = h;
+
+ subimage = CGImageCreateWithImageInRect(image, rect);
+ if (!subimage)
+ throw rdr::Exception("CGImageCreateImageWithImageInRect");
CGContextSaveGState(gc);
CGContextSetBlendMode(gc, mode);
CGContextSetAlpha(gc, alpha);
- // We have to use clipping to partially display an image
rect.origin.x = x;
rect.origin.y = y;
rect.size.width = w;
rect.size.height = h;
- CGContextClipToRect(gc, rect);
-
- rect.origin.x = x - src_x;
- rect.origin.y = y - src_y;
- rect.size.width = src_w;
- rect.size.height = src_h;
-
- CGContextDrawImage(gc, rect, image);
+ CGContextDrawImage(gc, rect, subimage);
CGContextRestoreGState(gc);
+
+ CGImageRelease(subimage);
}
static CGContextRef make_bitmap(int width, int height, unsigned char* data)
@@ -108,11 +112,10 @@ void Surface::draw(int src_x, int src_y, int x, int y, int w, int h)
CGContextConcatCTM(fl_gc, CGAffineTransformInvert(CGContextGetCTM(fl_gc)));
// macOS Coordinates are from bottom left, not top left
- src_y = height() - (src_y + h);
y = Fl_Window::current()->h() - (y + h);
render(fl_gc, image, kCGBlendModeCopy, 1.0,
- src_x, src_y, width(), height(), x, y, w, h);
+ src_x, src_y, x, y, w, h);
CGContextRestoreGState(fl_gc);
}
@@ -124,11 +127,10 @@ void Surface::draw(Surface* dst, int src_x, int src_y, int x, int y, int w, int
bitmap = make_bitmap(dst->width(), dst->height(), dst->data);
// macOS Coordinates are from bottom left, not top left
- src_y = height() - (src_y + h);
y = dst->height() - (y + h);
render(bitmap, image, kCGBlendModeCopy, 1.0,
- src_x, src_y, width(), height(), x, y, w, h);
+ src_x, src_y, x, y, w, h);
CGContextRelease(bitmap);
}
@@ -142,11 +144,10 @@ void Surface::blend(int src_x, int src_y, int x, int y, int w, int h, int a)
CGContextConcatCTM(fl_gc, CGAffineTransformInvert(CGContextGetCTM(fl_gc)));
// macOS Coordinates are from bottom left, not top left
- src_y = height() - (src_y + h);
y = Fl_Window::current()->h() - (y + h);
render(fl_gc, image, kCGBlendModeNormal, (CGFloat)a/255.0,
- src_x, src_y, width(), height(), x, y, w, h);
+ src_x, src_y, x, y, w, h);
CGContextRestoreGState(fl_gc);
}
@@ -158,11 +159,10 @@ void Surface::blend(Surface* dst, int src_x, int src_y, int x, int y, int w, int
bitmap = make_bitmap(dst->width(), dst->height(), dst->data);
// macOS Coordinates are from bottom left, not top left
- src_y = height() - (src_y + h);
y = dst->height() - (y + h);
render(bitmap, image, kCGBlendModeNormal, (CGFloat)a/255.0,
- src_x, src_y, width(), height(), x, y, w, h);
+ src_x, src_y, x, y, w, h);
CGContextRelease(bitmap);
}