1 /*
2 * Copyright (c) 2003, 2007, 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
28 import java.awt.AlphaComposite;
29 import java.awt.Composite;
30 import java.awt.Transparency;
31 import java.awt.geom.AffineTransform;
32 import java.awt.image.AffineTransformOp;
33 import java.awt.image.BufferedImage;
34 import java.awt.image.BufferedImageOp;
35 import java.lang.ref.WeakReference;
36 import sun.java2d.SurfaceData;
37 import sun.java2d.loops.Blit;
38 import sun.java2d.loops.CompositeType;
39 import sun.java2d.loops.GraphicsPrimitive;
40 import sun.java2d.loops.GraphicsPrimitiveMgr;
41 import sun.java2d.loops.ScaledBlit;
42 import sun.java2d.loops.SurfaceType;
43 import sun.java2d.loops.TransformBlit;
44 import sun.java2d.pipe.Region;
45 import sun.java2d.pipe.RenderBuffer;
46 import sun.java2d.pipe.RenderQueue;
47 import static sun.java2d.pipe.BufferedOpCodes.*;
48 import javax.tools.annotation.GenerateNativeHeader;
49
50 /* No native methods here, but the constants are needed in the supporting JNI code */
51 @GenerateNativeHeader
52 class OGLBlitLoops {
53
54 static void register() {
55 Blit blitIntArgbPreToSurface =
56 new OGLSwToSurfaceBlit(SurfaceType.IntArgbPre,
57 OGLSurfaceData.PF_INT_ARGB_PRE);
58 Blit blitIntArgbPreToTexture =
59 new OGLSwToTextureBlit(SurfaceType.IntArgbPre,
60 OGLSurfaceData.PF_INT_ARGB_PRE);
61
62 GraphicsPrimitive[] primitives = {
63 // surface->surface ops
64 new OGLSurfaceToSurfaceBlit(),
65 new OGLSurfaceToSurfaceScale(),
66 new OGLSurfaceToSurfaceTransform(),
67
68 // render-to-texture surface->surface ops
69 new OGLRTTSurfaceToSurfaceBlit(),
70 new OGLRTTSurfaceToSurfaceScale(),
71 new OGLRTTSurfaceToSurfaceTransform(),
173 OGLSurfaceData.PF_USHORT_555_RGBX),
174 new OGLSwToTextureBlit(SurfaceType.ByteGray,
175 OGLSurfaceData.PF_BYTE_GRAY),
176 new OGLSwToTextureBlit(SurfaceType.UshortGray,
177 OGLSurfaceData.PF_USHORT_GRAY),
178 new OGLGeneralBlit(OGLSurfaceData.OpenGLTexture,
179 CompositeType.SrcNoEa,
180 blitIntArgbPreToTexture),
181
182 new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLTexture),
183
184 };
185 GraphicsPrimitiveMgr.register(primitives);
186 }
187
188 /**
189 * The following offsets are used to pack the parameters in
190 * createPackedParams(). (They are also used at the native level when
191 * unpacking the params.)
192 */
193 private static final int OFFSET_SRCTYPE = 16;
194 private static final int OFFSET_HINT = 8;
195 private static final int OFFSET_TEXTURE = 3;
196 private static final int OFFSET_RTT = 2;
197 private static final int OFFSET_XFORM = 1;
198 private static final int OFFSET_ISOBLIT = 0;
199
200 /**
201 * Packs the given parameters into a single int value in order to save
202 * space on the rendering queue.
203 */
204 private static int createPackedParams(boolean isoblit, boolean texture,
205 boolean rtt, boolean xform,
206 int hint, int srctype)
207 {
208 return
209 ((srctype << OFFSET_SRCTYPE) |
210 (hint << OFFSET_HINT ) |
211 ((texture ? 1 : 0) << OFFSET_TEXTURE) |
212 ((rtt ? 1 : 0) << OFFSET_RTT ) |
213 ((xform ? 1 : 0) << OFFSET_XFORM ) |
214 ((isoblit ? 1 : 0) << OFFSET_ISOBLIT));
215 }
216
217 /**
218 * Enqueues a BLIT operation with the given parameters. Note that the
|
1 /*
2 * Copyright (c) 2003, 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
28 import java.awt.AlphaComposite;
29 import java.awt.Composite;
30 import java.awt.Transparency;
31 import java.awt.geom.AffineTransform;
32 import java.awt.image.AffineTransformOp;
33 import java.awt.image.BufferedImage;
34 import java.awt.image.BufferedImageOp;
35 import java.lang.ref.WeakReference;
36 import sun.java2d.SurfaceData;
37 import sun.java2d.loops.Blit;
38 import sun.java2d.loops.CompositeType;
39 import sun.java2d.loops.GraphicsPrimitive;
40 import sun.java2d.loops.GraphicsPrimitiveMgr;
41 import sun.java2d.loops.ScaledBlit;
42 import sun.java2d.loops.SurfaceType;
43 import sun.java2d.loops.TransformBlit;
44 import sun.java2d.pipe.Region;
45 import sun.java2d.pipe.RenderBuffer;
46 import sun.java2d.pipe.RenderQueue;
47 import static sun.java2d.pipe.BufferedOpCodes.*;
48 import java.lang.annotation.Native;
49
50 class OGLBlitLoops {
51
52 static void register() {
53 Blit blitIntArgbPreToSurface =
54 new OGLSwToSurfaceBlit(SurfaceType.IntArgbPre,
55 OGLSurfaceData.PF_INT_ARGB_PRE);
56 Blit blitIntArgbPreToTexture =
57 new OGLSwToTextureBlit(SurfaceType.IntArgbPre,
58 OGLSurfaceData.PF_INT_ARGB_PRE);
59
60 GraphicsPrimitive[] primitives = {
61 // surface->surface ops
62 new OGLSurfaceToSurfaceBlit(),
63 new OGLSurfaceToSurfaceScale(),
64 new OGLSurfaceToSurfaceTransform(),
65
66 // render-to-texture surface->surface ops
67 new OGLRTTSurfaceToSurfaceBlit(),
68 new OGLRTTSurfaceToSurfaceScale(),
69 new OGLRTTSurfaceToSurfaceTransform(),
171 OGLSurfaceData.PF_USHORT_555_RGBX),
172 new OGLSwToTextureBlit(SurfaceType.ByteGray,
173 OGLSurfaceData.PF_BYTE_GRAY),
174 new OGLSwToTextureBlit(SurfaceType.UshortGray,
175 OGLSurfaceData.PF_USHORT_GRAY),
176 new OGLGeneralBlit(OGLSurfaceData.OpenGLTexture,
177 CompositeType.SrcNoEa,
178 blitIntArgbPreToTexture),
179
180 new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLTexture),
181
182 };
183 GraphicsPrimitiveMgr.register(primitives);
184 }
185
186 /**
187 * The following offsets are used to pack the parameters in
188 * createPackedParams(). (They are also used at the native level when
189 * unpacking the params.)
190 */
191 @Native private static final int OFFSET_SRCTYPE = 16;
192 @Native private static final int OFFSET_HINT = 8;
193 @Native private static final int OFFSET_TEXTURE = 3;
194 @Native private static final int OFFSET_RTT = 2;
195 @Native private static final int OFFSET_XFORM = 1;
196 @Native private static final int OFFSET_ISOBLIT = 0;
197
198 /**
199 * Packs the given parameters into a single int value in order to save
200 * space on the rendering queue.
201 */
202 private static int createPackedParams(boolean isoblit, boolean texture,
203 boolean rtt, boolean xform,
204 int hint, int srctype)
205 {
206 return
207 ((srctype << OFFSET_SRCTYPE) |
208 (hint << OFFSET_HINT ) |
209 ((texture ? 1 : 0) << OFFSET_TEXTURE) |
210 ((rtt ? 1 : 0) << OFFSET_RTT ) |
211 ((xform ? 1 : 0) << OFFSET_XFORM ) |
212 ((isoblit ? 1 : 0) << OFFSET_ISOBLIT));
213 }
214
215 /**
216 * Enqueues a BLIT operation with the given parameters. Note that the
|