jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java
author erikj
Thu, 07 Jun 2012 18:05:09 -0700
changeset 12813 c10ab96dcf41
parent 12047 320a714614e9
child 14646 94eed98a7ecb
permissions -rw-r--r--
7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI Reviewed-by: ohair, ohrstrom, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1723
diff changeset
     2
 * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1723
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1723
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1723
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1723
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1723
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.java2d.opengl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Composite;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Transparency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.geom.AffineTransform;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.AffineTransformOp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.image.BufferedImageOp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.lang.ref.WeakReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.java2d.SurfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.java2d.loops.Blit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.java2d.loops.CompositeType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.java2d.loops.GraphicsPrimitive;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.java2d.loops.GraphicsPrimitiveMgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.java2d.loops.ScaledBlit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.java2d.loops.SurfaceType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.java2d.loops.TransformBlit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.java2d.pipe.Region;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.java2d.pipe.RenderBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import sun.java2d.pipe.RenderQueue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import static sun.java2d.pipe.BufferedOpCodes.*;
12813
c10ab96dcf41 7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents: 12047
diff changeset
    47
import javax.tools.annotation.GenerateNativeHeader;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
12813
c10ab96dcf41 7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents: 12047
diff changeset
    49
/* No native methods here, but the constants are needed in the supporting JNI code */
c10ab96dcf41 7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents: 12047
diff changeset
    50
