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 package sun.java2d.opengl;
27
28 import java.awt.AlphaComposite;
29 import java.awt.Composite;
30 import java.awt.GraphicsEnvironment;
31 import java.awt.Rectangle;
32 import java.awt.Transparency;
33 import java.awt.image.ColorModel;
34 import java.awt.image.Raster;
35 import sun.awt.SunHints;
36 import sun.awt.image.PixelConverter;
37 import sun.java2d.pipe.hw.AccelSurface;
38 import sun.java2d.SunGraphics2D;
39 import sun.java2d.SurfaceData;
40 import sun.java2d.SurfaceDataProxy;
41 import sun.java2d.loops.CompositeType;
42 import sun.java2d.loops.GraphicsPrimitive;
43 import sun.java2d.loops.MaskFill;
44 import sun.java2d.loops.SurfaceType;
45 import sun.java2d.pipe.ParallelogramPipe;
46 import sun.java2d.pipe.PixelToParallelogramConverter;
47 import sun.java2d.pipe.RenderBuffer;
48 import sun.java2d.pipe.TextPipe;
49 import static sun.java2d.pipe.BufferedOpCodes.*;
581 // disposing the native resources (e.g. texture object)
582 OGLContext.setScratchSurface(graphicsConfig);
583
584 RenderBuffer buf = rq.getBuffer();
585 rq.ensureCapacityAndAlignment(12, 4);
586 buf.putInt(FLUSH_SURFACE);
587 buf.putLong(getNativeOps());
588
589 // this call is expected to complete synchronously, so flush now
590 rq.flushNow();
591 } finally {
592 rq.unlock();
593 }
594 }
595
596 /**
597 * Disposes the native resources associated with the given OGLSurfaceData
598 * (referenced by the pData parameter). This method is invoked from
599 * the native Dispose() method from the Disposer thread when the
600 * Java-level OGLSurfaceData object is about to go away. Note that we
601 * also pass a reference to the native GLX/WGLGraphicsConfigInfo
602 * (pConfigInfo) for the purposes of making a context current.
603 */
604 static void dispose(long pData, long pConfigInfo) {
605 OGLRenderQueue rq = OGLRenderQueue.getInstance();
606 rq.lock();
607 try {
608 // make sure we have a current context before
609 // disposing the native resources (e.g. texture object)
610 OGLContext.setScratchSurface(pConfigInfo);
611
612 RenderBuffer buf = rq.getBuffer();
613 rq.ensureCapacityAndAlignment(12, 4);
614 buf.putInt(DISPOSE_SURFACE);
615 buf.putLong(pData);
616
617 // this call is expected to complete synchronously, so flush now
618 rq.flushNow();
619 } finally {
620 rq.unlock();
621 }
622 }
623
624 static void swapBuffers(long window) {
625 OGLRenderQueue rq = OGLRenderQueue.getInstance();
626 rq.lock();
627 try {
628 RenderBuffer buf = rq.getBuffer();
629 rq.ensureCapacityAndAlignment(12, 4);
630 buf.putInt(SWAP_BUFFERS);
|
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 package sun.java2d.opengl;
27
28 import java.awt.AlphaComposite;
29 import java.awt.Composite;
30 import java.awt.GraphicsConfiguration;
31 import java.awt.GraphicsEnvironment;
32 import java.awt.Rectangle;
33 import java.awt.Transparency;
34 import java.awt.image.ColorModel;
35 import java.awt.image.Raster;
36 import sun.awt.SunHints;
37 import sun.awt.image.PixelConverter;
38 import sun.java2d.pipe.hw.AccelSurface;
39 import sun.java2d.SunGraphics2D;
40 import sun.java2d.SurfaceData;
41 import sun.java2d.SurfaceDataProxy;
42 import sun.java2d.loops.CompositeType;
43 import sun.java2d.loops.GraphicsPrimitive;
44 import sun.java2d.loops.MaskFill;
45 import sun.java2d.loops.SurfaceType;
46 import sun.java2d.pipe.ParallelogramPipe;
47 import sun.java2d.pipe.PixelToParallelogramConverter;
48 import sun.java2d.pipe.RenderBuffer;
49 import sun.java2d.pipe.TextPipe;
50 import static sun.java2d.pipe.BufferedOpCodes.*;
582 // disposing the native resources (e.g. texture object)
583 OGLContext.setScratchSurface(graphicsConfig);
584
585 RenderBuffer buf = rq.getBuffer();
586 rq.ensureCapacityAndAlignment(12, 4);
587 buf.putInt(FLUSH_SURFACE);
588 buf.putLong(getNativeOps());
589
590 // this call is expected to complete synchronously, so flush now
591 rq.flushNow();
592 } finally {
593 rq.unlock();
594 }
595 }
596
597 /**
598 * Disposes the native resources associated with the given OGLSurfaceData
599 * (referenced by the pData parameter). This method is invoked from
600 * the native Dispose() method from the Disposer thread when the
601 * Java-level OGLSurfaceData object is about to go away. Note that we
602 * also pass a reference to the OGLGraphicsConfig
603 * for the purposes of making a context current.
604 */
605 static void dispose(long pData, OGLGraphicsConfig gc) {
606 OGLRenderQueue rq = OGLRenderQueue.getInstance();
607 rq.lock();
608 try {
609 // make sure we have a current context before
610 // disposing the native resources (e.g. texture object)
611 OGLContext.setScratchSurface(gc);
612
613 RenderBuffer buf = rq.getBuffer();
614 rq.ensureCapacityAndAlignment(12, 4);
615 buf.putInt(DISPOSE_SURFACE);
616 buf.putLong(pData);
617
618 // this call is expected to complete synchronously, so flush now
619 rq.flushNow();
620 } finally {
621 rq.unlock();
622 }
623 }
624
625 static void swapBuffers(long window) {
626 OGLRenderQueue rq = OGLRenderQueue.getInstance();
627 rq.lock();
628 try {
629 RenderBuffer buf = rq.getBuffer();
630 rq.ensureCapacityAndAlignment(12, 4);
631 buf.putInt(SWAP_BUFFERS);
|