src/java.desktop/macosx/classes/sun/java2d/metal/MetalLayer.java
author aghaisas
Wed, 20 Feb 2019 17:00:40 +0530
branchmetal-prototype-branch
changeset 57196 a95707a39ff5
permissions -rw-r--r--
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering Contributed-by: jdv, aghaisas
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57196
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
     1
/*
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
     2
 * Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved.
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
     4
 *
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    10
 *
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    15
 * accompanied this code).
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    16
 *
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    20
 *
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    23
 * questions.
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    24
 */
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    25
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    26
package sun.java2d.metal;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    27
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    28
import sun.lwawt.LWWindowPeer;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    29
import sun.lwawt.macosx.CFRetainedResource;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    30
import sun.java2d.SurfaceData;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    31
import sun.java2d.NullSurfaceData;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    32
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    33
import java.awt.*;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    34
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    35
import sun.awt.CGraphicsConfig;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    36
import sun.java2d.metal.MetalGraphicsConfig;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    37
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    38
public class MetalLayer extends CFRetainedResource {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    39
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    40
    private native long nativeCreateLayer();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    41
    private native long nativeInitLayer(long deviceInfo, long layer);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    42
    //private native long nativeValidate(long layer, long view);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    43
    //private native long nativeDraw(long layer);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    44
    private static native void validate(long layerPtr, MetalSurfaceData msd);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    45
    private static native void nativeSetScale(long layerPtr, double scale);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    46
    //private static native void nativeSetScale(long layerPtr, double scale);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    47
    //private static native void blitTexture(long layerPtr);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    48
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    49
    private LWWindowPeer peer;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    50
    private int scale = 1;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    51
    private SurfaceData surfaceData; // represents intermediate buffer (texture)
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    52
    private long pNativeLayer;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    53
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    54
    public MetalLayer(LWWindowPeer peer) {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    55
        super(0, true);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    56
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    57
        pNativeLayer = nativeCreateLayer();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    58
        setPtr(pNativeLayer);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    59
        this.peer = peer;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    60
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    61
        // TODO : No need to initialize layer here, it will be done
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    62
        // when we initialize surface in MetalSurfaceData.
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    63
        MetalGraphicsConfig gc = (MetalGraphicsConfig)getGraphicsConfiguration();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    64
        nativeInitLayer(gc.pConfigInfo, pNativeLayer);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    65
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    66
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    67
     public long getPointer() {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    68
        return ptr;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    69
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    70
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    71
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    72
    public Rectangle getBounds() {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    73
        return peer.getBounds();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    74
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    75
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    76
    public GraphicsConfiguration getGraphicsConfiguration() {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    77
        return peer.getGraphicsConfiguration();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    78
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    79
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    80
    public boolean isOpaque() {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    81
        return !peer.isTranslucent();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    82
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    83
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    84
    public int getTransparency() {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    85
        return isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    86
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    87
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    88
    public Object getDestination() {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    89
        return peer.getTarget();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    90
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    91
    
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    92
    public SurfaceData replaceSurfaceData() {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    93
        if (getBounds().isEmpty()) {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    94
            surfaceData = NullSurfaceData.theInstance;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    95
            return surfaceData;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    96
        }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    97
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    98
        // the layer redirects all painting to the buffer's graphics
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
    99
        // and blits the buffer to the layer surface (in drawInCGLContext callback)
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   100
        CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   101
        surfaceData = gc.createSurfaceData(this);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   102
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   103
        setScale(gc.getDevice().getScaleFactor());
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   104
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   105
        // the layer holds a reference to the buffer, which in
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   106
        // turn has a reference back to this layer
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   107
        if (surfaceData instanceof MetalSurfaceData) {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   108
            validate((MetalSurfaceData)surfaceData);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   109
        }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   110
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   111
        return surfaceData;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   112
       
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   113
    } 
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   114
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   115
    public SurfaceData getSurfaceData() {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   116
        return surfaceData;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   117
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   118
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   119
    /*public void validate(long viewPtr) {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   120
        //OGLRenderQueue rq = OGLRenderQueue.getInstance();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   121
        //rq.lock();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   122
        try {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   123
            execute(ptr -> nativeValidate(ptr, viewPtr));
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   124
        } finally {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   125
            //   rq.unlock();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   126
        }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   127
    }*/
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   128
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   129
    public void validate(final MetalSurfaceData metalsd) {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   130
        MetalRenderQueue rq = MetalRenderQueue.getInstance();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   131
        rq.lock();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   132
        try {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   133
            execute(ptr -> validate(ptr, metalsd));
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   134
        } finally {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   135
            rq.unlock();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   136
        }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   137
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   138
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   139
    @Override
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   140
    public void dispose() {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   141
        // break the connection between the layer and the buffer
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   142
        validate(null);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   143
        super.dispose();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   144
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   145
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   146
    private void setScale(final int _scale) {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   147
        if (scale != _scale) {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   148
            scale = _scale;
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   149
            execute(ptr -> nativeSetScale(ptr, scale));
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   150
        }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   151
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   152
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   153
    // ----------------------------------------------------------------------
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   154
    // NATIVE CALLBACKS : TODO: check how should this be done in Metal?
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   155
    // ----------------------------------------------------------------------
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   156
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   157
    public void drawInMetalContext(long viewPtr) {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   158
        // tell the flusher thread not to update the intermediate buffer
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   159
        // until we are done blitting from it
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   160
        /*OGLRenderQueue rq = OGLRenderQueue.getInstance();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   161
        rq.lock();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   162
        try {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   163
            execute(ptr -> blitTexture(ptr));
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   164
        } finally {
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   165
            rq.unlock();
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   166
        }*/
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   167
        System.out.println("drawInMetalContext method invoked");
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   168
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   169
        //nativeDraw(pNativeLayer);
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   170
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   171
    }
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   172
a95707a39ff5 Description : Metal Rendering Pipeline - initial implementation of line and quad rendering
aghaisas
parents:
diff changeset
   173
}