libbluray | branch: master | hpi1 <[email protected]> | Mon Aug 26 11:12:15 2013 +0300| [731c40ffffbfea1eec25c66e29d417e214e3c792] | committer: hpi1
Implement ImageProducer for off-screen images. Fixes Crank initial playlist. > http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=731c40ffffbfea1eec25c66e29d417e214e3c792 --- src/libbluray/bdj/java/java/awt/BDImageBase.java | 5 +- .../bdj/java/java/awt/BDOffScreenImageSource.java | 89 ++++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/src/libbluray/bdj/java/java/awt/BDImageBase.java b/src/libbluray/bdj/java/java/awt/BDImageBase.java index 95c5de4..c2a5b52 100644 --- a/src/libbluray/bdj/java/java/awt/BDImageBase.java +++ b/src/libbluray/bdj/java/java/awt/BDImageBase.java @@ -42,6 +42,7 @@ class BDImageBase extends Image { protected Area dirty; private GraphicsConfiguration gc; private Vector observers = new Vector(); + private ImageProducer offscreenSource = null; static { try { @@ -78,6 +79,8 @@ class BDImageBase extends Image { backBuffer = new int[width * height]; dirty = new Area(width, height); + + offscreenSource = new BDOffScreenImageSource(backBuffer, width, height); } public void flush() { @@ -132,7 +135,7 @@ class BDImageBase extends Image { } public ImageProducer getSource() { - return null; + return offscreenSource; } public Component getComponent() { diff --git a/src/libbluray/bdj/java/java/awt/BDOffScreenImageSource.java b/src/libbluray/bdj/java/java/awt/BDOffScreenImageSource.java new file mode 100644 index 0000000..a936dc8 --- /dev/null +++ b/src/libbluray/bdj/java/java/awt/BDOffScreenImageSource.java @@ -0,0 +1,89 @@ +/* + * This file is part of libbluray + * Copyright (C) 2013 Petri Hintukainen <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +package java.awt; + +import java.util.Hashtable; +import java.awt.Component; +import java.awt.color.ColorSpace; +import java.awt.image.ColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DirectColorModel; +import java.awt.image.ImageConsumer; +import java.awt.image.ImageProducer; + +class BDOffScreenImageSource implements ImageProducer { + private ImageConsumer consumer; + private int width; + private int height; + private int[] buffer; + + public BDOffScreenImageSource(int[] buffer, int w, int h) { + width = w; + height = h; + this.buffer = buffer; + } + + public synchronized void addConsumer(ImageConsumer ic) { + consumer = ic; + produce(); + } + + public synchronized boolean isConsumer(ImageConsumer ic) { + return (ic == consumer); + } + + public synchronized void removeConsumer(ImageConsumer ic) { + if (consumer == ic) { + consumer = null; + } + } + + public void startProduction(ImageConsumer ic) { + addConsumer(ic); + } + + private ColorModel getColorModel() { + return new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000, true, + DataBuffer.TYPE_INT); + } + + private void sendPixels() + { + if (consumer != null) { + consumer.setPixels(0, 0, width, height, getColorModel(), buffer, 0, width); + } + } + + private void produce() { + if (consumer != null) { + consumer.setDimensions(width, height); + } + if (consumer != null) { + consumer.setProperties(new Hashtable()); + } + sendPixels(); + if (consumer != null) { + consumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE); + } + } + + public void requestTopDownLeftRightResend(ImageConsumer ic) {} +} _______________________________________________ libbluray-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libbluray-devel
