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