src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MetalGraphicsConfig.h
branchmetal-prototype-branch
changeset 57416 e153174dba06
parent 57400 978ffc56771f
child 57417 28582d575a98
equal deleted inserted replaced
57400:978ffc56771f 57416:e153174dba06
     1 /*
       
     2  * Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 #ifndef MetalGraphicsConfig_h_Included
       
    27 #define MetalGraphicsConfig_h_Included
       
    28 
       
    29 #import "jni.h"
       
    30 //#import "J2D_GL/gl.h"
       
    31 #import <Metal/Metal.h>
       
    32 //@import Metal;
       
    33 //#import "MetalSurfaceData.h"
       
    34 //#import "OGLContext.h"
       
    35 #import <Cocoa/Cocoa.h>
       
    36 
       
    37 @interface MetalGraphicsConfigUtil : NSObject {}
       
    38 + (void) _getMetalConfigInfo: (NSMutableArray *)argValue;
       
    39 @end
       
    40 
       
    41 // REMIND: Using an NSOpenGLPixelBuffer as the scratch surface has been
       
    42 // problematic thus far (seeing garbage and flickering when switching
       
    43 // between an NSView and the scratch surface), so the following enables
       
    44 // an alternate codepath that uses a hidden NSWindow/NSView as the scratch
       
    45 // surface, for the purposes of making a context current in certain
       
    46 // situations.  It appears that calling [NSOpenGLContext setView] too
       
    47 // frequently contributes to the bad behavior, so we should try to avoid
       
    48 // switching to the scratch surface whenever possible.
       
    49 
       
    50 /* Do we need this if we are using all off-screen drawing ? */
       
    51 #define USE_NSVIEW_FOR_SCRATCH 1
       
    52 
       
    53 /* Uncomment to have an additional CAOGLLayer instance tied to
       
    54  * each instance, which can be used to test remoting the layer
       
    55  * to an out of process window. The additional layer is needed
       
    56  * because a layer can only be attached to one context (view/window).
       
    57  * This is only for testing purposes and can be removed if/when no
       
    58  * longer needed.
       
    59  */
       
    60 //#define REMOTELAYER 1
       
    61 
       
    62 #ifdef REMOTELAYER
       
    63 #import <JavaRuntimeSupport/JRSRemoteLayer.h>
       
    64 #import <pthread.h>
       
    65 #include <unistd.h>
       
    66 #include <stdio.h>
       
    67 #import <sys/socket.h>
       
    68 #import <sys/un.h>
       
    69 
       
    70 extern mach_port_t JRSRemotePort;
       
    71 extern int remoteSocketFD;
       
    72 extern void sendLayerID(int layerID);
       
    73 
       
    74 #endif /* REMOTELAYER */
       
    75 
       
    76 
       
    77 /**
       
    78  * The CGLGraphicsConfigInfo structure contains information specific to a
       
    79  * given CGLGraphicsConfig (pixel format).
       
    80  *
       
    81  *     jint screen;
       
    82  * The screen and PixelFormat for the associated CGLGraphicsConfig.
       
    83  *
       
    84  *     NSOpenGLPixelFormat *pixfmt;
       
    85  * The pixel format of the native NSOpenGL context.
       
    86  *
       
    87  *     OGLContext *context;
       
    88  * The context associated with this CGLGraphicsConfig.
       
    89  */
       
    90 typedef struct _MetalGraphicsConfigInfo {
       
    91     jint                 screen;
       
    92     id<MTLDevice>        device;
       
    93     id<MTLCommandQueue>  commandQueue;
       
    94     //MTLLibrary     *defaultLibrary;
       
    95 } MetalGraphicsConfigInfo;
       
    96 
       
    97 /**
       
    98  * The CGLCtxInfo structure contains the native CGLContext information
       
    99  * required by and is encapsulated by the platform-independent OGLContext
       
   100  * structure.
       
   101  *
       
   102  *     NSOpenGLContext *context;
       
   103  * The core native NSOpenGL context.  Rendering commands have no effect until
       
   104  * a context is made current (active).
       
   105  *
       
   106  *     NSOpenGLPixelBuffer *scratchSurface;
       
   107  * The scratch surface id used to make a context current when we do
       
   108  * not otherwise have a reference to an OpenGL surface for the purposes of
       
   109  * making a context current.
       
   110  */
       
   111 /*typedef struct _CGLCtxInfo {
       
   112     NSOpenGLContext     *context;
       
   113 #if USE_NSVIEW_FOR_SCRATCH
       
   114     NSView              *scratchSurface;
       
   115 #else
       
   116     NSOpenGLPixelBuffer *scratchSurface;
       
   117 #endif
       
   118 } CGLCtxInfo;*/
       
   119 
       
   120 #endif /* MetalGraphicsConfig_h_Included */