< prev index next >

modules/javafx.web/src/main/java/com/sun/javafx/webkit/prism/WCImageDecoderImpl.java

Print this page




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.webkit.prism;
  27 
  28 import com.sun.javafx.iio.ImageFrame;
  29 import com.sun.javafx.iio.ImageLoadListener;
  30 import com.sun.javafx.iio.ImageLoader;
  31 import com.sun.javafx.iio.ImageMetadata;
  32 import com.sun.javafx.iio.ImageStorage;
  33 import com.sun.javafx.iio.ImageStorageException;


  34 import com.sun.webkit.graphics.WCGraphicsManager;
  35 import com.sun.webkit.graphics.WCImage;
  36 import com.sun.webkit.graphics.WCImageDecoder;
  37 import com.sun.webkit.graphics.WCImageFrame;
  38 import java.io.ByteArrayInputStream;
  39 import java.io.IOException;
  40 import java.io.InputStream;
  41 import java.util.Arrays;
  42 import java.util.logging.Level;
  43 import java.util.logging.Logger;
  44 import javafx.concurrent.Service;
  45 import javafx.concurrent.Task;
  46 
  47 final class WCImageDecoderImpl extends WCImageDecoder {
  48 
  49     private final static Logger log;
  50 
  51     private Service<ImageFrame[]> loader;
  52 
  53     private int imageWidth = 0;
  54     private int imageHeight = 0;
  55     private ImageFrame[] frames;
  56     private int frameCount = 0; // keeps frame count when decoded frames are temporarily destroyed
  57     private boolean fullDataReceived = false;
  58     private boolean framesDecoded = false; // guards frames from repeated decoding
  59     private PrismImage[] images;
  60     private volatile byte[] data;
  61     private volatile int dataSize = 0;
  62     private String fileNameExtension;
  63 
  64     static {
  65         log = Logger.getLogger(WCImageDecoderImpl.class.getName());
  66     }
  67 
  68     /*
  69      * This method is supposed to be called from ImageSource::clear() method
  70      * when either the decoded data or the image decoder itself are to be destroyed.
  71      * It should free all complex object on the java layer and explicitely
  72      * destroy objects which has native resources.
  73      */
  74     @Override protected synchronized void destroy() {
  75         if (log.isLoggable(Level.FINE)) {
  76             log.fine(String.format("%X Destroy image decoder", hashCode()));
  77         }
  78 
  79         destroyLoader();
  80         frames = null;
  81         images = null;
  82         framesDecoded = false;
  83     }
  84 
  85     @Override protected String getFilenameExtension() {




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.webkit.prism;
  27 
  28 import com.sun.javafx.iio.ImageFrame;
  29 import com.sun.javafx.iio.ImageLoadListener;
  30 import com.sun.javafx.iio.ImageLoader;
  31 import com.sun.javafx.iio.ImageMetadata;
  32 import com.sun.javafx.iio.ImageStorage;
  33 import com.sun.javafx.iio.ImageStorageException;
  34 import com.sun.javafx.logging.PlatformLogger;
  35 import com.sun.javafx.logging.PlatformLogger.Level;
  36 import com.sun.webkit.graphics.WCGraphicsManager;
  37 import com.sun.webkit.graphics.WCImage;
  38 import com.sun.webkit.graphics.WCImageDecoder;
  39 import com.sun.webkit.graphics.WCImageFrame;
  40 import java.io.ByteArrayInputStream;
  41 import java.io.IOException;
  42 import java.io.InputStream;
  43 import java.util.Arrays;


  44 import javafx.concurrent.Service;
  45 import javafx.concurrent.Task;
  46 
  47 final class WCImageDecoderImpl extends WCImageDecoder {
  48 
  49     private final static PlatformLogger log;
  50 
  51     private Service<ImageFrame[]> loader;
  52 
  53     private int imageWidth = 0;
  54     private int imageHeight = 0;
  55     private ImageFrame[] frames;
  56     private int frameCount = 0; // keeps frame count when decoded frames are temporarily destroyed
  57     private boolean fullDataReceived = false;
  58     private boolean framesDecoded = false; // guards frames from repeated decoding
  59     private PrismImage[] images;
  60     private volatile byte[] data;
  61     private volatile int dataSize = 0;
  62     private String fileNameExtension;
  63 
  64     static {
  65         log = PlatformLogger.getLogger(WCImageDecoderImpl.class.getName());
  66     }
  67 
  68     /*
  69      * This method is supposed to be called from ImageSource::clear() method
  70      * when either the decoded data or the image decoder itself are to be destroyed.
  71      * It should free all complex object on the java layer and explicitely
  72      * destroy objects which has native resources.
  73      */
  74     @Override protected synchronized void destroy() {
  75         if (log.isLoggable(Level.FINE)) {
  76             log.fine(String.format("%X Destroy image decoder", hashCode()));
  77         }
  78 
  79         destroyLoader();
  80         frames = null;
  81         images = null;
  82         framesDecoded = false;
  83     }
  84 
  85     @Override protected String getFilenameExtension() {


< prev index next >