653 lines · 24.4 KB · Java
RawDownload
                sg2d.drawpipe = txPipe;                sg2d.fillpipe = nonTxPipe;            } else {                sg2d.drawpipe = nonTxPipe;                sg2d.fillpipe = nonTxPipe;            }            // Note that we use the transforming pipe here because it            // will examine the shape and possibly perform an optimized            // operation if it can be simplified.  The simplifications            // will be valid for all STROKE and TRANSFORM types.            sg2d.shapepipe = txPipe;        } else {            if (!validated) {                super.validatePipe(sg2d);            }        }         // install the text pipe based on our earlier decision        sg2d.textpipe = textpipe;         // always override the image pipe with the specialized OGL pipe        sg2d.imagepipe = oglImagePipe;    }     @Override    protected MaskFill getMaskFill(SunGraphics2D sg2d) {        if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) {            /*             * We can only accelerate non-Color MaskFill operations if             * all of the following conditions hold true:             *   - there is an implementation for the given paintState             *   - the current Paint can be accelerated for this destination             *   - multitexturing is available (since we need to modulate             *     the alpha mask texture with the paint texture)             *             * In all other cases, we return null, in which case the             * validation code will choose a more general software-based loop.             */            if (!OGLPaints.isValid(sg2d) ||                !graphicsConfig.isCapPresent(CAPS_MULTITEXTURE))            {                return null;            }        }        return super.getMaskFill(sg2d);    }     public boolean copyArea(SunGraphics2D sg2d,                            int x, int y, int w, int h, int dx, int dy)    {        if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&            sg2d.compositeState < sg2d.COMP_XOR)        {            x += sg2d.transX;            y += sg2d.transY;             oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);             return true;        }        return false;    }     public void flush() {        invalidate();        OGLRenderQueue rq = OGLRenderQueue.getInstance();        rq.lock();        try {            // make sure we have a current context before            // disposing the native resources (e.g. texture object)            OGLContext.setScratchSurface(graphicsConfig);             RenderBuffer buf = rq.getBuffer();            rq.ensureCapacityAndAlignment(12, 4);            buf.putInt(FLUSH_SURFACE);            buf.putLong(getNativeOps());             // this call is expected to complete synchronously, so flush now            rq.flushNow();        } finally {            rq.unlock();        }    }     /**     * Disposes the native resources associated with the given OGLSurfaceData     * (referenced by the pData parameter).  This method is invoked from     * the native Dispose() method from the Disposer thread when the     * Java-level OGLSurfaceData object is about to go away.  Note that we     * also pass a reference to the native GLX/WGLGraphicsConfigInfo     * (pConfigInfo) for the purposes of making a context current.     */    static void dispose(long pData, long pConfigInfo) {        OGLRenderQueue rq = OGLRenderQueue.getInstance();        rq.lock();        try {            // make sure we have a current context before            // disposing the native resources (e.g. texture object)            OGLContext.setScratchSurface(pConfigInfo);             RenderBuffer buf = rq.getBuffer();            rq.ensureCapacityAndAlignment(12, 4);            buf.putInt(DISPOSE_SURFACE);            buf.putLong(pData);             // this call is expected to complete synchronously, so flush now            rq.flushNow();        } finally {            rq.unlock();        }    }     static void swapBuffers(long window) {        OGLRenderQueue rq = OGLRenderQueue.getInstance();        rq.lock();        try {            RenderBuffer buf = rq.getBuffer();            rq.ensureCapacityAndAlignment(12, 4);            buf.putInt(SWAP_BUFFERS);            buf.putLong(window);            rq.flushNow();        } finally {            rq.unlock();        }    }     /**     * Returns true if OpenGL textures can have non-power-of-two dimensions     * when using the basic GL_TEXTURE_2D target.     */    boolean isTexNonPow2Available() {        return graphicsConfig.isCapPresent(CAPS_TEXNONPOW2);    }     /**     * Returns true if OpenGL textures can have non-power-of-two dimensions     * when using the GL_TEXTURE_RECTANGLE_ARB target (only available when the     * GL_ARB_texture_rectangle extension is present).     */    boolean isTexRectAvailable() {        return graphicsConfig.isCapPresent(CAPS_EXT_TEXRECT);    }     public Rectangle getNativeBounds() {        OGLRenderQueue rq = OGLRenderQueue.getInstance();        rq.lock();        try {            return new Rectangle(nativeWidth, nativeHeight);        } finally {            rq.unlock();        }    }}

Lines 501–653 of 653. Previous lines