aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorBrian P. Hinz <bphinz@users.sf.net>2017-05-24 23:17:37 -0400
committerBrian P. Hinz <bphinz@users.sf.net>2017-05-24 23:35:07 -0400
commit60a17853ade06082c7adc5682d8437db319db5eb (patch)
tree02bdbc9d54e2ddcfccc5b8cf5d23738b1b6395a0 /java
parent4aaef59e2079b3f9e7802a68b83b933f43ca3790 (diff)
downloadtigervnc-60a17853ade06082c7adc5682d8437db319db5eb.tar.gz
tigervnc-60a17853ade06082c7adc5682d8437db319db5eb.zip
Extend JavaPixelBuffer to make further use of Graphics2D ops
Diffstat (limited to 'java')
-rw-r--r--java/com/tigervnc/vncviewer/JavaPixelBuffer.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/java/com/tigervnc/vncviewer/JavaPixelBuffer.java b/java/com/tigervnc/vncviewer/JavaPixelBuffer.java
index 4febec15..016b8cf8 100644
--- a/java/com/tigervnc/vncviewer/JavaPixelBuffer.java
+++ b/java/com/tigervnc/vncviewer/JavaPixelBuffer.java
@@ -24,6 +24,7 @@ import java.awt.image.*;
import java.nio.*;
import com.tigervnc.rfb.*;
+import com.tigervnc.rfb.Point;
public class JavaPixelBuffer extends PlatformPixelBuffer
{
@@ -36,6 +37,23 @@ public class JavaPixelBuffer extends PlatformPixelBuffer
image.setAccelerationPriority(1);
}
+ public WritableRaster getBufferRW(Rect r)
+ {
+ synchronized(image) {
+ return ((BufferedImage)image)
+ .getSubimage(r.tl.x, r.tl.y, r.width(), r.height()).getRaster();
+ }
+ }
+
+ public Raster getBuffer(Rect r)
+ {
+ Rectangle rect =
+ new Rectangle(r.tl.x, r.tl.y, r.width(), r.height());
+ synchronized(image) {
+ return ((BufferedImage)image).getData(rect);
+ }
+ }
+
public void fillRect(Rect r, byte[] pix)
{
ColorModel cm = format.getColorModel();
@@ -43,7 +61,7 @@ public class JavaPixelBuffer extends PlatformPixelBuffer
ByteBuffer.wrap(pix).order(format.getByteOrder()).asIntBuffer().get(0);
Color c = new Color(cm.getRGB(pixel));
synchronized(image) {
- Graphics2D g2 = ((BufferedImage)image).createGraphics();
+ Graphics2D g2 = (Graphics2D)image.getGraphics();
g2.setColor(c);
g2.fillRect(r.tl.x, r.tl.y, r.width(), r.height());
g2.dispose();
@@ -52,6 +70,20 @@ public class JavaPixelBuffer extends PlatformPixelBuffer
commitBufferRW(r);
}
+ public void copyRect(Rect rect, Point move_by_delta)
+ {
+ synchronized(image) {
+ Graphics2D g2 = (Graphics2D)image.getGraphics();
+ g2.copyArea(rect.tl.x - move_by_delta.x,
+ rect.tl.y - move_by_delta.y,
+ rect.width(), rect.height(),
+ move_by_delta.x, move_by_delta.y);
+ g2.dispose();
+ }
+
+ commitBufferRW(rect);
+ }
+
private static PixelFormat getPreferredPF()
{
GraphicsEnvironment ge =