src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java

Print this page


   1 /*
   2  * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   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 sun.java2d.d3d;
  27 
  28 import java.awt.Composite;
  29 import java.awt.Transparency;
  30 import java.awt.geom.AffineTransform;
  31 import java.awt.image.AffineTransformOp;
  32 import java.awt.image.BufferedImage;
  33 import java.awt.image.BufferedImageOp;
  34 import java.lang.ref.WeakReference;
  35 import javax.tools.annotation.GenerateNativeHeader;
  36 import sun.java2d.ScreenUpdateManager;
  37 import sun.java2d.SurfaceData;
  38 import sun.java2d.loops.Blit;
  39 import sun.java2d.loops.CompositeType;
  40 import sun.java2d.loops.GraphicsPrimitive;
  41 import sun.java2d.loops.GraphicsPrimitiveMgr;
  42 import sun.java2d.loops.ScaledBlit;
  43 import sun.java2d.loops.SurfaceType;
  44 import sun.java2d.loops.TransformBlit;
  45 import sun.java2d.pipe.Region;
  46 import sun.java2d.pipe.RenderBuffer;
  47 import sun.java2d.pipe.RenderQueue;
  48 import static sun.java2d.pipe.BufferedOpCodes.*;
  49 import sun.java2d.windows.GDIWindowSurfaceData;
  50 
  51 /* No native methods here, but the constants are needed in the supporting JNI code */
  52 @GenerateNativeHeader
  53 class D3DBlitLoops {
  54 
  55     static void register() {
  56         Blit blitIntArgbPreToSurface =
  57             new D3DSwToSurfaceBlit(SurfaceType.IntArgbPre,
  58                                    D3DSurfaceData.ST_INT_ARGB_PRE);
  59         Blit blitIntArgbPreToTexture =
  60             new D3DSwToTextureBlit(SurfaceType.IntArgbPre,
  61                                    D3DSurfaceData.ST_INT_ARGB_PRE);
  62 
  63         GraphicsPrimitive[] primitives = {
  64             // prevent D3DSurface -> Screen blits
  65             new D3DSurfaceToGDIWindowSurfaceBlit(),
  66             new D3DSurfaceToGDIWindowSurfaceScale(),
  67             new D3DSurfaceToGDIWindowSurfaceTransform(),
  68 
  69             // surface->surface ops
  70             new D3DSurfaceToSurfaceBlit(),
  71             new D3DSurfaceToSurfaceScale(),
  72             new D3DSurfaceToSurfaceTransform(),


 162                                    D3DSurfaceData.ST_USHORT_565_RGB),
 163             new D3DSwToTextureBlit(SurfaceType.Ushort555Rgb,
 164                                    D3DSurfaceData.ST_USHORT_555_RGB),
 165             new D3DSwToTextureBlit(SurfaceType.ByteIndexed,
 166                                    D3DSurfaceData.ST_BYTE_INDEXED),
 167             // REMIND: we don't have a native sw loop to back this loop up
 168 //            new D3DSwToTextureBlit(SurfaceType.ByteIndexedBm,
 169 //                                   D3DSurfaceData.ST_BYTE_INDEXED_BM),
 170             new D3DGeneralBlit(D3DSurfaceData.D3DTexture,
 171                                CompositeType.SrcNoEa,
 172                                blitIntArgbPreToTexture),
 173         };
 174         GraphicsPrimitiveMgr.register(primitives);
 175     }
 176 
 177     /**
 178      * The following offsets are used to pack the parameters in
 179      * createPackedParams().  (They are also used at the native level when
 180      * unpacking the params.)
 181      */
 182     private static final int OFFSET_SRCTYPE = 16;
 183     private static final int OFFSET_HINT    =  8;
 184     private static final int OFFSET_TEXTURE =  3;
 185     private static final int OFFSET_RTT     =  2;
 186     private static final int OFFSET_XFORM   =  1;
 187     private static final int OFFSET_ISOBLIT =  0;
 188 
 189     /**
 190      * Packs the given parameters into a single int value in order to save
 191      * space on the rendering queue.
 192      */
 193     private static int createPackedParams(boolean isoblit, boolean texture,
 194                                           boolean rtt, boolean xform,
 195                                           int hint, int srctype)
 196     {
 197         return
 198             ((srctype           << OFFSET_SRCTYPE) |
 199              (hint              << OFFSET_HINT   ) |
 200              ((texture ? 1 : 0) << OFFSET_TEXTURE) |
 201              ((rtt     ? 1 : 0) << OFFSET_RTT    ) |
 202              ((xform   ? 1 : 0) << OFFSET_XFORM  ) |
 203              ((isoblit ? 1 : 0) << OFFSET_ISOBLIT));
 204     }
 205 
 206     /**
 207      * Enqueues a BLIT operation with the given parameters.  Note that the


   1 /*
   2  * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   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 sun.java2d.d3d;
  27 
  28 import java.awt.Composite;
  29 import java.awt.Transparency;
  30 import java.awt.geom.AffineTransform;
  31 import java.awt.image.AffineTransformOp;
  32 import java.awt.image.BufferedImage;
  33 import java.awt.image.BufferedImageOp;
  34 import java.lang.ref.WeakReference;
  35 import java.lang.annotation.Native;
  36 import sun.java2d.ScreenUpdateManager;
  37 import sun.java2d.SurfaceData;
  38 import sun.java2d.loops.Blit;
  39 import sun.java2d.loops.CompositeType;
  40 import sun.java2d.loops.GraphicsPrimitive;
  41 import sun.java2d.loops.GraphicsPrimitiveMgr;
  42 import sun.java2d.loops.ScaledBlit;
  43 import sun.java2d.loops.SurfaceType;
  44 import sun.java2d.loops.TransformBlit;
  45 import sun.java2d.pipe.Region;
  46 import sun.java2d.pipe.RenderBuffer;
  47 import sun.java2d.pipe.RenderQueue;
  48 import static sun.java2d.pipe.BufferedOpCodes.*;
  49 import sun.java2d.windows.GDIWindowSurfaceData;
  50 


  51 class D3DBlitLoops {
  52 
  53     static void register() {
  54         Blit blitIntArgbPreToSurface =
  55             new D3DSwToSurfaceBlit(SurfaceType.IntArgbPre,
  56                                    D3DSurfaceData.ST_INT_ARGB_PRE);
  57         Blit blitIntArgbPreToTexture =
  58             new D3DSwToTextureBlit(SurfaceType.IntArgbPre,
  59                                    D3DSurfaceData.ST_INT_ARGB_PRE);
  60 
  61         GraphicsPrimitive[] primitives = {
  62             // prevent D3DSurface -> Screen blits
  63             new D3DSurfaceToGDIWindowSurfaceBlit(),
  64             new D3DSurfaceToGDIWindowSurfaceScale(),
  65             new D3DSurfaceToGDIWindowSurfaceTransform(),
  66 
  67             // surface->surface ops
  68             new D3DSurfaceToSurfaceBlit(),
  69             new D3DSurfaceToSurfaceScale(),
  70             new D3DSurfaceToSurfaceTransform(),


 160                                    D3DSurfaceData.ST_USHORT_565_RGB),
 161             new D3DSwToTextureBlit(SurfaceType.Ushort555Rgb,
 162                                    D3DSurfaceData.ST_USHORT_555_RGB),
 163             new D3DSwToTextureBlit(SurfaceType.ByteIndexed,
 164                                    D3DSurfaceData.ST_BYTE_INDEXED),
 165             // REMIND: we don't have a native sw loop to back this loop up
 166 //            new D3DSwToTextureBlit(SurfaceType.ByteIndexedBm,
 167 //                                   D3DSurfaceData.ST_BYTE_INDEXED_BM),
 168             new D3DGeneralBlit(D3DSurfaceData.D3DTexture,
 169                                CompositeType.SrcNoEa,
 170                                blitIntArgbPreToTexture),
 171         };
 172         GraphicsPrimitiveMgr.register(primitives);
 173     }
 174 
 175     /**
 176      * The following offsets are used to pack the parameters in
 177      * createPackedParams().  (They are also used at the native level when
 178      * unpacking the params.)
 179      */
 180     @Native private static final int OFFSET_SRCTYPE = 16;
 181     @Native private static final int OFFSET_HINT    =  8;
 182     @Native private static final int OFFSET_TEXTURE =  3;
 183     @Native private static final int OFFSET_RTT     =  2;
 184     @Native private static final int OFFSET_XFORM   =  1;
 185     @Native private static final int OFFSET_ISOBLIT =  0;
 186 
 187     /**
 188      * Packs the given parameters into a single int value in order to save
 189      * space on the rendering queue.
 190      */
 191     private static int createPackedParams(boolean isoblit, boolean texture,
 192                                           boolean rtt, boolean xform,
 193                                           int hint, int srctype)
 194     {
 195         return
 196             ((srctype           << OFFSET_SRCTYPE) |
 197              (hint              << OFFSET_HINT   ) |
 198              ((texture ? 1 : 0) << OFFSET_TEXTURE) |
 199              ((rtt     ? 1 : 0) << OFFSET_RTT    ) |
 200              ((xform   ? 1 : 0) << OFFSET_XFORM  ) |
 201              ((isoblit ? 1 : 0) << OFFSET_ISOBLIT));
 202     }
 203 
 204     /**
 205      * Enqueues a BLIT operation with the given parameters.  Note that the