diff options
author | Brian P. Hinz <bphinz@users.sf.net> | 2017-02-26 20:55:40 -0500 |
---|---|---|
committer | Brian P. Hinz <bphinz@users.sf.net> | 2017-02-27 20:16:24 -0500 |
commit | 6fd7e019e9989befdcc53335970707772b8ff3ff (patch) | |
tree | 4e0548d582b38dfa8c27cc846c725295ef6199cb /java/com/tigervnc/vncviewer | |
parent | 7cb4f31f6290df318962226bb35f60d0e2fd975c (diff) | |
download | tigervnc-6fd7e019e9989befdcc53335970707772b8ff3ff.tar.gz tigervnc-6fd7e019e9989befdcc53335970707772b8ff3ff.zip |
Java client support for cursors with full alpha
Diffstat (limited to 'java/com/tigervnc/vncviewer')
-rw-r--r-- | java/com/tigervnc/vncviewer/CConn.java | 4 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/DesktopWindow.java | 4 | ||||
-rw-r--r-- | java/com/tigervnc/vncviewer/Viewport.java | 50 |
3 files changed, 14 insertions, 44 deletions
diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java index 128867b9..c53f8058 100644 --- a/java/com/tigervnc/vncviewer/CConn.java +++ b/java/com/tigervnc/vncviewer/CConn.java @@ -434,9 +434,9 @@ public class CConn extends CConnection implements } public void setCursor(int width, int height, Point hotspot, - byte[] data, byte[] mask) + byte[] data) { - desktop.setCursor(width, height, hotspot, data, mask); + desktop.setCursor(width, height, hotspot, data); } public void fence(int flags, int len, byte[] data) diff --git a/java/com/tigervnc/vncviewer/DesktopWindow.java b/java/com/tigervnc/vncviewer/DesktopWindow.java index 187fbad0..4169c769 100644 --- a/java/com/tigervnc/vncviewer/DesktopWindow.java +++ b/java/com/tigervnc/vncviewer/DesktopWindow.java @@ -282,9 +282,9 @@ public class DesktopWindow extends JFrame } public void setCursor(int width, int height, Point hotspot, - byte[] data, byte[] mask) + byte[] data) { - viewport.setCursor(width, height, hotspot, data, mask); + viewport.setCursor(width, height, hotspot, data); } public void fullscreen_on() diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java index bf07d2d5..f7448bc8 100644 --- a/java/com/tigervnc/vncviewer/Viewport.java +++ b/java/com/tigervnc/vncviewer/Viewport.java @@ -2,7 +2,7 @@ * Copyright (C) 2006 Constantin Kaplinsky. All Rights Reserved. * Copyright (C) 2009 Paul Donohue. All Rights Reserved. * Copyright (C) 2010, 2012-2013 D. R. Commander. All Rights Reserved. - * Copyright (C) 2011-2014 Brian P. Hinz + * Copyright (C) 2011-2017 Brian P. Hinz * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -125,16 +125,14 @@ class Viewport extends JPanel implements MouseListener, }; public void setCursor(int width, int height, Point hotspot, - byte[] data, byte[] mask) + byte[] data) { - - int mask_len = ((width+7)/8) * height; int i; - for (i = 0; i < mask_len; i++) - if ((mask[i] & 0xff) != 0) break; + for (i = 0; i < width*height; i++) + if (data[i*4 + 3] != 0) break; - if ((i == mask_len) && dotWhenNoCursor.getValue()) { + if ((i == width*height) && dotWhenNoCursor.getValue()) { vlog.debug("cursor is empty - using dot"); cursor = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB_PRE); cursor.setRGB(0, 0, 5, 5, dotcursor_xpm, 0, 5); @@ -146,39 +144,11 @@ class Viewport extends JPanel implements MouseListener, BufferedImage.TYPE_INT_ARGB_PRE); cursorHotspot.x = cursorHotspot.y = 0; } else { - ByteBuffer buffer = ByteBuffer.allocate(width*height*4); - ByteBuffer in, o, m; - int m_width; - - PixelFormat pf; - - pf = cc.cp.pf(); - - in = (ByteBuffer)ByteBuffer.wrap(data).mark(); - o = (ByteBuffer)buffer.duplicate().mark(); - m = ByteBuffer.wrap(mask); - m_width = (width+7)/8; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - // NOTE: BufferedImage needs ARGB, rather than RGBA - if ((m.get((m_width*y)+(x/8)) & 0x80>>(x%8)) != 0) - o.put((byte)255); - else - o.put((byte)0); - - pf.rgbFromBuffer(o, in.duplicate(), 1); - - o.position(o.reset().position() + 4).mark(); - in.position(in.position() + pf.bpp/8); - } - } - - IntBuffer rgb = - IntBuffer.allocate(width*height).put(buffer.asIntBuffer()); - cursor = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE); - cursor.setRGB(0, 0, width, height, rgb.array(), 0, width); - + IntBuffer buffer = IntBuffer.allocate(width*height); + buffer.put(ByteBuffer.wrap(data).asIntBuffer()); + cursor = + new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE); + cursor.setRGB(0, 0, width, height, buffer.array(), 0, width); cursorHotspot = hotspot; } |