< prev index next >

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

Print this page




   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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.prism.Graphics;
  30 import com.sun.prism.Image;
  31 import com.sun.prism.PrinterGraphics;
  32 import com.sun.prism.ResourceFactory;
  33 import com.sun.prism.Texture;
  34 import com.sun.prism.image.CompoundCoords;
  35 import com.sun.prism.image.CompoundTexture;
  36 import com.sun.prism.image.Coords;
  37 import com.sun.prism.image.ViewPort;
  38 import java.nio.ByteBuffer;
  39 import java.util.logging.Level;
  40 import java.util.logging.Logger;
  41 import javafx.scene.image.PixelFormat;
  42 
  43 /**
  44  * @author Alexey.Ushakov
  45  */
  46 final class WCImageImpl extends PrismImage {
  47     private final static Logger log =
  48         Logger.getLogger(WCImageImpl.class.getName());
  49 
  50     private final Image img;
  51     private Texture texture;
  52     private CompoundTexture compoundTexture;
  53 
  54 
  55     WCImageImpl(int w, int h) {
  56         if (log.isLoggable(Level.FINE)) {
  57             log.log(Level.FINE, "Creating empty image({0},{1})",
  58                     new Object[] {w, h});
  59         }
  60         img = Image.fromIntArgbPreData(new int[w*h], w, h);
  61     }
  62 
  63     WCImageImpl(int[] buffer, int w, int h) {
  64         if (log.isLoggable(Level.FINE)) {
  65             log.log(Level.FINE, "Creating image({0},{1}) from buffer",
  66                     new Object[] {w, h});
  67         }
  68         img = Image.fromIntArgbPreData(buffer, w, h);
  69     }
  70 
  71     WCImageImpl(ImageFrame frame) {
  72         if (log.isLoggable(Level.FINE)) {
  73             log.log(Level.FINE, "Creating image {0}x{1} of type {2} from buffer",
  74                     new Object[]{frame.getWidth(), frame.getHeight(), frame.getImageType()});
  75         }
  76         img = Image.convertImageFrame(frame);
  77     }
  78 
  79     Image getImage() {
  80         return img;
  81     }
  82 
  83     @Override
  84     Graphics getGraphics() {
  85         return null;
  86     }
  87 
  88     @Override
  89     void draw(Graphics g,
  90             int dstx1, int dsty1, int dstx2, int dsty2,
  91             int srcx1, int srcy1, int srcx2, int srcy2)
  92     {
  93         if (g instanceof PrinterGraphics) {




   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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.logging.PlatformLogger;
  30 import com.sun.javafx.logging.PlatformLogger.Level;
  31 import com.sun.prism.Graphics;
  32 import com.sun.prism.Image;
  33 import com.sun.prism.PrinterGraphics;
  34 import com.sun.prism.ResourceFactory;
  35 import com.sun.prism.Texture;
  36 import com.sun.prism.image.CompoundCoords;
  37 import com.sun.prism.image.CompoundTexture;
  38 import com.sun.prism.image.Coords;
  39 import com.sun.prism.image.ViewPort;
  40 import java.nio.ByteBuffer;


  41 import javafx.scene.image.PixelFormat;
  42 
  43 /**
  44  * @author Alexey.Ushakov
  45  */
  46 final class WCImageImpl extends PrismImage {
  47     private final static PlatformLogger log =
  48             PlatformLogger.getLogger(WCImageImpl.class.getName());
  49 
  50     private final Image img;
  51     private Texture texture;
  52     private CompoundTexture compoundTexture;
  53 
  54 
  55     WCImageImpl(int w, int h) {
  56         if (log.isLoggable(Level.FINE)) {
  57             log.fine("Creating empty image({0},{1})",
  58                     new Object[] {w, h});
  59         }
  60         img = Image.fromIntArgbPreData(new int[w*h], w, h);
  61     }
  62 
  63     WCImageImpl(int[] buffer, int w, int h) {
  64         if (log.isLoggable(Level.FINE)) {
  65             log.fine("Creating image({0},{1}) from buffer",
  66                     new Object[] {w, h});
  67         }
  68         img = Image.fromIntArgbPreData(buffer, w, h);
  69     }
  70 
  71     WCImageImpl(ImageFrame frame) {
  72         if (log.isLoggable(Level.FINE)) {
  73             log.fine("Creating image {0}x{1} of type {2} from buffer",
  74                     new Object[]{frame.getWidth(), frame.getHeight(), frame.getImageType()});
  75         }
  76         img = Image.convertImageFrame(frame);
  77     }
  78 
  79     Image getImage() {
  80         return img;
  81     }
  82 
  83     @Override
  84     Graphics getGraphics() {
  85         return null;
  86     }
  87 
  88     @Override
  89     void draw(Graphics g,
  90             int dstx1, int dsty1, int dstx2, int dsty2,
  91             int srcx1, int srcy1, int srcx2, int srcy2)
  92     {
  93         if (g instanceof PrinterGraphics) {


< prev index next >