001: /*
002: * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.java2d.opengl;
027:
028: import java.awt.Color;
029: import java.awt.Image;
030: import java.awt.geom.AffineTransform;
031: import java.awt.image.AffineTransformOp;
032: import java.awt.image.BufferedImage;
033: import java.awt.image.BufferedImageOp;
034: import sun.java2d.SunGraphics2D;
035: import sun.java2d.SurfaceData;
036: import sun.java2d.loops.SurfaceType;
037: import sun.java2d.loops.TransformBlit;
038: import sun.java2d.pipe.DrawImage;
039:
040: public class OGLDrawImage extends DrawImage {
041:
042: @Override
043: protected void renderImageXform(SunGraphics2D sg, Image img,
044: AffineTransform tx, int interpType, int sx1, int sy1,
045: int sx2, int sy2, Color bgColor) {
046: // punt to the MediaLib-based transformImage() in the superclass if:
047: // - bicubic interpolation is specified
048: // - a background color is specified and will be used
049: // - the source surface is neither a texture nor render-to-texture
050: // surface, and a non-default interpolation hint is specified
051: // (we can only control the filtering for texture->surface
052: // copies)
053: // REMIND: we should tweak the sw->texture->surface
054: // transform case to handle filtering appropriately
055: // (see 4841762)...
056: // - an appropriate TransformBlit primitive could not be found
057: if (interpType != AffineTransformOp.TYPE_BICUBIC) {
058: SurfaceData dstData = sg.surfaceData;
059: SurfaceData srcData = dstData.getSourceSurfaceData(img,
060: sg.TRANSFORM_GENERIC, sg.imageComp, bgColor);
061:
062: if (srcData != null
063: && !isBgOperation(srcData, bgColor)
064: && (srcData.getSurfaceType() == OGLSurfaceData.OpenGLTexture
065: || srcData.getSurfaceType() == OGLSurfaceData.OpenGLSurfaceRTT || interpType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR)) {
066: SurfaceType srcType = srcData.getSurfaceType();
067: SurfaceType dstType = dstData.getSurfaceType();
068: TransformBlit blit = TransformBlit.getFromCache(
069: srcType, sg.imageComp, dstType);
070:
071: if (blit != null) {
072: blit.Transform(srcData, dstData, sg.composite, sg
073: .getCompClip(), tx, interpType, sx1, sy1,
074: 0, 0, sx2 - sx1, sy2 - sy1);
075: return;
076: }
077: }
078: }
079:
080: super .renderImageXform(sg, img, tx, interpType, sx1, sy1, sx2,
081: sy2, bgColor);
082: }
083:
084: @Override
085: public void transformImage(SunGraphics2D sg, BufferedImage img,
086: BufferedImageOp op, int x, int y) {
087: if (op != null) {
088: if (op instanceof AffineTransformOp) {
089: AffineTransformOp atop = (AffineTransformOp) op;
090: transformImage(sg, img, x, y, atop.getTransform(), atop
091: .getInterpolationType());
092: return;
093: } else {
094: if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
095: return;
096: }
097: }
098: img = op.filter(img, null);
099: }
100: copyImage(sg, img, x, y, null);
101: }
102: }
|