--- /dev/null 2019-03-05 14:31:15.000000000 +0300 +++ new/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLBlitLoops.m 2019-03-05 14:31:15.000000000 +0300 @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef HEADLESS + +#include +#include + +#include "SurfaceData.h" +#include "MTLBlitLoops.h" +#include "MTLRenderQueue.h" +#include "MTLSurfaceDataBase.h" +#include "GraphicsPrimitiveMgr.h" + +#include // malloc +#include // memcpy +#include "IntArgbPre.h" + +extern MTLPixelFormat PixelFormats[]; + +/** + * Inner loop used for copying a source MTL "Surface" (window, pbuffer, + * etc.) to a destination OpenGL "Surface". Note that the same surface can + * be used as both the source and destination, as is the case in a copyArea() + * operation. This method is invoked from MTLBlitLoops_IsoBlit() as well as + * MTLBlitLoops_CopyArea(). + * + * The standard glCopyPixels() mechanism is used to copy the source region + * into the destination region. If the regions have different dimensions, + * the source will be scaled into the destination as appropriate (only + * nearest neighbor filtering will be applied for simple scale operations). + */ +static void +MTLBlitSurfaceToSurface(MTLContext *mtlc, BMTLSDOps *srcOps, BMTLSDOps *dstOps, + jint sx1, jint sy1, jint sx2, jint sy2, + jdouble dx1, jdouble dy1, jdouble dx2, jdouble dy2) +{ + //TODO + J2dTraceNotImplPrimitive("MTLBlitSurfaceToSurface"); +} + +/** + * Inner loop used for copying a source MTL "Texture" to a destination + * OpenGL "Surface". This method is invoked from MTLBlitLoops_IsoBlit(). + * + * This method will copy, scale, or transform the source texture into the + * destination depending on the transform state, as established in + * and MTLContext_SetTransform(). If the source texture is + * transformed in any way when rendered into the destination, the filtering + * method applied is determined by the hint parameter (can be GL_NEAREST or + * GL_LINEAR). + */ +static void +MTLBlitTextureToSurface(MTLContext *mtlc, + MTLSDOps *srcOps, MTLSDOps *dstOps, + jboolean rtt, jint hint, + jint sx1, jint sy1, jint sx2, jint sy2, + jdouble dx1, jdouble dy1, jdouble dx2, jdouble dy2) +{ + //TODO + J2dTraceNotImplPrimitive("MTLBlitTextureToSurface"); +} + +/** + * Inner loop used for copying a source system memory ("Sw") surface to a + * destination MTL "Surface". This method is invoked from + * MTLBlitLoops_Blit(). + * + * The standard glDrawPixels() mechanism is used to copy the source region + * into the destination region. If the regions have different + * dimensions, the source will be scaled into the destination + * as appropriate (only nearest neighbor filtering will be applied for simple + * scale operations). + */ +static void +MTLBlitSwToSurface(MTLContext *mtlc, SurfaceDataRasInfo *srcInfo, + MTPixelFormat *pf, + jint sx1, jint sy1, jint sx2, jint sy2, + jdouble dx1, jdouble dy1, jdouble dx2, jdouble dy2) +{ + //TODO + J2dTraceNotImplPrimitive("MTLBlitSwToSurface"); +} + +/** + * Inner loop used for copying a source system memory ("Sw") surface or + * MTL "Surface" to a destination OpenGL "Surface", using an MTL texture + * tile as an intermediate surface. This method is invoked from + * MTLBlitLoops_Blit() for "Sw" surfaces and MTLBlitLoops_IsoBlit() for + * "Surface" surfaces. + * + * This method is used to transform the source surface into the destination. + * Pixel rectangles cannot be arbitrarily transformed (without the + * GL_EXT_pixel_transform extension, which is not supported on most modern + * hardware). However, texture mapped quads do respect the GL_MODELVIEW + * transform matrix, so we use textures here to perform the transform + * operation. This method uses a tile-based approach in which a small + * subregion of the source surface is copied into a cached texture tile. The + * texture tile is then mapped into the appropriate location in the + * destination surface. + * + * REMIND: this only works well using GL_NEAREST for the filtering mode + * (GL_LINEAR causes visible stitching problems between tiles, + * but this can be fixed by making use of texture borders) + */ +static void +MTLBlitToSurfaceViaTexture(MTLContext *mtlc, SurfaceDataRasInfo *srcInfo, + MTPixelFormat *pf, MTLSDOps *srcOps, + jboolean swsurface, jint hint, + jint sx1, jint sy1, jint sx2, jint sy2, + jdouble dx1, jdouble dy1, jdouble dx2, jdouble dy2) +{ + //TODO + J2dTraceNotImplPrimitive("MTLBlitToSurfaceViaTexture"); +} + +/** + * Inner loop used for copying a source system memory ("Sw") surface to a + * destination OpenGL "Texture". This method is invoked from + * MTLBlitLoops_Blit(). + * + * The source surface is effectively loaded into the MTL texture object, + * which must have already been initialized by MTLSD_initTexture(). Note + * that this method is only capable of copying the source surface into the + * destination surface (i.e. no scaling or general transform is allowed). + * This restriction should not be an issue as this method is only used + * currently to cache a static system memory image into an MTL texture in + * a hidden-acceleration situation. + */ +static void +MTLBlitSwToTexture(SurfaceDataRasInfo *srcInfo, MTPixelFormat *pf, + MTLSDOps *dstOps, + jint dx1, jint dy1, jint dx2, jint dy2) +{ + //TODO + J2dTraceNotImplPrimitive("MTLBlitSwToTexture"); +} + +/** + * General blit method for copying a native MTL surface (of type "Surface" + * or "Texture") to another MTL "Surface". If texture is JNI_TRUE, this + * method will invoke the Texture->Surface inner loop; otherwise, one of the + * Surface->Surface inner loops will be invoked, depending on the transform + * state. + * + * REMIND: we can trick these blit methods into doing XOR simply by passing + * in the (pixel ^ xorpixel) as the pixel value and preceding the + * blit with a fillrect... + */ +void +MTLBlitLoops_IsoBlit(JNIEnv *env, + MTLContext *mtlc, jlong pSrcOps, jlong pDstOps, + jboolean xform, jint hint, + jboolean texture, jboolean rtt, + jint sx1, jint sy1, jint sx2, jint sy2, + jdouble dx1, jdouble dy1, jdouble dx2, jdouble dy2) +{ + //TODO + J2dTraceNotImplPrimitive("MTLBlitLoops_IsoBlit"); +} + +/** + * General blit method for copying a system memory ("Sw") surface to a native + * MTL surface (of type "Surface" or "Texture"). If texture is JNI_TRUE, + * this method will invoke the Sw->Texture inner loop; otherwise, one of the + * Sw->Surface inner loops will be invoked, depending on the transform state. + */ +void +MTLBlitLoops_Blit(JNIEnv *env, + MTLContext *mtlc, jlong pSrcOps, jlong pDstOps, + jboolean xform, jint hint, + jint srctype, jboolean texture, + jint sx1, jint sy1, jint sx2, jint sy2, + jdouble dx1, jdouble dy1, jdouble dx2, jdouble dy2) +{ + //TODO + J2dTraceNotImplPrimitive("MTLBlitLoops_Blit"); +} + +/** + * Specialized blit method for copying a native MTL "Surface" (pbuffer, + * window, etc.) to a system memory ("Sw") surface. + */ +void +MTLBlitLoops_SurfaceToSwBlit(JNIEnv *env, MTLContext *mtlc, + jlong pSrcOps, jlong pDstOps, jint dsttype, + jint srcx, jint srcy, jint dstx, jint dsty, + jint width, jint height) +{ + //TODO + J2dTraceNotImplPrimitive("MTLBlitLoops_SurfaceToSwBlit"); +} + +void +MTLBlitLoops_CopyArea(JNIEnv *env, + MTLContext *mtlc, BMTLSDOps *dstOps, + jint x, jint y, jint width, jint height, + jint dx, jint dy) +{ + //TODO + J2dTraceNotImplPrimitive("MTLBlitLoops_CopyArea"); +} + +#endif /* !HEADLESS */