@GenerateNativeHeader
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
class OGLBlitLoops {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    static void register() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        Blit blitIntArgbPreToSurface =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            new OGLSwToSurfaceBlit(SurfaceType.IntArgbPre,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                                   OGLSurfaceData.PF_INT_ARGB_PRE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        Blit blitIntArgbPreToTexture =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            new OGLSwToTextureBlit(SurfaceType.IntArgbPre,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                                   OGLSurfaceData.PF_INT_ARGB_PRE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        GraphicsPrimitive[] primitives = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            // surface->surface ops
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            new OGLSurfaceToSurfaceBlit(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            new OGLSurfaceToSurfaceScale(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            new OGLSurfaceToSurfaceTransform(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            // render-to-texture surface->surface ops
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            new OGLRTTSurfaceToSurfaceBlit(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            new OGLRTTSurfaceToSurfaceScale(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            new OGLRTTSurfaceToSurfaceTransform(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            // surface->sw ops
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            new OGLSurfaceToSwBlit(SurfaceType.IntArgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                                   OGLSurfaceData.PF_INT_ARGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            // sw->surface ops
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            blitIntArgbPreToSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            new OGLSwToSurfaceBlit(SurfaceType.IntRgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                                   OGLSurfaceData.PF_INT_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            new OGLSwToSurfaceBlit(SurfaceType.IntRgbx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                                   OGLSurfaceData.PF_INT_RGBX),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            new OGLSwToSurfaceBlit(SurfaceType.IntBgr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                                   OGLSurfaceData.PF_INT_BGR),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            new OGLSwToSurfaceBlit(SurfaceType.IntBgrx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                                   OGLSurfaceData.PF_INT_BGRX),
1723
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 2
diff changeset
    86
            new OGLSwToSurfaceBlit(SurfaceType.ThreeByteBgr,
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 2
diff changeset
    87
                                   OGLSurfaceData.PF_3BYTE_BGR),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            new OGLSwToSurfaceBlit(SurfaceType.Ushort565Rgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                   OGLSurfaceData.PF_USHORT_565_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            new OGLSwToSurfaceBlit(SurfaceType.Ushort555Rgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                                   OGLSurfaceData.PF_USHORT_555_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            new OGLSwToSurfaceBlit(SurfaceType.Ushort555Rgbx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                                   OGLSurfaceData.PF_USHORT_555_RGBX),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            new OGLSwToSurfaceBlit(SurfaceType.ByteGray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                                   OGLSurfaceData.PF_BYTE_GRAY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            new OGLSwToSurfaceBlit(SurfaceType.UshortGray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                                   OGLSurfaceData.PF_USHORT_GRAY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            new OGLGeneralBlit(OGLSurfaceData.OpenGLSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                               CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                               blitIntArgbPreToSurface),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            new OGLSwToSurfaceScale(SurfaceType.IntRgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                                    OGLSurfaceData.PF_INT_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            new OGLSwToSurfaceScale(SurfaceType.IntRgbx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                                    OGLSurfaceData.PF_INT_RGBX),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            new OGLSwToSurfaceScale(SurfaceType.IntBgr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                                    OGLSurfaceData.PF_INT_BGR),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            new OGLSwToSurfaceScale(SurfaceType.IntBgrx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                    OGLSurfaceData.PF_INT_BGRX),
1723
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 2
diff changeset
   110
            new OGLSwToSurfaceScale(SurfaceType.ThreeByteBgr,
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 2
diff changeset
   111
                                    OGLSurfaceData.PF_3BYTE_BGR),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            new OGLSwToSurfaceScale(SurfaceType.Ushort565Rgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                                    OGLSurfaceData.PF_USHORT_565_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            new OGLSwToSurfaceScale(SurfaceType.Ushort555Rgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                                    OGLSurfaceData.PF_USHORT_555_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            new OGLSwToSurfaceScale(SurfaceType.Ushort555Rgbx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                                    OGLSurfaceData.PF_USHORT_555_RGBX),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            new OGLSwToSurfaceScale(SurfaceType.ByteGray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                                    OGLSurfaceData.PF_BYTE_GRAY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            new OGLSwToSurfaceScale(SurfaceType.UshortGray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                                    OGLSurfaceData.PF_USHORT_GRAY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            new OGLSwToSurfaceScale(SurfaceType.IntArgbPre,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                                    OGLSurfaceData.PF_INT_ARGB_PRE),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            new OGLSwToSurfaceTransform(SurfaceType.IntRgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                                        OGLSurfaceData.PF_INT_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            new OGLSwToSurfaceTransform(SurfaceType.IntRgbx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                                        OGLSurfaceData.PF_INT_RGBX),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            new OGLSwToSurfaceTransform(SurfaceType.IntBgr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                        OGLSurfaceData.PF_INT_BGR),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            new OGLSwToSurfaceTransform(SurfaceType.IntBgrx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                                        OGLSurfaceData.PF_INT_BGRX),
1723
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 2
diff changeset
   133
            new OGLSwToSurfaceTransform(SurfaceType.ThreeByteBgr,
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 2
diff changeset
   134
                                        OGLSurfaceData.PF_3BYTE_BGR),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            new OGLSwToSurfaceTransform(SurfaceType.Ushort565Rgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                                        OGLSurfaceData.PF_USHORT_565_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            new OGLSwToSurfaceTransform(SurfaceType.Ushort555Rgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                                        OGLSurfaceData.PF_USHORT_555_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            new OGLSwToSurfaceTransform(SurfaceType.Ushort555Rgbx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                                        OGLSurfaceData.PF_USHORT_555_RGBX),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            new OGLSwToSurfaceTransform(SurfaceType.ByteGray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                                        OGLSurfaceData.PF_BYTE_GRAY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            new OGLSwToSurfaceTransform(SurfaceType.UshortGray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                                        OGLSurfaceData.PF_USHORT_GRAY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            new OGLSwToSurfaceTransform(SurfaceType.IntArgbPre,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                        OGLSurfaceData.PF_INT_ARGB_PRE),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            // texture->surface ops
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            new OGLTextureToSurfaceBlit(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            new OGLTextureToSurfaceScale(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            new OGLTextureToSurfaceTransform(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            // sw->texture ops
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            blitIntArgbPreToTexture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            new OGLSwToTextureBlit(SurfaceType.IntRgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                   OGLSurfaceData.PF_INT_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            new OGLSwToTextureBlit(SurfaceType.IntRgbx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                                   OGLSurfaceData.PF_INT_RGBX),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            new OGLSwToTextureBlit(SurfaceType.IntBgr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                   OGLSurfaceData.PF_INT_BGR),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            new OGLSwToTextureBlit(SurfaceType.IntBgrx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                                   OGLSurfaceData.PF_INT_BGRX),
1723
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 2
diff changeset
   163
            new OGLSwToTextureBlit(SurfaceType.ThreeByteBgr,
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 2
diff changeset
   164
                                   OGLSurfaceData.PF_3BYTE_BGR),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            new OGLSwToTextureBlit(SurfaceType.Ushort565Rgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                                   OGLSurfaceData.PF_USHORT_565_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            new OGLSwToTextureBlit(SurfaceType.Ushort555Rgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                   OGLSurfaceData.PF_USHORT_555_RGB),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            new OGLSwToTextureBlit(SurfaceType.Ushort555Rgbx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                                   OGLSurfaceData.PF_USHORT_555_RGBX),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            new OGLSwToTextureBlit(SurfaceType.ByteGray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                                   OGLSurfaceData.PF_BYTE_GRAY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            new OGLSwToTextureBlit(SurfaceType.UshortGray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                                   OGLSurfaceData.PF_USHORT_GRAY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            new OGLGeneralBlit(OGLSurfaceData.OpenGLTexture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                               CompositeType.SrcNoEa,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                               blitIntArgbPreToTexture),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        GraphicsPrimitiveMgr.register(primitives);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * The following offsets are used to pack the parameters in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * createPackedParams().  (They are also used at the native level when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * unpacking the params.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    private static final int OFFSET_SRCTYPE = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    private static final int OFFSET_HINT    =  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    private static final int OFFSET_TEXTURE =  3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    private static final int OFFSET_RTT     =  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    private static final int OFFSET_XFORM   =  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    private static final int OFFSET_ISOBLIT =  0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * Packs the given parameters into a single int value in order to save
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * space on the rendering queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    private static int createPackedParams(boolean isoblit, boolean texture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                                          boolean rtt, boolean xform,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                                          int hint, int srctype)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            ((srctype           << OFFSET_SRCTYPE) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
             (hint              << OFFSET_HINT   ) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
             ((texture ? 1 : 0) << OFFSET_TEXTURE) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
             ((rtt     ? 1 : 0) << OFFSET_RTT    ) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
             ((xform   ? 1 : 0) << OFFSET_XFORM  ) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
             ((isoblit ? 1 : 0) << OFFSET_ISOBLIT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * Enqueues a BLIT operation with the given parameters.  Note that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * RenderQueue lock must be held before calling this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    private static void enqueueBlit(RenderQueue rq,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                                    SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                                    int packedParams,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                                    int sx1, int sy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                                    int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                    double dx1, double dy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                    double dx2, double dy2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        // assert rq.lock.isHeldByCurrentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        RenderBuffer buf = rq.getBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        rq.ensureCapacityAndAlignment(72, 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        buf.putInt(BLIT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        buf.putInt(packedParams);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        buf.putInt(sx1).putInt(sy1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        buf.putInt(sx2).putInt(sy2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        buf.putDouble(dx1).putDouble(dy1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        buf.putDouble(dx2).putDouble(dy2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        buf.putLong(src.getNativeOps());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        buf.putLong(dst.getNativeOps());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    static void Blit(SurfaceData srcData, SurfaceData dstData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                     Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                     AffineTransform xform, int hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                     int sx1, int sy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                     int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                     double dx1, double dy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                     double dx2, double dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                     int srctype, boolean texture)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        int ctxflags = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        if (srcData.getTransparency() == Transparency.OPAQUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            ctxflags |= OGLContext.SRC_IS_OPAQUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        rq.lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            // make sure the RenderQueue keeps a hard reference to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            // source (sysmem) SurfaceData to prevent it from being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            // disposed while the operation is processed on the QFT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            rq.addReference(srcData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            OGLSurfaceData oglDst = (OGLSurfaceData)dstData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            if (texture) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                // make sure we have a current context before uploading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                // the sysmem data to the texture object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                OGLGraphicsConfig gc = oglDst.getOGLGraphicsConfig();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                OGLContext.setScratchSurface(gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                OGLContext.validateContext(oglDst, oglDst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                                           clip, comp, xform, null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                           ctxflags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            int packedParams = createPackedParams(false, texture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                                                  false, xform != null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                                                  hint, srctype);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            enqueueBlit(rq, srcData, dstData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                        packedParams,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                        sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                        dx1, dy1, dx2, dy2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            // always flush immediately, since we (currently) have no means
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            // of tracking changes to the system memory surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            rq.flushNow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            rq.unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * Note: The srcImg and biop parameters are only used when invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * from the OGLBufImgOps.renderImageWithOp() method; in all other cases,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * this method can be called with null values for those two parameters,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * and they will be effectively ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    static void IsoBlit(SurfaceData srcData, SurfaceData dstData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                        BufferedImage srcImg, BufferedImageOp biop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                        Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                        AffineTransform xform, int hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                        int sx1, int sy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                        int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                        double dx1, double dy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                        double dx2, double dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                        boolean texture)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        int ctxflags = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        if (srcData.getTransparency() == Transparency.OPAQUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            ctxflags |= OGLContext.SRC_IS_OPAQUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        rq.lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            OGLSurfaceData oglSrc = (OGLSurfaceData)srcData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            OGLSurfaceData oglDst = (OGLSurfaceData)dstData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            int srctype = oglSrc.getType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            boolean rtt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            OGLSurfaceData srcCtxData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            if (srctype == OGLSurfaceData.TEXTURE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                // the source is a regular texture object; we substitute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                // the destination surface for the purposes of making a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                // context current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                rtt = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                srcCtxData = oglDst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                // the source is a pbuffer, backbuffer, or render-to-texture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                // surface; we set rtt to true to differentiate this kind
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                // of surface from a regular texture object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                rtt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                if (srctype == OGLSurfaceData.FBOBJECT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                    srcCtxData = oglDst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                    srcCtxData = oglSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            OGLContext.validateContext(srcCtxData, oglDst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                                       clip, comp, xform, null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                                       ctxflags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            if (biop != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                OGLBufImgOps.enableBufImgOp(rq, oglSrc, srcImg, biop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            int packedParams = createPackedParams(true, texture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                                                  rtt, xform != null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                                                  hint, 0 /*unused*/);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            enqueueBlit(rq, srcData, dstData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                        packedParams,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                        sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                        dx1, dy1, dx2, dy2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            if (biop != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                OGLBufImgOps.disableBufImgOp(rq, biop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 5506
diff changeset
   353
            if (rtt && oglDst.isOnScreen()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                // we only have to flush immediately when copying from a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                // (non-texture) surface to the screen; otherwise Swing apps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                // might appear unresponsive until the auto-flush completes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                rq.flushNow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            rq.unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
class OGLSurfaceToSurfaceBlit extends Blit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    OGLSurfaceToSurfaceBlit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        super(OGLSurfaceData.OpenGLSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    public void Blit(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                     Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                     int sx, int sy, int dx, int dy, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        OGLBlitLoops.IsoBlit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                             null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                             comp, clip, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                             AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                             sx, sy, sx+w, sy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                             dx, dy, dx+w, dy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                             false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
class OGLSurfaceToSurfaceScale extends ScaledBlit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    OGLSurfaceToSurfaceScale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        super(OGLSurfaceData.OpenGLSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    public void Scale(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                      Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                      int sx1, int sy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                      int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                      double dx1, double dy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                      double dx2, double dy2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        OGLBlitLoops.IsoBlit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                             null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                             comp, clip, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                             AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                             sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                             dx1, dy1, dx2, dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                             false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
class OGLSurfaceToSurfaceTransform extends TransformBlit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    OGLSurfaceToSurfaceTransform() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        super(OGLSurfaceData.OpenGLSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    public void Transform(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                          Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                          AffineTransform at, int hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                          int sx, int sy, int dx, int dy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                          int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        OGLBlitLoops.IsoBlit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                             null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                             comp, clip, at, hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                             sx, sy, sx+w, sy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                             dx, dy, dx+w, dy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                             false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
class OGLRTTSurfaceToSurfaceBlit extends Blit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    OGLRTTSurfaceToSurfaceBlit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        super(OGLSurfaceData.OpenGLSurfaceRTT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    public void Blit(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                     Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                     int sx, int sy, int dx, int dy, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        OGLBlitLoops.IsoBlit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                             null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                             comp, clip, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                             AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                             sx, sy, sx+w, sy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                             dx, dy, dx+w, dy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                             true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
class OGLRTTSurfaceToSurfaceScale extends ScaledBlit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    OGLRTTSurfaceToSurfaceScale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        super(OGLSurfaceData.OpenGLSurfaceRTT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    public void Scale(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                      Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                      int sx1, int sy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                      int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                      double dx1, double dy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                      double dx2, double dy2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        OGLBlitLoops.IsoBlit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                             null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                             comp, clip, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                             AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                             sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                             dx1, dy1, dx2, dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                             true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
class OGLRTTSurfaceToSurfaceTransform extends TransformBlit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    OGLRTTSurfaceToSurfaceTransform() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        super(OGLSurfaceData.OpenGLSurfaceRTT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    public void Transform(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                          Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                          AffineTransform at, int hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                          int sx, int sy, int dx, int dy, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        OGLBlitLoops.IsoBlit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                             null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                             comp, clip, at, hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                             sx, sy, sx+w, sy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                             dx, dy, dx+w, dy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                             true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
class OGLSurfaceToSwBlit extends Blit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    private int typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    // REMIND: destination will actually be opaque/premultiplied...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    OGLSurfaceToSwBlit(SurfaceType dstType, int typeval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        super(OGLSurfaceData.OpenGLSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
              CompositeType.SrcNoEa,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
              dstType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        this.typeval = typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    public void Blit(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                     Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                     int sx, int sy, int dx, int dy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                     int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        rq.lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            // make sure the RenderQueue keeps a hard reference to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            // destination (sysmem) SurfaceData to prevent it from being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            // disposed while the operation is processed on the QFT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            rq.addReference(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            RenderBuffer buf = rq.getBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            OGLContext.validateContext((OGLSurfaceData)src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            rq.ensureCapacityAndAlignment(48, 32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            buf.putInt(SURFACE_TO_SW_BLIT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            buf.putInt(sx).putInt(sy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            buf.putInt(dx).putInt(dy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            buf.putInt(w).putInt(h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            buf.putInt(typeval);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            buf.putLong(src.getNativeOps());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            buf.putLong(dst.getNativeOps());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            // always flush immediately
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            rq.flushNow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            rq.unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
class OGLSwToSurfaceBlit extends Blit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    private int typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    OGLSwToSurfaceBlit(SurfaceType srcType, int typeval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        super(srcType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        this.typeval = typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    public void Blit(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                     Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                     int sx, int sy, int dx, int dy, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        OGLBlitLoops.Blit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                          comp, clip, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                          AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                          sx, sy, sx+w, sy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                          dx, dy, dx+w, dy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                          typeval, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
class OGLSwToSurfaceScale extends ScaledBlit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    private int typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    OGLSwToSurfaceScale(SurfaceType srcType, int typeval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        super(srcType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        this.typeval = typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    public void Scale(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                      Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                      int sx1, int sy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                      int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                      double dx1, double dy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                      double dx2, double dy2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        OGLBlitLoops.Blit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                          comp, clip, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                          AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                          sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                          dx1, dy1, dx2, dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                          typeval, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
class OGLSwToSurfaceTransform extends TransformBlit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    private int typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    OGLSwToSurfaceTransform(SurfaceType srcType, int typeval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        super(srcType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        this.typeval = typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    public void Transform(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                          Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                          AffineTransform at, int hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                          int sx, int sy, int dx, int dy, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        OGLBlitLoops.Blit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                          comp, clip, at, hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                          sx, sy, sx+w, sy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                          dx, dy, dx+w, dy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                          typeval, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
class OGLSwToTextureBlit extends Blit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    private int typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    OGLSwToTextureBlit(SurfaceType srcType, int typeval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        super(srcType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
              CompositeType.SrcNoEa,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
              OGLSurfaceData.OpenGLTexture);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        this.typeval = typeval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    public void Blit(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                     Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                     int sx, int sy, int dx, int dy, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        OGLBlitLoops.Blit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                          comp, clip, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                          AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                          sx, sy, sx+w, sy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                          dx, dy, dx+w, dy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                          typeval, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
class OGLTextureToSurfaceBlit extends Blit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    OGLTextureToSurfaceBlit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        super(OGLSurfaceData.OpenGLTexture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    public void Blit(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                     Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                     int sx, int sy, int dx, int dy, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        OGLBlitLoops.IsoBlit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                             null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                             comp, clip, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                             AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                             sx, sy, sx+w, sy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                             dx, dy, dx+w, dy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                             true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
class OGLTextureToSurfaceScale extends ScaledBlit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    OGLTextureToSurfaceScale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        super(OGLSurfaceData.OpenGLTexture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    public void Scale(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                      Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                      int sx1, int sy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                      int sx2, int sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                      double dx1, double dy1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                      double dx2, double dy2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        OGLBlitLoops.IsoBlit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                             null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                             comp, clip, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                             AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                             sx1, sy1, sx2, sy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                             dx1, dy1, dx2, dy2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                             true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
class OGLTextureToSurfaceTransform extends TransformBlit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    OGLTextureToSurfaceTransform() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        super(OGLSurfaceData.OpenGLTexture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
              CompositeType.AnyAlpha,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
              OGLSurfaceData.OpenGLSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    public void Transform(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                          Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                          AffineTransform at, int hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                          int sx, int sy, int dx, int dy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                          int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        OGLBlitLoops.IsoBlit(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                             null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                             comp, clip, at, hint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                             sx, sy, sx+w, sy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                             dx, dy, dx+w, dy+h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                             true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
 * This general Blit implemenation converts any source surface to an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
 * intermediate IntArgbPre surface, and then uses the more specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
 * IntArgbPre->OpenGLSurface/Texture loop to get the intermediate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
 * (premultiplied) surface down to OpenGL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
class OGLGeneralBlit extends Blit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    private Blit performop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    private WeakReference srcTmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    OGLGeneralBlit(SurfaceType dstType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                   CompositeType compType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                   Blit performop)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        super(SurfaceType.Any, compType, dstType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        this.performop = performop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    public synchronized void Blit(SurfaceData src, SurfaceData dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                                  Composite comp, Region clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                                  int sx, int sy, int dx, int dy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                                  int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        Blit convertsrc = Blit.getFromCache(src.getSurfaceType(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                                            CompositeType.SrcNoEa,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                                            SurfaceType.IntArgbPre);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        SurfaceData cachedSrc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        if (srcTmp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            // use cached intermediate surface, if available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            cachedSrc = (SurfaceData)srcTmp.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        // convert source to IntArgbPre
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        src = convertFrom(convertsrc, src, sx, sy, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                          cachedSrc, BufferedImage.TYPE_INT_ARGB_PRE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        // copy IntArgbPre intermediate surface to OpenGL surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        performop.Blit(src, dst, comp, clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                       0, 0, dx, dy, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        if (src != cachedSrc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
            // cache the intermediate surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            srcTmp = new WeakReference(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
}