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.*;
561 // disposing the native resources (e.g. texture object)
562 OGLContext.setScratchSurface(graphicsConfig);
563
564 RenderBuffer buf = rq.getBuffer();
565 rq.ensureCapacityAndAlignment(12, 4);
566 buf.putInt(FLUSH_SURFACE);
567 buf.putLong(getNativeOps());
568
569 // this call is expected to complete synchronously, so flush now
570 rq.flushNow();
571 } finally {
572 rq.unlock();
573 }
574 }
575
576 /**
577 * Disposes the native resources associated with the given OGLSurfaceData
578 * (referenced by the pData parameter). This method is invoked from
579 * the native Dispose() method from the Disposer thread when the
580 * Java-level OGLSurfaceData object is about to go away. Note that we
581 * also pass a reference to the native GLX/WGLGraphicsConfigInfo
582 * (pConfigInfo) for the purposes of making a context current.
583 */
584 static void dispose(long pData, long pConfigInfo) {
585 OGLRenderQueue rq = OGLRenderQueue.getInstance();
586 rq.lock();
587 try {
588 // make sure we have a current context before
589 // disposing the native resources (e.g. texture object)
590 OGLContext.setScratchSurface(pConfigInfo);
591
592 RenderBuffer buf = rq.getBuffer();
593 rq.ensureCapacityAndAlignment(12, 4);
594 buf.putInt(DISPOSE_SURFACE);
595 buf.putLong(pData);
596
597 // this call is expected to complete synchronously, so flush now
598 rq.flushNow();
599 } finally {
600 rq.unlock();
601 }
602 }
603
604 static void swapBuffers(long window) {
605 OGLRenderQueue rq = OGLRenderQueue.getInstance();
606 rq.lock();
607 try {
608 RenderBuffer buf = rq.getBuffer();
609 rq.ensureCapacityAndAlignment(12, 4);
610 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.*;
562 // disposing the native resources (e.g. texture object)
563 OGLContext.setScratchSurface(graphicsConfig);
564
565 RenderBuffer buf = rq.getBuffer();
566 rq.ensureCapacityAndAlignment(12, 4);
567 buf.putInt(FLUSH_SURFACE);
568 buf.putLong(getNativeOps());
569
570 // this call is expected to complete synchronously, so flush now
571 rq.flushNow();
572 } finally {
573 rq.unlock();
574 }
575 }
576
577 /**
578 * Disposes the native resources associated with the given OGLSurfaceData
579 * (referenced by the pData parameter). This method is invoked from
580 * the native Dispose() method from the Disposer thread when the
581 * Java-level OGLSurfaceData object is about to go away. Note that we
582 * also pass a reference to the OGLGraphicsConfig
583 * for the purposes of making a context current.
584 */
585 static void dispose(long pData, OGLGraphicsConfig gc) {
586 OGLRenderQueue rq = OGLRenderQueue.getInstance();
587 rq.lock();
588 try {
589 // make sure we have a current context before
590 // disposing the native resources (e.g. texture object)
591 OGLContext.setScratchSurface(gc);
592
593 RenderBuffer buf = rq.getBuffer();
594 rq.ensureCapacityAndAlignment(12, 4);
595 buf.putInt(DISPOSE_SURFACE);
596 buf.putLong(pData);
597
598 // this call is expected to complete synchronously, so flush now
599 rq.flushNow();
600 } finally {
601 rq.unlock();
602 }
603 }
604
605 static void swapBuffers(long window) {
606 OGLRenderQueue rq = OGLRenderQueue.getInstance();
607 rq.lock();
608 try {
609 RenderBuffer buf = rq.getBuffer();
610 rq.ensureCapacityAndAlignment(12, 4);
611 buf.putInt(SWAP_BUFFERS);
|