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